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