-
Notifications
You must be signed in to change notification settings - Fork 13.6k
MSP430: Partially move runtime libcall config out of TargetLowering #142709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: users/arsenm/msp430/stop-using-setCmpLibcallCC
Are you sure you want to change the base?
MSP430: Partially move runtime libcall config out of TargetLowering #142709
Conversation
RuntimeLibcalls needs to be correct outside of codegen contexts.
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-backend-msp430 Author: Matt Arsenault (arsenm) ChangesRuntimeLibcalls needs to be correct outside of codegen contexts. Full diff: https://github.com/llvm/llvm-project/pull/142709.diff 2 Files Affected:
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index d8451b818e8e3..0a97f09535d88 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -11,6 +11,123 @@
using namespace llvm;
using namespace RTLIB;
+static void setMSP430Libcalls(RuntimeLibcallsInfo &Info, const Triple &TT) {
+ // EABI Libcalls - EABI Section 6.2
+ const struct {
+ const RTLIB::Libcall Op;
+ const char *const Name;
+ } LibraryCalls[] = {
+ // Floating point conversions - EABI Table 6
+ {RTLIB::FPROUND_F64_F32, "__mspabi_cvtdf"},
+ {RTLIB::FPEXT_F32_F64, "__mspabi_cvtfd"},
+ // The following is NOT implemented in libgcc
+ //{ RTLIB::FPTOSINT_F64_I16, "__mspabi_fixdi" },
+ {RTLIB::FPTOSINT_F64_I32, "__mspabi_fixdli"},
+ {RTLIB::FPTOSINT_F64_I64, "__mspabi_fixdlli"},
+ // The following is NOT implemented in libgcc
+ //{ RTLIB::FPTOUINT_F64_I16, "__mspabi_fixdu" },
+ {RTLIB::FPTOUINT_F64_I32, "__mspabi_fixdul"},
+ {RTLIB::FPTOUINT_F64_I64, "__mspabi_fixdull"},
+ // The following is NOT implemented in libgcc
+ //{ RTLIB::FPTOSINT_F32_I16, "__mspabi_fixfi" },
+ {RTLIB::FPTOSINT_F32_I32, "__mspabi_fixfli"},
+ {RTLIB::FPTOSINT_F32_I64, "__mspabi_fixflli"},
+ // The following is NOT implemented in libgcc
+ //{ RTLIB::FPTOUINT_F32_I16, "__mspabi_fixfu" },
+ {RTLIB::FPTOUINT_F32_I32, "__mspabi_fixful"},
+ {RTLIB::FPTOUINT_F32_I64, "__mspabi_fixfull"},
+ // TODO The following IS implemented in libgcc
+ //{ RTLIB::SINTTOFP_I16_F64, "__mspabi_fltid" },
+ {RTLIB::SINTTOFP_I32_F64, "__mspabi_fltlid"},
+ // TODO The following IS implemented in libgcc but is not in the EABI
+ {RTLIB::SINTTOFP_I64_F64, "__mspabi_fltllid"},
+ // TODO The following IS implemented in libgcc
+ //{ RTLIB::UINTTOFP_I16_F64, "__mspabi_fltud" },
+ {RTLIB::UINTTOFP_I32_F64, "__mspabi_fltuld"},
+ // The following IS implemented in libgcc but is not in the EABI
+ {RTLIB::UINTTOFP_I64_F64, "__mspabi_fltulld"},
+ // TODO The following IS implemented in libgcc
+ //{ RTLIB::SINTTOFP_I16_F32, "__mspabi_fltif" },
+ {RTLIB::SINTTOFP_I32_F32, "__mspabi_fltlif"},
+ // TODO The following IS implemented in libgcc but is not in the EABI
+ {RTLIB::SINTTOFP_I64_F32, "__mspabi_fltllif"},
+ // TODO The following IS implemented in libgcc
+ //{ RTLIB::UINTTOFP_I16_F32, "__mspabi_fltuf" },
+ {RTLIB::UINTTOFP_I32_F32, "__mspabi_fltulf"},
+ // The following IS implemented in libgcc but is not in the EABI
+ {RTLIB::UINTTOFP_I64_F32, "__mspabi_fltullf"},
+
+ // Floating point comparisons - EABI Table 7
+ {RTLIB::OEQ_F64, "__mspabi_cmpd"},
+ {RTLIB::UNE_F64, "__mspabi_cmpd"},
+ {RTLIB::OGE_F64, "__mspabi_cmpd"},
+ {RTLIB::OLT_F64, "__mspabi_cmpd"},
+ {RTLIB::OLE_F64, "__mspabi_cmpd"},
+ {RTLIB::OGT_F64, "__mspabi_cmpd"},
+ {RTLIB::OEQ_F32, "__mspabi_cmpf"},
+ {RTLIB::UNE_F32, "__mspabi_cmpf"},
+ {RTLIB::OGE_F32, "__mspabi_cmpf"},
+ {RTLIB::OLT_F32, "__mspabi_cmpf"},
+ {RTLIB::OLE_F32, "__mspabi_cmpf"},
+ {RTLIB::OGT_F32, "__mspabi_cmpf"},
+
+ // Floating point arithmetic - EABI Table 8
+ {RTLIB::ADD_F64, "__mspabi_addd"},
+ {RTLIB::ADD_F32, "__mspabi_addf"},
+ {RTLIB::DIV_F64, "__mspabi_divd"},
+ {RTLIB::DIV_F32, "__mspabi_divf"},
+ {RTLIB::MUL_F64, "__mspabi_mpyd"},
+ {RTLIB::MUL_F32, "__mspabi_mpyf"},
+ {RTLIB::SUB_F64, "__mspabi_subd"},
+ {RTLIB::SUB_F32, "__mspabi_subf"},
+ // The following are NOT implemented in libgcc
+ // { RTLIB::NEG_F64, "__mspabi_negd" },
+ // { RTLIB::NEG_F32, "__mspabi_negf" },
+
+ // Universal Integer Operations - EABI Table 9
+ {RTLIB::SDIV_I16, "__mspabi_divi"},
+ {RTLIB::SDIV_I32, "__mspabi_divli"},
+ {RTLIB::SDIV_I64, "__mspabi_divlli"},
+ {RTLIB::UDIV_I16, "__mspabi_divu"},
+ {RTLIB::UDIV_I32, "__mspabi_divul"},
+ {RTLIB::UDIV_I64, "__mspabi_divull"},
+ {RTLIB::SREM_I16, "__mspabi_remi"},
+ {RTLIB::SREM_I32, "__mspabi_remli"},
+ {RTLIB::SREM_I64, "__mspabi_remlli"},
+ {RTLIB::UREM_I16, "__mspabi_remu"},
+ {RTLIB::UREM_I32, "__mspabi_remul"},
+ {RTLIB::UREM_I64, "__mspabi_remull"},
+
+ // Bitwise Operations - EABI Table 10
+ // TODO: __mspabi_[srli/srai/slli] ARE implemented in libgcc
+ {RTLIB::SRL_I32, "__mspabi_srll"},
+ {RTLIB::SRA_I32, "__mspabi_sral"},
+ {RTLIB::SHL_I32, "__mspabi_slll"},
+ // __mspabi_[srlll/srall/sllll/rlli/rlll] are NOT implemented in libgcc
+ };
+
+ for (const auto &LC : LibraryCalls)
+ Info.setLibcallName(LC.Op, LC.Name);
+
+ // Several of the runtime library functions use a special calling conv
+ Info.setLibcallCallingConv(RTLIB::UDIV_I64, CallingConv::MSP430_BUILTIN);
+ Info.setLibcallCallingConv(RTLIB::UREM_I64, CallingConv::MSP430_BUILTIN);
+ Info.setLibcallCallingConv(RTLIB::SDIV_I64, CallingConv::MSP430_BUILTIN);
+ Info.setLibcallCallingConv(RTLIB::SREM_I64, CallingConv::MSP430_BUILTIN);
+ Info.setLibcallCallingConv(RTLIB::ADD_F64, CallingConv::MSP430_BUILTIN);
+ Info.setLibcallCallingConv(RTLIB::SUB_F64, CallingConv::MSP430_BUILTIN);
+ Info.setLibcallCallingConv(RTLIB::MUL_F64, CallingConv::MSP430_BUILTIN);
+ Info.setLibcallCallingConv(RTLIB::DIV_F64, CallingConv::MSP430_BUILTIN);
+ Info.setLibcallCallingConv(RTLIB::OEQ_F64, CallingConv::MSP430_BUILTIN);
+ Info.setLibcallCallingConv(RTLIB::UNE_F64, CallingConv::MSP430_BUILTIN);
+ Info.setLibcallCallingConv(RTLIB::OGE_F64, CallingConv::MSP430_BUILTIN);
+ Info.setLibcallCallingConv(RTLIB::OLT_F64, CallingConv::MSP430_BUILTIN);
+ Info.setLibcallCallingConv(RTLIB::OLE_F64, CallingConv::MSP430_BUILTIN);
+ Info.setLibcallCallingConv(RTLIB::OGT_F64, CallingConv::MSP430_BUILTIN);
+
+ // TODO: __mspabi_srall, __mspabi_srlll, __mspabi_sllll
+}
+
/// Set default libcall names. If a target wants to opt-out of a libcall it
/// should be placed here.
void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
@@ -291,4 +408,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
for (auto &E : RTLibCallCommon)
setLibcallName(E.Code, E.Name);
}
+
+ if (TT.getArch() == Triple::ArchType::msp430)
+ setMSP430Libcalls(*this, TT);
}
diff --git a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
index 8c55f77d062b7..c2946de838d77 100644
--- a/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
+++ b/llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
@@ -148,103 +148,6 @@ MSP430TargetLowering::MSP430TargetLowering(const TargetMachine &TM,
setOperationAction(ISD::VACOPY, MVT::Other, Expand);
setOperationAction(ISD::JumpTable, MVT::i16, Custom);
- // EABI Libcalls - EABI Section 6.2
- const struct {
- const RTLIB::Libcall Op;
- const char *const Name;
- } LibraryCalls[] = {
- // Floating point conversions - EABI Table 6
- {RTLIB::FPROUND_F64_F32, "__mspabi_cvtdf"},
- {RTLIB::FPEXT_F32_F64, "__mspabi_cvtfd"},
- // The following is NOT implemented in libgcc
- //{ RTLIB::FPTOSINT_F64_I16, "__mspabi_fixdi" },
- {RTLIB::FPTOSINT_F64_I32, "__mspabi_fixdli"},
- {RTLIB::FPTOSINT_F64_I64, "__mspabi_fixdlli"},
- // The following is NOT implemented in libgcc
- //{ RTLIB::FPTOUINT_F64_I16, "__mspabi_fixdu" },
- {RTLIB::FPTOUINT_F64_I32, "__mspabi_fixdul"},
- {RTLIB::FPTOUINT_F64_I64, "__mspabi_fixdull"},
- // The following is NOT implemented in libgcc
- //{ RTLIB::FPTOSINT_F32_I16, "__mspabi_fixfi" },
- {RTLIB::FPTOSINT_F32_I32, "__mspabi_fixfli"},
- {RTLIB::FPTOSINT_F32_I64, "__mspabi_fixflli"},
- // The following is NOT implemented in libgcc
- //{ RTLIB::FPTOUINT_F32_I16, "__mspabi_fixfu" },
- {RTLIB::FPTOUINT_F32_I32, "__mspabi_fixful"},
- {RTLIB::FPTOUINT_F32_I64, "__mspabi_fixfull"},
- // TODO The following IS implemented in libgcc
- //{ RTLIB::SINTTOFP_I16_F64, "__mspabi_fltid" },
- {RTLIB::SINTTOFP_I32_F64, "__mspabi_fltlid"},
- // TODO The following IS implemented in libgcc but is not in the EABI
- {RTLIB::SINTTOFP_I64_F64, "__mspabi_fltllid"},
- // TODO The following IS implemented in libgcc
- //{ RTLIB::UINTTOFP_I16_F64, "__mspabi_fltud" },
- {RTLIB::UINTTOFP_I32_F64, "__mspabi_fltuld"},
- // The following IS implemented in libgcc but is not in the EABI
- {RTLIB::UINTTOFP_I64_F64, "__mspabi_fltulld"},
- // TODO The following IS implemented in libgcc
- //{ RTLIB::SINTTOFP_I16_F32, "__mspabi_fltif" },
- {RTLIB::SINTTOFP_I32_F32, "__mspabi_fltlif"},
- // TODO The following IS implemented in libgcc but is not in the EABI
- {RTLIB::SINTTOFP_I64_F32, "__mspabi_fltllif"},
- // TODO The following IS implemented in libgcc
- //{ RTLIB::UINTTOFP_I16_F32, "__mspabi_fltuf" },
- {RTLIB::UINTTOFP_I32_F32, "__mspabi_fltulf"},
- // The following IS implemented in libgcc but is not in the EABI
- {RTLIB::UINTTOFP_I64_F32, "__mspabi_fltullf"},
-
- // Floating point comparisons - EABI Table 7
- {RTLIB::OEQ_F64, "__mspabi_cmpd"},
- {RTLIB::UNE_F64, "__mspabi_cmpd"},
- {RTLIB::OGE_F64, "__mspabi_cmpd"},
- {RTLIB::OLT_F64, "__mspabi_cmpd"},
- {RTLIB::OLE_F64, "__mspabi_cmpd"},
- {RTLIB::OGT_F64, "__mspabi_cmpd"},
- {RTLIB::OEQ_F32, "__mspabi_cmpf"},
- {RTLIB::UNE_F32, "__mspabi_cmpf"},
- {RTLIB::OGE_F32, "__mspabi_cmpf"},
- {RTLIB::OLT_F32, "__mspabi_cmpf"},
- {RTLIB::OLE_F32, "__mspabi_cmpf"},
- {RTLIB::OGT_F32, "__mspabi_cmpf"},
-
- // Floating point arithmetic - EABI Table 8
- {RTLIB::ADD_F64, "__mspabi_addd"},
- {RTLIB::ADD_F32, "__mspabi_addf"},
- {RTLIB::DIV_F64, "__mspabi_divd"},
- {RTLIB::DIV_F32, "__mspabi_divf"},
- {RTLIB::MUL_F64, "__mspabi_mpyd"},
- {RTLIB::MUL_F32, "__mspabi_mpyf"},
- {RTLIB::SUB_F64, "__mspabi_subd"},
- {RTLIB::SUB_F32, "__mspabi_subf"},
- // The following are NOT implemented in libgcc
- // { RTLIB::NEG_F64, "__mspabi_negd" },
- // { RTLIB::NEG_F32, "__mspabi_negf" },
-
- // Universal Integer Operations - EABI Table 9
- {RTLIB::SDIV_I16, "__mspabi_divi"},
- {RTLIB::SDIV_I32, "__mspabi_divli"},
- {RTLIB::SDIV_I64, "__mspabi_divlli"},
- {RTLIB::UDIV_I16, "__mspabi_divu"},
- {RTLIB::UDIV_I32, "__mspabi_divul"},
- {RTLIB::UDIV_I64, "__mspabi_divull"},
- {RTLIB::SREM_I16, "__mspabi_remi"},
- {RTLIB::SREM_I32, "__mspabi_remli"},
- {RTLIB::SREM_I64, "__mspabi_remlli"},
- {RTLIB::UREM_I16, "__mspabi_remu"},
- {RTLIB::UREM_I32, "__mspabi_remul"},
- {RTLIB::UREM_I64, "__mspabi_remull"},
-
- // Bitwise Operations - EABI Table 10
- // TODO: __mspabi_[srli/srai/slli] ARE implemented in libgcc
- {RTLIB::SRL_I32, "__mspabi_srll"},
- {RTLIB::SRA_I32, "__mspabi_sral"},
- {RTLIB::SHL_I32, "__mspabi_slll"},
- // __mspabi_[srlll/srall/sllll/rlli/rlll] are NOT implemented in libgcc
- };
-
- for (const auto &LC : LibraryCalls)
- setLibcallName(LC.Op, LC.Name);
-
if (STI.hasHWMult16()) {
const struct {
const RTLIB::Libcall Op;
@@ -308,23 +211,6 @@ MSP430TargetLowering::MSP430TargetLowering(const TargetMachine &TM,
setLibcallCallingConv(RTLIB::MUL_I64, CallingConv::MSP430_BUILTIN);
}
- // Several of the runtime library functions use a special calling conv
- setLibcallCallingConv(RTLIB::UDIV_I64, CallingConv::MSP430_BUILTIN);
- setLibcallCallingConv(RTLIB::UREM_I64, CallingConv::MSP430_BUILTIN);
- setLibcallCallingConv(RTLIB::SDIV_I64, CallingConv::MSP430_BUILTIN);
- setLibcallCallingConv(RTLIB::SREM_I64, CallingConv::MSP430_BUILTIN);
- setLibcallCallingConv(RTLIB::ADD_F64, CallingConv::MSP430_BUILTIN);
- setLibcallCallingConv(RTLIB::SUB_F64, CallingConv::MSP430_BUILTIN);
- setLibcallCallingConv(RTLIB::MUL_F64, CallingConv::MSP430_BUILTIN);
- setLibcallCallingConv(RTLIB::DIV_F64, CallingConv::MSP430_BUILTIN);
- setLibcallCallingConv(RTLIB::OEQ_F64, CallingConv::MSP430_BUILTIN);
- setLibcallCallingConv(RTLIB::UNE_F64, CallingConv::MSP430_BUILTIN);
- setLibcallCallingConv(RTLIB::OGE_F64, CallingConv::MSP430_BUILTIN);
- setLibcallCallingConv(RTLIB::OLT_F64, CallingConv::MSP430_BUILTIN);
- setLibcallCallingConv(RTLIB::OLE_F64, CallingConv::MSP430_BUILTIN);
- setLibcallCallingConv(RTLIB::OGT_F64, CallingConv::MSP430_BUILTIN);
- // TODO: __mspabi_srall, __mspabi_srlll, __mspabi_sllll
-
setMinFunctionAlignment(Align(2));
setPrefFunctionAlignment(Align(2));
setMaxAtomicSizeInBitsSupported(0);
|
RuntimeLibcalls needs to be correct outside of codegen contexts.