llvm.org GIT mirror llvm / 65c3c8f
Retype from unsigned to CallingConv::ID accordingly. Approved by Bob Wilson. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80773 91177308-0d34-0410-b5e6-96231b3b80d8 Sandeep Patel 10 years ago
43 changed file(s) with 215 addition(s) and 182 deletion(s). Raw diff Collapse all Expand all
1717 #include "llvm/ADT/SmallVector.h"
1818 #include "llvm/CodeGen/ValueTypes.h"
1919 #include "llvm/CodeGen/SelectionDAGNodes.h"
20 #include "llvm/CallingConv.h"
2021
2122 namespace llvm {
2223 class TargetRegisterInfo;
141142 /// return values. It captures which registers are already assigned and which
142143 /// stack slots are used. It provides accessors to allocate these values.
143144 class CCState {
144 unsigned CallingConv;
145 CallingConv::ID CallingConv;
145146 bool IsVarArg;
146147 const TargetMachine &TM;
147148 const TargetRegisterInfo &TRI;
151152 unsigned StackOffset;
152153 SmallVector UsedRegs;
153154 public:
154 CCState(unsigned CC, bool isVarArg, const TargetMachine &TM,
155 CCState(CallingConv::ID CC, bool isVarArg, const TargetMachine &TM,
155156 SmallVector &locs, LLVMContext &C);
156157
157158 void addLoc(const CCValAssign &V) {
160161
161162 LLVMContext &getContext() const { return Context; }
162163 const TargetMachine &getTarget() const { return TM; }
163 unsigned getCallingConv() const { return CallingConv; }
164 CallingConv::ID getCallingConv() const { return CallingConv; }
164165 bool isVarArg() const { return IsVarArg; }
165166
166167 unsigned getNextStackOffset() const { return StackOffset; }
1818 #define LLVM_FUNCTION_H
1919
2020 #include "llvm/GlobalValue.h"
21 #include "llvm/CallingConv.h"
2122 #include "llvm/BasicBlock.h"
2223 #include "llvm/Argument.h"
2324 #include "llvm/Attributes.h"
8586 AttrListPtr AttributeList; ///< Parameter attributes
8687
8788 // The Calling Convention is stored in Value::SubclassData.
88 /*unsigned CallingConvention;*/
89 /*CallingConv::ID CallingConvention;*/
8990
9091 friend class SymbolTableListTraits;
9192
149150 unsigned getIntrinsicID() const;
150151 bool isIntrinsic() const { return getIntrinsicID() != 0; }
151152
152 /// getCallingConv()/setCallingConv(uint) - These method get and set the
153 /// getCallingConv()/setCallingConv(CC) - These method get and set the
153154 /// calling convention of this function. The enum values for the known
154155 /// calling conventions are defined in CallingConv.h.
155 unsigned getCallingConv() const { return SubclassData >> 1; }
156 void setCallingConv(unsigned CC) {
157 SubclassData = (SubclassData & 1) | (CC << 1);
156 CallingConv::ID getCallingConv() const {
157 return static_cast(SubclassData >> 1);
158 }
159 void setCallingConv(CallingConv::ID CC) {
160 SubclassData = (SubclassData & 1) | (static_cast(CC) << 1);
158161 }
159162
160163 /// getAttributes - Return the attribute list for this Function.
1919 #include "llvm/DerivedTypes.h"
2020 #include "llvm/Attributes.h"
2121 #include "llvm/BasicBlock.h"
22 #include "llvm/CallingConv.h"
2223 #include "llvm/LLVMContext.h"
2324 #include "llvm/ADT/SmallVector.h"
2425 #include
10411042
10421043 /// getCallingConv/setCallingConv - Get or set the calling convention of this
10431044 /// function call.
1044 unsigned getCallingConv() const { return SubclassData >> 1; }
1045 void setCallingConv(unsigned CC) {
1046 SubclassData = (SubclassData & 1) | (CC << 1);
1045 CallingConv::ID getCallingConv() const {
1046 return static_cast(SubclassData >> 1);
1047 }
1048 void setCallingConv(CallingConv::ID CC) {
1049 SubclassData = (SubclassData & 1) | (static_cast(CC) << 1);
10471050 }
10481051
10491052 /// getAttributes - Return the parameter attributes for this call.
23812384
23822385 /// getCallingConv/setCallingConv - Get or set the calling convention of this
23832386 /// function call.
2384 unsigned getCallingConv() const { return SubclassData; }
2385 void setCallingConv(unsigned CC) {
2386 SubclassData = CC;
2387 CallingConv::ID getCallingConv() const {
2388 return static_cast(SubclassData);
2389 }
2390 void setCallingConv(CallingConv::ID CC) {
2391 SubclassData = static_cast(CC);
23872392 }
23882393
23892394 /// getAttributes - Return the parameter attributes for this invoke.
2525 #include "llvm/Attributes.h"
2626 #include "llvm/ADT/PointerIntPair.h"
2727 #include "llvm/BasicBlock.h"
28 #include "llvm/CallingConv.h"
2829 #include "llvm/Instruction.h"
2930
3031 namespace llvm {
6061
6162 /// getCallingConv/setCallingConv - get or set the calling convention of the
6263 /// call.
63 unsigned getCallingConv() const;
64 void setCallingConv(unsigned CC);
64 CallingConv::ID getCallingConv() const;
65 void setCallingConv(CallingConv::ID CC);
6566
6667 /// getAttributes/setAttributes - get or set the parameter attributes of
6768 /// the call.
11151115 ///
11161116 virtual SDValue
11171117 LowerFormalArguments(SDValue Chain,
1118 unsigned CallConv, bool isVarArg,
1118 CallingConv::ID CallConv, bool isVarArg,
11191119 const SmallVectorImpl &Ins,
11201120 DebugLoc dl, SelectionDAG &DAG,
11211121 SmallVectorImpl &InVals) {
11461146 std::pair
11471147 LowerCallTo(SDValue Chain, const Type *RetTy, bool RetSExt, bool RetZExt,
11481148 bool isVarArg, bool isInreg, unsigned NumFixedArgs,
1149 unsigned CallConv, bool isTailCall, bool isReturnValueUsed,
1150 SDValue Callee, ArgListTy &Args, SelectionDAG &DAG, DebugLoc dl);
1149 CallingConv::ID CallConv, bool isTailCall,
1150 bool isReturnValueUsed, SDValue Callee, ArgListTy &Args,
1151 SelectionDAG &DAG, DebugLoc dl);
11511152
11521153 /// LowerCall - This hook must be implemented to lower calls into the
11531154 /// the specified DAG. The outgoing arguments to the call are described
11631164 ///
11641165 virtual SDValue
11651166 LowerCall(SDValue Chain, SDValue Callee,
1166 unsigned CallConv, bool isVarArg, bool isTailCall,
1167 CallingConv::ID CallConv, bool isVarArg, bool isTailCall,
11671168 const SmallVectorImpl &Outs,
11681169 const SmallVectorImpl &Ins,
11691170 DebugLoc dl, SelectionDAG &DAG,
11781179 /// value.
11791180 ///
11801181 virtual SDValue
1181 LowerReturn(SDValue Chain, unsigned CallConv, bool isVarArg,
1182 LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
11821183 const SmallVectorImpl &Outs,
11831184 DebugLoc dl, SelectionDAG &DAG) {
11841185 assert(0 && "Not Implemented");
12821283 /// should override this function.
12831284 virtual bool
12841285 IsEligibleForTailCallOptimization(SDValue Callee,
1285 unsigned CalleeCC,
1286 CallingConv::ID CalleeCC,
12861287 bool isVarArg,
12871288 const SmallVectorImpl &Ins,
12881289 SelectionDAG& DAG) const {
997997 /// ::= 'arm_aapcs_vfpcc'
998998 /// ::= 'cc' UINT
999999 ///
1000 bool LLParser::ParseOptionalCallingConv(unsigned &CC) {
1000 bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) {
10011001 switch (Lex.getKind()) {
10021002 default: CC = CallingConv::C; return false;
10031003 case lltok::kw_ccc: CC = CallingConv::C; break;
10081008 case lltok::kw_arm_apcscc: CC = CallingConv::ARM_APCS; break;
10091009 case lltok::kw_arm_aapcscc: CC = CallingConv::ARM_AAPCS; break;
10101010 case lltok::kw_arm_aapcs_vfpcc:CC = CallingConv::ARM_AAPCS_VFP; break;
1011 case lltok::kw_cc: Lex.Lex(); return ParseUInt32(CC);
1012 }
1011 case lltok::kw_cc: {
1012 unsigned ArbitraryCC;
1013 Lex.Lex();
1014 if (ParseUInt32(ArbitraryCC)) {
1015 return true;
1016 } else
1017 CC = static_cast(ArbitraryCC);
1018 return false;
1019 }
1020 break;
1021 }
1022
10131023 Lex.Lex();
10141024 return false;
10151025 }
23562366 LocTy LinkageLoc = Lex.getLoc();
23572367 unsigned Linkage;
23582368
2359 unsigned Visibility, CC, RetAttrs;
2369 unsigned Visibility, RetAttrs;
2370 CallingConv::ID CC;
23602371 PATypeHolder RetType(Type::getVoidTy(Context));
23612372 LocTy RetTypeLoc = Lex.getLoc();
23622373 if (ParseOptionalLinkage(Linkage) ||
29162927 /// OptionalAttrs 'to' TypeAndValue 'unwind' TypeAndValue
29172928 bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
29182929 LocTy CallLoc = Lex.getLoc();
2919 unsigned CC, RetAttrs, FnAttrs;
2930 unsigned RetAttrs, FnAttrs;
2931 CallingConv::ID CC;
29202932 PATypeHolder RetType(Type::getVoidTy(Context));
29212933 LocTy RetTypeLoc;
29222934 ValID CalleeID;
32643276 /// ParameterList OptionalAttrs
32653277 bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
32663278 bool isTail) {
3267 unsigned CC, RetAttrs, FnAttrs;
3279 unsigned RetAttrs, FnAttrs;
3280 CallingConv::ID CC;
32683281 PATypeHolder RetType(Type::getVoidTy(Context));
32693282 LocTy RetTypeLoc;
32703283 ValID CalleeID;
125125 bool HasLinkage; return ParseOptionalLinkage(Linkage, HasLinkage);
126126 }
127127 bool ParseOptionalVisibility(unsigned &Visibility);
128 bool ParseOptionalCallingConv(unsigned &CC);
128 bool ParseOptionalCallingConv(CallingConv::ID &CC);
129129 bool ParseOptionalAlignment(unsigned &Alignment);
130130 bool ParseOptionalCommaAlignment(unsigned &Alignment);
131131 bool ParseIndexList(SmallVectorImpl &Indices);
14161416 Function *Func = Function::Create(FTy, GlobalValue::ExternalLinkage,
14171417 "", TheModule);
14181418
1419 Func->setCallingConv(Record[1]);
1419 Func->setCallingConv(static_cast(Record[1]));
14201420 bool isProto = Record[2];
14211421 Func->setLinkage(GetDecodedLinkage(Record[3]));
14221422 Func->setAttributes(getAttributes(Record[4]));
19171917
19181918 I = InvokeInst::Create(Callee, NormalBB, UnwindBB,
19191919 Ops.begin(), Ops.end());
1920 cast(I)->setCallingConv(CCInfo);
1920 cast(I)->setCallingConv(
1921 static_cast(CCInfo));
19211922 cast(I)->setAttributes(PAL);
19221923 break;
19231924 }
20552056 }
20562057
20572058 I = CallInst::Create(Callee, Args.begin(), Args.end());
2058 cast(I)->setCallingConv(CCInfo>>1);
2059 cast(I)->setCallingConv(
2060 static_cast(CCInfo>>1));
20592061 cast(I)->setTailCall(CCInfo & 1);
20602062 cast(I)->setAttributes(PAL);
20612063 break;
1919 #include "llvm/Target/TargetMachine.h"
2020 using namespace llvm;
2121
22 CCState::CCState(unsigned CC, bool isVarArg, const TargetMachine &tm,
22 CCState::CCState(CallingConv::ID CC, bool isVarArg, const TargetMachine &tm,
2323 SmallVector &locs, LLVMContext &C)
2424 : CallingConv(CC), IsVarArg(isVarArg), TM(tm),
2525 TRI(*TM.getRegisterInfo()), Locs(locs), Context(C) {
988988 }
989989
990990 bool isVarArg = DAG.getMachineFunction().getFunction()->isVarArg();
991 unsigned CallConv = DAG.getMachineFunction().getFunction()->getCallingConv();
991 CallingConv::ID CallConv =
992 DAG.getMachineFunction().getFunction()->getCallingConv();
992993 Chain = TLI.LowerReturn(Chain, CallConv, isVarArg,
993994 Outs, getCurDebugLoc(), DAG);
994995
56125613 TargetLowering::LowerCallTo(SDValue Chain, const Type *RetTy,
56135614 bool RetSExt, bool RetZExt, bool isVarArg,
56145615 bool isInreg, unsigned NumFixedArgs,
5615 unsigned CallConv, bool isTailCall,
5616 CallingConv::ID CallConv, bool isTailCall,
56165617 bool isReturnValueUsed,
56175618 SDValue Callee,
56185619 ArgListTy &Args, SelectionDAG &DAG, DebugLoc dl) {
684684
685685 /// CCAssignFnForNode - Selects the correct CCAssignFn for a the
686686 /// given CallingConvention value.
687 CCAssignFn *ARMTargetLowering::CCAssignFnForNode(unsigned CC,
687 CCAssignFn *ARMTargetLowering::CCAssignFnForNode(CallingConv::ID CC,
688688 bool Return,
689689 bool isVarArg) const {
690690 switch (CC) {
714714 /// appropriate copies out of appropriate physical registers.
715715 SDValue
716716 ARMTargetLowering::LowerCallResult(SDValue Chain, SDValue InFlag,
717 unsigned CallConv, bool isVarArg,
717 CallingConv::ID CallConv, bool isVarArg,
718718 const SmallVectorImpl &Ins,
719719 DebugLoc dl, SelectionDAG &DAG,
720720 SmallVectorImpl &InVals) {
845845 /// nodes.
846846 SDValue
847847 ARMTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
848 unsigned CallConv, bool isVarArg,
848 CallingConv::ID CallConv, bool isVarArg,
849849 bool isTailCall,
850850 const SmallVectorImpl &Outs,
851851 const SmallVectorImpl &Ins,
10491049
10501050 SDValue
10511051 ARMTargetLowering::LowerReturn(SDValue Chain,
1052 unsigned CallConv, bool isVarArg,
1052 CallingConv::ID CallConv, bool isVarArg,
10531053 const SmallVectorImpl &Outs,
10541054 DebugLoc dl, SelectionDAG &DAG) {
10551055
15491549
15501550 SDValue
15511551 ARMTargetLowering::LowerFormalArguments(SDValue Chain,
1552 unsigned CallConv, bool isVarArg,
1552 CallingConv::ID CallConv, bool isVarArg,
15531553 const SmallVectorImpl
15541554 &Ins,
15551555 DebugLoc dl, SelectionDAG &DAG,
245245 SDValue GetF64FormalArgument(CCValAssign &VA, CCValAssign &NextVA,
246246 SDValue &Root, SelectionDAG &DAG, DebugLoc dl);
247247
248 CCAssignFn *CCAssignFnForNode(unsigned CC, bool Return, bool isVarArg) const;
248 CCAssignFn *CCAssignFnForNode(CallingConv::ID CC, bool Return, bool isVarArg) const;
249249 SDValue LowerMemOpCallTo(SDValue Chain, SDValue StackPtr, SDValue Arg,
250250 DebugLoc dl, SelectionDAG &DAG,
251251 const CCValAssign &VA,
272272 const Value *DstSV, uint64_t DstSVOff,
273273 const Value *SrcSV, uint64_t SrcSVOff);
274274 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
275 unsigned CallConv, bool isVarArg,
275 CallingConv::ID CallConv, bool isVarArg,
276276 const SmallVectorImpl &Ins,
277277 DebugLoc dl, SelectionDAG &DAG,
278278 SmallVectorImpl &InVals);
279279
280280 virtual SDValue
281281 LowerFormalArguments(SDValue Chain,
282 unsigned CallConv, bool isVarArg,
282 CallingConv::ID CallConv, bool isVarArg,
283283 const SmallVectorImpl &Ins,
284284 DebugLoc dl, SelectionDAG &DAG,
285285 SmallVectorImpl &InVals);
286286
287287 virtual SDValue
288288 LowerCall(SDValue Chain, SDValue Callee,
289 unsigned CallConv, bool isVarArg,
289 CallingConv::ID CallConv, bool isVarArg,
290290 bool isTailCall,
291291 const SmallVectorImpl &Outs,
292292 const SmallVectorImpl &Ins,
295295
296296 virtual SDValue
297297 LowerReturn(SDValue Chain,
298 unsigned CallConv, bool isVarArg,
298 CallingConv::ID CallConv, bool isVarArg,
299299 const SmallVectorImpl &Outs,
300300 DebugLoc dl, SelectionDAG &DAG);
301301 };
231231
232232 SDValue
233233 AlphaTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
234 unsigned CallConv, bool isVarArg,
234 CallingConv::ID CallConv, bool isVarArg,
235235 bool isTailCall,
236236 const SmallVectorImpl &Outs,
237237 const SmallVectorImpl &Ins,
347347 ///
348348 SDValue
349349 AlphaTargetLowering::LowerCallResult(SDValue Chain, SDValue InFlag,
350 unsigned CallConv, bool isVarArg,
350 CallingConv::ID CallConv, bool isVarArg,
351351 const SmallVectorImpl &Ins,
352352 DebugLoc dl, SelectionDAG &DAG,
353353 SmallVectorImpl &InVals) {
389389
390390 SDValue
391391 AlphaTargetLowering::LowerFormalArguments(SDValue Chain,
392 unsigned CallConv, bool isVarArg,
392 CallingConv::ID CallConv, bool isVarArg,
393393 const SmallVectorImpl
394394 &Ins,
395395 DebugLoc dl, SelectionDAG &DAG,
470470
471471 SDValue
472472 AlphaTargetLowering::LowerReturn(SDValue Chain,
473 unsigned CallConv, bool isVarArg,
473 CallingConv::ID CallConv, bool isVarArg,
474474 const SmallVectorImpl &Outs,
475475 DebugLoc dl, SelectionDAG &DAG) {
476476
8181 const char *getTargetNodeName(unsigned Opcode) const;
8282
8383 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
84 unsigned CallConv, bool isVarArg,
84 CallingConv::ID CallConv, bool isVarArg,
8585 const SmallVectorImpl &Ins,
8686 DebugLoc dl, SelectionDAG &DAG,
8787 SmallVectorImpl &InVals);
107107
108108 virtual SDValue
109109 LowerFormalArguments(SDValue Chain,
110 unsigned CallConv, bool isVarArg,
110 CallingConv::ID CallConv, bool isVarArg,
111111 const SmallVectorImpl &Ins,
112112 DebugLoc dl, SelectionDAG &DAG,
113113 SmallVectorImpl &InVals);
114114
115115 virtual SDValue
116116 LowerCall(SDValue Chain, SDValue Callee,
117 unsigned CallConv, bool isVarArg, bool isTailCall,
117 CallingConv::ID CallConv, bool isVarArg, bool isTailCall,
118118 const SmallVectorImpl &Outs,
119119 const SmallVectorImpl &Ins,
120120 DebugLoc dl, SelectionDAG &DAG,
122122
123123 virtual SDValue
124124 LowerReturn(SDValue Chain,
125 unsigned CallConv, bool isVarArg,
125 CallingConv::ID CallConv, bool isVarArg,
126126 const SmallVectorImpl &Outs,
127127 DebugLoc dl, SelectionDAG &DAG);
128128 };
160160
161161 SDValue
162162 BlackfinTargetLowering::LowerFormalArguments(SDValue Chain,
163 unsigned CallConv, bool isVarArg,
163 CallingConv::ID CallConv, bool isVarArg,
164164 const SmallVectorImpl
165165 &Ins,
166166 DebugLoc dl, SelectionDAG &DAG,
217217
218218 SDValue
219219 BlackfinTargetLowering::LowerReturn(SDValue Chain,
220 unsigned CallConv, bool isVarArg,
220 CallingConv::ID CallConv, bool isVarArg,
221221 const SmallVectorImpl &Outs,
222222 DebugLoc dl, SelectionDAG &DAG) {
223223
274274
275275 SDValue
276276 BlackfinTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
277 unsigned CallConv, bool isVarArg,
277 CallingConv::ID CallConv, bool isVarArg,
278278 bool isTailCall,
279279 const SmallVectorImpl &Outs,
280280 const SmallVectorImpl &Ins,
5757
5858 virtual SDValue
5959 LowerFormalArguments(SDValue Chain,
60 unsigned CallConv, bool isVarArg,
60 CallingConv::ID CallConv, bool isVarArg,
6161 const SmallVectorImpl &Ins,
6262 DebugLoc dl, SelectionDAG &DAG,
6363 SmallVectorImpl &InVals);
6464 virtual SDValue
6565 LowerCall(SDValue Chain, SDValue Callee,
66 unsigned CallConv, bool isVarArg, bool isTailCall,
66 CallingConv::ID CallConv, bool isVarArg, bool isTailCall,
6767 const SmallVectorImpl &Outs,
6868 const SmallVectorImpl &Ins,
6969 DebugLoc dl, SelectionDAG &DAG,
7171
7272 virtual SDValue
7373 LowerReturn(SDValue Chain,
74 unsigned CallConv, bool isVarArg,
74 CallingConv::ID CallConv, bool isVarArg,
7575 const SmallVectorImpl &Outs,
7676 DebugLoc dl, SelectionDAG &DAG);
7777 };
22822282 case CallingConv::X86_FastCall:
22832283 Out << "__attribute__((fastcall)) ";
22842284 break;
2285 default:
2286 break;
22852287 }
22862288
22872289 // Loop over the arguments, printing them...
10141014
10151015 SDValue
10161016 SPUTargetLowering::LowerFormalArguments(SDValue Chain,
1017 unsigned CallConv, bool isVarArg,
1017 CallingConv::ID CallConv, bool isVarArg,
10181018 const SmallVectorImpl
10191019 &Ins,
10201020 DebugLoc dl, SelectionDAG &DAG,
11431143
11441144 SDValue
11451145 SPUTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
1146 unsigned CallConv, bool isVarArg,
1146 CallingConv::ID CallConv, bool isVarArg,
11471147 bool isTailCall,
11481148 const SmallVectorImpl &Outs,
11491149 const SmallVectorImpl &Ins,
13701370
13711371 SDValue
13721372 SPUTargetLowering::LowerReturn(SDValue Chain,
1373 unsigned CallConv, bool isVarArg,
1373 CallingConv::ID CallConv, bool isVarArg,
13741374 const SmallVectorImpl &Outs,
13751375 DebugLoc dl, SelectionDAG &DAG) {
13761376
149149
150150 virtual SDValue
151151 LowerFormalArguments(SDValue Chain,
152 unsigned CallConv, bool isVarArg,
152 CallingConv::ID CallConv, bool isVarArg,
153153 const SmallVectorImpl &Ins,
154154 DebugLoc dl, SelectionDAG &DAG,
155155 SmallVectorImpl &InVals);
156156
157157 virtual SDValue
158158 LowerCall(SDValue Chain, SDValue Callee,
159 unsigned CallConv, bool isVarArg,
159 CallingConv::ID CallConv, bool isVarArg,
160160 bool isTailCall,
161161 const SmallVectorImpl &Outs,
162162 const SmallVectorImpl &Ins,
165165
166166 virtual SDValue
167167 LowerReturn(SDValue Chain,
168 unsigned CallConv, bool isVarArg,
168 CallingConv::ID CallConv, bool isVarArg,
169169 const SmallVectorImpl &Outs,
170170 DebugLoc dl, SelectionDAG &DAG);
171171 };
122122 private:
123123 void printLinkageType(GlobalValue::LinkageTypes LT);
124124 void printVisibilityType(GlobalValue::VisibilityTypes VisTypes);
125 void printCallingConv(unsigned cc);
125 void printCallingConv(CallingConv::ID cc);
126126 void printEscapedString(const std::string& str);
127127 void printCFP(const ConstantFP* CFP);
128128
267267 Out << ")";
268268 }
269269
270 void CppWriter::printCallingConv(unsigned cc){
270 void CppWriter::printCallingConv(CallingConv::ID cc){
271271 // Print the calling convention.
272272 switch (cc) {
273273 case CallingConv::C: Out << "CallingConv::C"; break;
269269 }
270270
271271
272 std::string MSILWriter::getConvModopt(unsigned CallingConvID) {
272 std::string MSILWriter::getConvModopt(CallingConv::ID CallingConvID) {
273273 switch (CallingConvID) {
274274 case CallingConv::C:
275275 case CallingConv::Cold:
16221622
16231623
16241624 const char* MSILWriter::getLibraryName(const GlobalVariable* GV) {
1625 return getLibraryForSymbol(Mang->getMangledName(GV), false, 0);
1625 return getLibraryForSymbol(Mang->getMangledName(GV), false, CallingConv::C);
16261626 }
16271627
16281628
16291629 const char* MSILWriter::getLibraryForSymbol(const StringRef &Name,
16301630 bool isFunction,
1631 unsigned CallingConv) {
1631 CallingConv::ID CallingConv) {
16321632 // TODO: Read *.def file with function and libraries definitions.
16331633 return "MSVCRT.DLL";
16341634 }
1212 #ifndef MSILWRITER_H
1313 #define MSILWRITER_H
1414
15 #include "llvm/CallingConv.h"
1516 #include "llvm/Constants.h"
1617 #include "llvm/Module.h"
1718 #include "llvm/Instructions.h"
132133
133134 std::string getLabelName(const std::string& Name);
134135
135 std::string getConvModopt(unsigned CallingConvID);
136 std::string getConvModopt(CallingConv::ID CallingConvID);
136137
137138 std::string getArrayTypeName(Type::TypeID TyID, const Type* Ty);
138139
247248 const char* getLibraryName(const GlobalVariable* GV);
248249
249250 const char* getLibraryForSymbol(const StringRef &Name, bool isFunction,
250 unsigned CallingConv);
251 CallingConv::ID CallingConv);
251252
252253 void printExternals();
253254 };
195195
196196 SDValue
197197 MSP430TargetLowering::LowerFormalArguments(SDValue Chain,
198 unsigned CallConv,
198 CallingConv::ID CallConv,
199199 bool isVarArg,
200200 const SmallVectorImpl
201201 &Ins,
214214
215215 SDValue
216216 MSP430TargetLowering::LowerCall(SDValue Chain, SDValue Callee,
217 unsigned CallConv, bool isVarArg,
217 CallingConv::ID CallConv, bool isVarArg,
218218 bool isTailCall,
219219 const SmallVectorImpl &Outs,
220220 const SmallVectorImpl &Ins,
237237 // FIXME: varargs
238238 SDValue
239239 MSP430TargetLowering::LowerCCCArguments(SDValue Chain,
240 unsigned CallConv,
240 CallingConv::ID CallConv,
241241 bool isVarArg,
242242 const SmallVectorImpl
243243 &Ins,
317317
318318 SDValue
319319 MSP430TargetLowering::LowerReturn(SDValue Chain,
320 unsigned CallConv, bool isVarArg,
320 CallingConv::ID CallConv, bool isVarArg,
321321 const SmallVectorImpl &Outs,
322322 DebugLoc dl, SelectionDAG &DAG) {
323323
366366 /// TODO: sret.
367367 SDValue
368368 MSP430TargetLowering::LowerCCCCallTo(SDValue Chain, SDValue Callee,
369 unsigned CallConv, bool isVarArg,
369 CallingConv::ID CallConv, bool isVarArg,
370370 bool isTailCall,
371371 const SmallVectorImpl
372372 &Outs,
492492 ///
493493 SDValue
494494 MSP430TargetLowering::LowerCallResult(SDValue Chain, SDValue InFlag,
495 unsigned CallConv, bool isVarArg,
495 CallingConv::ID CallConv, bool isVarArg,
496496 const SmallVectorImpl &Ins,
497497 DebugLoc dl, SelectionDAG &DAG,
498498 SmallVectorImpl &InVals) {
9393
9494 private:
9595 SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee,
96 unsigned CallConv, bool isVarArg,
96 CallingConv::ID CallConv, bool isVarArg,
9797 bool isTailCall,
9898 const SmallVectorImpl &Outs,
9999 const SmallVectorImpl &Ins,
101101 SmallVectorImpl &InVals);
102102
103103 SDValue LowerCCCArguments(SDValue Chain,
104 unsigned CallConv,
104 CallingConv::ID CallConv,
105105 bool isVarArg,
106106 const SmallVectorImpl &Ins,
107107 DebugLoc dl,
109109 SmallVectorImpl &InVals);
110110
111111 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
112 unsigned CallConv, bool isVarArg,
112 CallingConv::ID CallConv, bool isVarArg,
113113 const SmallVectorImpl &Ins,
114114 DebugLoc dl, SelectionDAG &DAG,
115115 SmallVectorImpl &InVals);
116116
117117 virtual SDValue
118118 LowerFormalArguments(SDValue Chain,
119 unsigned CallConv, bool isVarArg,
119 CallingConv::ID CallConv, bool isVarArg,
120120 const SmallVectorImpl &Ins,
121121 DebugLoc dl, SelectionDAG &DAG,
122122 SmallVectorImpl &InVals);
123123 virtual SDValue
124124 LowerCall(SDValue Chain, SDValue Callee,
125 unsigned CallConv, bool isVarArg, bool isTailCall,
125 CallingConv::ID CallConv, bool isVarArg, bool isTailCall,
126126 const SmallVectorImpl &Outs,
127127 const SmallVectorImpl &Ins,
128128 DebugLoc dl, SelectionDAG &DAG,
130130
131131 virtual SDValue
132132 LowerReturn(SDValue Chain,
133 unsigned CallConv, bool isVarArg,
133 CallingConv::ID CallConv, bool isVarArg,
134134 const SmallVectorImpl &Outs,
135135 DebugLoc dl, SelectionDAG &DAG);
136136
682682 /// TODO: isVarArg, isTailCall.
683683 SDValue
684684 MipsTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
685 unsigned CallConv, bool isVarArg,
685 CallingConv::ID CallConv, bool isVarArg,
686686 bool isTailCall,
687687 const SmallVectorImpl &Outs,
688688 const SmallVectorImpl &Ins,
873873 /// appropriate copies out of appropriate physical registers.
874874 SDValue
875875 MipsTargetLowering::LowerCallResult(SDValue Chain, SDValue InFlag,
876 unsigned CallConv, bool isVarArg,
876 CallingConv::ID CallConv, bool isVarArg,
877877 const SmallVectorImpl &Ins,
878878 DebugLoc dl, SelectionDAG &DAG,
879879 SmallVectorImpl &InVals) {
906906 /// TODO: isVarArg
907907 SDValue
908908 MipsTargetLowering::LowerFormalArguments(SDValue Chain,
909 unsigned CallConv, bool isVarArg,
909 CallingConv::ID CallConv, bool isVarArg,
910910 const SmallVectorImpl
911911 &Ins,
912912 DebugLoc dl, SelectionDAG &DAG,
10551055
10561056 SDValue
10571057 MipsTargetLowering::LowerReturn(SDValue Chain,
1058 unsigned CallConv, bool isVarArg,
1058 CallingConv::ID CallConv, bool isVarArg,
10591059 const SmallVectorImpl &Outs,
10601060 DebugLoc dl, SelectionDAG &DAG) {
10611061
9090
9191 // Lower Operand helpers
9292 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
93 unsigned CallConv, bool isVarArg,
93 CallingConv::ID CallConv, bool isVarArg,
9494 const SmallVectorImpl &Ins,
9595 DebugLoc dl, SelectionDAG &DAG,
9696 SmallVectorImpl &InVals);
109109
110110 virtual SDValue
111111 LowerFormalArguments(SDValue Chain,
112 unsigned CallConv, bool isVarArg,
112 CallingConv::ID CallConv, bool isVarArg,
113113 const SmallVectorImpl &Ins,
114114 DebugLoc dl, SelectionDAG &DAG,
115115 SmallVectorImpl &InVals);
116116
117117 virtual SDValue
118118 LowerCall(SDValue Chain, SDValue Callee,
119 unsigned CallConv, bool isVarArg,
119 CallingConv::ID CallConv, bool isVarArg,
120120 bool isTailCall,
121121 const SmallVectorImpl &Outs,
122122 const SmallVectorImpl &Ins,
125125
126126 virtual SDValue
127127 LowerReturn(SDValue Chain,
128 unsigned CallConv, bool isVarArg,
128 CallingConv::ID CallConv, bool isVarArg,
129129 const SmallVectorImpl &Outs,
130130 DebugLoc dl, SelectionDAG &DAG);
131131
12541254
12551255 SDValue
12561256 PIC16TargetLowering::LowerReturn(SDValue Chain,
1257 unsigned CallConv, bool isVarArg,
1257 CallingConv::ID CallConv, bool isVarArg,
12581258 const SmallVectorImpl &Outs,
12591259 DebugLoc dl, SelectionDAG &DAG) {
12601260
13461346
13471347 SDValue
13481348 PIC16TargetLowering::LowerCall(SDValue Chain, SDValue Callee,
1349 unsigned CallConv, bool isVarArg,
1349 CallingConv::ID CallConv, bool isVarArg,
13501350 bool isTailCall,
13511351 const SmallVectorImpl &Outs,
13521352 const SmallVectorImpl &Ins,
16021602
16031603 SDValue
16041604 PIC16TargetLowering::LowerFormalArguments(SDValue Chain,
1605 unsigned CallConv,
1605 CallingConv::ID CallConv,
16061606 bool isVarArg,
16071607 const SmallVectorImpl &Ins,
16081608 DebugLoc dl,
131131
132132 virtual SDValue
133133 LowerFormalArguments(SDValue Chain,
134 unsigned CallConv,
134 CallingConv::ID CallConv,
135135 bool isVarArg,
136136 const SmallVectorImpl &Ins,
137137 DebugLoc dl, SelectionDAG &DAG,
139139
140140 virtual SDValue
141141 LowerCall(SDValue Chain, SDValue Callee,
142 unsigned CallConv, bool isVarArg, bool isTailCall,
142 CallingConv::ID CallConv, bool isVarArg, bool isTailCall,
143143 const SmallVectorImpl &Outs,
144144 const SmallVectorImpl &Ins,
145145 DebugLoc dl, SelectionDAG &DAG,
147147
148148 virtual SDValue
149149 LowerReturn(SDValue Chain,
150 unsigned CallConv, bool isVarArg,
150 CallingConv::ID CallConv, bool isVarArg,
151151 const SmallVectorImpl &Outs,
152152 DebugLoc dl, SelectionDAG &DAG);
153153
14831483
14841484 SDValue
14851485 PPCTargetLowering::LowerFormalArguments(SDValue Chain,
1486 unsigned CallConv, bool isVarArg,
1486 CallingConv::ID CallConv, bool isVarArg,
14871487 const SmallVectorImpl
14881488 &Ins,
14891489 DebugLoc dl, SelectionDAG &DAG,
15001500 SDValue
15011501 PPCTargetLowering::LowerFormalArguments_SVR4(
15021502 SDValue Chain,
1503 unsigned CallConv, bool isVarArg,
1503 CallingConv::ID CallConv, bool isVarArg,
15041504 const SmallVectorImpl
15051505 &Ins,
15061506 DebugLoc dl, SelectionDAG &DAG,
17271727 SDValue
17281728 PPCTargetLowering::LowerFormalArguments_Darwin(
17291729 SDValue Chain,
1730 unsigned CallConv, bool isVarArg,
1730 CallingConv::ID CallConv, bool isVarArg,
17311731 const SmallVectorImpl
17321732 &Ins,
17331733 DebugLoc dl, SelectionDAG &DAG,
21632163 /// optimization should implement this function.
21642164 bool
21652165 PPCTargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
2166 unsigned CalleeCC,
2166 CallingConv::ID CalleeCC,
21672167 bool isVarArg,
21682168 const SmallVectorImpl &Ins,
21692169 SelectionDAG& DAG) const {
21722172 return false;
21732173
21742174 MachineFunction &MF = DAG.getMachineFunction();
2175 unsigned CallerCC = MF.getFunction()->getCallingConv();
2175 CallingConv::ID CallerCC = MF.getFunction()->getCallingConv();
21762176 if (CalleeCC == CallingConv::Fast && CallerCC == CalleeCC) {
21772177 // Functions containing by val parameters are not supported.
21782178 for (unsigned i = 0; i != Ins.size(); i++) {
24522452
24532453 SDValue
24542454 PPCTargetLowering::LowerCallResult(SDValue Chain, SDValue InFlag,
2455 unsigned CallConv, bool isVarArg,
2455 CallingConv::ID CallConv, bool isVarArg,
24562456 const SmallVectorImpl &Ins,
24572457 DebugLoc dl, SelectionDAG &DAG,
24582458 SmallVectorImpl &InVals) {
24772477 }
24782478
24792479 SDValue
2480 PPCTargetLowering::FinishCall(unsigned CallConv, DebugLoc dl, bool isTailCall,
2481 bool isVarArg,
2480 PPCTargetLowering::FinishCall(CallingConv::ID CallConv, DebugLoc dl,
2481 bool isTailCall, bool isVarArg,
24822482 SelectionDAG &DAG,
24832483 SmallVector, 8>
24842484 &RegsToPass,
25532553
25542554 SDValue
25552555 PPCTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
2556 unsigned CallConv, bool isVarArg,
2556 CallingConv::ID CallConv, bool isVarArg,
25572557 bool isTailCall,
25582558 const SmallVectorImpl &Outs,
25592559 const SmallVectorImpl &Ins,
25722572
25732573 SDValue
25742574 PPCTargetLowering::LowerCall_SVR4(SDValue Chain, SDValue Callee,
2575 unsigned CallConv, bool isVarArg,
2575 CallingConv::ID CallConv, bool isVarArg,
25762576 bool isTailCall,
25772577 const SmallVectorImpl &Outs,
25782578 const SmallVectorImpl &Ins,
27812781
27822782 SDValue
27832783 PPCTargetLowering::LowerCall_Darwin(SDValue Chain, SDValue Callee,
2784 unsigned CallConv, bool isVarArg,
2784 CallingConv::ID CallConv, bool isVarArg,
27852785 bool isTailCall,
27862786 const SmallVectorImpl &Outs,
27872787 const SmallVectorImpl &Ins,
31153115
31163116 SDValue
31173117 PPCTargetLowering::LowerReturn(SDValue Chain,
3118 unsigned CallConv, bool isVarArg,
3118 CallingConv::ID CallConv, bool isVarArg,
31193119 const SmallVectorImpl &Outs,
31203120 DebugLoc dl, SelectionDAG &DAG) {
31213121
331331
332332 virtual bool
333333 IsEligibleForTailCallOptimization(SDValue Callee,
334 unsigned CalleeCC,
334 CallingConv::ID CalleeCC,
335335 bool isVarArg,
336336 const SmallVectorImpl &Ins,
337337 SelectionDAG& DAG) const;
390390 SDValue LowerMUL(SDValue Op, SelectionDAG &DAG);
391391
392392 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
393 unsigned CallConv, bool isVarArg,
393 CallingConv::ID CallConv, bool isVarArg,
394394 const SmallVectorImpl &Ins,
395395 DebugLoc dl, SelectionDAG &DAG,
396396 SmallVectorImpl &InVals);
397 SDValue FinishCall(unsigned CallConv, DebugLoc dl, bool isTailCall,
397 SDValue FinishCall(CallingConv::ID CallConv, DebugLoc dl, bool isTailCall,
398398 bool isVarArg,
399399 SelectionDAG &DAG,
400400 SmallVector, 8>
407407
408408 virtual SDValue
409409 LowerFormalArguments(SDValue Chain,
410 unsigned CallConv, bool isVarArg,
410 CallingConv::ID CallConv, bool isVarArg,
411411 const SmallVectorImpl &Ins,
412412 DebugLoc dl, SelectionDAG &DAG,
413413 SmallVectorImpl &InVals);
414414
415415 virtual SDValue
416416 LowerCall(SDValue Chain, SDValue Callee,
417 unsigned CallConv, bool isVarArg, bool isTailCall,
417 CallingConv::ID CallConv, bool isVarArg, bool isTailCall,
418418 const SmallVectorImpl &Outs,
419419 const SmallVectorImpl &Ins,
420420 DebugLoc dl, SelectionDAG &DAG,
422422
423423 virtual SDValue
424424 LowerReturn(SDValue Chain,
425 unsigned CallConv, bool isVarArg,
425 CallingConv::ID CallConv, bool isVarArg,
426426 const SmallVectorImpl &Outs,
427427 DebugLoc dl, SelectionDAG &DAG);
428428
429429 SDValue
430430 LowerFormalArguments_Darwin(SDValue Chain,
431 unsigned CallConv, bool isVarArg,
431 CallingConv::ID CallConv, bool isVarArg,
432432 const SmallVectorImpl &Ins,
433433 DebugLoc dl, SelectionDAG &DAG,
434434 SmallVectorImpl &InVals);
435435 SDValue
436436 LowerFormalArguments_SVR4(SDValue Chain,
437 unsigned CallConv, bool isVarArg,
437 CallingConv::ID CallConv, bool isVarArg,
438438 const SmallVectorImpl &Ins,
439439 DebugLoc dl, SelectionDAG &DAG,
440440 SmallVectorImpl &InVals);
441441
442442 SDValue
443443 LowerCall_Darwin(SDValue Chain, SDValue Callee,
444 unsigned CallConv, bool isVarArg, bool isTailCall,
444 CallingConv::ID CallConv, bool isVarArg, bool isTailCall,
445445 const SmallVectorImpl &Outs,
446446 const SmallVectorImpl &Ins,
447447 DebugLoc dl, SelectionDAG &DAG,
448448 SmallVectorImpl &InVals);
449449 SDValue
450450 LowerCall_SVR4(SDValue Chain, SDValue Callee,
451 unsigned CallConv, bool isVarArg, bool isTailCall,
451 CallingConv::ID CallConv, bool isVarArg, bool isTailCall,
452452 const SmallVectorImpl &Outs,
453453 const SmallVectorImpl &Ins,
454454 DebugLoc dl, SelectionDAG &DAG,
3434
3535 SDValue
3636 SparcTargetLowering::LowerReturn(SDValue Chain,
37 unsigned CallConv, bool isVarArg,
37 CallingConv::ID CallConv, bool isVarArg,
3838 const SmallVectorImpl &Outs,
3939 DebugLoc dl, SelectionDAG &DAG) {
4040
8080 /// pass FP values in FP registers for fastcc functions.
8181 SDValue
8282 SparcTargetLowering::LowerFormalArguments(SDValue Chain,
83 unsigned CallConv, bool isVarArg,
83 CallingConv::ID CallConv, bool isVarArg,
8484 const SmallVectorImpl
8585 &Ins,
8686 DebugLoc dl, SelectionDAG &DAG,
245245
246246 SDValue
247247 SparcTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
248 unsigned CallConv, bool isVarArg,
248 CallingConv::ID CallConv, bool isVarArg,
249249 bool isTailCall,
250250 const SmallVectorImpl &Outs,
251251 const SmallVectorImpl &Ins,
7575
7676 virtual SDValue
7777 LowerFormalArguments(SDValue Chain,
78 unsigned CallConv,
78 CallingConv::ID CallConv,
7979 bool isVarArg,
8080 const SmallVectorImpl &Ins,
8181 DebugLoc dl, SelectionDAG &DAG,
8383
8484 virtual SDValue
8585 LowerCall(SDValue Chain, SDValue Callee,
86 unsigned CallConv, bool isVarArg,
86 CallingConv::ID CallConv, bool isVarArg,
8787 bool isTailCall,
8888 const SmallVectorImpl &Outs,
8989 const SmallVectorImpl &Ins,
9292
9393 virtual SDValue
9494 LowerReturn(SDValue Chain,
95 unsigned CallConv, bool isVarArg,
95 CallingConv::ID CallConv, bool isVarArg,
9696 const SmallVectorImpl &Outs,
9797 DebugLoc dl, SelectionDAG &DAG);
9898 };
216216
217217 SDValue
218218 SystemZTargetLowering::LowerFormalArguments(SDValue Chain,
219 unsigned CallConv,
219 CallingConv::ID CallConv,
220220 bool isVarArg,
221221 const SmallVectorImpl
222222 &Ins,
235235
236236 SDValue
237237 SystemZTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
238 unsigned CallConv, bool isVarArg,
238 CallingConv::ID CallConv, bool isVarArg,
239239 bool isTailCall,
240240 const SmallVectorImpl &Outs,
241241 const SmallVectorImpl &Ins,
258258 // FIXME: varargs
259259 SDValue
260260 SystemZTargetLowering::LowerCCCArguments(SDValue Chain,
261 unsigned CallConv,
261 CallingConv::ID CallConv,
262262 bool isVarArg,
263263 const SmallVectorImpl
264264 &Ins,
348348 /// TODO: sret.
349349 SDValue
350350 SystemZTargetLowering::LowerCCCCallTo(SDValue Chain, SDValue Callee,
351 unsigned CallConv, bool isVarArg,
351 CallingConv::ID CallConv, bool isVarArg,
352352 bool isTailCall,
353353 const SmallVectorImpl
354354 &Outs,
483483 ///
484484 SDValue
485485 SystemZTargetLowering::LowerCallResult(SDValue Chain, SDValue InFlag,
486 unsigned CallConv, bool isVarArg,
486 CallingConv::ID CallConv, bool isVarArg,
487487 const SmallVectorImpl
488488 &Ins,
489489 DebugLoc dl, SelectionDAG &DAG,
527527
528528 SDValue
529529 SystemZTargetLowering::LowerReturn(SDValue Chain,
530 unsigned CallConv, bool isVarArg,
530 CallingConv::ID CallConv, bool isVarArg,
531531 const SmallVectorImpl &Outs,
532532 DebugLoc dl, SelectionDAG &DAG) {
533533
8989
9090 private:
9191 SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee,
92 unsigned CallConv, bool isVarArg,
92 CallingConv::ID CallConv, bool isVarArg,
9393 bool isTailCall,
9494 const SmallVectorImpl &Outs,
9595 const SmallVectorImpl &Ins,
9797 SmallVectorImpl &InVals);
9898
9999 SDValue LowerCCCArguments(SDValue Chain,
100 unsigned CallConv,
100 CallingConv::ID CallConv,
101101 bool isVarArg,
102102 const SmallVectorImpl &Ins,
103103 DebugLoc dl,
105105 SmallVectorImpl &InVals);
106106
107107 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
108 unsigned CallConv, bool isVarArg,
108 CallingConv::ID CallConv, bool isVarArg,
109109 const SmallVectorImpl &Ins,
110110 DebugLoc dl, SelectionDAG &DAG,
111111 SmallVectorImpl &InVals);
112112
113113 virtual SDValue
114114 LowerFormalArguments(SDValue Chain,
115 unsigned CallConv, bool isVarArg,
115 CallingConv::ID CallConv, bool isVarArg,
116116 const SmallVectorImpl &Ins,
117117 DebugLoc dl, SelectionDAG &DAG,
118118 SmallVectorImpl &InVals);
119119 virtual SDValue
120120 LowerCall(SDValue Chain, SDValue Callee,
121 unsigned CallConv, bool isVarArg, bool isTailCall,
121 CallingConv::ID CallConv, bool isVarArg, bool isTailCall,
122122 const SmallVectorImpl &Outs,
123123 const SmallVectorImpl &Ins,
124124 DebugLoc dl, SelectionDAG &DAG,
126126
127127 virtual SDValue
128128 LowerReturn(SDValue Chain,
129 unsigned CallConv, bool isVarArg,
129 CallingConv::ID CallConv, bool isVarArg,
130130 const SmallVectorImpl &Outs,
131131 DebugLoc dl, SelectionDAG &DAG);
132132
125125 CygMingStubs.insert(Name);
126126
127127 // We don't want to decorate non-stdcall or non-fastcall functions right now
128 unsigned CC = F->getCallingConv();
128 CallingConv::ID CC = F->getCallingConv();
129129 if (CC != CallingConv::X86_StdCall && CC != CallingConv::X86_FastCall)
130130 return;
131131
236236 bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
237237 const Function *F = MF.getFunction();
238238 this->MF = &MF;
239 unsigned CC = F->getCallingConv();
239 CallingConv::ID CC = F->getCallingConv();
240240
241241 SetupMachineFunction(MF);
242242 O << "\n\n";
7878 if (!F) return;
7979
8080 // We don't want to decorate non-stdcall or non-fastcall functions right now
81 unsigned CC = F->getCallingConv();
81 CallingConv::ID CC = F->getCallingConv();
8282 if (CC != CallingConv::X86_StdCall && CC != CallingConv::X86_FastCall)
8383 return;
8484
133133
134134 // Print out labels for the function.
135135 const Function *F = MF.getFunction();
136 unsigned CC = F->getCallingConv();
136 CallingConv::ID CC = F->getCallingConv();
137137 unsigned FnAlign = MF.getAlignment();
138138
139139 // Populate function information map. Actually, We don't want to populate
117117 bool X86VisitIntrinsicCall(IntrinsicInst &I);
118118 bool X86SelectCall(Instruction *I);
119119
120 CCAssignFn *CCAssignFnForCall(unsigned CC, bool isTailCall = false);
120 CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool isTailCall = false);
121121
122122 const X86InstrInfo *getInstrInfo() const {
123123 return getTargetMachine()->getInstrInfo();
168168
169169 /// CCAssignFnForCall - Selects the correct CCAssignFn for a given calling
170170 /// convention.
171 CCAssignFn *X86FastISel::CCAssignFnForCall(unsigned CC, bool isTaillCall) {
171 CCAssignFn *X86FastISel::CCAssignFnForCall(CallingConv::ID CC,
172 bool isTaillCall) {
172173 if (Subtarget->is64Bit()) {
173174 if (Subtarget->isTargetWin64())
174175 return CC_X86_Win64_C;
12221223
12231224 // Handle only C and fastcc calling conventions for now.
12241225 CallSite CS(CI);
1225 unsigned CC = CS.getCallingConv();
1226 CallingConv::ID CC = CS.getCallingConv();
12261227 if (CC != CallingConv::C &&
12271228 CC != CallingConv::Fast &&
12281229 CC != CallingConv::X86_FastCall)
10621062
10631063 SDValue
10641064 X86TargetLowering::LowerReturn(SDValue Chain,
1065 unsigned CallConv, bool isVarArg,
1065 CallingConv::ID CallConv, bool isVarArg,
10661066 const SmallVectorImpl &Outs,
10671067 DebugLoc dl, SelectionDAG &DAG) {
10681068
11541154 ///
11551155 SDValue
11561156 X86TargetLowering::LowerCallResult(SDValue Chain, SDValue InFlag,
1157 unsigned CallConv, bool isVarArg,
1157 CallingConv::ID CallConv, bool isVarArg,
11581158 const SmallVectorImpl &Ins,
11591159 DebugLoc dl, SelectionDAG &DAG,
11601160 SmallVectorImpl &InVals) {
12541254
12551255 /// IsCalleePop - Determines whether the callee is required to pop its
12561256 /// own arguments. Callee pop is necessary to support tail calls.
1257 bool X86TargetLowering::IsCalleePop(bool IsVarArg, unsigned CallingConv) {
1257 bool X86TargetLowering::IsCalleePop(bool IsVarArg, CallingConv::ID CallingConv){
12581258 if (IsVarArg)
12591259 return false;
12601260
12721272
12731273 /// CCAssignFnForNode - Selects the correct CCAssignFn for a the
12741274 /// given CallingConvention value.
1275 CCAssignFn *X86TargetLowering::CCAssignFnForNode(unsigned CC) const {
1275 CCAssignFn *X86TargetLowering::CCAssignFnForNode(CallingConv::ID CC) const {
12761276 if (Subtarget->is64Bit()) {
12771277 if (Subtarget->isTargetWin64())
12781278 return CC_X86_Win64_C;
12911291 /// NameDecorationForCallConv - Selects the appropriate decoration to
12921292 /// apply to a MachineFunction containing a given calling convention.
12931293 NameDecorationStyle
1294 X86TargetLowering::NameDecorationForCallConv(unsigned CallConv) {
1294 X86TargetLowering::NameDecorationForCallConv(CallingConv::ID CallConv) {
12951295 if (CallConv == CallingConv::X86_FastCall)
12961296 return FastCall;
12971297 else if (CallConv == CallingConv::X86_StdCall)
13151315
13161316 SDValue
13171317 X86TargetLowering::LowerMemArgument(SDValue Chain,
1318 unsigned CallConv,
1318 CallingConv::ID CallConv,
13191319 const SmallVectorImpl &Ins,
13201320 DebugLoc dl, SelectionDAG &DAG,
13211321 const CCValAssign &VA,
13501350
13511351 SDValue
13521352 X86TargetLowering::LowerFormalArguments(SDValue Chain,
1353 unsigned CallConv,
1353 CallingConv::ID CallConv,
13541354 bool isVarArg,
13551355 const SmallVectorImpl &Ins,
13561356 DebugLoc dl,
16511651
16521652 SDValue
16531653 X86TargetLowering::LowerCall(SDValue Chain, SDValue Callee,
1654 unsigned CallConv, bool isVarArg, bool isTailCall,
1654 CallingConv::ID CallConv, bool isVarArg,
1655 bool isTailCall,
16551656 const SmallVectorImpl &Outs,
16561657 const SmallVectorImpl &Ins,
16571658 DebugLoc dl, SelectionDAG &DAG,
20962097 /// optimization should implement this function.
20972098 bool
20982099 X86TargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
2099 unsigned CalleeCC,
2100 CallingConv::ID CalleeCC,
21002101 bool isVarArg,
21012102 const SmallVectorImpl &Ins,
21022103 SelectionDAG& DAG) const {
21032104 MachineFunction &MF = DAG.getMachineFunction();
2104 unsigned CallerCC = MF.getFunction()->getCallingConv();
2105 CallingConv::ID CallerCC = MF.getFunction()->getCallingConv();
21052106 return CalleeCC == CallingConv::Fast && CallerCC == CalleeCC;
21062107 }
21072108
64756476 } else {
64766477 const Function *Func =
64776478 cast(cast(Op.getOperand(5))->getValue());
6478 unsigned CC = Func->getCallingConv();
6479 CallingConv::ID CC = Func->getCallingConv();
64796480 unsigned NestReg;
64806481
64816482 switch (CC) {
520520 /// optimization should implement this function.
521521 virtual bool
522522 IsEligibleForTailCallOptimization(SDValue Callee,
523 unsigned CalleeCC,
523 CallingConv::ID CalleeCC,
524524 bool isVarArg,
525525 const SmallVectorImpl &Ins,
526526 SelectionDAG& DAG) const;
577577 bool X86ScalarSSEf64;
578578
579579 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
580 unsigned CallConv, bool isVarArg,
580 CallingConv::ID CallConv, bool isVarArg,
581581 const SmallVectorImpl &Ins,
582582 DebugLoc dl, SelectionDAG &DAG,
583583 SmallVectorImpl &InVals);
584584 SDValue LowerMemArgument(SDValue Chain,
585 unsigned CallConv,
585 CallingConv::ID CallConv,
586586 const SmallVectorImpl &ArgInfo,
587587 DebugLoc dl, SelectionDAG &DAG,
588588 const CCValAssign &VA, MachineFrameInfo *MFI,
593593 ISD::ArgFlagsTy Flags);
594594
595595 // Call lowering helpers.
596 bool IsCalleePop(bool isVarArg, unsigned CallConv);
596 bool IsCalleePop(bool isVarArg, CallingConv::ID CallConv);
597597 SDValue EmitTailCallLoadRetAddr(SelectionDAG &DAG, SDValue &OutRetAddr,
598598 SDValue Chain, bool IsTailCall, bool Is64Bit,
599599 int FPDiff, DebugLoc dl);
600600
601 CCAssignFn *CCAssignFnForNode(unsigned CallConv) const;
602 NameDecorationStyle NameDecorationForCallConv(unsigned CallConv);
601 CCAssignFn *CCAssignFnForNode(CallingConv::ID CallConv) const;
602 NameDecorationStyle NameDecorationForCallConv(CallingConv::ID CallConv);
603603 unsigned GetAlignedArgumentStackSize(unsigned StackSize, SelectionDAG &DAG);
604604
605605 std::pair FP_TO_INTHelper(SDValue Op, SelectionDAG &DAG,
658658
659659 virtual SDValue
660660 LowerFormalArguments(SDValue Chain,
661 unsigned CallConv, bool isVarArg,
661 CallingConv::ID CallConv, bool isVarArg,
662662 const SmallVectorImpl &Ins,
663663 DebugLoc dl, SelectionDAG &DAG,
664664 SmallVectorImpl &InVals);
665665 virtual SDValue
666666 LowerCall(SDValue Chain, SDValue Callee,
667 unsigned CallConv, bool isVarArg, bool isTailCall,
667 CallingConv::ID CallConv, bool isVarArg, bool isTailCall,
668668 const SmallVectorImpl &Outs,
669669 const SmallVectorImpl &Ins,
670670 DebugLoc dl, SelectionDAG &DAG,
672672
673673 virtual SDValue
674674 LowerReturn(SDValue Chain,
675 unsigned CallConv, bool isVarArg,
675 CallingConv::ID CallConv, bool isVarArg,
676676 const SmallVectorImpl &Outs,
677677 DebugLoc dl, SelectionDAG &DAG);
678678
610610 /// XCore call implementation
611611 SDValue
612612 XCoreTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
613 unsigned CallConv, bool isVarArg,
613 CallingConv::ID CallConv, bool isVarArg,
614614 bool isTailCall,
615615 const SmallVectorImpl &Outs,
616616 const SmallVectorImpl &Ins,
635635 /// TODO: isTailCall, sret.
636636 SDValue
637637 XCoreTargetLowering::LowerCCCCallTo(SDValue Chain, SDValue Callee,
638 unsigned CallConv, bool isVarArg,
638 CallingConv::ID CallConv, bool isVarArg,
639639 bool isTailCall,
640640 const SmallVectorImpl &Outs,
641641 const SmallVectorImpl &Ins,
760760 /// appropriate copies out of appropriate physical registers.
761761 SDValue
762762 XCoreTargetLowering::LowerCallResult(SDValue Chain, SDValue InFlag,
763 unsigned CallConv, bool isVarArg,
763 CallingConv::ID CallConv, bool isVarArg,
764764 const SmallVectorImpl &Ins,
765765 DebugLoc dl, SelectionDAG &DAG,
766766 SmallVectorImpl &InVals) {
790790 /// XCore formal arguments implementation
791791 SDValue
792792 XCoreTargetLowering::LowerFormalArguments(SDValue Chain,
793 unsigned CallConv,
793 CallingConv::ID CallConv,
794794 bool isVarArg,
795795 const SmallVectorImpl &Ins,
796796 DebugLoc dl,
813813 /// TODO: sret
814814 SDValue
815815 XCoreTargetLowering::LowerCCCArguments(SDValue Chain,
816 unsigned CallConv,
816 CallingConv::ID CallConv,
817817 bool isVarArg,
818818 const SmallVectorImpl
819819 &Ins,
927927
928928 SDValue
929929 XCoreTargetLowering::LowerReturn(SDValue Chain,
930 unsigned CallConv, bool isVarArg,
930 CallingConv::ID CallConv, bool isVarArg,
931931 const SmallVectorImpl &Outs,
932932 DebugLoc dl, SelectionDAG &DAG) {
933933
9292
9393 // Lower Operand helpers
9494 SDValue LowerCCCArguments(SDValue Chain,
95 unsigned CallConv,
95 CallingConv::ID CallConv,
9696 bool isVarArg,
9797 const SmallVectorImpl &Ins,
9898 DebugLoc dl, SelectionDAG &DAG,
9999 SmallVectorImpl &InVals);
100100 SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee,
101 unsigned CallConv, bool isVarArg,
101 CallingConv::ID CallConv, bool isVarArg,
102102 bool isTailCall,
103103 const SmallVectorImpl &Outs,
104104 const SmallVectorImpl &Ins,
105105 DebugLoc dl, SelectionDAG &DAG,
106106 SmallVectorImpl &InVals);
107107 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
108 unsigned CallConv, bool isVarArg,
108 CallingConv::ID CallConv, bool isVarArg,
109109 const SmallVectorImpl &Ins,
110110 DebugLoc dl, SelectionDAG &DAG,
111111 SmallVectorImpl &InVals);
137137
138138 virtual SDValue
139139 LowerFormalArguments(SDValue Chain,
140 unsigned CallConv,
140 CallingConv::ID CallConv,
141141 bool isVarArg,
142142 const SmallVectorImpl &Ins,
143143 DebugLoc dl, SelectionDAG &DAG,
145145
146146 virtual SDValue
147147 LowerCall(SDValue Chain, SDValue Callee,
148 unsigned CallConv, bool isVarArg,
148 CallingConv::ID CallConv, bool isVarArg,
149149 bool isTailCall,
150150 const SmallVectorImpl &Outs,
151151 const SmallVectorImpl &Ins,
154154
155155 virtual SDValue
156156 LowerReturn(SDValue Chain,
157 unsigned CallConv, bool isVarArg,
157 CallingConv::ID CallConv, bool isVarArg,
158158 const SmallVectorImpl &Outs,
159159 DebugLoc dl, SelectionDAG &DAG);
160160 };
11171117 }
11181118
11191119 void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC) {
1120 return unwrap(Fn)->setCallingConv(CC);
1120 return unwrap(Fn)->setCallingConv(
1121 static_cast(CC));
11211122 }
11221123
11231124 const char *LLVMGetGC(LLVMValueRef Fn) {
13611362 void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) {
13621363 Value *V = unwrap(Instr);
13631364 if (CallInst *CI = dyn_cast(V))
1364 return CI->setCallingConv(CC);
1365 return CI->setCallingConv(static_cast(CC));
13651366 else if (InvokeInst *II = dyn_cast(V))
1366 return II->setCallingConv(CC);
1367 return II->setCallingConv(static_cast(CC));
13671368 llvm_unreachable("LLVMSetInstructionCallConv applies only to call and invoke!");
13681369 }
13691370
4444 I.setPointer(C);
4545 I.setInt(isa(C));
4646 }
47 unsigned CallSite::getCallingConv() const {
47 CallingConv::ID CallSite::getCallingConv() const {
4848 CALLSITE_DELEGATE_GETTER(getCallingConv());
4949 }
50 void CallSite::setCallingConv(unsigned CC) {
50 void CallSite::setCallingConv(CallingConv::ID CC) {
5151 CALLSITE_DELEGATE_SETTER(setCallingConv(CC));
5252 }
5353 const AttrListPtr &CallSite::getAttributes() const {