Skip to content

Commit 26b50d9

Browse files
committed
RuntimeLibcalls: Invert handling of 64-bit only libcalls
Switch the default set to exclude these conditionally available calls, so they are opt-in instead of opt-out.
1 parent 91d017a commit 26b50d9

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,26 +439,21 @@ let IsDefault = true in {
439439
def __ashlhi3 : RuntimeLibcallImpl<SHL_I16>;
440440
def __ashlsi3 : RuntimeLibcallImpl<SHL_I32>;
441441
def __ashldi3 : RuntimeLibcallImpl<SHL_I64>;
442-
def __ashlti3 : RuntimeLibcallImpl<SHL_I128>;
443442

444443
def __lshrhi3 : RuntimeLibcallImpl<SRL_I16>;
445444
def __lshrsi3 : RuntimeLibcallImpl<SRL_I32>;
446445
def __lshrdi3 : RuntimeLibcallImpl<SRL_I64>;
447-
def __lshrti3 : RuntimeLibcallImpl<SRL_I128>;
448446

449447
def __ashrhi3 : RuntimeLibcallImpl<SRA_I16>;
450448
def __ashrsi3 : RuntimeLibcallImpl<SRA_I32>;
451449
def __ashrdi3 : RuntimeLibcallImpl<SRA_I64>;
452-
def __ashrti3 : RuntimeLibcallImpl<SRA_I128>;
453450

454451
def __mulqi3 : RuntimeLibcallImpl<MUL_I8>;
455452
def __mulhi3 : RuntimeLibcallImpl<MUL_I16>;
456453
def __mulsi3 : RuntimeLibcallImpl<MUL_I32>;
457454
def __muldi3 : RuntimeLibcallImpl<MUL_I64>;
458-
def __multi3 : RuntimeLibcallImpl<MUL_I128>;
459455

460456
def __mulosi4 : RuntimeLibcallImpl<MULO_I32>;
461-
def __mulodi4 : RuntimeLibcallImpl<MULO_I64>;
462457

463458
def __divqi3 : RuntimeLibcallImpl<SDIV_I8>;
464459
def __divhi3 : RuntimeLibcallImpl<SDIV_I16>;
@@ -938,6 +933,11 @@ def calloc : RuntimeLibcallImpl<CALLOC>;
938933
// compiler-rt, not available for most architectures
939934
//--------------------------------------------------------------------
940935

936+
def __ashlti3 : RuntimeLibcallImpl<SHL_I128>;
937+
def __lshrti3 : RuntimeLibcallImpl<SRL_I128>;
938+
def __ashrti3 : RuntimeLibcallImpl<SRA_I128>;
939+
def __multi3 : RuntimeLibcallImpl<MUL_I128>;
940+
def __mulodi4 : RuntimeLibcallImpl<MULO_I64>;
941941
def __muloti4 : RuntimeLibcallImpl<MULO_I128>;
942942

943943
//--------------------------------------------------------------------

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
139139
EABI EABIVersion, StringRef ABIName) {
140140
setTargetRuntimeLibcallSets(TT, FloatABI);
141141

142+
// Early exit for targets that have fully ported to tablegen.
143+
if (TT.isAMDGPU() || TT.isNVPTX() || TT.isWasm())
144+
return;
145+
142146
// Use the f128 variants of math functions on x86
143147
if (TT.isX86() && TT.isGNUEnvironment())
144148
setLongDoubleIsF128Libm(*this, /*FiniteOnlyFuncs=*/true);
@@ -241,15 +245,13 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
241245
if (TT.isARM() || TT.isThumb())
242246
setARMLibcallNames(*this, TT, FloatABI, EABIVersion);
243247

244-
if (!TT.isWasm()) {
245-
// These libcalls are only available in compiler-rt, not libgcc.
246-
if (TT.isArch32Bit()) {
247-
setLibcallImpl(RTLIB::SHL_I128, RTLIB::Unsupported);
248-
setLibcallImpl(RTLIB::SRL_I128, RTLIB::Unsupported);
249-
setLibcallImpl(RTLIB::SRA_I128, RTLIB::Unsupported);
250-
setLibcallImpl(RTLIB::MUL_I128, RTLIB::Unsupported);
251-
setLibcallImpl(RTLIB::MULO_I64, RTLIB::Unsupported);
252-
}
248+
// These libcalls are only available in compiler-rt, not libgcc.
249+
if (TT.isArch64Bit()) {
250+
setLibcallImpl(RTLIB::SHL_I128, RTLIB::__ashlti3);
251+
setLibcallImpl(RTLIB::SRL_I128, RTLIB::__lshrti3);
252+
setLibcallImpl(RTLIB::SRA_I128, RTLIB::__ashrti3);
253+
setLibcallImpl(RTLIB::MUL_I128, RTLIB::__multi3);
254+
setLibcallImpl(RTLIB::MULO_I64, RTLIB::__mulodi4);
253255
}
254256

255257
if (TT.getArch() == Triple::ArchType::msp430) {

0 commit comments

Comments
 (0)