mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 16:41:06 +03:00
Treat atomic instructions as intrinsics
Whose types aren't rewritten by the regular TargetABI.
This commit is contained in:
parent
ab2e8e3646
commit
1a42358cf6
5 changed files with 19 additions and 8 deletions
|
@ -1743,7 +1743,7 @@ bool functionParameters(Loc loc, Scope *sc, TypeFunction *tf,
|
||||||
// If not D linkage, do promotions
|
// If not D linkage, do promotions
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
// LDC: don't do promotions on intrinsics
|
// LDC: don't do promotions on intrinsics
|
||||||
if (tf->linkage != LINKd && (!fd || fd->llvmInternal != LLVMintrinsic))
|
if (tf->linkage != LINKd && (!fd || !DtoIsIntrinsic(fd)))
|
||||||
#else
|
#else
|
||||||
if (tf->linkage != LINKd)
|
if (tf->linkage != LINKd)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -288,7 +288,7 @@ llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl)
|
||||||
|
|
||||||
LLFunctionType* functype = DtoFunctionType(fdecl->type, getIrFunc(fdecl, true)->irFty, dthis, dnest,
|
LLFunctionType* functype = DtoFunctionType(fdecl->type, getIrFunc(fdecl, true)->irFty, dthis, dnest,
|
||||||
fdecl->isMain(), fdecl->isCtorDeclaration(),
|
fdecl->isMain(), fdecl->isCtorDeclaration(),
|
||||||
fdecl->llvmInternal == LLVMintrinsic);
|
DtoIsIntrinsic(fdecl));
|
||||||
|
|
||||||
return functype;
|
return functype;
|
||||||
}
|
}
|
||||||
|
@ -456,7 +456,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
||||||
//printf("declare function: %s\n", fdecl->toPrettyChars());
|
//printf("declare function: %s\n", fdecl->toPrettyChars());
|
||||||
|
|
||||||
// intrinsic sanity check
|
// intrinsic sanity check
|
||||||
if (fdecl->llvmInternal == LLVMintrinsic && fdecl->fbody) {
|
if (DtoIsIntrinsic(fdecl) && fdecl->fbody) {
|
||||||
error(fdecl->loc, "intrinsics cannot have function bodies");
|
error(fdecl->loc, "intrinsics cannot have function bodies");
|
||||||
fatal();
|
fatal();
|
||||||
}
|
}
|
||||||
|
@ -474,7 +474,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
||||||
|
|
||||||
// calling convention
|
// calling convention
|
||||||
LINK link = f->linkage;
|
LINK link = f->linkage;
|
||||||
if (vafunc || fdecl->llvmInternal == LLVMintrinsic
|
if (vafunc || DtoIsIntrinsic(fdecl)
|
||||||
// DMD treats _Dmain as having C calling convention and this has been
|
// DMD treats _Dmain as having C calling convention and this has been
|
||||||
// hardcoded into druntime, even if the frontend type has D linkage.
|
// hardcoded into druntime, even if the frontend type has D linkage.
|
||||||
// See Bugzilla issue 9028.
|
// See Bugzilla issue 9028.
|
||||||
|
@ -616,7 +616,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
||||||
static LinkageWithCOMDAT lowerFuncLinkage(FuncDeclaration* fdecl)
|
static LinkageWithCOMDAT lowerFuncLinkage(FuncDeclaration* fdecl)
|
||||||
{
|
{
|
||||||
// Intrinsics are always external.
|
// Intrinsics are always external.
|
||||||
if (fdecl->llvmInternal == LLVMintrinsic)
|
if (DtoIsIntrinsic(fdecl))
|
||||||
return LinkageWithCOMDAT(llvm::GlobalValue::ExternalLinkage, false);
|
return LinkageWithCOMDAT(llvm::GlobalValue::ExternalLinkage, false);
|
||||||
|
|
||||||
// Generated array op functions behave like templates in that they might be
|
// Generated array op functions behave like templates in that they might be
|
||||||
|
|
|
@ -567,7 +567,18 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
|
||||||
|
|
||||||
bool DtoIsIntrinsic(FuncDeclaration *fd)
|
bool DtoIsIntrinsic(FuncDeclaration *fd)
|
||||||
{
|
{
|
||||||
return (fd->llvmInternal == LLVMintrinsic || DtoIsVaIntrinsic(fd));
|
switch (fd->llvmInternal)
|
||||||
|
{
|
||||||
|
case LLVMintrinsic:
|
||||||
|
case LLVMatomic_store:
|
||||||
|
case LLVMatomic_load:
|
||||||
|
case LLVMatomic_cmp_xchg:
|
||||||
|
case LLVMatomic_rmw:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DtoIsVaIntrinsic(fd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DtoIsVaIntrinsic(FuncDeclaration *fd)
|
bool DtoIsVaIntrinsic(FuncDeclaration *fd)
|
||||||
|
|
|
@ -629,7 +629,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
|
||||||
DFuncValue* dfnval = fnval->isFunc();
|
DFuncValue* dfnval = fnval->isFunc();
|
||||||
|
|
||||||
// handle intrinsics
|
// handle intrinsics
|
||||||
bool intrinsic = (dfnval && dfnval->func && dfnval->func->llvmInternal == LLVMintrinsic);
|
bool intrinsic = (dfnval && dfnval->func && DtoIsIntrinsic(dfnval->func));
|
||||||
|
|
||||||
// get function type info
|
// get function type info
|
||||||
IrFuncTy &irFty = DtoIrTypeFunction(fnval);
|
IrFuncTy &irFty = DtoIrTypeFunction(fnval);
|
||||||
|
|
|
@ -50,7 +50,7 @@ RET retStyle(TypeFunction *tf)
|
||||||
bool DtoIsReturnInArg(CallExp *ce)
|
bool DtoIsReturnInArg(CallExp *ce)
|
||||||
{
|
{
|
||||||
TypeFunction *tf = static_cast<TypeFunction *>(ce->e1->type->toBasetype());
|
TypeFunction *tf = static_cast<TypeFunction *>(ce->e1->type->toBasetype());
|
||||||
if (tf->ty == Tfunction && (!ce->f || ce->f->llvmInternal != LLVMintrinsic))
|
if (tf->ty == Tfunction && (!ce->f || !DtoIsIntrinsic(ce->f)))
|
||||||
return retStyle(tf) == RETstack;
|
return retStyle(tf) == RETstack;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue