1 //===- SparcV8Instrs.td - Target Description for SparcV8 Target -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the SparcV8 instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // Instruction format superclass
16 //===----------------------------------------------------------------------===//
18 class InstV8 : Instruction { // SparcV8 instruction baseline
24 let Inst{31-30} = op; // Top two bits are the 'op' field
26 // Bit attributes specific to SparcV8 instructions
27 bit isPasi = 0; // Does this instruction affect an alternate addr space?
28 bit isPrivileged = 0; // Is this a privileged instruction?
31 include "SparcV8InstrFormats.td"
33 //===----------------------------------------------------------------------===//
35 //===----------------------------------------------------------------------===//
37 // Pseudo instructions.
38 class PseudoInstV8<string nm> : InstV8 {
41 def PHI : PseudoInstV8<"PHI">;
42 def ADJCALLSTACKDOWN : PseudoInstV8<"ADJCALLSTACKDOWN">;
43 def ADJCALLSTACKUP : PseudoInstV8<"ADJCALLSTACKUP">;
44 def IMPLICIT_USE : PseudoInstV8<"IMPLICIT_USE">;
45 def IMPLICIT_DEF : PseudoInstV8<"IMPLICIT_DEF">;
46 def FpMOVD : PseudoInstV8<"FpMOVD">; // pseudo 64-bit double move
48 // Section A.3 - Synthetic Instructions, p. 85
49 // special cases of JMPL:
50 let isReturn = 1, isTerminator = 1, hasDelaySlot = 1 in {
51 let rd = I7.Num, rs1 = G0.Num, simm13 = 8 in
52 def RET : F3_2<2, 0b111000, "ret">;
53 let rd = O7.Num, rs1 = G0.Num, simm13 = 8 in
54 def RETL: F3_2<2, 0b111000, "retl">;
56 // CMP is a special case of SUBCC where destination is ignored, by setting it to
57 // %g0 (hardwired zero).
58 // FIXME: should keep track of the fact that it defs the integer condition codes
60 def CMPri: F3_2<2, 0b010100, "cmp">;
62 // Section B.1 - Load Integer Instructions, p. 90
63 def LDSB: F3_2<3, 0b001001, "ldsb">;
64 def LDSH: F3_2<3, 0b001010, "ldsh">;
65 def LDUB: F3_2<3, 0b000001, "ldub">;
66 def LDUH: F3_2<3, 0b000010, "lduh">;
67 def LD : F3_2<3, 0b000000, "ld">;
68 def LDD : F3_2<3, 0b000011, "ldd">;
70 // Section B.2 - Load Floating-point Instructions, p. 92
71 def LDFrr : F3_1<3, 0b100000, "ld">;
72 def LDFri : F3_2<3, 0b100000, "ld">;
73 def LDDFrr : F3_1<3, 0b100011, "ldd">;
74 def LDDFri : F3_2<3, 0b100011, "ldd">;
75 def LDFSRrr: F3_1<3, 0b100001, "ld">;
76 def LDFSRri: F3_2<3, 0b100001, "ld">;
78 // Section B.4 - Store Integer Instructions, p. 95
79 def STB : F3_2<3, 0b000101, "stb">;
80 def STH : F3_2<3, 0b000110, "sth">;
81 def ST : F3_2<3, 0b000100, "st">;
82 def STD : F3_2<3, 0b000111, "std">;
84 // Section B.5 - Store Floating-point Instructions, p. 97
85 def STFrr : F3_1<3, 0b100100, "st">;
86 def STFri : F3_2<3, 0b100100, "st">;
87 def STDFrr : F3_1<3, 0b100111, "std">;
88 def STDFri : F3_2<3, 0b100111, "std">;
89 def STFSRrr : F3_1<3, 0b100101, "st">;
90 def STFSRri : F3_2<3, 0b100101, "st">;
91 def STDFQrr : F3_1<3, 0b100110, "std">;
92 def STDFQri : F3_2<3, 0b100110, "std">;
94 // Section B.9 - SETHI Instruction, p. 104
95 def SETHIi: F2_1<0b100, "sethi">;
97 // Section B.10 - NOP Instruction, p. 105
98 // (It's a special case of SETHI)
99 let rd = 0, imm22 = 0 in
100 def NOP : F2_1<0b100, "nop">;
102 // Section B.11 - Logical Instructions, p. 106
103 def ANDrr : F3_1<2, 0b000001, "and">;
104 def ANDri : F3_2<2, 0b000001, "and">;
105 def ORrr : F3_1<2, 0b000010, "or">;
106 def ORri : F3_2<2, 0b000010, "or">;
107 def XORrr : F3_1<2, 0b000011, "xor">;
108 def XORri : F3_2<2, 0b000011, "xor">;
110 // Section B.12 - Shift Instructions, p. 107
111 def SLLrr : F3_1<2, 0b100101, "sll">;
112 def SLLri : F3_2<2, 0b100101, "sll">;
113 def SRLrr : F3_1<2, 0b100110, "srl">;
114 def SRLri : F3_2<2, 0b100110, "srl">;
115 def SRArr : F3_1<2, 0b100111, "sra">;
116 def SRAri : F3_2<2, 0b100111, "sra">;
118 // Section B.13 - Add Instructions, p. 108
119 def ADDrr : F3_1<2, 0b000000, "add">;
120 def ADDri : F3_2<2, 0b000000, "add">;
121 def ADDCCrr : F3_1<2, 0b010000, "addcc">;
122 def ADDCCri : F3_2<2, 0b010000, "addcc">;
123 def ADDXrr : F3_1<2, 0b001000, "addx">;
124 def ADDXri : F3_2<2, 0b001000, "addx">;
125 def ADDXCCrr: F3_1<2, 0b011000, "addxcc">;
126 def ADDXCCri: F3_2<2, 0b011000, "addxcc">;
128 // Section B.15 - Subtract Instructions, p. 110
129 def SUBrr : F3_1<2, 0b000100, "sub">;
130 def SUBri : F3_2<2, 0b000100, "sub">;
131 def SUBCCrr : F3_1<2, 0b010100, "subcc">;
132 def SUBCCri : F3_2<2, 0b010100, "subcc">;
133 def SUBXrr : F3_1<2, 0b001100, "subx">;
134 def SUBXri : F3_2<2, 0b001100, "subx">;
135 def SUBXCCrr: F3_1<2, 0b011100, "subxcc">;
136 def SUBXCCri: F3_2<2, 0b011100, "subxcc">;
138 // Section B.18 - Multiply Instructions, p. 113
139 def UMULrr : F3_1<2, 0b001010, "umul">;
140 def SMULrr : F3_1<2, 0b001011, "smul">;
142 // Section B.19 - Divide Instructions, p. 115
143 def UDIVrr : F3_1<2, 0b001110, "udiv">;
144 def UDIVri : F3_2<2, 0b001110, "udiv">;
145 def SDIVrr : F3_1<2, 0b001111, "sdiv">;
146 def SDIVri : F3_2<2, 0b001111, "sdiv">;
147 def UDIVCCrr : F3_1<2, 0b011110, "udivcc">;
148 def UDIVCCri : F3_2<2, 0b011110, "udivcc">;
149 def SDIVCCrr : F3_1<2, 0b011111, "sdivcc">;
150 def SDIVCCri : F3_2<2, 0b011111, "sdivcc">;
152 // Section B.20 - SAVE and RESTORE, p. 117
153 def SAVErr : F3_1<2, 0b111100, "save">; // save r, r, r
154 def SAVEri : F3_2<2, 0b111100, "save">; // save r, i, r
155 def RESTORErr : F3_1<2, 0b111101, "restore">; // restore r, r, r
156 def RESTOREri : F3_2<2, 0b111101, "restore">; // restore r, i, r
158 // Section B.21 - Branch on Integer Condition Codes Instructions, p. 119
160 // conditional branch class:
161 class BranchV8<bits<4> cc, string nm> : F2_2<cc, 0b010, nm> {
163 let isTerminator = 1;
164 let hasDelaySlot = 1;
168 def BA : BranchV8<0b1000, "ba">;
169 def BN : BranchV8<0b0000, "bn">;
170 def BNE : BranchV8<0b1001, "bne">;
171 def BE : BranchV8<0b0001, "be">;
172 def BG : BranchV8<0b1010, "bg">;
173 def BLE : BranchV8<0b0010, "ble">;
174 def BGE : BranchV8<0b1011, "bge">;
175 def BL : BranchV8<0b0011, "bl">;
176 def BGU : BranchV8<0b1100, "bgu">;
177 def BLEU : BranchV8<0b0100, "bleu">;
178 def BCC : BranchV8<0b1101, "bcc">;
179 def BCS : BranchV8<0b0101, "bcs">;
181 // Section B.22 - Branch on Floating-point Condition Codes Instructions, p. 121
183 // floating-point conditional branch class:
184 class FPBranchV8<bits<4> cc, string nm> : F2_2<cc, 0b110, nm> {
186 let isTerminator = 1;
187 let hasDelaySlot = 1;
190 def FBA : FPBranchV8<0b1000, "fba">;
191 def FBN : FPBranchV8<0b0000, "fbn">;
192 def FBU : FPBranchV8<0b0111, "fbu">;
193 def FBG : FPBranchV8<0b0110, "fbg">;
194 def FBUG : FPBranchV8<0b0101, "fbug">;
195 def FBL : FPBranchV8<0b0100, "fbl">;
196 def FBUL : FPBranchV8<0b0011, "fbul">;
197 def FBLG : FPBranchV8<0b0010, "fblg">;
198 def FBNE : FPBranchV8<0b0001, "fbne">;
199 def FBE : FPBranchV8<0b1001, "fbe">;
200 def FBUE : FPBranchV8<0b1010, "fbue">;
201 def FBGE : FPBranchV8<0b1011, "fbge">;
202 def FBUGE: FPBranchV8<0b1100, "fbuge">;
203 def FBLE : FPBranchV8<0b1101, "fble">;
204 def FBULE: FPBranchV8<0b1110, "fbule">;
205 def FBO : FPBranchV8<0b1111, "fbo">;
209 // Section B.24 - Call and Link Instruction, p. 125
210 // This is the only Format 1 instruction
211 let Uses = [O0, O1, O2, O3, O4, O5], hasDelaySlot = 1, isCall = 1 in {
213 let Defs = [O0, O1, O2, O3, O4, O5, O7, G1, G2, G3, G4, G5, G6, G7,
214 D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15] in
218 let Inst{29-0} = disp;
222 // indirect call (O7 is an EXPLICIT def in indirect calls, so it cannot also
223 // be an implicit def):
224 let Defs = [O0, O1, O2, O3, O4, O5, G1, G2, G3, G4, G5, G6, G7,
225 D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15] in
226 def JMPLrr : F3_1<2, 0b111000, "jmpl">; // jmpl [rs1+rs2], rd
229 // Section B.29 - Write State Register Instructions
230 def WRrr : F3_1<2, 0b110000, "wr">; // wr rs1, rs2, rd
231 def WRri : F3_2<2, 0b110000, "wr">; // wr rs1, imm, rd
233 // Convert Integer to Floating-point Instructions, p. 141
234 def FITOS : F3_3<2, 0b110100, 0b011000100, "fitos">;
235 def FITOD : F3_3<2, 0b110100, 0b011001000, "fitod">;
237 // Convert Floating-point to Integer Instructions, p. 142
238 def FSTOI : F3_3<2, 0b110100, 0b011010001, "fstoi">;
239 def FDTOI : F3_3<2, 0b110100, 0b011010010, "fdtoi">;
241 // Convert between Floating-point Formats Instructions, p. 143
242 def FSTOD : F3_3<2, 0b110100, 0b011001001, "fstod">;
243 def FDTOS : F3_3<2, 0b110100, 0b011000110, "fdtos">;
245 // Floating-point Move Instructions, p. 144
246 def FMOVS : F3_3<2, 0b110100, 0b000000001, "fmovs">;
247 def FNEGS : F3_3<2, 0b110100, 0b000000101, "fnegs">;
248 def FABSS : F3_3<2, 0b110100, 0b000001001, "fabss">;
250 // Floating-point Add and Subtract Instructions, p. 146
251 def FADDS : F3_3<2, 0b110100, 0b001000001, "fadds">;
252 def FADDD : F3_3<2, 0b110100, 0b001000010, "faddd">;
253 def FSUBS : F3_3<2, 0b110100, 0b001000101, "fsubs">;
254 def FSUBD : F3_3<2, 0b110100, 0b001000110, "fsubd">;
256 // Floating-point Multiply and Divide Instructions, p. 147
257 def FMULS : F3_3<2, 0b110100, 0b001001001, "fmuls">;
258 def FMULD : F3_3<2, 0b110100, 0b001001010, "fmuld">;
259 def FSMULD : F3_3<2, 0b110100, 0b001101001, "fsmuld">;
260 def FDIVS : F3_3<2, 0b110100, 0b001001101, "fdivs">;
261 def FDIVD : F3_3<2, 0b110100, 0b001001110, "fdivd">;
263 // Floating-point Compare Instructions, p. 148
264 // Note: the 2nd template arg is different for these guys.
265 // Note 2: the result of a FCMP is not available until the 2nd cycle
266 // after the instr is retired, but there is no interlock. This behavior
267 // is modelled as a delay slot.
268 let hasDelaySlot = 1 in {
269 def FCMPS : F3_3<2, 0b110101, 0b001010001, "fcmps">;
270 def FCMPD : F3_3<2, 0b110101, 0b001010010, "fcmpd">;
271 def FCMPES : F3_3<2, 0b110101, 0b001010101, "fcmpes">;
272 def FCMPED : F3_3<2, 0b110101, 0b001010110, "fcmped">;