forked from OSchip/llvm-project
ARM: slightly more table driven libcall setup
Switch some additional library call setup to be table driven. This makes it more immediately obvious what the library call looks like. This is important for ARM since the calling conventions for the builtins change based on the target/libcall name. NFC llvm-svn: 291789
This commit is contained in:
parent
095f633b74
commit
555e5980a5
|
@ -608,15 +608,27 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
|
|||
// In EABI, these functions have an __aeabi_ prefix, but in GNUEABI they have
|
||||
// a __gnu_ prefix (which is the default).
|
||||
if (Subtarget->isTargetAEABI()) {
|
||||
setLibcallName(RTLIB::FPROUND_F32_F16, "__aeabi_f2h");
|
||||
setLibcallName(RTLIB::FPROUND_F64_F16, "__aeabi_d2h");
|
||||
setLibcallName(RTLIB::FPEXT_F16_F32, "__aeabi_h2f");
|
||||
static const struct {
|
||||
const RTLIB::Libcall Op;
|
||||
const char * const Name;
|
||||
const CallingConv::ID CC;
|
||||
} LibraryCalls[] = {
|
||||
{ RTLIB::FPROUND_F32_F16, "__aeabi_f2h", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::FPROUND_F64_F16, "__aeabi_d2h", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::FPEXT_F16_F32, "__aeabi_h2f", CallingConv::ARM_AAPCS },
|
||||
};
|
||||
|
||||
for (const auto &LC : LibraryCalls) {
|
||||
setLibcallName(LC.Op, LC.Name);
|
||||
setLibcallCallingConv(LC.Op, LC.CC);
|
||||
}
|
||||
}
|
||||
|
||||
if (Subtarget->isThumb1Only())
|
||||
addRegisterClass(MVT::i32, &ARM::tGPRRegClass);
|
||||
else
|
||||
addRegisterClass(MVT::i32, &ARM::GPRRegClass);
|
||||
|
||||
if (!Subtarget->useSoftFloat() && Subtarget->hasVFP2() &&
|
||||
!Subtarget->isThumb1Only()) {
|
||||
addRegisterClass(MVT::f32, &ARM::SPRRegClass);
|
||||
|
@ -976,6 +988,7 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
|
|||
|
||||
setOperationAction(ISD::SREM, MVT::i32, Expand);
|
||||
setOperationAction(ISD::UREM, MVT::i32, Expand);
|
||||
|
||||
// Register based DivRem for AEABI (RTABI 4.2)
|
||||
if (Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid() ||
|
||||
Subtarget->isTargetGNUAEABI() || Subtarget->isTargetMuslAEABI() ||
|
||||
|
@ -984,29 +997,49 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
|
|||
setOperationAction(ISD::UREM, MVT::i64, Custom);
|
||||
HasStandaloneRem = false;
|
||||
|
||||
for (const auto &LC :
|
||||
{RTLIB::SDIVREM_I8, RTLIB::SDIVREM_I16, RTLIB::SDIVREM_I32})
|
||||
setLibcallName(LC, Subtarget->isTargetWindows() ? "__rt_sdiv"
|
||||
: "__aeabi_idivmod");
|
||||
setLibcallName(RTLIB::SDIVREM_I64, Subtarget->isTargetWindows()
|
||||
? "__rt_sdiv64"
|
||||
: "__aeabi_ldivmod");
|
||||
for (const auto &LC :
|
||||
{RTLIB::UDIVREM_I8, RTLIB::UDIVREM_I16, RTLIB::UDIVREM_I32})
|
||||
setLibcallName(LC, Subtarget->isTargetWindows() ? "__rt_udiv"
|
||||
: "__aeabi_uidivmod");
|
||||
setLibcallName(RTLIB::UDIVREM_I64, Subtarget->isTargetWindows()
|
||||
? "__rt_udiv64"
|
||||
: "__aeabi_uldivmod");
|
||||
if (Subtarget->isTargetWindows()) {
|
||||
const struct {
|
||||
const RTLIB::Libcall Op;
|
||||
const char * const Name;
|
||||
const CallingConv::ID CC;
|
||||
} LibraryCalls[] = {
|
||||
{ RTLIB::SDIVREM_I8, "__rt_sdiv", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::SDIVREM_I16, "__rt_sdiv", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::SDIVREM_I32, "__rt_sdiv", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::SDIVREM_I64, "__rt_sdiv64", CallingConv::ARM_AAPCS },
|
||||
|
||||
setLibcallCallingConv(RTLIB::SDIVREM_I8, CallingConv::ARM_AAPCS);
|
||||
setLibcallCallingConv(RTLIB::SDIVREM_I16, CallingConv::ARM_AAPCS);
|
||||
setLibcallCallingConv(RTLIB::SDIVREM_I32, CallingConv::ARM_AAPCS);
|
||||
setLibcallCallingConv(RTLIB::SDIVREM_I64, CallingConv::ARM_AAPCS);
|
||||
setLibcallCallingConv(RTLIB::UDIVREM_I8, CallingConv::ARM_AAPCS);
|
||||
setLibcallCallingConv(RTLIB::UDIVREM_I16, CallingConv::ARM_AAPCS);
|
||||
setLibcallCallingConv(RTLIB::UDIVREM_I32, CallingConv::ARM_AAPCS);
|
||||
setLibcallCallingConv(RTLIB::UDIVREM_I64, CallingConv::ARM_AAPCS);
|
||||
{ RTLIB::UDIVREM_I8, "__rt_udiv", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::UDIVREM_I16, "__rt_udiv", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::UDIVREM_I32, "__rt_udiv", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::UDIVREM_I64, "__rt_udiv64", CallingConv::ARM_AAPCS },
|
||||
};
|
||||
|
||||
for (const auto &LC : LibraryCalls) {
|
||||
setLibcallName(LC.Op, LC.Name);
|
||||
setLibcallCallingConv(LC.Op, LC.CC);
|
||||
}
|
||||
} else {
|
||||
const struct {
|
||||
const RTLIB::Libcall Op;
|
||||
const char * const Name;
|
||||
const CallingConv::ID CC;
|
||||
} LibraryCalls[] = {
|
||||
{ RTLIB::SDIVREM_I8, "__aeabi_idivmod", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::SDIVREM_I16, "__aeabi_idivmod", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::SDIVREM_I32, "__aeabi_idivmod", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::SDIVREM_I64, "__aeabi_ldivmod", CallingConv::ARM_AAPCS },
|
||||
|
||||
{ RTLIB::UDIVREM_I8, "__aeabi_uidivmod", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::UDIVREM_I16, "__aeabi_uidivmod", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::UDIVREM_I32, "__aeabi_uidivmod", CallingConv::ARM_AAPCS },
|
||||
{ RTLIB::UDIVREM_I64, "__aeabi_uldivmod", CallingConv::ARM_AAPCS },
|
||||
};
|
||||
|
||||
for (const auto &LC : LibraryCalls) {
|
||||
setLibcallName(LC.Op, LC.Name);
|
||||
setLibcallCallingConv(LC.Op, LC.CC);
|
||||
}
|
||||
}
|
||||
|
||||
setOperationAction(ISD::SDIVREM, MVT::i32, Custom);
|
||||
setOperationAction(ISD::UDIVREM, MVT::i32, Custom);
|
||||
|
|
Loading…
Reference in New Issue