[svn r260] Changed some of the LLVMDC specific code in the Tango core and did some minor cleanups.

This commit is contained in:
Tomas Lindquist Olsen
2008-06-09 03:02:14 +02:00
parent 951657ccdc
commit e23169d5d8
4 changed files with 46 additions and 159 deletions

View File

@@ -223,36 +223,28 @@ void Type::init()
tvoidptr = tvoid->pointerTo();
// set size_t / ptrdiff_t types
if (global.params.is64bit)
{
PTRSIZE = 8;
#if !IN_LLVM
if (global.params.isLinux)
REALSIZE = 10;
else
REALSIZE = 8;
#else
REALSIZE = 8;
REALPAD = 0;
#endif
Tsize_t = Tuns64;
Tptrdiff_t = Tint64;
Tsize_t = Tuns64;
Tptrdiff_t = Tint64;
}
else
{
Tsize_t = Tuns32;
Tptrdiff_t = Tint32;
}
// set real size and padding
if (global.params.useFP80)
{
REALSIZE = 12;
REALPAD = 2;
}
else
{
PTRSIZE = 4;
#if IN_LLVM
REALSIZE = 8;
REALPAD = 0;
#elif TARGET_LINUX
REALSIZE = 12;
REALPAD = 2;
#else
REALSIZE = 10;
REALPAD = 0;
#endif
Tsize_t = Tuns32;
Tptrdiff_t = Tint32;
}
}

View File

@@ -1199,6 +1199,8 @@ DValue* CallExp::toElem(IRState* p)
palist = palist.addAttr(j+1, llvm::ParamAttr::ByVal);
// this hack is necessary :/
// thing is DMD doesn't create correct signatures for the DMD generated calls to the runtime.
// only the return type is right, no arguments (parameters==NULL) ...
if (dfn && dfn->func && dfn->func->runTimeHack) {
llvm::Function* fn = dfn->func->ir.irFunc->func;
assert(fn);
@@ -1302,76 +1304,6 @@ DValue* SymOffExp::toElem(IRState* p)
LOG_SCOPE;
assert(0 && "SymOffExp::toElem should no longer be called :/");
if (VarDeclaration* vd = var->isVarDeclaration())
{
Logger::println("VarDeclaration");
// handle forward reference
if (!vd->ir.declared && vd->isDataseg()) {
vd->toObjFile(); // TODO
}
assert(vd->ir.getIrValue());
Type* t = DtoDType(type);
Type* tnext = DtoDType(t->next);
Type* vdtype = DtoDType(vd->type);
LLValue* llvalue = vd->nestedref ? DtoNestedVariable(vd) : vd->ir.getIrValue();
LLValue* varmem = 0;
if (vdtype->ty == Tstruct && !(t->ty == Tpointer && t->next == vdtype)) {
Logger::println("struct");
TypeStruct* vdt = (TypeStruct*)vdtype;
assert(vdt->sym);
const LLType* llt = DtoType(t);
if (offset == 0) {
varmem = p->ir->CreateBitCast(llvalue, llt, "tmp");
}
else {
DStructIndexVector dst;
varmem = DtoIndexStruct(llvalue,vdt->sym, tnext, offset, dst);
}
}
else if (vdtype->ty == Tsarray) {
Logger::println("sarray");
assert(llvalue);
//e->arg = llvalue; // TODO
const LLType* llt = DtoType(t);
LLValue* off = 0;
if (offset != 0) {
Logger::println("offset = %d\n", offset);
}
if (offset == 0) {
varmem = llvalue;
}
else {
const LLType* elemtype = llvalue->getType()->getContainedType(0)->getContainedType(0);
size_t elemsz = getABITypeSize(elemtype);
varmem = DtoGEPi(llvalue, 0, offset / elemsz, "tmp");
}
}
else if (offset == 0) {
Logger::println("normal symoff");
assert(llvalue);
varmem = llvalue;
const LLType* llt = DtoType(t);
if (llvalue->getType() != llt) {
varmem = p->ir->CreateBitCast(varmem, llt, "tmp");
}
}
else {
assert(0);
}
return new DFieldValue(type, varmem, true);
}
assert(0);
return 0;
}
@@ -1459,19 +1391,6 @@ DValue* DotVarExp::toElem(IRState* p)
DStructIndexVector vdoffsets;
arrptr = DtoIndexClass(src, tc->sym, vd->type, vd->offset, vdoffsets);
/*std::vector<unsigned> vdoffsets(1,0);
tc->sym->offsetToIndex(vd->type, vd->offset, vdoffsets);
LLValue* src = l->getRVal();
Logger::println("indices:");
for (size_t i=0; i<vdoffsets.size(); ++i)
Logger::println("%d", vdoffsets[i]);
Logger::cout() << "src: " << *src << '\n';
arrptr = DtoGEP(src,vdoffsets,"tmp",p->scopebb());
Logger::cout() << "dst: " << *arrptr << '\n';*/
}
else
assert(0);
@@ -1517,8 +1436,6 @@ DValue* DotVarExp::toElem(IRState* p)
funcval = DtoBitCast(funcval, getPtrToType(DtoType(fdecl->type)));
Logger::cout() << "funcval casted: " << *funcval << '\n';
#endif
//assert(funcval->getType() == DtoType(fdecl->type));
//cc = DtoCallingConv(fdecl->linkage);
}
// static call
else {
@@ -3153,40 +3070,6 @@ int TypedefDeclaration::cvMember(unsigned char*)
void obj_includelib(char*){}
/* this has moved to asmstmt.cpp
AsmStatement::AsmStatement(Loc loc, Token *tokens) :
Statement(loc)
{
this->tokens = tokens;
}
Statement *AsmStatement::syntaxCopy()
{
//error("%s: inline asm is not yet implemented", loc.toChars());
//fatal();
//assert(0);
return 0;
}
Statement *AsmStatement::semantic(Scope *sc)
{
return Statement::semantic(sc);
}
void AsmStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
{
Statement::toCBuffer(buf, hgs);
}
int AsmStatement::comeFrom()
{
//error("%s: inline asm is not yet implemented", loc.toChars());
//fatal();
//assert(0);
return 0;
}
*/
void
backend_init()
{

View File

@@ -244,7 +244,30 @@ else version( Posix )
}
body
{
version( D_InlineAsm_X86 )
version( LLVMDC )
{
// put registers on the stack
version(D_InlineAsm_X86)
{
uint _eax, _ecx, _edx, _ebx, _esp, _ebp, _esi, _edi;
asm
{
mov _eax, EAX;
mov _ecx, ECX;
mov _edx, EDX;
mov _ebx, EBX;
mov _esp, ESP;
mov _ebp, EBP;
mov _esi, ESI;
mov _edi, EDI;
}
}
else
{
// FIXME
}
}
else version( D_InlineAsm_X86 )
{
asm
{
@@ -255,10 +278,6 @@ else version( Posix )
{
__builtin_unwind_init();
}
else version( LLVMDC )
{
// TODO below as well
}
else
{
static assert( false, "Architecture not supported." );
@@ -301,7 +320,11 @@ else version( Posix )
}
}
version( D_InlineAsm_X86 )
version( LLVMDC )
{
// nothing to do
}
else version( D_InlineAsm_X86 )
{
asm
{
@@ -312,10 +335,6 @@ else version( Posix )
{
// registers will be popped automatically
}
else version( LLVMDC )
{
// TODO
}
else
{
static assert( false, "Architecture not supported." );

View File

@@ -69,15 +69,8 @@ extern (C) void gc_term()
//
// NOTE: Due to popular demand, this has been re-enabled. It still has
// the problems mentioned above though, so I guess we'll see.
version(LLVMDC)
{
// currently crashes a lot
}
else
{
_gc.fullCollectNoStack(); // not really a 'collect all' -- still scans
// static data area, roots, and ranges.
}
_gc.Dtor();
}