Make FuncDeclaration::isIntrinsic and FuncDeclaration::isVaIntrinsic free functions

This commit is contained in:
Alexey Prokhin 2014-09-22 16:51:02 +04:00
parent 68649882f4
commit 0f7a3b64c5
6 changed files with 24 additions and 26 deletions

View file

@ -756,9 +756,6 @@ public:
std::string intrinsicName; std::string intrinsicName;
uint32_t priority; uint32_t priority;
bool isIntrinsic();
bool isVaIntrinsic();
// true if overridden with the pragma(LDC_allow_inline); stmt // true if overridden with the pragma(LDC_allow_inline); stmt
bool allowInlining; bool allowInlining;

View file

@ -9249,11 +9249,11 @@ Expression *AddrExp::semantic(Scope *sc)
if (f) if (f)
{ {
#if IN_LLVM #if IN_LLVM
if (f->isIntrinsic()) if (DtoIsIntrinsic(f))
{ {
error("cannot take the address of intrinsic function %s", e1->toChars()); error("cannot take the address of intrinsic function %s", e1->toChars());
return this; return this;
} }
#endif #endif
/* Because nested functions cannot be overloaded, /* Because nested functions cannot be overloaded,

View file

@ -449,7 +449,7 @@ static llvm::FunctionType* DtoVaFunctionType(FuncDeclaration* fdecl)
llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl) llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl)
{ {
// handle for C vararg intrinsics // handle for C vararg intrinsics
if (fdecl->isVaIntrinsic()) if (DtoIsVaIntrinsic(fdecl))
return DtoVaFunctionType(fdecl); return DtoVaFunctionType(fdecl);
Type *dthis=0, *dnest=0; Type *dthis=0, *dnest=0;
@ -770,7 +770,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
IrFunction *irFunc = getIrFunc(fdecl, true); IrFunction *irFunc = getIrFunc(fdecl, true);
LLFunction* vafunc = 0; LLFunction* vafunc = 0;
if (fdecl->isVaIntrinsic()) if (DtoIsVaIntrinsic(fdecl))
vafunc = DtoDeclareVaFunction(fdecl); vafunc = DtoDeclareVaFunction(fdecl);
// calling convention // calling convention
@ -817,7 +817,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
irFunc->func = func; irFunc->func = func;
// parameter attributes // parameter attributes
if (!fdecl->isIntrinsic()) { if (!DtoIsIntrinsic(fdecl)) {
set_param_attrs(f, func, fdecl); set_param_attrs(f, func, fdecl);
if (global.params.disableRedZone) { if (global.params.disableRedZone) {
func->addFnAttr(llvm::Attribute::NoRedZone); func->addFnAttr(llvm::Attribute::NoRedZone);
@ -1298,20 +1298,6 @@ void DtoVariadicArgument(Expression* argexp, LLValue* dst)
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
bool FuncDeclaration::isIntrinsic()
{
return (llvmInternal == LLVMintrinsic || isVaIntrinsic());
}
bool FuncDeclaration::isVaIntrinsic()
{
return (llvmInternal == LLVMva_start ||
llvmInternal == LLVMva_copy ||
llvmInternal == LLVMva_end);
}
//////////////////////////////////////////////////////////////////////////////////////////
int binary(const char *p , const char **tab, int high) int binary(const char *p , const char **tab, int high)
{ {
int i = 0, j = high, k, l; int i = 0, j = high, k, l;

View file

@ -560,3 +560,15 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s,
ident->toChars()); ident->toChars());
} }
} }
bool DtoIsIntrinsic(FuncDeclaration *fd)
{
return (fd->llvmInternal == LLVMintrinsic || DtoIsVaIntrinsic(fd));
}
bool DtoIsVaIntrinsic(FuncDeclaration *fd)
{
return (fd->llvmInternal == LLVMva_start ||
fd->llvmInternal == LLVMva_copy ||
fd->llvmInternal == LLVMva_end);
}

View file

@ -17,6 +17,7 @@
#include <string> #include <string>
class PragmaDeclaration; class PragmaDeclaration;
class FuncDeclaration;
class Dsymbol; class Dsymbol;
struct Scope; struct Scope;
@ -50,5 +51,7 @@ enum Pragma
Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str); Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str);
void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *sym, void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *sym,
Pragma llvm_internal, const std::string &arg1str); Pragma llvm_internal, const std::string &arg1str);
bool DtoIsIntrinsic(FuncDeclaration *fd);
bool DtoIsVaIntrinsic(FuncDeclaration *fd);
#endif // LDC_GEN_PRAGMA_H #endif // LDC_GEN_PRAGMA_H

View file

@ -349,7 +349,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
bool intrinsic = (dfnval && dfnval->func && dfnval->func->llvmInternal == LLVMintrinsic); bool intrinsic = (dfnval && dfnval->func && dfnval->func->llvmInternal == LLVMintrinsic);
// handle special vararg intrinsics // handle special vararg intrinsics
bool va_intrinsic = (dfnval && dfnval->func && dfnval->func->isVaIntrinsic()); bool va_intrinsic = (dfnval && dfnval->func && DtoIsVaIntrinsic(dfnval->func));
// get function type info // get function type info
IrFuncTy &irFty = DtoIrTypeFunction(fnval); IrFuncTy &irFty = DtoIrTypeFunction(fnval);