Skip to content

Commit

Permalink
X86: use a data driven configuration of Windows x86 libcalls (NFC)
Browse files Browse the repository at this point in the history
Rather than creating a series of associated calls and ensuring that
everything is lined up, use a table driven approach that ensures that
they two always stay in sync.
  • Loading branch information
compnerd committed Dec 9, 2020
1 parent 540007b commit ee74d1b
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,24 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
addBypassSlowDiv(64, 32);
}

if (Subtarget.isTargetWindowsMSVC() ||
Subtarget.isTargetWindowsItanium()) {
// Setup Windows compiler runtime calls.
setLibcallName(RTLIB::SDIV_I64, "_alldiv");
setLibcallName(RTLIB::UDIV_I64, "_aulldiv");
setLibcallName(RTLIB::SREM_I64, "_allrem");
setLibcallName(RTLIB::UREM_I64, "_aullrem");
setLibcallName(RTLIB::MUL_I64, "_allmul");
setLibcallCallingConv(RTLIB::SDIV_I64, CallingConv::X86_StdCall);
setLibcallCallingConv(RTLIB::UDIV_I64, CallingConv::X86_StdCall);
setLibcallCallingConv(RTLIB::SREM_I64, CallingConv::X86_StdCall);
setLibcallCallingConv(RTLIB::UREM_I64, CallingConv::X86_StdCall);
setLibcallCallingConv(RTLIB::MUL_I64, CallingConv::X86_StdCall);
// Setup Windows compiler runtime calls.
if (Subtarget.isTargetWindowsMSVC() || Subtarget.isTargetWindowsItanium()) {
static const struct {
const RTLIB::Libcall Op;
const char * const Name;
const CallingConv::ID CC;
} LibraryCalls[] = {
{ RTLIB::SDIV_I64, "_alldiv", CallingConv::X86_StdCall },
{ RTLIB::UDIV_I64, "_aulldiv", CallingConv::X86_StdCall },
{ RTLIB::SREM_I64, "_allrem", CallingConv::X86_StdCall },
{ RTLIB::UREM_I64, "_aullrem", CallingConv::X86_StdCall },
{ RTLIB::MUL_I64, "_allmul", CallingConv::X86_StdCall },
};

for (const auto &LC : LibraryCalls) {
setLibcallName(LC.Op, LC.Name);
setLibcallCallingConv(LC.Op, LC.CC);
}
}

if (Subtarget.getTargetTriple().isOSMSVCRT()) {
Expand Down

0 comments on commit ee74d1b

Please sign in to comment.