llvm.org GIT mirror llvm / 13f3144
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291789 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 3 years ago
1 changed file(s) with 59 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
607607 // In EABI, these functions have an __aeabi_ prefix, but in GNUEABI they have
608608 // a __gnu_ prefix (which is the default).
609609 if (Subtarget->isTargetAEABI()) {
610 setLibcallName(RTLIB::FPROUND_F32_F16, "__aeabi_f2h");
611 setLibcallName(RTLIB::FPROUND_F64_F16, "__aeabi_d2h");
612 setLibcallName(RTLIB::FPEXT_F16_F32, "__aeabi_h2f");
610 static const struct {
611 const RTLIB::Libcall Op;
612 const char * const Name;
613 const CallingConv::ID CC;
614 } LibraryCalls[] = {
615 { RTLIB::FPROUND_F32_F16, "__aeabi_f2h", CallingConv::ARM_AAPCS },
616 { RTLIB::FPROUND_F64_F16, "__aeabi_d2h", CallingConv::ARM_AAPCS },
617 { RTLIB::FPEXT_F16_F32, "__aeabi_h2f", CallingConv::ARM_AAPCS },
618 };
619
620 for (const auto &LC : LibraryCalls) {
621 setLibcallName(LC.Op, LC.Name);
622 setLibcallCallingConv(LC.Op, LC.CC);
623 }
613624 }
614625
615626 if (Subtarget->isThumb1Only())
616627 addRegisterClass(MVT::i32, &ARM::tGPRRegClass);
617628 else
618629 addRegisterClass(MVT::i32, &ARM::GPRRegClass);
630
619631 if (!Subtarget->useSoftFloat() && Subtarget->hasVFP2() &&
620632 !Subtarget->isThumb1Only()) {
621633 addRegisterClass(MVT::f32, &ARM::SPRRegClass);
975987
976988 setOperationAction(ISD::SREM, MVT::i32, Expand);
977989 setOperationAction(ISD::UREM, MVT::i32, Expand);
990
978991 // Register based DivRem for AEABI (RTABI 4.2)
979992 if (Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid() ||
980993 Subtarget->isTargetGNUAEABI() || Subtarget->isTargetMuslAEABI() ||
983996 setOperationAction(ISD::UREM, MVT::i64, Custom);
984997 HasStandaloneRem = false;
985998
986 for (const auto &LC :
987 {RTLIB::SDIVREM_I8, RTLIB::SDIVREM_I16, RTLIB::SDIVREM_I32})
988 setLibcallName(LC, Subtarget->isTargetWindows() ? "__rt_sdiv"
989 : "__aeabi_idivmod");
990 setLibcallName(RTLIB::SDIVREM_I64, Subtarget->isTargetWindows()
991 ? "__rt_sdiv64"
992 : "__aeabi_ldivmod");
993 for (const auto &LC :
994 {RTLIB::UDIVREM_I8, RTLIB::UDIVREM_I16, RTLIB::UDIVREM_I32})
995 setLibcallName(LC, Subtarget->isTargetWindows() ? "__rt_udiv"
996 : "__aeabi_uidivmod");
997 setLibcallName(RTLIB::UDIVREM_I64, Subtarget->isTargetWindows()
998 ? "__rt_udiv64"
999 : "__aeabi_uldivmod");
1000
1001 setLibcallCallingConv(RTLIB::SDIVREM_I8, CallingConv::ARM_AAPCS);
1002 setLibcallCallingConv(RTLIB::SDIVREM_I16, CallingConv::ARM_AAPCS);
1003 setLibcallCallingConv(RTLIB::SDIVREM_I32, CallingConv::ARM_AAPCS);
1004 setLibcallCallingConv(RTLIB::SDIVREM_I64, CallingConv::ARM_AAPCS);
1005 setLibcallCallingConv(RTLIB::UDIVREM_I8, CallingConv::ARM_AAPCS);
1006 setLibcallCallingConv(RTLIB::UDIVREM_I16, CallingConv::ARM_AAPCS);
1007 setLibcallCallingConv(RTLIB::UDIVREM_I32, CallingConv::ARM_AAPCS);
1008 setLibcallCallingConv(RTLIB::UDIVREM_I64, CallingConv::ARM_AAPCS);
999 if (Subtarget->isTargetWindows()) {
1000 const struct {
1001 const RTLIB::Libcall Op;
1002 const char * const Name;
1003 const CallingConv::ID CC;
1004 } LibraryCalls[] = {
1005 { RTLIB::SDIVREM_I8, "__rt_sdiv", CallingConv::ARM_AAPCS },
1006 { RTLIB::SDIVREM_I16, "__rt_sdiv", CallingConv::ARM_AAPCS },
1007 { RTLIB::SDIVREM_I32, "__rt_sdiv", CallingConv::ARM_AAPCS },
1008 { RTLIB::SDIVREM_I64, "__rt_sdiv64", CallingConv::ARM_AAPCS },
1009
1010 { RTLIB::UDIVREM_I8, "__rt_udiv", CallingConv::ARM_AAPCS },
1011 { RTLIB::UDIVREM_I16, "__rt_udiv", CallingConv::ARM_AAPCS },
1012 { RTLIB::UDIVREM_I32, "__rt_udiv", CallingConv::ARM_AAPCS },
1013 { RTLIB::UDIVREM_I64, "__rt_udiv64", CallingConv::ARM_AAPCS },
1014 };
1015
1016 for (const auto &LC : LibraryCalls) {
1017 setLibcallName(LC.Op, LC.Name);
1018 setLibcallCallingConv(LC.Op, LC.CC);
1019 }
1020 } else {
1021 const struct {
1022 const RTLIB::Libcall Op;
1023 const char * const Name;
1024 const CallingConv::ID CC;
1025 } LibraryCalls[] = {
1026 { RTLIB::SDIVREM_I8, "__aeabi_idivmod", CallingConv::ARM_AAPCS },
1027 { RTLIB::SDIVREM_I16, "__aeabi_idivmod", CallingConv::ARM_AAPCS },
1028 { RTLIB::SDIVREM_I32, "__aeabi_idivmod", CallingConv::ARM_AAPCS },
1029 { RTLIB::SDIVREM_I64, "__aeabi_ldivmod", CallingConv::ARM_AAPCS },
1030
1031 { RTLIB::UDIVREM_I8, "__aeabi_uidivmod", CallingConv::ARM_AAPCS },
1032 { RTLIB::UDIVREM_I16, "__aeabi_uidivmod", CallingConv::ARM_AAPCS },
1033 { RTLIB::UDIVREM_I32, "__aeabi_uidivmod", CallingConv::ARM_AAPCS },
1034 { RTLIB::UDIVREM_I64, "__aeabi_uldivmod", CallingConv::ARM_AAPCS },
1035 };
1036
1037 for (const auto &LC : LibraryCalls) {
1038 setLibcallName(LC.Op, LC.Name);
1039 setLibcallCallingConv(LC.Op, LC.CC);
1040 }
1041 }
10091042
10101043 setOperationAction(ISD::SDIVREM, MVT::i32, Custom);
10111044 setOperationAction(ISD::UDIVREM, MVT::i32, Custom);