@@ -16,36 +16,41 @@ include "RISCVInstrFormats.td"
16
16
// RISC-V specific DAG Nodes.
17
17
//===----------------------------------------------------------------------===//
18
18
19
- def SDT_RISCVCall : SDTypeProfile<0, -1, [SDTCisVT<0, XLenVT>]>;
20
- def SDT_RISCVCallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>,
21
- SDTCisVT<1, i32>]>;
22
- def SDT_RISCVCallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
23
- SDTCisVT<1, i32>]>;
24
- def SDT_RISCVSelectCC : SDTypeProfile<1, 5, [SDTCisSameAs<1, 2>,
25
- SDTCisSameAs<0, 4>,
26
- SDTCisSameAs<4, 5>]>;
27
-
28
-
29
- def Call : SDNode<"RISCVISD::CALL", SDT_RISCVCall,
30
- [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
31
- SDNPVariadic]>;
32
- def CallSeqStart : SDNode<"ISD::CALLSEQ_START", SDT_RISCVCallSeqStart,
33
- [SDNPHasChain, SDNPOutGlue]>;
34
- def CallSeqEnd : SDNode<"ISD::CALLSEQ_END", SDT_RISCVCallSeqEnd,
35
- [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
36
- def RetFlag : SDNode<"RISCVISD::RET_FLAG", SDTNone,
37
- [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
38
- def URetFlag : SDNode<"RISCVISD::URET_FLAG", SDTNone,
39
- [SDNPHasChain, SDNPOptInGlue]>;
40
- def SRetFlag : SDNode<"RISCVISD::SRET_FLAG", SDTNone,
41
- [SDNPHasChain, SDNPOptInGlue]>;
42
- def MRetFlag : SDNode<"RISCVISD::MRET_FLAG", SDTNone,
43
- [SDNPHasChain, SDNPOptInGlue]>;
44
- def SelectCC : SDNode<"RISCVISD::SELECT_CC", SDT_RISCVSelectCC,
45
- [SDNPInGlue]>;
46
- def Tail : SDNode<"RISCVISD::TAIL", SDT_RISCVCall,
47
- [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
48
- SDNPVariadic]>;
19
+ // Target-independent type requirements, but with target-specific formats.
20
+ def SDT_CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>,
21
+ SDTCisVT<1, i32>]>;
22
+ def SDT_CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
23
+ SDTCisVT<1, i32>]>;
24
+
25
+ // Target-dependent type requirements.
26
+ def SDT_RISCVCall : SDTypeProfile<0, -1, [SDTCisVT<0, XLenVT>]>;
27
+ def SDT_RISCVSelectCC : SDTypeProfile<1, 5, [SDTCisSameAs<1, 2>,
28
+ SDTCisSameAs<0, 4>,
29
+ SDTCisSameAs<4, 5>]>;
30
+
31
+ // Target-independent nodes, but with target-specific formats.
32
+ def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_CallSeqStart,
33
+ [SDNPHasChain, SDNPOutGlue]>;
34
+ def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_CallSeqEnd,
35
+ [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
36
+
37
+ // Target-dependent nodes.
38
+ def riscv_call : SDNode<"RISCVISD::CALL", SDT_RISCVCall,
39
+ [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
40
+ SDNPVariadic]>;
41
+ def riscv_ret_flag : SDNode<"RISCVISD::RET_FLAG", SDTNone,
42
+ [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
43
+ def riscv_uret_flag : SDNode<"RISCVISD::URET_FLAG", SDTNone,
44
+ [SDNPHasChain, SDNPOptInGlue]>;
45
+ def riscv_sret_flag : SDNode<"RISCVISD::SRET_FLAG", SDTNone,
46
+ [SDNPHasChain, SDNPOptInGlue]>;
47
+ def riscv_mret_flag : SDNode<"RISCVISD::MRET_FLAG", SDTNone,
48
+ [SDNPHasChain, SDNPOptInGlue]>;
49
+ def riscv_selectcc : SDNode<"RISCVISD::SELECT_CC", SDT_RISCVSelectCC,
50
+ [SDNPInGlue]>;
51
+ def riscv_tail : SDNode<"RISCVISD::TAIL", SDT_RISCVCall,
52
+ [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
53
+ SDNPVariadic]>;
49
54
50
55
//===----------------------------------------------------------------------===//
51
56
// Operand and SDNode transformation definitions.
@@ -745,7 +750,7 @@ class SelectCC_rrirr<RegisterClass valty, RegisterClass cmpty>
745
750
: Pseudo<(outs valty:$dst),
746
751
(ins cmpty:$lhs, cmpty:$rhs, ixlenimm:$imm,
747
752
valty:$truev, valty:$falsev),
748
- [(set valty:$dst, (SelectCC cmpty:$lhs, cmpty:$rhs,
753
+ [(set valty:$dst, (riscv_selectcc cmpty:$lhs, cmpty:$rhs,
749
754
(XLenVT imm:$imm), valty:$truev, valty:$falsev))]>;
750
755
751
756
def Select_GPR_Using_CC_GPR : SelectCC_rrirr<GPR, GPR>;
@@ -801,22 +806,23 @@ def : Pat<(brind (add GPR:$rs1, simm12:$imm12)),
801
806
// Define isCodeGenOnly = 0 to support parsing assembly "call" instruction.
802
807
let isCall = 1, Defs = [X1], isCodeGenOnly = 0 in
803
808
def PseudoCALL : Pseudo<(outs), (ins bare_symbol:$func),
804
- [(Call tglobaladdr:$func)]> {
809
+ [(riscv_call tglobaladdr:$func)]> {
805
810
let AsmString = "call\t$func";
806
811
}
807
812
808
- def : Pat<(Call texternalsym:$func), (PseudoCALL texternalsym:$func)>;
813
+ def : Pat<(riscv_call texternalsym:$func), (PseudoCALL texternalsym:$func)>;
809
814
810
- def : Pat<(URetFlag ), (URET X0, X0)>;
811
- def : Pat<(SRetFlag ), (SRET X0, X0)>;
812
- def : Pat<(MRetFlag ), (MRET X0, X0)>;
815
+ def : Pat<(riscv_uret_flag ), (URET X0, X0)>;
816
+ def : Pat<(riscv_sret_flag ), (SRET X0, X0)>;
817
+ def : Pat<(riscv_mret_flag ), (MRET X0, X0)>;
813
818
814
819
let isCall = 1, Defs = [X1] in
815
- def PseudoCALLIndirect : Pseudo<(outs), (ins GPR:$rs1), [(Call GPR:$rs1)]>,
820
+ def PseudoCALLIndirect : Pseudo<(outs), (ins GPR:$rs1),
821
+ [(riscv_call GPR:$rs1)]>,
816
822
PseudoInstExpansion<(JALR X1, GPR:$rs1, 0)>;
817
823
818
824
let isBarrier = 1, isReturn = 1, isTerminator = 1 in
819
- def PseudoRET : Pseudo<(outs), (ins), [(RetFlag )]>,
825
+ def PseudoRET : Pseudo<(outs), (ins), [(riscv_ret_flag )]>,
820
826
PseudoInstExpansion<(JALR X0, X1, 0)>;
821
827
822
828
// PseudoTAIL is a pseudo instruction similar to PseudoCALL and will eventually
@@ -829,12 +835,13 @@ def PseudoTAIL : Pseudo<(outs), (ins bare_symbol:$dst), []> {
829
835
}
830
836
831
837
let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [X2] in
832
- def PseudoTAILIndirect : Pseudo<(outs), (ins GPRTC:$rs1), [(Tail GPRTC:$rs1)]>,
838
+ def PseudoTAILIndirect : Pseudo<(outs), (ins GPRTC:$rs1),
839
+ [(riscv_tail GPRTC:$rs1)]>,
833
840
PseudoInstExpansion<(JALR X0, GPR:$rs1, 0)>;
834
841
835
- def : Pat<(Tail (iPTR tglobaladdr:$dst)),
842
+ def : Pat<(riscv_tail (iPTR tglobaladdr:$dst)),
836
843
(PseudoTAIL texternalsym:$dst)>;
837
- def : Pat<(Tail (iPTR texternalsym:$dst)),
844
+ def : Pat<(riscv_tail (iPTR texternalsym:$dst)),
838
845
(PseudoTAIL texternalsym:$dst)>;
839
846
840
847
let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isCodeGenOnly = 0,
@@ -905,9 +912,9 @@ def : Pat<(atomic_fence (XLenVT 7), (imm)), (FENCE 0b11, 0b11)>;
905
912
// Pessimistically assume the stack pointer will be clobbered
906
913
let Defs = [X2], Uses = [X2] in {
907
914
def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
908
- [(CallSeqStart timm:$amt1, timm:$amt2)]>;
915
+ [(callseq_start timm:$amt1, timm:$amt2)]>;
909
916
def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
910
- [(CallSeqEnd timm:$amt1, timm:$amt2)]>;
917
+ [(callseq_end timm:$amt1, timm:$amt2)]>;
911
918
} // Defs = [X2], Uses = [X2]
912
919
913
920
/// RV64 patterns
0 commit comments