mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-04-25 05:09:02 +02:00
[svn r98] Added support for std.c.stdlib.alloca via pragma(LLVM_internal, "alloca").
Added support for array .sort and .reverse properties. Fixed some bugs with pointer arithmetic. Disabled some DMD AST optimizations that was messing things up, destroying valuable information. Added a KDevelop project file, this is what I use for coding LLVMDC now :) Other minor stuff.
This commit is contained in:
15
dmd/attrib.c
15
dmd/attrib.c
@@ -879,6 +879,10 @@ void PragmaDeclaration::semantic(Scope *sc)
|
||||
llvm_internal = LLVMnotypeinfo;
|
||||
assert(args->dim == 1);
|
||||
}
|
||||
else if (strcmp(str,"alloca")==0) {
|
||||
llvm_internal = LLVMalloca;
|
||||
assert(args->dim == 1);
|
||||
}
|
||||
else {
|
||||
error("unknown pragma command: %s", str);
|
||||
}
|
||||
@@ -904,6 +908,7 @@ void PragmaDeclaration::semantic(Scope *sc)
|
||||
case LLVMva_arg:
|
||||
case LLVMva_start:
|
||||
case LLVMnotypeinfo:
|
||||
case LLVMalloca:
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -960,6 +965,16 @@ void PragmaDeclaration::semantic(Scope *sc)
|
||||
s->llvmInternal = llvm_internal;
|
||||
break;
|
||||
|
||||
case LLVMalloca:
|
||||
if (FuncDeclaration* fd = s->isFuncDeclaration()) {
|
||||
fd->llvmInternal = llvm_internal;
|
||||
}
|
||||
else {
|
||||
error("may only be used on function declarations");
|
||||
assert(0);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0 && "invalid LLVM_internal pragma got through :/");
|
||||
}
|
||||
|
||||
@@ -1116,7 +1116,7 @@ Expression *BinExp::scaleFactor(Scope *sc)
|
||||
e2->type = t;
|
||||
type = e1->type;
|
||||
}
|
||||
else if (t2b->ty && t1b->isintegral())
|
||||
else if (t2b->ty == Tpointer && t1b->isintegral())
|
||||
{ // Need to adjust operator by the stride
|
||||
// Replace (int + ptr) with (ptr + (int * stride))
|
||||
Type *t = Type::tptrdiff_t;
|
||||
@@ -1127,11 +1127,13 @@ Expression *BinExp::scaleFactor(Scope *sc)
|
||||
e = e1->castTo(sc, t);
|
||||
else
|
||||
e = e1;
|
||||
#if !IN_LLVM
|
||||
if (t2b->next->isbit())
|
||||
// BUG: should add runtime check for misaligned offsets
|
||||
e = new UshrExp(loc, e, new IntegerExp(0, 3, t));
|
||||
else
|
||||
e = new MulExp(loc, e, new IntegerExp(0, stride, t));
|
||||
#endif
|
||||
e->type = t;
|
||||
type = e2->type;
|
||||
e1 = e2;
|
||||
|
||||
@@ -159,6 +159,9 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
|
||||
bcfile = new File(bcfilename);
|
||||
llfile = new File(llfilename);
|
||||
symfile = new File(symfilename);
|
||||
|
||||
// LLVMDC
|
||||
llvmCompileUnit = 0;
|
||||
}
|
||||
|
||||
void Module::setDocfile()
|
||||
|
||||
@@ -29,6 +29,7 @@ struct VarDeclaration;
|
||||
#if IN_LLVM
|
||||
struct DValue;
|
||||
typedef DValue elem;
|
||||
namespace llvm { class GlobalVariable; }
|
||||
#else
|
||||
#ifdef IN_GCC
|
||||
union tree_node; typedef union tree_node elem;
|
||||
@@ -166,6 +167,9 @@ struct Module : Package
|
||||
Symbol *toSymbol();
|
||||
void genmoduleinfo();
|
||||
|
||||
// LLVMDC
|
||||
llvm::GlobalVariable* llvmCompileUnit;
|
||||
|
||||
Module *isModule() { return this; }
|
||||
};
|
||||
|
||||
|
||||
@@ -1514,6 +1514,7 @@ Expression *TypeArray::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
||||
|
||||
nm = name[n->ty == Twchar];
|
||||
fd = FuncDeclaration::genCfunc(Type::tindex, nm);
|
||||
fd->llvmRunTimeHack = true;
|
||||
ec = new VarExp(0, fd);
|
||||
e = e->castTo(sc, n->arrayOf()); // convert to dynamic array
|
||||
arguments = new Expressions();
|
||||
@@ -1531,6 +1532,7 @@ Expression *TypeArray::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
||||
|
||||
nm = name[n->ty == Twchar];
|
||||
fd = FuncDeclaration::genCfunc(Type::tindex, nm);
|
||||
fd->llvmRunTimeHack = true;
|
||||
ec = new VarExp(0, fd);
|
||||
e = e->castTo(sc, n->arrayOf()); // convert to dynamic array
|
||||
arguments = new Expressions();
|
||||
@@ -1568,6 +1570,7 @@ Expression *TypeArray::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
||||
|
||||
fd = FuncDeclaration::genCfunc(tint32->arrayOf(),
|
||||
(char*)(n->ty == Tbit ? "_adSortBit" : "_adSort"));
|
||||
fd->llvmRunTimeHack = true;
|
||||
ec = new VarExp(0, fd);
|
||||
e = e->castTo(sc, n->arrayOf()); // convert to dynamic array
|
||||
arguments = new Expressions();
|
||||
|
||||
@@ -209,6 +209,7 @@ Expression *AddrExp::optimize(int result)
|
||||
}
|
||||
return e;
|
||||
}
|
||||
#if !IN_LLVM
|
||||
if (e1->op == TOKvar)
|
||||
{ VarExp *ve = (VarExp *)e1;
|
||||
if (!ve->var->isOut() && !ve->var->isRef() &&
|
||||
@@ -240,6 +241,7 @@ Expression *AddrExp::optimize(int result)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user