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 "SparcV8InstrInfo_F2.td"
32 include "SparcV8InstrInfo_F3.td"
34 //===----------------------------------------------------------------------===//
36 //===----------------------------------------------------------------------===//
38 // Pseudo instructions.
42 def ADJCALLSTACKDOWN : InstV8 {
43 let Name = "ADJCALLSTACKDOWN";
45 def ADJCALLSTACKUP : InstV8 {
46 let Name = "ADJCALLSTACKUP";
49 // Section A.3 - Synthetic Instructions, p. 85
50 // special cases of JMPL:
51 let isReturn = 1, isTerminator = 1, simm13 = 8 in
52 def RET : F3_2<2, 0b111000, "ret">;
53 let isReturn = 1, isTerminator = 1, simm13 = 8 in
54 def RETL: F3_2<2, 0b111000, "retl">;
55 // CMP is a special case of SUBCC where destination is ignored, by setting it to
56 // %g0 (hardwired zero).
57 // FIXME: should keep track of the fact that it defs the integer condition codes
59 def CMPri: F3_2<2, 0b010100, "cmp">;
61 // Section B.1 - Load Integer Instructions, p. 90
62 def LDSBmr: F3_2<3, 0b001001, "ldsb">;
63 def LDSHmr: F3_2<3, 0b001010, "ldsh">;
64 def LDUBmr: F3_2<3, 0b000001, "ldub">;
65 def LDUHmr: F3_2<3, 0b000010, "lduh">;
66 def LDmr : F3_2<3, 0b000000, "ld">;
67 def LDDmr : F3_2<3, 0b000011, "ldd">;
69 // Section B.4 - Store Integer Instructions, p. 95
70 def STBrm : F3_2<3, 0b000101, "stb">;
71 def STHrm : F3_2<3, 0b000110, "sth">;
72 def STrm : F3_2<3, 0b000100, "st">;
73 def STDrm : F3_2<3, 0b000111, "std">;
75 // Section B.9 - SETHI Instruction, p. 104
76 def SETHIi: F2_1<0b100, "sethi">;
78 // Section B.10 - NOP Instruction, p. 105
79 // (It's a special case of SETHI)
80 let rd = 0, imm = 0 in
81 def NOP : F2_1<0b100, "nop">;
83 // Section B.11 - Logical Instructions, p. 106
84 def ANDrr : F3_1<2, 0b000001, "and">;
85 def ANDri : F3_2<2, 0b000001, "and">;
86 def ORrr : F3_1<2, 0b000010, "or">;
87 def ORri : F3_2<2, 0b000010, "or">;
88 def XORrr : F3_1<2, 0b000011, "xor">;
89 def XORri : F3_2<2, 0b000011, "xor">;
91 // Section B.12 - Shift Instructions, p. 107
92 def SLLrr : F3_1<2, 0b100101, "sll">;
93 def SLLri : F3_2<2, 0b100101, "sll">;
94 def SRLrr : F3_1<2, 0b100110, "srl">;
95 def SRLri : F3_2<2, 0b100110, "srl">;
96 def SRArr : F3_1<2, 0b100111, "sra">;
97 def SRAri : F3_2<2, 0b100111, "sra">;
99 // Section B.13 - Add Instructions, p. 108
100 def ADDrr : F3_1<2, 0b000000, "add">;
101 def ADDri : F3_2<2, 0b000000, "add">;
103 // Section B.15 - Subtract Instructions, p. 110
104 def SUBrr : F3_1<2, 0b000100, "sub">;
105 def SUBCCrr : F3_1<2, 0b010100, "subcc">;
106 def SUBCCri : F3_2<2, 0b010100, "subcc">;
108 // Section B.18 - Multiply Instructions, p. 113
109 def UMULrr : F3_1<2, 0b001010, "umul">;
110 def SMULrr : F3_1<2, 0b001011, "smul">;
112 // Section B.19 - Divide Instructions, p. 115
113 def UDIVrr : F3_1<2, 0b001110, "udiv">;
114 def UDIVri : F3_2<2, 0b001110, "udiv">;
115 def SDIVrr : F3_1<2, 0b001111, "sdiv">;
116 def SDIVri : F3_2<2, 0b001111, "sdiv">;
117 def UDIVCCrr : F3_1<2, 0b011110, "udivcc">;
118 def UDIVCCri : F3_2<2, 0b011110, "udivcc">;
119 def SDIVCCrr : F3_1<2, 0b011111, "sdivcc">;
120 def SDIVCCri : F3_2<2, 0b011111, "sdivcc">;
122 // Section B.20 - SAVE and RESTORE, p. 117
123 def SAVErr : F3_1<2, 0b111100, "save">; // save r, r, r
124 def SAVEri : F3_2<2, 0b111100, "save">; // save r, i, r
125 def RESTORErr : F3_1<2, 0b111101, "restore">; // restore r, r, r
126 def RESTOREri : F3_2<2, 0b111101, "restore">; // restore r, i, r
128 // Section B.21 - Branch on Integer Condition Codes Instructions, p. 119
130 // conditional branch class:
131 class BranchV8<bits<4> cc, string nm> : F2_2<cc, 0b010, nm> {
133 let isTerminator = 1;
135 def BA : BranchV8<0b1000, "ba">;
136 def BN : BranchV8<0b0000, "bn">;
137 def BNE : BranchV8<0b1001, "bne">;
138 def BE : BranchV8<0b0001, "be">;
139 def BG : BranchV8<0b1010, "bg">;
140 def BLE : BranchV8<0b0010, "ble">;
141 def BGE : BranchV8<0b1011, "bge">;
142 def BL : BranchV8<0b0011, "bl">;
143 def BGU : BranchV8<0b1100, "bgu">;
144 def BLEU : BranchV8<0b0100, "bleu">;
145 def BCC : BranchV8<0b1101, "bcc">;
146 def BCS : BranchV8<0b0101, "bcs">;
148 // Section B.24 - Call and Link Instruction, p. 125
149 // This is the only Format 1 instruction
153 let Inst{29-0} = disp;
158 // Section B.25 - Jump and Link, p. 126
159 // FIXME: are they to be used as branches, calls, or returns? (not used now)
160 def JMPLrr : F3_1<2, 0b111000, "jmpl">; // jmpl [rs1+rs2], rd
161 def JMPLri : F3_2<2, 0b111000, "jmpl">; // jmpl [rs1+imm], rd
163 // Section B.29 - Write State Register Instructions
164 def WRrr : F3_1<2, 0b110000, "wr">; // wr rs1, rs2, rd
165 def WRri : F3_2<2, 0b110000, "wr">; // wr rs1, imm, rd