Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit f315bf0

Browse files
committed
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351823 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 39a7204 commit f315bf0

File tree

1 file changed

+50
-43
lines changed

1 file changed

+50
-43
lines changed

lib/Target/RISCV/RISCVInstrInfo.td

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

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

5055
//===----------------------------------------------------------------------===//
5156
// Operand and SDNode transformation definitions.
@@ -745,7 +750,7 @@ class SelectCC_rrirr<RegisterClass valty, RegisterClass cmpty>
745750
: Pseudo<(outs valty:$dst),
746751
(ins cmpty:$lhs, cmpty:$rhs, ixlenimm:$imm,
747752
valty:$truev, valty:$falsev),
748-
[(set valty:$dst, (SelectCC cmpty:$lhs, cmpty:$rhs,
753+
[(set valty:$dst, (riscv_selectcc cmpty:$lhs, cmpty:$rhs,
749754
(XLenVT imm:$imm), valty:$truev, valty:$falsev))]>;
750755

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

808-
def : Pat<(Call texternalsym:$func), (PseudoCALL texternalsym:$func)>;
813+
def : Pat<(riscv_call texternalsym:$func), (PseudoCALL texternalsym:$func)>;
809814

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

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

818824
let isBarrier = 1, isReturn = 1, isTerminator = 1 in
819-
def PseudoRET : Pseudo<(outs), (ins), [(RetFlag)]>,
825+
def PseudoRET : Pseudo<(outs), (ins), [(riscv_ret_flag)]>,
820826
PseudoInstExpansion<(JALR X0, X1, 0)>;
821827

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

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

835-
def : Pat<(Tail (iPTR tglobaladdr:$dst)),
842+
def : Pat<(riscv_tail (iPTR tglobaladdr:$dst)),
836843
(PseudoTAIL texternalsym:$dst)>;
837-
def : Pat<(Tail (iPTR texternalsym:$dst)),
844+
def : Pat<(riscv_tail (iPTR texternalsym:$dst)),
838845
(PseudoTAIL texternalsym:$dst)>;
839846

840847
let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isCodeGenOnly = 0,
@@ -905,9 +912,9 @@ def : Pat<(atomic_fence (XLenVT 7), (imm)), (FENCE 0b11, 0b11)>;
905912
// Pessimistically assume the stack pointer will be clobbered
906913
let Defs = [X2], Uses = [X2] in {
907914
def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
908-
[(CallSeqStart timm:$amt1, timm:$amt2)]>;
915+
[(callseq_start timm:$amt1, timm:$amt2)]>;
909916
def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
910-
[(CallSeqEnd timm:$amt1, timm:$amt2)]>;
917+
[(callseq_end timm:$amt1, timm:$amt2)]>;
911918
} // Defs = [X2], Uses = [X2]
912919

913920
/// RV64 patterns

0 commit comments

Comments
 (0)