Skip to content

Commit 82de92c

Browse files
committed
Merge pull request #1089 from kinke/intrinsic
Treat atomic instructions as intrinsics
2 parents ab8f817 + 1a42358 commit 82de92c

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

dmd2/expression.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1743,7 +1743,7 @@ bool functionParameters(Loc loc, Scope *sc, TypeFunction *tf,
17431743
// If not D linkage, do promotions
17441744
#if IN_LLVM
17451745
// LDC: don't do promotions on intrinsics
1746-
if (tf->linkage != LINKd && (!fd || fd->llvmInternal != LLVMintrinsic))
1746+
if (tf->linkage != LINKd && (!fd || !DtoIsIntrinsic(fd)))
17471747
#else
17481748
if (tf->linkage != LINKd)
17491749
#endif

gen/functions.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl)
288288

289289
LLFunctionType* functype = DtoFunctionType(fdecl->type, getIrFunc(fdecl, true)->irFty, dthis, dnest,
290290
fdecl->isMain(), fdecl->isCtorDeclaration(),
291-
fdecl->llvmInternal == LLVMintrinsic);
291+
DtoIsIntrinsic(fdecl));
292292

293293
return functype;
294294
}
@@ -456,7 +456,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
456456
//printf("declare function: %s\n", fdecl->toPrettyChars());
457457

458458
// intrinsic sanity check
459-
if (fdecl->llvmInternal == LLVMintrinsic && fdecl->fbody) {
459+
if (DtoIsIntrinsic(fdecl) && fdecl->fbody) {
460460
error(fdecl->loc, "intrinsics cannot have function bodies");
461461
fatal();
462462
}
@@ -474,7 +474,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
474474

475475
// calling convention
476476
LINK link = f->linkage;
477-
if (vafunc || fdecl->llvmInternal == LLVMintrinsic
477+
if (vafunc || DtoIsIntrinsic(fdecl)
478478
// DMD treats _Dmain as having C calling convention and this has been
479479
// hardcoded into druntime, even if the frontend type has D linkage.
480480
// See Bugzilla issue 9028.
@@ -616,7 +616,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
616616
static LinkageWithCOMDAT lowerFuncLinkage(FuncDeclaration* fdecl)
617617
{
618618
// Intrinsics are always external.
619-
if (fdecl->llvmInternal == LLVMintrinsic)
619+
if (DtoIsIntrinsic(fdecl))
620620
return LinkageWithCOMDAT(llvm::GlobalValue::ExternalLinkage, false);
621621

622622
// Generated array op functions behave like templates in that they might be

gen/pragma.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,18 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
567567

568568
bool DtoIsIntrinsic(FuncDeclaration *fd)
569569
{
570-
return (fd->llvmInternal == LLVMintrinsic || DtoIsVaIntrinsic(fd));
570+
switch (fd->llvmInternal)
571+
{
572+
case LLVMintrinsic:
573+
case LLVMatomic_store:
574+
case LLVMatomic_load:
575+
case LLVMatomic_cmp_xchg:
576+
case LLVMatomic_rmw:
577+
return true;
578+
579+
default:
580+
return DtoIsVaIntrinsic(fd);
581+
}
571582
}
572583

573584
bool DtoIsVaIntrinsic(FuncDeclaration *fd)

gen/tocall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
629629
DFuncValue* dfnval = fnval->isFunc();
630630

631631
// handle intrinsics
632-
bool intrinsic = (dfnval && dfnval->func && dfnval->func->llvmInternal == LLVMintrinsic);
632+
bool intrinsic = (dfnval && dfnval->func && DtoIsIntrinsic(dfnval->func));
633633

634634
// get function type info
635635
IrFuncTy &irFty = DtoIrTypeFunction(fnval);

gen/tollvm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ RET retStyle(TypeFunction *tf)
5050
bool DtoIsReturnInArg(CallExp *ce)
5151
{
5252
TypeFunction *tf = static_cast<TypeFunction *>(ce->e1->type->toBasetype());
53-
if (tf->ty == Tfunction && (!ce->f || ce->f->llvmInternal != LLVMintrinsic))
53+
if (tf->ty == Tfunction && (!ce->f || !DtoIsIntrinsic(ce->f)))
5454
return retStyle(tf) == RETstack;
5555
return false;
5656
}

0 commit comments

Comments
 (0)