mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-04-17 17:29:02 +02:00
Merge remote-tracking branch 'upstream/llvm3.0'
This commit is contained in:
@@ -1205,7 +1205,64 @@ void PragmaDeclaration::semantic(Scope *sc)
|
||||
}
|
||||
llvm_internal = LLVMva_arg;
|
||||
}
|
||||
|
||||
|
||||
// pragma(fence) { templdecl(s) }
|
||||
else if (ident == Id::fence)
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
{
|
||||
error("takes no parameters");
|
||||
fatal();
|
||||
}
|
||||
llvm_internal = LLVMfence;
|
||||
}
|
||||
|
||||
// pragma(atomic_load) { templdecl(s) }
|
||||
else if (ident == Id::atomic_load)
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
{
|
||||
error("takes no parameters");
|
||||
fatal();
|
||||
}
|
||||
llvm_internal = LLVMatomic_load;
|
||||
}
|
||||
|
||||
// pragma(atomic_store) { templdecl(s) }
|
||||
else if (ident == Id::atomic_store)
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
{
|
||||
error("takes no parameters");
|
||||
fatal();
|
||||
}
|
||||
llvm_internal = LLVMatomic_store;
|
||||
}
|
||||
|
||||
// pragma(atomic_cmp_xchg) { templdecl(s) }
|
||||
else if (ident == Id::atomic_cmp_xchg)
|
||||
{
|
||||
if (args && args->dim > 0)
|
||||
{
|
||||
error("takes no parameters");
|
||||
fatal();
|
||||
}
|
||||
llvm_internal = LLVMatomic_cmp_xchg;
|
||||
}
|
||||
|
||||
// pragma(atomic_rmw, "string") { templdecl(s) }
|
||||
else if (ident == Id::atomic_rmw)
|
||||
{
|
||||
Expression* expr = (Expression *)args->data[0];
|
||||
expr = expr->semantic(sc);
|
||||
if (!args || args->dim != 1 || !parseStringExp(expr, arg1str))
|
||||
{
|
||||
error("requires exactly 1 string literal parameter");
|
||||
fatal();
|
||||
}
|
||||
llvm_internal = LLVMatomic_rmw;
|
||||
}
|
||||
|
||||
// pragma(ldc, "string") { templdecl(s) }
|
||||
else if (ident == Id::ldc)
|
||||
{
|
||||
@@ -1317,8 +1374,24 @@ void PragmaDeclaration::semantic(Scope *sc)
|
||||
}
|
||||
break;
|
||||
|
||||
case LLVMatomic_rmw:
|
||||
if (TemplateDeclaration* td = s->isTemplateDeclaration())
|
||||
{
|
||||
td->llvmInternal = llvm_internal;
|
||||
td->intrinsicName = arg1str;
|
||||
}
|
||||
else
|
||||
{
|
||||
error("the '%s' pragma is only allowed on template declarations", ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
break;
|
||||
|
||||
case LLVMva_start:
|
||||
case LLVMva_arg:
|
||||
case LLVMatomic_load:
|
||||
case LLVMatomic_store:
|
||||
case LLVMatomic_cmp_xchg:
|
||||
if (TemplateDeclaration* td = s->isTemplateDeclaration())
|
||||
{
|
||||
if (td->parameters->dim != 1)
|
||||
@@ -1347,6 +1420,7 @@ void PragmaDeclaration::semantic(Scope *sc)
|
||||
|
||||
case LLVMva_copy:
|
||||
case LLVMva_end:
|
||||
case LLVMfence:
|
||||
if (FuncDeclaration* fd = s->isFuncDeclaration())
|
||||
{
|
||||
fd->llvmInternal = llvm_internal;
|
||||
|
||||
@@ -3776,6 +3776,9 @@ StructLiteralExp::StructLiteralExp(Loc loc, StructDeclaration *sd, Expressions *
|
||||
#endif
|
||||
this->soffset = 0;
|
||||
this->fillHoles = 1;
|
||||
#if IN_LLVM
|
||||
constType = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
Expression *StructLiteralExp::syntaxCopy()
|
||||
|
||||
@@ -74,6 +74,7 @@ struct DValue;
|
||||
namespace llvm {
|
||||
class Constant;
|
||||
class ConstantInt;
|
||||
class StructType;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -590,6 +591,7 @@ struct StructLiteralExp : Expression
|
||||
#elif IN_LLVM
|
||||
DValue* toElem(IRState* irs);
|
||||
llvm::Constant *toConstElem(IRState *irs);
|
||||
llvm::StructType *constType;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
20
dmd2/func.c
20
dmd2/func.c
@@ -1648,29 +1648,13 @@ void FuncDeclaration::semantic3(Scope *sc)
|
||||
#if STRUCTTHISREF
|
||||
if (ad->isStructDeclaration())
|
||||
v = v->addressOf(sc);
|
||||
#endif
|
||||
#if IN_LLVM
|
||||
//e = new AssertExp(loc, v, NULL);
|
||||
|
||||
// LDC: check for null this
|
||||
//v = new ThisExp(0);
|
||||
//v->type = vthis->type;
|
||||
//v->var = vthis; // Error: Expression has no property var... in D1 typeof(v) == ThisExp
|
||||
|
||||
//NullExp *nv = new NullExp(0);
|
||||
//nv->type = v->type;
|
||||
|
||||
//IdentityExp *ie = new IdentityExp(TOKnotidentity, 0, v, nv);
|
||||
//ie->type = Type::tbool;
|
||||
#endif
|
||||
Expression *se = new StringExp(0, (char *)"null this");
|
||||
se = se->semantic(sc);
|
||||
#if !IN_LLVM
|
||||
se->type = Type::tchar->arrayOf();
|
||||
//#if IN_LLVM
|
||||
// ee = new AssertExp(loc, ie, se);
|
||||
//#else
|
||||
#endif
|
||||
e = new AssertExp(loc, v, se);
|
||||
//#endif
|
||||
}
|
||||
if (ee)
|
||||
{
|
||||
|
||||
@@ -282,6 +282,11 @@ Msgtable msgtable[] =
|
||||
{ "ldc" },
|
||||
{ "allow_inline" },
|
||||
{ "llvm_inline_asm" },
|
||||
{ "fence" },
|
||||
{ "atomic_load" },
|
||||
{ "atomic_store" },
|
||||
{ "atomic_cmp_xchg" },
|
||||
{ "atomic_rmw" },
|
||||
#endif
|
||||
|
||||
// For special functions
|
||||
|
||||
@@ -114,6 +114,9 @@ StructInitializer::StructInitializer(Loc loc)
|
||||
: Initializer(loc)
|
||||
{
|
||||
ad = NULL;
|
||||
#if IN_LLVM
|
||||
ltype = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
Initializer *StructInitializer::syntaxCopy()
|
||||
|
||||
@@ -28,6 +28,12 @@ struct ArrayInitializer;
|
||||
struct ExpInitializer;
|
||||
struct HdrGenState;
|
||||
|
||||
#if IN_LLVM
|
||||
namespace llvm {
|
||||
class StructType;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
struct Initializer : Object
|
||||
{
|
||||
@@ -91,6 +97,9 @@ struct StructInitializer : Initializer
|
||||
#endif
|
||||
|
||||
StructInitializer *isStructInitializer() { return this; }
|
||||
#if IN_LLVM
|
||||
llvm::StructType *ltype;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct ArrayInitializer : Initializer
|
||||
|
||||
@@ -213,7 +213,7 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
|
||||
// LDC
|
||||
llvmForceLogging = false;
|
||||
moduleInfoVar = NULL;
|
||||
moduleInfoType = new llvm::PATypeHolder(llvm::OpaqueType::get(llvm::getGlobalContext()));
|
||||
moduleInfoType = llvm::StructType::create(llvm::getGlobalContext());
|
||||
this->doDocComment = doDocComment;
|
||||
this->doHdrGen = doHdrGen;
|
||||
this->isRoot = false;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace llvm {
|
||||
class LLVMContext;
|
||||
class Module;
|
||||
class GlobalVariable;
|
||||
class PATypeHolder;
|
||||
class StructType;
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -208,7 +208,7 @@ struct Module : Package
|
||||
|
||||
bool llvmForceLogging;
|
||||
llvm::GlobalVariable* moduleInfoVar;
|
||||
llvm::PATypeHolder* moduleInfoType;
|
||||
llvm::StructType* moduleInfoType;
|
||||
|
||||
// array ops emitted in this module already
|
||||
AA *arrayfuncs;
|
||||
|
||||
@@ -106,6 +106,7 @@ enum BE
|
||||
struct Statement : Object
|
||||
{
|
||||
Loc loc;
|
||||
virtual ~Statement() {}
|
||||
|
||||
Statement(Loc loc);
|
||||
virtual Statement *syntaxCopy();
|
||||
|
||||
Reference in New Issue
Block a user