@@ -38,14 +38,6 @@ def SDT_RISCVSelectCC : SDTypeProfile<1, 5, [SDTCisSameAs<1, 2>,
3838def SDT_RISCVBrCC : SDTypeProfile<0, 4, [SDTCisSameAs<0, 1>,
3939 SDTCisVT<2, OtherVT>,
4040 SDTCisVT<3, OtherVT>]>;
41- def SDT_RISCVReadCSR : SDTypeProfile<1, 1, [SDTCisInt<0>, SDTCisInt<1>]>;
42- def SDT_RISCVWriteCSR : SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisInt<1>]>;
43- def SDT_RISCVSwapCSR : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisInt<1>,
44- SDTCisInt<2>]>;
45- def SDT_RISCVReadCounterWide : SDTypeProfile<2, 2, [SDTCisVT<0, i32>,
46- SDTCisVT<1, i32>,
47- SDTCisInt<2>,
48- SDTCisInt<3>]>;
4941def SDT_RISCVIntUnaryOpW : SDTypeProfile<1, 1, [
5042 SDTCisSameAs<0, 1>, SDTCisVT<0, i64>
5143]>;
@@ -62,13 +54,21 @@ def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_CallSeqStart,
6254def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_CallSeqEnd,
6355 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
6456
65- // Target-dependent nodes.
6657def riscv_call : RVSDNode<"CALL", SDT_RISCVCall,
6758 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
6859 SDNPVariadic]>;
60+ def riscv_tail : RVSDNode<"TAIL", SDT_RISCVCall,
61+ [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
62+ SDNPVariadic]>;
63+
64+ // Software guarded calls for large code model
6965def riscv_sw_guarded_call : RVSDNode<"SW_GUARDED_CALL", SDT_RISCVCall,
7066 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
7167 SDNPVariadic]>;
68+ def riscv_sw_guarded_tail : RVSDNode<"SW_GUARDED_TAIL", SDT_RISCVCall,
69+ [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
70+ SDNPVariadic]>;
71+
7272def riscv_ret_glue : RVSDNode<"RET_GLUE", SDTNone,
7373 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
7474def riscv_sret_glue : RVSDNode<"SRET_GLUE", SDTNone,
@@ -77,40 +77,78 @@ def riscv_mret_glue : RVSDNode<"MRET_GLUE", SDTNone,
7777 [SDNPHasChain, SDNPOptInGlue]>;
7878def riscv_mileaveret_glue : RVSDNode<"QC_C_MILEAVERET_GLUE", SDTNone,
7979 [SDNPHasChain, SDNPOptInGlue]>;
80+
81+ // Select with condition operator - This selects between a true value and
82+ // a false value (ops #3 and #4) based on the boolean result of comparing
83+ // the lhs and rhs (ops #0 and #1) of a conditional expression with the
84+ // condition code in op #2, a XLenVT constant from the ISD::CondCode enum.
85+ // The lhs and rhs are XLenVT integers. The true and false values can be
86+ // integer or floating point.
8087def riscv_selectcc : RVSDNode<"SELECT_CC", SDT_RISCVSelectCC>;
8188def riscv_brcc : RVSDNode<"BR_CC", SDT_RISCVBrCC,
8289 [SDNPHasChain]>;
83- def riscv_tail : RVSDNode<"TAIL", SDT_RISCVCall,
84- [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
85- SDNPVariadic]>;
86- def riscv_sw_guarded_tail : RVSDNode<"SW_GUARDED_TAIL", SDT_RISCVCall,
87- [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
88- SDNPVariadic]>;
90+
91+ // Software guarded BRIND node. Operand is the target address.
8992def riscv_sw_guarded_brind : RVSDNode<"SW_GUARDED_BRIND",
9093 SDTBrind, [SDNPHasChain]>;
94+
95+ // RV64I shifts, directly matching the semantics of the named RISC-V
96+ // instructions.
9197def riscv_sllw : RVSDNode<"SLLW", SDT_RISCVIntBinOpW>;
9298def riscv_sraw : RVSDNode<"SRAW", SDT_RISCVIntBinOpW>;
9399def riscv_srlw : RVSDNode<"SRLW", SDT_RISCVIntBinOpW>;
94- def riscv_read_csr : RVSDNode<"READ_CSR", SDT_RISCVReadCSR,
100+
101+ // Reads value of CSR. The first operand is the address of the required CSR.
102+ // The result is the read value.
103+ def riscv_read_csr : RVSDNode<"READ_CSR",
104+ SDTypeProfile<1, 1, [SDTCisInt<0>,
105+ SDTCisInt<1>]>,
95106 [SDNPHasChain]>;
96- def riscv_write_csr : RVSDNode<"WRITE_CSR", SDT_RISCVWriteCSR,
107+ // Write value to CSR. The first operand is the address of the required CSR,
108+ // the second is the value to write.
109+ def riscv_write_csr : RVSDNode<"WRITE_CSR",
110+ SDTypeProfile<0, 2, [SDTCisInt<0>,
111+ SDTCisInt<1>]>,
97112 [SDNPHasChain]>;
98- def riscv_swap_csr : RVSDNode<"SWAP_CSR", SDT_RISCVSwapCSR,
113+
114+ // Read and write value of CSR. The first operand is the address of the
115+ // required CSR, the second is the value to write, and the result is the
116+ // read value (before modification).
117+ def riscv_swap_csr : RVSDNode<"SWAP_CSR",
118+ SDTypeProfile<1, 2, [SDTCisInt<0>,
119+ SDTCisInt<1>,
120+ SDTCisInt<2>]>,
99121 [SDNPHasChain]>;
100122
123+ // A read of the 64-bit counter CSR on a 32-bit target (returns (Lo, Hi)).
124+ // It takes a chain operand and another two target constant operands (the
125+ // CSR numbers of the low and high parts of the counter).
101126def riscv_read_counter_wide : RVSDNode<"READ_COUNTER_WIDE",
102- SDT_RISCVReadCounterWide,
127+ SDTypeProfile<2, 2, [SDTCisVT<0, i32>,
128+ SDTCisVT<1, i32>,
129+ SDTCisInt<2>,
130+ SDTCisInt<3>]>,
103131 [SDNPHasChain, SDNPSideEffect]>;
104132
133+ // Add the Lo 12 bits from an address. Selected to ADDI.
105134def riscv_add_lo : RVSDNode<"ADD_LO", SDTIntBinOp>;
135+
136+ // Get the Hi 20 bits from an address. Selected to LUI.
106137def riscv_hi : RVSDNode<"HI", SDTIntUnaryOp>;
138+
139+ // Represents an AUIPC+ADDI pair. Selected to PseudoLLA.
107140def riscv_lla : RVSDNode<"LLA", SDTIntUnaryOp>;
141+
142+ // Selected as PseudoAddTPRel. Used to emit a TP-relative relocation.
108143def riscv_add_tprel : RVSDNode<"ADD_TPREL",
109144 SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>,
110145 SDTCisSameAs<0, 2>,
111146 SDTCisSameAs<0, 3>,
112147 SDTCisInt<0>]>>;
113148
149+ // To avoid stack clash, allocation is performed by block and each block is
150+ // probed.
151+ // FIXME: The Type Profile here is incorrect.
114152def riscv_probed_alloca : RVSDNode<"PROBED_ALLOCA",
115153 SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>,
116154 SDTCisVT<0, i32>]>,
0 commit comments