Misha Brukman | e07c2aa | 2004-02-25 21:02:21 +0000 | [diff] [blame] | 1 | //===- SparcV8Instrs.td - Target Description for SparcV8 Target -----------===// |
Brian Gaeke | e785e53 | 2004-02-25 19:28:19 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 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. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Misha Brukman | e07c2aa | 2004-02-25 21:02:21 +0000 | [diff] [blame] | 10 | // This file describes the SparcV8 instructions in TableGen format. |
Brian Gaeke | e785e53 | 2004-02-25 19:28:19 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Misha Brukman | e07c2aa | 2004-02-25 21:02:21 +0000 | [diff] [blame] | 14 | //===----------------------------------------------------------------------===// |
Misha Brukman | 23e6c1f | 2004-02-26 00:37:12 +0000 | [diff] [blame] | 15 | // Instruction format superclass |
Misha Brukman | e07c2aa | 2004-02-25 21:02:21 +0000 | [diff] [blame] | 16 | //===----------------------------------------------------------------------===// |
| 17 | |
| 18 | class InstV8 : Instruction { // SparcV8 instruction baseline |
| 19 | field bits<32> Inst; |
| 20 | |
| 21 | let Namespace = "V8"; |
| 22 | |
| 23 | bits<2> op; |
| 24 | let Inst{31-30} = op; // Top two bits are the 'op' field |
| 25 | |
| 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? |
Brian Gaeke | e785e53 | 2004-02-25 19:28:19 +0000 | [diff] [blame] | 29 | } |
| 30 | |
Chris Lattner | a85d46e | 2004-02-28 19:45:39 +0000 | [diff] [blame] | 31 | include "SparcV8InstrInfo_F2.td" |
| 32 | include "SparcV8InstrInfo_F3.td" |
Brian Gaeke | e785e53 | 2004-02-25 19:28:19 +0000 | [diff] [blame] | 33 | |
Misha Brukman | 23e6c1f | 2004-02-26 00:37:12 +0000 | [diff] [blame] | 34 | //===----------------------------------------------------------------------===// |
| 35 | // Instructions |
| 36 | //===----------------------------------------------------------------------===// |
| 37 | |
Chris Lattner | 275f645 | 2004-02-28 19:37:18 +0000 | [diff] [blame] | 38 | // Pseudo instructions. |
| 39 | def PHI : InstV8 { |
| 40 | let Name = "PHI"; |
| 41 | } |
| 42 | def ADJCALLSTACKDOWN : InstV8 { |
| 43 | let Name = "ADJCALLSTACKDOWN"; |
| 44 | } |
| 45 | def ADJCALLSTACKUP : InstV8 { |
| 46 | let Name = "ADJCALLSTACKUP"; |
| 47 | } |
| 48 | |
Brian Gaeke | a8056fa | 2004-03-06 05:32:13 +0000 | [diff] [blame] | 49 | // Section A.3 - Synthetic Instructions, p. 85 |
Brian Gaeke | c3e9701 | 2004-05-08 04:21:32 +0000 | [diff] [blame] | 50 | // special cases of JMPL: |
Brian Gaeke | a8056fa | 2004-03-06 05:32:13 +0000 | [diff] [blame] | 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 |
Brian Gaeke | 8542e08 | 2004-04-02 20:53:37 +0000 | [diff] [blame] | 54 | def RETL: F3_2<2, 0b111000, "retl">; |
Brian Gaeke | c3e9701 | 2004-05-08 04:21:32 +0000 | [diff] [blame] | 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 |
| 58 | let rd = 0 in |
| 59 | def CMPri: F3_2<2, 0b010100, "cmp">; |
Brian Gaeke | 8542e08 | 2004-04-02 20:53:37 +0000 | [diff] [blame] | 60 | |
| 61 | // Section B.1 - Load Integer Instructions, p. 90 |
Brian Gaeke | e7f9e0b | 2004-06-24 07:36:59 +0000 | [diff] [blame] | 62 | def LDSB: F3_2<3, 0b001001, "ldsb">; |
| 63 | def LDSH: F3_2<3, 0b001010, "ldsh">; |
| 64 | def LDUB: F3_2<3, 0b000001, "ldub">; |
| 65 | def LDUH: F3_2<3, 0b000010, "lduh">; |
| 66 | def LD : F3_2<3, 0b000000, "ld">; |
| 67 | def LDD : F3_2<3, 0b000011, "ldd">; |
Brian Gaeke | 8542e08 | 2004-04-02 20:53:37 +0000 | [diff] [blame] | 68 | |
Brian Gaeke | 562d5b0 | 2004-06-18 05:19:27 +0000 | [diff] [blame] | 69 | // Section B.2 - Load Floating-point Instructions, p. 92 |
Brian Gaeke | e7f9e0b | 2004-06-24 07:36:59 +0000 | [diff] [blame] | 70 | def LDFrr : F3_1<3, 0b100000, "ld">; |
| 71 | def LDFri : F3_2<3, 0b100000, "ld">; |
| 72 | def LDDFrr : F3_1<3, 0b100011, "ldd">; |
| 73 | def LDDFri : F3_2<3, 0b100011, "ldd">; |
| 74 | def LDFSRrr: F3_1<3, 0b100001, "ld">; |
| 75 | def LDFSRri: F3_2<3, 0b100001, "ld">; |
Brian Gaeke | 562d5b0 | 2004-06-18 05:19:27 +0000 | [diff] [blame] | 76 | |
Brian Gaeke | 8542e08 | 2004-04-02 20:53:37 +0000 | [diff] [blame] | 77 | // Section B.4 - Store Integer Instructions, p. 95 |
Brian Gaeke | e7f9e0b | 2004-06-24 07:36:59 +0000 | [diff] [blame] | 78 | def STB : F3_2<3, 0b000101, "stb">; |
| 79 | def STH : F3_2<3, 0b000110, "sth">; |
| 80 | def ST : F3_2<3, 0b000100, "st">; |
| 81 | def STD : F3_2<3, 0b000111, "std">; |
| 82 | |
| 83 | // Section B.5 - Store Floating-point Instructions, p. 97 |
| 84 | def STFrr : F3_1<3, 0b100100, "st">; |
| 85 | def STFri : F3_2<3, 0b100100, "st">; |
| 86 | def STDFrr : F3_1<3, 0b100111, "std">; |
| 87 | def STDFri : F3_2<3, 0b100111, "std">; |
| 88 | def STFSRrr : F3_1<3, 0b100101, "st">; |
| 89 | def STFSRri : F3_2<3, 0b100101, "st">; |
| 90 | def STDFQrr : F3_1<3, 0b100110, "std">; |
| 91 | def STDFQri : F3_2<3, 0b100110, "std">; |
Misha Brukman | 23e6c1f | 2004-02-26 00:37:12 +0000 | [diff] [blame] | 92 | |
Brian Gaeke | 775158d | 2004-03-04 04:37:45 +0000 | [diff] [blame] | 93 | // Section B.9 - SETHI Instruction, p. 104 |
Brian Gaeke | e806173 | 2004-03-04 00:56:25 +0000 | [diff] [blame] | 94 | def SETHIi: F2_1<0b100, "sethi">; |
| 95 | |
Brian Gaeke | 8542e08 | 2004-04-02 20:53:37 +0000 | [diff] [blame] | 96 | // Section B.10 - NOP Instruction, p. 105 |
| 97 | // (It's a special case of SETHI) |
| 98 | let rd = 0, imm = 0 in |
| 99 | def NOP : F2_1<0b100, "nop">; |
| 100 | |
Brian Gaeke | bc1d27a | 2004-03-03 23:03:14 +0000 | [diff] [blame] | 101 | // Section B.11 - Logical Instructions, p. 106 |
Chris Lattner | 22ede70 | 2004-04-07 04:06:46 +0000 | [diff] [blame] | 102 | def ANDrr : F3_1<2, 0b000001, "and">; |
Brian Gaeke | bc1d27a | 2004-03-03 23:03:14 +0000 | [diff] [blame] | 103 | def ANDri : F3_2<2, 0b000001, "and">; |
| 104 | def ORrr : F3_1<2, 0b000010, "or">; |
Brian Gaeke | e806173 | 2004-03-04 00:56:25 +0000 | [diff] [blame] | 105 | def ORri : F3_2<2, 0b000010, "or">; |
Chris Lattner | 22ede70 | 2004-04-07 04:06:46 +0000 | [diff] [blame] | 106 | def XORrr : F3_1<2, 0b000011, "xor">; |
| 107 | def XORri : F3_2<2, 0b000011, "xor">; |
Brian Gaeke | bc1d27a | 2004-03-03 23:03:14 +0000 | [diff] [blame] | 108 | |
| 109 | // Section B.12 - Shift Instructions, p. 107 |
Chris Lattner | a562efc | 2004-04-07 04:26:57 +0000 | [diff] [blame] | 110 | def SLLrr : F3_1<2, 0b100101, "sll">; |
| 111 | def SLLri : F3_2<2, 0b100101, "sll">; |
| 112 | def SRLrr : F3_1<2, 0b100110, "srl">; |
| 113 | def SRLri : F3_2<2, 0b100110, "srl">; |
| 114 | def SRArr : F3_1<2, 0b100111, "sra">; |
| 115 | def SRAri : F3_2<2, 0b100111, "sra">; |
Brian Gaeke | bc1d27a | 2004-03-03 23:03:14 +0000 | [diff] [blame] | 116 | |
| 117 | // Section B.13 - Add Instructions, p. 108 |
| 118 | def ADDrr : F3_1<2, 0b000000, "add">; |
Brian Gaeke | 6b1d2fa | 2004-05-08 05:26:55 +0000 | [diff] [blame] | 119 | def ADDri : F3_2<2, 0b000000, "add">; |
Brian Gaeke | bc1d27a | 2004-03-03 23:03:14 +0000 | [diff] [blame] | 120 | |
Brian Gaeke | 775158d | 2004-03-04 04:37:45 +0000 | [diff] [blame] | 121 | // Section B.15 - Subtract Instructions, p. 110 |
Chris Lattner | 6179047 | 2004-04-07 05:04:01 +0000 | [diff] [blame] | 122 | def SUBrr : F3_1<2, 0b000100, "sub">; |
| 123 | def SUBCCrr : F3_1<2, 0b010100, "subcc">; |
Brian Gaeke | c3e9701 | 2004-05-08 04:21:32 +0000 | [diff] [blame] | 124 | def SUBCCri : F3_2<2, 0b010100, "subcc">; |
Brian Gaeke | 775158d | 2004-03-04 04:37:45 +0000 | [diff] [blame] | 125 | |
Brian Gaeke | 032f80f | 2004-03-16 22:37:13 +0000 | [diff] [blame] | 126 | // Section B.18 - Multiply Instructions, p. 113 |
| 127 | def UMULrr : F3_1<2, 0b001010, "umul">; |
| 128 | def SMULrr : F3_1<2, 0b001011, "smul">; |
| 129 | |
Brian Gaeke | e88c9dc | 2004-04-07 04:01:00 +0000 | [diff] [blame] | 130 | // Section B.19 - Divide Instructions, p. 115 |
Chris Lattner | 22ede70 | 2004-04-07 04:06:46 +0000 | [diff] [blame] | 131 | def UDIVrr : F3_1<2, 0b001110, "udiv">; |
| 132 | def UDIVri : F3_2<2, 0b001110, "udiv">; |
| 133 | def SDIVrr : F3_1<2, 0b001111, "sdiv">; |
| 134 | def SDIVri : F3_2<2, 0b001111, "sdiv">; |
| 135 | def UDIVCCrr : F3_1<2, 0b011110, "udivcc">; |
| 136 | def UDIVCCri : F3_2<2, 0b011110, "udivcc">; |
| 137 | def SDIVCCrr : F3_1<2, 0b011111, "sdivcc">; |
| 138 | def SDIVCCri : F3_2<2, 0b011111, "sdivcc">; |
Brian Gaeke | e88c9dc | 2004-04-07 04:01:00 +0000 | [diff] [blame] | 139 | |
Brian Gaeke | a8056fa | 2004-03-06 05:32:13 +0000 | [diff] [blame] | 140 | // Section B.20 - SAVE and RESTORE, p. 117 |
| 141 | def SAVErr : F3_1<2, 0b111100, "save">; // save r, r, r |
| 142 | def SAVEri : F3_2<2, 0b111100, "save">; // save r, i, r |
| 143 | def RESTORErr : F3_1<2, 0b111101, "restore">; // restore r, r, r |
| 144 | def RESTOREri : F3_2<2, 0b111101, "restore">; // restore r, i, r |
| 145 | |
Brian Gaeke | c3e9701 | 2004-05-08 04:21:32 +0000 | [diff] [blame] | 146 | // Section B.21 - Branch on Integer Condition Codes Instructions, p. 119 |
Brian Gaeke | 070bb4a | 2004-06-17 22:34:29 +0000 | [diff] [blame] | 147 | |
| 148 | // conditional branch class: |
| 149 | class BranchV8<bits<4> cc, string nm> : F2_2<cc, 0b010, nm> { |
| 150 | let isBranch = 1; |
| 151 | let isTerminator = 1; |
| 152 | } |
| 153 | def BA : BranchV8<0b1000, "ba">; |
| 154 | def BN : BranchV8<0b0000, "bn">; |
| 155 | def BNE : BranchV8<0b1001, "bne">; |
| 156 | def BE : BranchV8<0b0001, "be">; |
| 157 | def BG : BranchV8<0b1010, "bg">; |
| 158 | def BLE : BranchV8<0b0010, "ble">; |
| 159 | def BGE : BranchV8<0b1011, "bge">; |
| 160 | def BL : BranchV8<0b0011, "bl">; |
| 161 | def BGU : BranchV8<0b1100, "bgu">; |
| 162 | def BLEU : BranchV8<0b0100, "bleu">; |
| 163 | def BCC : BranchV8<0b1101, "bcc">; |
| 164 | def BCS : BranchV8<0b0101, "bcs">; |
Brian Gaeke | c3e9701 | 2004-05-08 04:21:32 +0000 | [diff] [blame] | 165 | |
Brian Gaeke | 8542e08 | 2004-04-02 20:53:37 +0000 | [diff] [blame] | 166 | // Section B.24 - Call and Link Instruction, p. 125 |
Brian Gaeke | a8056fa | 2004-03-06 05:32:13 +0000 | [diff] [blame] | 167 | // This is the only Format 1 instruction |
| 168 | def CALL : InstV8 { |
| 169 | bits<30> disp; |
| 170 | let op = 1; |
| 171 | let Inst{29-0} = disp; |
| 172 | let Name = "call"; |
| 173 | let isCall = 1; |
| 174 | } |
| 175 | |
Brian Gaeke | bc1d27a | 2004-03-03 23:03:14 +0000 | [diff] [blame] | 176 | // Section B.25 - Jump and Link, p. 126 |
Brian Gaeke | f89cc65 | 2004-06-18 06:28:10 +0000 | [diff] [blame] | 177 | let isCall = 1 in |
| 178 | def JMPLrr : F3_1<2, 0b111000, "jmpl">; // jmpl [rs1+rs2], rd |
Misha Brukman | 23e6c1f | 2004-02-26 00:37:12 +0000 | [diff] [blame] | 179 | |
Chris Lattner | 22ede70 | 2004-04-07 04:06:46 +0000 | [diff] [blame] | 180 | // Section B.29 - Write State Register Instructions |
| 181 | def WRrr : F3_1<2, 0b110000, "wr">; // wr rs1, rs2, rd |
| 182 | def WRri : F3_2<2, 0b110000, "wr">; // wr rs1, imm, rd |
Chris Lattner | 6179047 | 2004-04-07 05:04:01 +0000 | [diff] [blame] | 183 | |
Brian Gaeke | c53105c | 2004-06-27 22:53:56 +0000 | [diff] [blame] | 184 | // Convert Integer to Floating-point Instructions, p. 141 |
| 185 | def FITOS : F3_3<2, 0b110100, 0b011000100, "fitos">; |
| 186 | def FITOD : F3_3<2, 0b110100, 0b011001000, "fitos">; |
| 187 | |
Brian Gaeke | 57ff2e3 | 2004-06-24 21:22:09 +0000 | [diff] [blame] | 188 | // Convert between Floating-point Formats Instructions, p. 143 |
| 189 | def FSTOD : F3_3<2, 0b110100, 0b011001001, "fstod">; |
| 190 | def FDTOS : F3_3<2, 0b110100, 0b011000110, "fdtos">; |
| 191 | |
Brian Gaeke | f89cc65 | 2004-06-18 06:28:10 +0000 | [diff] [blame] | 192 | // Floating-point Move Instructions, p. 144 |
| 193 | def FMOVS : F3_3<2, 0b110100, 0b000000001, "fmovs">; |
| 194 | def FNEGS : F3_3<2, 0b110100, 0b000000101, "fnegs">; |
| 195 | def FABSS : F3_3<2, 0b110100, 0b000001001, "fabss">; |
| 196 | |
Brian Gaeke | c53105c | 2004-06-27 22:53:56 +0000 | [diff] [blame] | 197 | // Floating-point Add and Subtract Instructions, p. 146 |
| 198 | def FADDS : F3_3<2, 0b110100, 0b001000001, "fadds">; |
| 199 | def FADDD : F3_3<2, 0b110100, 0b001000010, "faddd">; |
| 200 | def FSUBS : F3_3<2, 0b110100, 0b001000101, "fsubs">; |
| 201 | def FSUBD : F3_3<2, 0b110100, 0b001000110, "fsubd">; |
| 202 | |
| 203 | // Floating-point Multiply and Divide Instructions, p. 147 |
| 204 | def FMULS : F3_3<2, 0b110100, 0b001001001, "fmuls">; |
| 205 | def FMULD : F3_3<2, 0b110100, 0b001001010, "fmuld">; |
| 206 | def FSMULD : F3_3<2, 0b110100, 0b001101001, "fsmuld">; |
| 207 | def FDIVS : F3_3<2, 0b110100, 0b001001101, "fdivs">; |
| 208 | def FDIVD : F3_3<2, 0b110100, 0b001001110, "fdivd">; |
Brian Gaeke | 57ff2e3 | 2004-06-24 21:22:09 +0000 | [diff] [blame] | 209 | |