Skip to content

Commit c6daa4f

Browse files
asbDisasm
authored andcommitted
[RISCV][NFC] Change naming scheme for RISC-V specific DAG nodes
Previously we had names like 'Call' or 'Tail'. This potentially clashes with the naming scheme used elsewhere in RISCVInstrInfo.td. Many other backends would use names like AArch64call or PPCtail. I prefer the SystemZ approach, which uses prefixed all-lowercase names. This matches the naming scheme used for target-independent SelectionDAG nodes. llvm-svn: 351823
1 parent 421a6bc commit c6daa4f

File tree

1 file changed

+50
-43
lines changed

1 file changed

+50
-43
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,41 @@ include "RISCVInstrFormats.td"
1717
// RISC-V specific DAG Nodes.
1818
//===----------------------------------------------------------------------===//
1919

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]>;
5055

5156
//===----------------------------------------------------------------------===//
5257
// Operand and SDNode transformation definitions.
@@ -746,7 +751,7 @@ class SelectCC_rrirr<RegisterClass valty, RegisterClass cmpty>
746751
: Pseudo<(outs valty:$dst),
747752
(ins cmpty:$lhs, cmpty:$rhs, ixlenimm:$imm,
748753
valty:$truev, valty:$falsev),
749-
[(set valty:$dst, (SelectCC cmpty:$lhs, cmpty:$rhs,
754+
[(set valty:$dst, (riscv_selectcc cmpty:$lhs, cmpty:$rhs,
750755
(XLenVT imm:$imm), valty:$truev, valty:$falsev))]>;
751756

752757
def Select_GPR_Using_CC_GPR : SelectCC_rrirr<GPR, GPR>;
@@ -802,22 +807,23 @@ def : Pat<(brind (add GPR:$rs1, simm12:$imm12)),
802807
// Define isCodeGenOnly = 0 to support parsing assembly "call" instruction.
803808
let isCall = 1, Defs = [X1], isCodeGenOnly = 0 in
804809
def PseudoCALL : Pseudo<(outs), (ins bare_symbol:$func),
805-
[(Call tglobaladdr:$func)]> {
810+
[(riscv_call tglobaladdr:$func)]> {
806811
let AsmString = "call\t$func";
807812
}
808813

809-
def : Pat<(Call texternalsym:$func), (PseudoCALL texternalsym:$func)>;
814+
def : Pat<(riscv_call texternalsym:$func), (PseudoCALL texternalsym:$func)>;
810815

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)>;
814819

815820
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)]>,
817823
PseudoInstExpansion<(JALR X1, GPR:$rs1, 0)>;
818824

819825
let isBarrier = 1, isReturn = 1, isTerminator = 1 in
820-
def PseudoRET : Pseudo<(outs), (ins), [(RetFlag)]>,
826+
def PseudoRET : Pseudo<(outs), (ins), [(riscv_ret_flag)]>,
821827
PseudoInstExpansion<(JALR X0, X1, 0)>;
822828

823829
// PseudoTAIL is a pseudo instruction similar to PseudoCALL and will eventually
@@ -830,12 +836,13 @@ def PseudoTAIL : Pseudo<(outs), (ins bare_symbol:$dst), []> {
830836
}
831837

832838
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)]>,
834841
PseudoInstExpansion<(JALR X0, GPR:$rs1, 0)>;
835842

836-
def : Pat<(Tail (iPTR tglobaladdr:$dst)),
843+
def : Pat<(riscv_tail (iPTR tglobaladdr:$dst)),
837844
(PseudoTAIL texternalsym:$dst)>;
838-
def : Pat<(Tail (iPTR texternalsym:$dst)),
845+
def : Pat<(riscv_tail (iPTR texternalsym:$dst)),
839846
(PseudoTAIL texternalsym:$dst)>;
840847

841848
let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isCodeGenOnly = 0,
@@ -906,9 +913,9 @@ def : Pat<(atomic_fence (XLenVT 7), (imm)), (FENCE 0b11, 0b11)>;
906913
// Pessimistically assume the stack pointer will be clobbered
907914
let Defs = [X2], Uses = [X2] in {
908915
def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
909-
[(CallSeqStart timm:$amt1, timm:$amt2)]>;
916+
[(callseq_start timm:$amt1, timm:$amt2)]>;
910917
def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
911-
[(CallSeqEnd timm:$amt1, timm:$amt2)]>;
918+
[(callseq_end timm:$amt1, timm:$amt2)]>;
912919
} // Defs = [X2], Uses = [X2]
913920

914921
/// RV64 patterns

0 commit comments

Comments
 (0)