mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 03:29:40 +00:00
Add 8 bit libcalls and make use of them for msp430
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86384 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8046ef4379
commit
8983da729a
@ -41,22 +41,27 @@ namespace RTLIB {
|
||||
SRA_I32,
|
||||
SRA_I64,
|
||||
SRA_I128,
|
||||
MUL_I8,
|
||||
MUL_I16,
|
||||
MUL_I32,
|
||||
MUL_I64,
|
||||
MUL_I128,
|
||||
SDIV_I8,
|
||||
SDIV_I16,
|
||||
SDIV_I32,
|
||||
SDIV_I64,
|
||||
SDIV_I128,
|
||||
UDIV_I8,
|
||||
UDIV_I16,
|
||||
UDIV_I32,
|
||||
UDIV_I64,
|
||||
UDIV_I128,
|
||||
SREM_I8,
|
||||
SREM_I16,
|
||||
SREM_I32,
|
||||
SREM_I64,
|
||||
SREM_I128,
|
||||
UREM_I8,
|
||||
UREM_I16,
|
||||
UREM_I32,
|
||||
UREM_I64,
|
||||
|
@ -148,8 +148,11 @@ private:
|
||||
SDValue ExpandFPLibCall(SDNode *Node, RTLIB::Libcall Call_F32,
|
||||
RTLIB::Libcall Call_F64, RTLIB::Libcall Call_F80,
|
||||
RTLIB::Libcall Call_PPCF128);
|
||||
SDValue ExpandIntLibCall(SDNode *Node, bool isSigned, RTLIB::Libcall Call_I16,
|
||||
RTLIB::Libcall Call_I32, RTLIB::Libcall Call_I64,
|
||||
SDValue ExpandIntLibCall(SDNode *Node, bool isSigned,
|
||||
RTLIB::Libcall Call_I8,
|
||||
RTLIB::Libcall Call_I16,
|
||||
RTLIB::Libcall Call_I32,
|
||||
RTLIB::Libcall Call_I64,
|
||||
RTLIB::Libcall Call_I128);
|
||||
|
||||
SDValue EmitStackConvert(SDValue SrcOp, EVT SlotVT, EVT DestVT, DebugLoc dl);
|
||||
@ -1909,6 +1912,7 @@ SDValue SelectionDAGLegalize::ExpandFPLibCall(SDNode* Node,
|
||||
}
|
||||
|
||||
SDValue SelectionDAGLegalize::ExpandIntLibCall(SDNode* Node, bool isSigned,
|
||||
RTLIB::Libcall Call_I8,
|
||||
RTLIB::Libcall Call_I16,
|
||||
RTLIB::Libcall Call_I32,
|
||||
RTLIB::Libcall Call_I64,
|
||||
@ -1916,9 +1920,10 @@ SDValue SelectionDAGLegalize::ExpandIntLibCall(SDNode* Node, bool isSigned,
|
||||
RTLIB::Libcall LC;
|
||||
switch (Node->getValueType(0).getSimpleVT().SimpleTy) {
|
||||
default: llvm_unreachable("Unexpected request for libcall!");
|
||||
case MVT::i16: LC = Call_I16; break;
|
||||
case MVT::i32: LC = Call_I32; break;
|
||||
case MVT::i64: LC = Call_I64; break;
|
||||
case MVT::i8: LC = Call_I8; break;
|
||||
case MVT::i16: LC = Call_I16; break;
|
||||
case MVT::i32: LC = Call_I32; break;
|
||||
case MVT::i64: LC = Call_I64; break;
|
||||
case MVT::i128: LC = Call_I128; break;
|
||||
}
|
||||
return ExpandLibCall(LC, Node, isSigned);
|
||||
@ -2624,10 +2629,14 @@ void SelectionDAGLegalize::ExpandNode(SDNode *Node,
|
||||
Tmp1 = DAG.getNode(ISD::MUL, dl, VT, Tmp1, Tmp3);
|
||||
Tmp1 = DAG.getNode(ISD::SUB, dl, VT, Tmp2, Tmp1);
|
||||
} else if (isSigned) {
|
||||
Tmp1 = ExpandIntLibCall(Node, true, RTLIB::SREM_I16, RTLIB::SREM_I32,
|
||||
Tmp1 = ExpandIntLibCall(Node, true,
|
||||
RTLIB::SREM_I8,
|
||||
RTLIB::SREM_I16, RTLIB::SREM_I32,
|
||||
RTLIB::SREM_I64, RTLIB::SREM_I128);
|
||||
} else {
|
||||
Tmp1 = ExpandIntLibCall(Node, false, RTLIB::UREM_I16, RTLIB::UREM_I32,
|
||||
Tmp1 = ExpandIntLibCall(Node, false,
|
||||
RTLIB::UREM_I8,
|
||||
RTLIB::UREM_I16, RTLIB::UREM_I32,
|
||||
RTLIB::UREM_I64, RTLIB::UREM_I128);
|
||||
}
|
||||
Results.push_back(Tmp1);
|
||||
@ -2643,10 +2652,14 @@ void SelectionDAGLegalize::ExpandNode(SDNode *Node,
|
||||
Tmp1 = DAG.getNode(DivRemOpc, dl, VTs, Node->getOperand(0),
|
||||
Node->getOperand(1));
|
||||
else if (isSigned)
|
||||
Tmp1 = ExpandIntLibCall(Node, true, RTLIB::SDIV_I16, RTLIB::SDIV_I32,
|
||||
Tmp1 = ExpandIntLibCall(Node, true,
|
||||
RTLIB::SDIV_I8,
|
||||
RTLIB::SDIV_I16, RTLIB::SDIV_I32,
|
||||
RTLIB::SDIV_I64, RTLIB::SDIV_I128);
|
||||
else
|
||||
Tmp1 = ExpandIntLibCall(Node, false, RTLIB::UDIV_I16, RTLIB::UDIV_I32,
|
||||
Tmp1 = ExpandIntLibCall(Node, false,
|
||||
RTLIB::UDIV_I8,
|
||||
RTLIB::UDIV_I16, RTLIB::UDIV_I32,
|
||||
RTLIB::UDIV_I64, RTLIB::UDIV_I128);
|
||||
Results.push_back(Tmp1);
|
||||
break;
|
||||
@ -2691,7 +2704,9 @@ void SelectionDAGLegalize::ExpandNode(SDNode *Node,
|
||||
Node->getOperand(1)));
|
||||
break;
|
||||
}
|
||||
Tmp1 = ExpandIntLibCall(Node, false, RTLIB::MUL_I16, RTLIB::MUL_I32,
|
||||
Tmp1 = ExpandIntLibCall(Node, false,
|
||||
RTLIB::MUL_I8,
|
||||
RTLIB::MUL_I16, RTLIB::MUL_I32,
|
||||
RTLIB::MUL_I64, RTLIB::MUL_I128);
|
||||
Results.push_back(Tmp1);
|
||||
break;
|
||||
|
@ -65,22 +65,27 @@ static void InitLibcallNames(const char **Names) {
|
||||
Names[RTLIB::SRA_I32] = "__ashrsi3";
|
||||
Names[RTLIB::SRA_I64] = "__ashrdi3";
|
||||
Names[RTLIB::SRA_I128] = "__ashrti3";
|
||||
Names[RTLIB::MUL_I8] = "__mulqi3";
|
||||
Names[RTLIB::MUL_I16] = "__mulhi3";
|
||||
Names[RTLIB::MUL_I32] = "__mulsi3";
|
||||
Names[RTLIB::MUL_I64] = "__muldi3";
|
||||
Names[RTLIB::MUL_I128] = "__multi3";
|
||||
Names[RTLIB::SDIV_I8] = "__divqi3";
|
||||
Names[RTLIB::SDIV_I16] = "__divhi3";
|
||||
Names[RTLIB::SDIV_I32] = "__divsi3";
|
||||
Names[RTLIB::SDIV_I64] = "__divdi3";
|
||||
Names[RTLIB::SDIV_I128] = "__divti3";
|
||||
Names[RTLIB::UDIV_I8] = "__udivqi3";
|
||||
Names[RTLIB::UDIV_I16] = "__udivhi3";
|
||||
Names[RTLIB::UDIV_I32] = "__udivsi3";
|
||||
Names[RTLIB::UDIV_I64] = "__udivdi3";
|
||||
Names[RTLIB::UDIV_I128] = "__udivti3";
|
||||
Names[RTLIB::SREM_I8] = "__modqi3";
|
||||
Names[RTLIB::SREM_I16] = "__modhi3";
|
||||
Names[RTLIB::SREM_I32] = "__modsi3";
|
||||
Names[RTLIB::SREM_I64] = "__moddi3";
|
||||
Names[RTLIB::SREM_I128] = "__modti3";
|
||||
Names[RTLIB::UREM_I8] = "__umodqi3";
|
||||
Names[RTLIB::UREM_I16] = "__umodhi3";
|
||||
Names[RTLIB::UREM_I32] = "__umodsi3";
|
||||
Names[RTLIB::UREM_I64] = "__umoddi3";
|
||||
|
@ -115,12 +115,23 @@ MSP430TargetLowering::MSP430TargetLowering(MSP430TargetMachine &tm) :
|
||||
setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand);
|
||||
|
||||
// FIXME: Implement efficiently multiplication by a constant
|
||||
setOperationAction(ISD::MUL, MVT::i8, Expand);
|
||||
setOperationAction(ISD::MULHS, MVT::i8, Expand);
|
||||
setOperationAction(ISD::MULHU, MVT::i8, Expand);
|
||||
setOperationAction(ISD::SMUL_LOHI, MVT::i8, Expand);
|
||||
setOperationAction(ISD::UMUL_LOHI, MVT::i8, Expand);
|
||||
setOperationAction(ISD::MUL, MVT::i16, Expand);
|
||||
setOperationAction(ISD::MULHS, MVT::i16, Expand);
|
||||
setOperationAction(ISD::MULHU, MVT::i16, Expand);
|
||||
setOperationAction(ISD::SMUL_LOHI, MVT::i16, Expand);
|
||||
setOperationAction(ISD::UMUL_LOHI, MVT::i16, Expand);
|
||||
|
||||
setOperationAction(ISD::UDIV, MVT::i8, Expand);
|
||||
setOperationAction(ISD::UDIVREM, MVT::i8, Expand);
|
||||
setOperationAction(ISD::UREM, MVT::i8, Expand);
|
||||
setOperationAction(ISD::SDIV, MVT::i8, Expand);
|
||||
setOperationAction(ISD::SDIVREM, MVT::i8, Expand);
|
||||
setOperationAction(ISD::SREM, MVT::i8, Expand);
|
||||
setOperationAction(ISD::UDIV, MVT::i16, Expand);
|
||||
setOperationAction(ISD::UDIVREM, MVT::i16, Expand);
|
||||
setOperationAction(ISD::UREM, MVT::i16, Expand);
|
||||
|
22
test/CodeGen/MSP430/2009-11-05-8BitLibcalls.ll
Normal file
22
test/CodeGen/MSP430/2009-11-05-8BitLibcalls.ll
Normal file
@ -0,0 +1,22 @@
|
||||
; RUN: llc < %s | FileCheck %s
|
||||
|
||||
target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"
|
||||
target triple = "msp430-elf"
|
||||
|
||||
@g_29 = common global i8 0, align 1 ; <i8*> [#uses=0]
|
||||
|
||||
define signext i8 @foo(i8 signext %_si1, i8 signext %_si2) nounwind readnone {
|
||||
entry:
|
||||
; CHECK: foo:
|
||||
; CHECK: call #__mulqi3
|
||||
%mul = mul i8 %_si2, %_si1 ; <i8> [#uses=1]
|
||||
ret i8 %mul
|
||||
}
|
||||
|
||||
define void @uint81(i16* nocapture %p_32) nounwind {
|
||||
entry:
|
||||
%call = tail call i16 @bar(i8* bitcast (i8 (i8, i8)* @foo to i8*)) nounwind ; <i16> [#uses=0]
|
||||
ret void
|
||||
}
|
||||
|
||||
declare i16 @bar(i8*)
|
Loading…
Reference in New Issue
Block a user