llvm.org GIT mirror llvm / 72977a4
Allow targets to specify their choice of calling conventions per libcall. Take advantage of this in the ARM backend to rectify broken choice of CC when hard float is in effect. PIC16 may want to see if it could be of use in MakePIC16Libcall, which works unchanged. Patch by Sandeep! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79033 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 11 years ago
7 changed file(s) with 44 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
2121 #ifndef LLVM_TARGET_TARGETLOWERING_H
2222 #define LLVM_TARGET_TARGETLOWERING_H
2323
24 #include "llvm/CallingConv.h"
2425 #include "llvm/InlineAsm.h"
2526 #include "llvm/CodeGen/SelectionDAGNodes.h"
2627 #include "llvm/CodeGen/RuntimeLibcalls.h"
15381539 return CmpLibcallCCs[Call];
15391540 }
15401541
1542 /// setLibcallCallingConv - Set the CallingConv that should be used for the
1543 /// specified libcall.
1544 void setLibcallCallingConv(RTLIB::Libcall Call, CallingConv::ID CC) {
1545 LibcallCallingConvs[Call] = CC;
1546 }
1547
1548 /// getLibcallCallingConv - Get the CallingConv that should be used for the
1549 /// specified libcall.
1550 CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const {
1551 return LibcallCallingConvs[Call];
1552 }
1553
15411554 private:
15421555 TargetMachine &TM;
15431556 const TargetData *TD;
17031716 /// CmpLibcallCCs - The ISD::CondCode that should be used to test the result
17041717 /// of each of the comparison libcall against zero.
17051718 ISD::CondCode CmpLibcallCCs[RTLIB::UNKNOWN_LIBCALL];
1719
1720 /// LibcallCallingConvs - Stores the CallingConv that should be used for each
1721 /// libcall.
1722 CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL];
17061723
17071724 protected:
17081725 /// When lowering \@llvm.memset this field specifies the maximum number of
18681868 const Type *RetTy = Node->getValueType(0).getTypeForEVT(*DAG.getContext());
18691869 std::pair CallInfo =
18701870 TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
1871 0, CallingConv::C, false,
1871 0, TLI.getLibcallCallingConv(LC), false,
18721872 /*isReturnValueUsed=*/true,
18731873 Callee, Args, DAG,
18741874 Node->getDebugLoc());
10181018 const Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());
10191019 std::pair CallInfo =
10201020 TLI.LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false,
1021 false, 0, CallingConv::C, false,
1021 false, 0, TLI.getLibcallCallingConv(LC), false,
10221022 /*isReturnValueUsed=*/true,
10231023 Callee, Args, DAG, dl);
10241024 return CallInfo.first;
33893389 // FIXME: pass in DebugLoc
33903390 std::pair CallResult =
33913391 TLI.LowerCallTo(Chain, Type::getVoidTy(*getContext()),
3392 false, false, false, false, 0, CallingConv::C, false,
3392 false, false, false, false, 0,
3393 TLI.getLibcallCallingConv(RTLIB::MEMCPY), false,
33933394 /*isReturnValueUsed=*/false,
33943395 getExternalSymbol(TLI.getLibcallName(RTLIB::MEMCPY),
33953396 TLI.getPointerTy()),
34373438 // FIXME: pass in DebugLoc
34383439 std::pair CallResult =
34393440 TLI.LowerCallTo(Chain, Type::getVoidTy(*getContext()),
3440 false, false, false, false, 0, CallingConv::C, false,
3441 false, false, false, false, 0,
3442 TLI.getLibcallCallingConv(RTLIB::MEMMOVE), false,
34413443 /*isReturnValueUsed=*/false,
34423444 getExternalSymbol(TLI.getLibcallName(RTLIB::MEMMOVE),
34433445 TLI.getPointerTy()),
34953497 // FIXME: pass in DebugLoc
34963498 std::pair CallResult =
34973499 TLI.LowerCallTo(Chain, Type::getVoidTy(*getContext()),
3498 false, false, false, false, 0, CallingConv::C, false,
3500 false, false, false, false, 0,
3501 TLI.getLibcallCallingConv(RTLIB::MEMSET), false,
34993502 /*isReturnValueUsed=*/false,
35003503 getExternalSymbol(TLI.getLibcallName(RTLIB::MEMSET),
35013504 TLI.getPointerTy()),
246246 Names[RTLIB::UNWIND_RESUME] = "_Unwind_Resume";
247247 }
248248
249 /// InitLibcallCallingConvs - Set default libcall CallingConvs.
250 ///
251 static void InitLibcallCallingConvs(CallingConv::ID *CCs) {
252 for (int i = 0; i < RTLIB::UNKNOWN_LIBCALL; ++i) {
253 CCs[i] = CallingConv::C;
254 }
255 }
256
249257 /// getFPEXT - Return the FPEXT_*_* value for the given types, or
250258 /// UNKNOWN_LIBCALL if there is none.
251259 RTLIB::Libcall RTLIB::getFPEXT(EVT OpVT, EVT RetVT) {
519527
520528 InitLibcallNames(LibcallRoutineNames);
521529 InitCmpLibcallCCs(CmpLibcallCCs);
530 InitLibcallCallingConvs(LibcallCallingConvs);
522531
523532 // Tell Legalize whether the assembler supports DEBUG_LOC.
524533 const TargetAsmInfo *TASM = TM.getTargetAsmInfo();
199199 setLibcallName(RTLIB::SHL_I128, 0);
200200 setLibcallName(RTLIB::SRL_I128, 0);
201201 setLibcallName(RTLIB::SRA_I128, 0);
202
203 // Libcalls should use the AAPCS base standard ABI, even if hard float
204 // is in effect, as per the ARM RTABI specification, section 4.1.2.
205 if (Subtarget->isAAPCS_ABI()) {
206 for (int i = 0; i < RTLIB::UNKNOWN_LIBCALL; ++i) {
207 setLibcallCallingConv(static_cast(i),
208 CallingConv::ARM_AAPCS);
209 }
210 }
202211
203212 if (Subtarget->isThumb1Only())
204213 addRegisterClass(MVT::i32, ARM::tGPRRegisterClass);
115115 Op.getNode()->getValueType(0).getTypeForEVT(*DAG.getContext());
116116 std::pair CallInfo =
117117 TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
118 0, CallingConv::C, false,
118 0, TLI.getLibcallCallingConv(LC), false,
119119 /*isReturnValueUsed=*/true,
120120 Callee, Args, DAG,
121121 Op.getDebugLoc());