mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 04:30:12 +00:00
Properly handle sdiv / udiv / srem / urem libcalls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70764 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b78e214274
commit
813090cf89
@ -45,15 +45,19 @@ namespace RTLIB {
|
||||
MUL_I32,
|
||||
MUL_I64,
|
||||
MUL_I128,
|
||||
SDIV_I16,
|
||||
SDIV_I32,
|
||||
SDIV_I64,
|
||||
SDIV_I128,
|
||||
UDIV_I16,
|
||||
UDIV_I32,
|
||||
UDIV_I64,
|
||||
UDIV_I128,
|
||||
SREM_I16,
|
||||
SREM_I32,
|
||||
SREM_I64,
|
||||
SREM_I128,
|
||||
UREM_I16,
|
||||
UREM_I32,
|
||||
UREM_I64,
|
||||
UREM_I128,
|
||||
|
@ -3308,16 +3308,20 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) {
|
||||
switch (Node->getOpcode()) {
|
||||
case ISD::UDIV:
|
||||
case ISD::SDIV:
|
||||
if (VT == MVT::i32) {
|
||||
LC = Node->getOpcode() == ISD::UDIV
|
||||
? RTLIB::UDIV_I32 : RTLIB::SDIV_I32;
|
||||
isSigned = Node->getOpcode() == ISD::SDIV;
|
||||
}
|
||||
break;
|
||||
isSigned = Node->getOpcode() == ISD::SDIV;
|
||||
if (VT == MVT::i16)
|
||||
LC = (isSigned ? RTLIB::SDIV_I16 : RTLIB::UDIV_I16);
|
||||
else if (VT == MVT::i32)
|
||||
LC = (isSigned ? RTLIB::SDIV_I32 : RTLIB::UDIV_I32);
|
||||
else if (VT == MVT::i64)
|
||||
LC = (isSigned ? RTLIB::SDIV_I64 : RTLIB::UDIV_I64);
|
||||
else if (VT == MVT::i128)
|
||||
LC = (isSigned ? RTLIB::SDIV_I128 : RTLIB::UDIV_I128);
|
||||
break;
|
||||
case ISD::MUL:
|
||||
if (VT == MVT::i16)
|
||||
LC = RTLIB::MUL_I16;
|
||||
if (VT == MVT::i32)
|
||||
else if (VT == MVT::i32)
|
||||
LC = RTLIB::MUL_I32;
|
||||
else if (VT == MVT::i64)
|
||||
LC = RTLIB::MUL_I64;
|
||||
|
@ -67,15 +67,19 @@ static void InitLibcallNames(const char **Names) {
|
||||
Names[RTLIB::MUL_I32] = "__mulsi3";
|
||||
Names[RTLIB::MUL_I64] = "__muldi3";
|
||||
Names[RTLIB::MUL_I128] = "__multi3";
|
||||
Names[RTLIB::SDIV_I16] = "__divhi3";
|
||||
Names[RTLIB::SDIV_I32] = "__divsi3";
|
||||
Names[RTLIB::SDIV_I64] = "__divdi3";
|
||||
Names[RTLIB::SDIV_I128] = "__divti3";
|
||||
Names[RTLIB::UDIV_I32] = "__udivhi3";
|
||||
Names[RTLIB::UDIV_I32] = "__udivsi3";
|
||||
Names[RTLIB::UDIV_I64] = "__udivdi3";
|
||||
Names[RTLIB::UDIV_I128] = "__udivti3";
|
||||
Names[RTLIB::SREM_I16] = "__modhi3";
|
||||
Names[RTLIB::SREM_I32] = "__modsi3";
|
||||
Names[RTLIB::SREM_I64] = "__moddi3";
|
||||
Names[RTLIB::SREM_I128] = "__modti3";
|
||||
Names[RTLIB::UREM_I16] = "__umodsi3";
|
||||
Names[RTLIB::UREM_I32] = "__umodsi3";
|
||||
Names[RTLIB::UREM_I64] = "__umoddi3";
|
||||
Names[RTLIB::UREM_I128] = "__umodti3";
|
||||
|
Loading…
Reference in New Issue
Block a user