CC_X86StdCall, // __attribute__((stdcall))
CC_X86FastCall, // __attribute__((fastcall))
CC_X86ThisCall, // __attribute__((thiscall))
- CC_X86Pascal, // __attribute__((pascal))
- CC_Win64ThisCall
+ CC_X86Pascal // __attribute__((pascal))
};
typedef std::pair<const Type*, Qualifiers> SplitQualType;
virtual const char *getStaticInitSectionSpecifier() const {
return 0;
}
-
- // isWin64 - Whether the target is MSVC Win64.
- bool isWin64() const {
- return (Triple.getArch() == llvm::Triple::x86_64)
- && (Triple.getOS() == llvm::Triple::Win32);
- }
protected:
virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
return PointerWidth;
case CC_X86StdCall: return set("cc", "x86_stdcall");
case CC_X86ThisCall: return set("cc", "x86_thiscall");
case CC_X86Pascal: return set("cc", "x86_pascal");
- case CC_Win64ThisCall: return set("cc", "win64_thiscall");
}
}
case CC_X86ThisCall: Out << 'E'; break;
case CC_X86StdCall: Out << 'G'; break;
case CC_X86FastCall: Out << 'I'; break;
- case CC_Win64ThisCall:
- assert(false && "Don't know how to mangle Win64 thiscall cc yet!");
- break;
}
}
void MicrosoftCXXNameMangler::mangleThrowSpecification(
case CC_X86FastCall: return "fastcall";
case CC_X86ThisCall: return "thiscall";
case CC_X86Pascal: return "pascal";
- case CC_Win64ThisCall: return "win64_thiscall";
}
llvm_unreachable("Invalid calling convention.");
// Begin generating the function.
StartFunction(blockDecl, fnType->getResultType(), fn, args,
- blockInfo.getBlockExpr()->getBody()->getLocEnd(), CC_Default);
+ blockInfo.getBlockExpr()->getBody()->getLocEnd());
CurFuncDecl = outerFnDecl; // StartFunction sets this to blockDecl
// Okay. Undo some of what StartFunction did.
SC_None,
false,
true);
- StartFunction(FD, C.VoidTy, Fn, args, SourceLocation(), CC_Default);
+ StartFunction(FD, C.VoidTy, Fn, args, SourceLocation());
const llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
SC_Static,
SC_None,
false, true);
- StartFunction(FD, C.VoidTy, Fn, args, SourceLocation(), CC_Default);
+ StartFunction(FD, C.VoidTy, Fn, args, SourceLocation());
const llvm::Type *structPtrTy = blockInfo.StructureType->getPointerTo();
SC_Static,
SC_None,
false, true);
- StartFunction(FD, R, Fn, Args, SourceLocation(), CC_Default);
+ StartFunction(FD, R, Fn, Args, SourceLocation());
// dst->x
llvm::Value *V = GetAddrOfLocalVar(Dst);
SC_Static,
SC_None,
false, true);
- StartFunction(FD, R, Fn, Args, SourceLocation(), CC_Default);
+ StartFunction(FD, R, Fn, Args, SourceLocation());
llvm::Value *V = GetAddrOfLocalVar(Src);
V = Builder.CreateBitCast(V, llvm::PointerType::get(T, 0));
case CC_X86StdCall: return llvm::CallingConv::X86_StdCall;
case CC_X86FastCall: return llvm::CallingConv::X86_FastCall;
case CC_X86ThisCall: return llvm::CallingConv::X86_ThisCall;
- case CC_Win64ThisCall: return llvm::CallingConv::Win64_ThisCall;
// TODO: add support for CC_X86Pascal to llvm
}
}
static const CGFunctionInfo &getFunctionInfo(CodeGenTypes &CGT,
llvm::SmallVectorImpl<CanQualType> &ArgTys,
CanQual<FunctionProtoType> FTP,
- CallingConv CC,
bool IsRecursive = false) {
// FIXME: Kill copy.
for (unsigned i = 0, e = FTP->getNumArgs(); i != e; ++i)
ArgTys.push_back(FTP->getArgType(i));
CanQualType ResTy = FTP->getResultType().getUnqualifiedType();
-
- return CGT.getFunctionInfo(ResTy, ArgTys,
- FTP->getExtInfo().withCallingConv(CC),
- IsRecursive);
+ return CGT.getFunctionInfo(ResTy, ArgTys, FTP->getExtInfo(), IsRecursive);
}
const CGFunctionInfo &
CodeGenTypes::getFunctionInfo(CanQual<FunctionProtoType> FTP,
bool IsRecursive) {
llvm::SmallVector<CanQualType, 16> ArgTys;
- return ::getFunctionInfo(*this, ArgTys, FTP, CC_Default, IsRecursive);
+ return ::getFunctionInfo(*this, ArgTys, FTP, IsRecursive);
}
static CallingConv getCallingConventionForDecl(const Decl *D) {
// Add the 'this' pointer.
ArgTys.push_back(GetThisType(Context, RD));
- CallingConv CC = Context.Target.isWin64() ? CC_Win64ThisCall : CC_Default;
-
return ::getFunctionInfo(*this, ArgTys,
- FTP->getCanonicalTypeUnqualified().getAs<FunctionProtoType>(), CC);
+ FTP->getCanonicalTypeUnqualified().getAs<FunctionProtoType>());
}
const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const CXXMethodDecl *MD) {
if (MD->isInstance())
ArgTys.push_back(GetThisType(Context, MD->getParent()));
- CallingConv CC = Context.Target.isWin64() ? CC_Win64ThisCall : CC_Default;
-
- return ::getFunctionInfo(*this, ArgTys, GetFormalType(MD), CC);
+ return ::getFunctionInfo(*this, ArgTys, GetFormalType(MD));
}
const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const CXXConstructorDecl *D,
for (unsigned i = 0, e = FTP->getNumArgs(); i != e; ++i)
ArgTys.push_back(FTP->getArgType(i));
- CallingConv CC = Context.Target.isWin64() ? CC_Win64ThisCall : CC_Default;
-
- return getFunctionInfo(ResTy, ArgTys, FTP->getExtInfo().withCallingConv(CC));
+ return getFunctionInfo(ResTy, ArgTys, FTP->getExtInfo());
}
const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const CXXDestructorDecl *D,
CanQual<FunctionProtoType> FTP = GetFormalType(D);
assert(FTP->getNumArgs() == 0 && "dtor with formal parameters");
- CallingConv CC = Context.Target.isWin64() ? CC_Win64ThisCall : CC_Default;
-
- return getFunctionInfo(ResTy, ArgTys, FTP->getExtInfo().withCallingConv(CC));
+ return getFunctionInfo(ResTy, ArgTys, FTP->getExtInfo());
}
const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionDecl *FD) {
return *FI;
// Construct the function info.
- FI = new CGFunctionInfo(CC, Info.getNoReturn(), Info.getRegParm(),
- ResTy, ArgTys.data(), ArgTys.size());
+ FI = new CGFunctionInfo(CC, Info.getNoReturn(), Info.getRegParm(), ResTy,
+ ArgTys.data(), ArgTys.size());
FunctionInfos.InsertNode(FI, InsertPos);
// Compute ABI information.
const VarDecl *D,
llvm::GlobalVariable *Addr) {
StartFunction(GlobalDecl(), getContext().VoidTy, Fn, FunctionArgList(),
- SourceLocation(), CC_Default);
+ SourceLocation());
// Use guarded initialization if the global variable is weak due to
// being a class template's static data member.
llvm::Constant **Decls,
unsigned NumDecls) {
StartFunction(GlobalDecl(), getContext().VoidTy, Fn, FunctionArgList(),
- SourceLocation(), CC_Default);
+ SourceLocation());
for (unsigned i = 0; i != NumDecls; ++i)
if (Decls[i])
void CodeGenFunction::GenerateCXXGlobalDtorFunc(llvm::Function *Fn,
const std::vector<std::pair<llvm::WeakVH, llvm::Constant*> >
&DtorsAndObjects) {
- const bool IsWin64 = getContext().Target.isWin64();
-
StartFunction(GlobalDecl(), getContext().VoidTy, Fn, FunctionArgList(),
- SourceLocation(), IsWin64 ? CC_Win64ThisCall : CC_Default);
+ SourceLocation());
// Emit the dtors, in reverse order from construction.
for (unsigned i = 0, e = DtorsAndObjects.size(); i != e; ++i) {
llvm::Function *Fn =
CreateGlobalInitOrDestructFunction(CGM, FTy, "__cxx_global_array_dtor");
- StartFunction(GlobalDecl(), getContext().VoidTy, Fn, Args, SourceLocation(),
- CC_Default);
+ StartFunction(GlobalDecl(), getContext().VoidTy, Fn, Args, SourceLocation());
QualType BaseElementTy = getContext().getBaseElementType(Array);
const llvm::Type *BasePtr = ConvertType(BaseElementTy)->getPointerTo();
CallArgList Args;
EmitCallArgs(Args, dyn_cast<FunctionProtoType>(FnType), ArgBeg, ArgEnd);
- return EmitCall(CGM.getTypes().getFunctionInfo(Args, FnType, CC_Default),
+ return EmitCall(CGM.getTypes().getFunctionInfo(Args, FnType),
Callee, ReturnValue, Args, TargetDecl);
}
EmitCallArgs(Args, FPT, ArgBeg, ArgEnd);
QualType ResultType = FPT->getResultType();
- FunctionType::ExtInfo Info = FPT->getExtInfo();
-
- if (getContext().Target.isWin64()) {
- Info = Info.withCallingConv(CC_Win64ThisCall);
- }
-
- return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args, Info),
+ return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args,
+ FPT->getExtInfo()),
Callee, ReturnValue, Args, MD);
}
// And the rest of the call args
EmitCallArgs(Args, FPT, E->arg_begin(), E->arg_end());
const FunctionType *BO_FPT = BO->getType()->getAs<FunctionProtoType>();
-
- const CGFunctionInfo &FI = CGM.getTypes().getFunctionInfo(Args, BO_FPT,
- CGM.getContext().Target.isWin64() ? CC_Win64ThisCall : CC_Default);
-
- return EmitCall(FI , Callee, ReturnValue, Args);
+ return EmitCall(CGM.getTypes().getFunctionInfo(Args, BO_FPT), Callee,
+ ReturnValue, Args);
}
RValue
for (unsigned I = 0; I != NumPlacementArgs; ++I)
DeleteArgs.push_back(std::make_pair(getPlacementArgs()[I], *AI++));
- // FIXME Check whether this needs thiscall on Win64.
// Call 'operator delete'.
- CGF.EmitCall(CGF.CGM.getTypes().getFunctionInfo(DeleteArgs, FPT,
- CC_Default),
+ CGF.EmitCall(CGF.CGM.getTypes().getFunctionInfo(DeleteArgs, FPT),
CGF.CGM.GetAddrOfFunction(OperatorDelete),
ReturnValueSlot(), DeleteArgs, OperatorDelete);
}
DeleteArgs.push_back(std::make_pair(RV, *AI++));
}
- // FIXME Check whether this needs thiscall on Win64.
// Call 'operator delete'.
- CGF.EmitCall(CGF.CGM.getTypes().getFunctionInfo(DeleteArgs, FPT,
- CC_Default),
+ CGF.EmitCall(CGF.CGM.getTypes().getFunctionInfo(DeleteArgs, FPT),
CGF.CGM.GetAddrOfFunction(OperatorDelete),
ReturnValueSlot(), DeleteArgs, OperatorDelete);
}
// Emit the call to new.
RValue RV =
- EmitCall(CGM.getTypes().getFunctionInfo(NewArgs, NewFTy, CC_Default),
+ EmitCall(CGM.getTypes().getFunctionInfo(NewArgs, NewFTy),
CGM.GetAddrOfFunction(NewFD), ReturnValueSlot(), NewArgs, NewFD);
// If an allocation function is declared with an empty exception specification
DeleteArgs.push_back(std::make_pair(RValue::get(Size), SizeTy));
// Emit the call to delete.
- EmitCall(CGM.getTypes().getFunctionInfo(DeleteArgs, DeleteFTy, CC_Default),
+ EmitCall(CGM.getTypes().getFunctionInfo(DeleteArgs, DeleteFTy),
CGM.GetAddrOfFunction(DeleteFD), ReturnValueSlot(),
DeleteArgs, DeleteFD);
}
}
// Emit the call to delete.
- CGF.EmitCall(CGF.getTypes().getFunctionInfo(Args, DeleteFTy, CC_Default),
+ CGF.EmitCall(CGF.getTypes().getFunctionInfo(Args, DeleteFTy),
CGF.CGM.GetAddrOfFunction(OperatorDelete),
ReturnValueSlot(), Args, OperatorDelete);
}
CurGD = OMD;
- StartFunction(OMD, OMD->getResultType(), Fn, Args, OMD->getLocStart(),
- CC_Default);
+ StartFunction(OMD, OMD->getResultType(), Fn, Args, OMD->getLocStart());
}
void CodeGenFunction::GenerateObjCGetterBody(ObjCIvarDecl *Ivar,
FunctionArgs.push_back(std::make_pair(Param, Param->getType()));
}
-
- const bool IsWin64 = CGM.getContext().Target.isWin64();
-
- StartFunction(GlobalDecl(), ResultType, Fn, FunctionArgs, SourceLocation(),
- IsWin64 ? CC_Win64ThisCall : CC_Default);
+
+ StartFunction(GlobalDecl(), ResultType, Fn, FunctionArgs, SourceLocation());
CGM.getCXXABI().EmitInstanceFunctionProlog(*this);
FPT->isVariadic());
llvm::Value *Callee = CGM.GetAddrOfFunction(GD, Ty, /*ForVTable=*/true);
- FunctionType::ExtInfo Info = FPT->getExtInfo();
-
- if (IsWin64) {
- Info = Info.withCallingConv(CC_Win64ThisCall);
- }
-
const CGFunctionInfo &FnInfo =
- CGM.getTypes().getFunctionInfo(ResultType, CallArgs, Info);
+ CGM.getTypes().getFunctionInfo(ResultType, CallArgs,
+ FPT->getExtInfo());
// Determine whether we have a return value slot to use.
ReturnValueSlot Slot;
void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
llvm::Function *Fn,
const FunctionArgList &Args,
- SourceLocation StartLoc,
- CallingConv CC) {
+ SourceLocation StartLoc) {
const Decl *D = GD.getDecl();
DidCallStackSave = false;
// FIXME: Leaked.
// CC info is ignored, hopefully?
CurFnInfo = &CGM.getTypes().getFunctionInfo(FnRetTy, Args,
- FunctionType::ExtInfo().withCallingConv(CC));
+ FunctionType::ExtInfo());
if (RetTy->isVoidType()) {
// Void type; nothing to return.
if (Stmt *Body = FD->getBody()) BodyRange = Body->getSourceRange();
// Emit the standard function prologue.
- StartFunction(GD, ResTy, Fn, Args, BodyRange.getBegin(), CC_Default);
+ StartFunction(GD, ResTy, Fn, Args, BodyRange.getBegin());
// Generate the body of the function.
if (isa<CXXDestructorDecl>(FD))
void StartFunction(GlobalDecl GD, QualType RetTy,
llvm::Function *Fn,
const FunctionArgList &Args,
- SourceLocation StartLoc,
- CallingConv CC);
+ SourceLocation StartLoc);
void EmitConstructorBody(FunctionArgList &Args);
void EmitDestructorBody(FunctionArgList &Args);
CXXDtorType Type);
const CGFunctionInfo &getFunctionInfo(const CallArgList &Args,
- const FunctionType *Ty,
- CallingConv CC) {
- FunctionType::ExtInfo Info = Ty->getExtInfo().withCallingConv(CC);
-
- return getFunctionInfo(Ty->getResultType(), Args, Info);
+ const FunctionType *Ty) {
+ return getFunctionInfo(Ty->getResultType(), Args,
+ Ty->getExtInfo());
}
const CGFunctionInfo &getFunctionInfo(CanQual<FunctionProtoType> Ty,
return false;
}
-
- void SetTargetAttributes(const Decl *D,
- llvm::GlobalValue *GV,
- CodeGen::CodeGenModule &M) const {
- if (M.getContext().Target.isWin64()) {
- if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
- const CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(FD);
-
- if ((M && M->isInstance())
- || dyn_cast<CXXConstructorDecl>(FD)
- || dyn_cast<CXXDestructorDecl>(FD)) {
- // When using the MSVC Win64 ABI, methods/constructors/destructors
- // use the Win64 thiscall calling convention.
- llvm::Function *F = cast<llvm::Function>(GV);
- F->setCallingConv(llvm::CallingConv::Win64_ThisCall);
- }
- }
- }
- }
-
};
}