Akira Hatanaka | df98a7a | 2012-05-24 18:32:33 +0000 | [diff] [blame] | 1 | //===- Mips16InstrInfo.td - Target Description for Mips16 -*- tablegen -*-=// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file describes Mips16 instructions. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
Reed Kotler | 2403221 | 2012-10-05 18:27:54 +0000 | [diff] [blame] | 13 | // |
Reed Kotler | 3589dd7 | 2012-10-28 06:02:37 +0000 | [diff] [blame] | 14 | // |
| 15 | // Mips Address |
| 16 | // |
| 17 | def addr16 : |
Akira Hatanaka | 040d225 | 2013-03-14 18:33:23 +0000 | [diff] [blame] | 18 | ComplexPattern<iPTR, 3, "selectAddr16", [frameindex], [SDNPWantParent]>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 19 | |
| 20 | // |
Reed Kotler | 0f2e44a | 2012-10-10 01:58:16 +0000 | [diff] [blame] | 21 | // Address operand |
| 22 | def mem16 : Operand<i32> { |
| 23 | let PrintMethod = "printMemOperand"; |
Reed Kotler | 30cedf6 | 2013-08-04 01:13:25 +0000 | [diff] [blame] | 24 | let MIOperandInfo = (ops CPU16Regs, simm16, CPU16RegsPlusSP); |
Reed Kotler | 3589dd7 | 2012-10-28 06:02:37 +0000 | [diff] [blame] | 25 | let EncoderMethod = "getMemEncoding"; |
| 26 | } |
| 27 | |
| 28 | def mem16_ea : Operand<i32> { |
| 29 | let PrintMethod = "printMemOperandEA"; |
Reed Kotler | 30cedf6 | 2013-08-04 01:13:25 +0000 | [diff] [blame] | 30 | let MIOperandInfo = (ops CPU16RegsPlusSP, simm16); |
Reed Kotler | 0f2e44a | 2012-10-10 01:58:16 +0000 | [diff] [blame] | 31 | let EncoderMethod = "getMemEncoding"; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 32 | } |
| 33 | |
Reed Kotler | 0f2e44a | 2012-10-10 01:58:16 +0000 | [diff] [blame] | 34 | // |
Reed Kotler | f662cff | 2013-02-13 20:28:27 +0000 | [diff] [blame] | 35 | // |
| 36 | // I8 instruction format |
| 37 | // |
| 38 | |
| 39 | class FI816_ins_base<bits<3> _func, string asmstr, |
| 40 | string asmstr2, InstrItinClass itin>: |
| 41 | FI816<_func, (outs), (ins simm16:$imm), !strconcat(asmstr, asmstr2), |
| 42 | [], itin>; |
| 43 | |
| 44 | |
| 45 | class FI816_SP_ins<bits<3> _func, string asmstr, |
| 46 | InstrItinClass itin>: |
| 47 | FI816_ins_base<_func, asmstr, "\t$$sp, $imm # 16 bit inst", itin>; |
| 48 | |
| 49 | // |
Reed Kotler | b9bf8dc | 2013-02-08 21:42:56 +0000 | [diff] [blame] | 50 | // RI instruction format |
| 51 | // |
| 52 | |
| 53 | |
Reed Kotler | d821719 | 2013-02-19 00:20:58 +0000 | [diff] [blame] | 54 | class FRI16_ins_base<bits<5> op, string asmstr, string asmstr2, |
| 55 | InstrItinClass itin>: |
| 56 | FRI16<op, (outs CPU16Regs:$rx), (ins simm16:$imm), |
| 57 | !strconcat(asmstr, asmstr2), [], itin>; |
| 58 | |
| 59 | class FRI16_ins<bits<5> op, string asmstr, |
| 60 | InstrItinClass itin>: |
| 61 | FRI16_ins_base<op, asmstr, "\t$rx, $imm \t# 16 bit inst", itin>; |
Reed Kotler | 7b503c2 | 2013-02-20 05:45:15 +0000 | [diff] [blame] | 62 | |
| 63 | class FRI16R_ins_base<bits<5> op, string asmstr, string asmstr2, |
| 64 | InstrItinClass itin>: |
| 65 | FRI16<op, (outs), (ins CPU16Regs:$rx, simm16:$imm), |
| 66 | !strconcat(asmstr, asmstr2), [], itin>; |
| 67 | |
| 68 | class FRI16R_ins<bits<5> op, string asmstr, |
| 69 | InstrItinClass itin>: |
| 70 | FRI16R_ins_base<op, asmstr, "\t$rx, $imm \t# 16 bit inst", itin>; |
| 71 | |
Reed Kotler | b9bf8dc | 2013-02-08 21:42:56 +0000 | [diff] [blame] | 72 | class F2RI16_ins<bits<5> _op, string asmstr, |
| 73 | InstrItinClass itin>: |
| 74 | FRI16<_op, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_, simm16:$imm), |
| 75 | !strconcat(asmstr, "\t$rx, $imm\t# 16 bit inst"), [], itin> { |
| 76 | let Constraints = "$rx_ = $rx"; |
| 77 | } |
| 78 | |
Reed Kotler | 97ba5f2 | 2013-02-21 04:22:38 +0000 | [diff] [blame] | 79 | class FRI16_B_ins<bits<5> _op, string asmstr, |
| 80 | InstrItinClass itin>: |
| 81 | FRI16<_op, (outs), (ins CPU16Regs:$rx, brtarget:$imm), |
| 82 | !strconcat(asmstr, "\t$rx, $imm # 16 bit inst"), [], itin>; |
Reed Kotler | b9bf8dc | 2013-02-08 21:42:56 +0000 | [diff] [blame] | 83 | // |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 84 | // Compare a register and immediate and place result in CC |
| 85 | // Implicit use of T8 |
| 86 | // |
| 87 | // EXT-CCRR Instruction format |
| 88 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 89 | class FEXT_CCRXI16_ins<string asmstr>: |
| 90 | MipsPseudo16<(outs CPU16Regs:$cc), (ins CPU16Regs:$rx, simm16:$imm), |
| 91 | !strconcat(asmstr, "\t$rx, $imm\n\tmove\t$cc, $$t8"), []> { |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 92 | let isCodeGenOnly=1; |
Reed Kotler | bd1058a | 2013-02-25 02:25:47 +0000 | [diff] [blame] | 93 | let usesCustomInserter = 1; |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 94 | } |
| 95 | |
Reed Kotler | f8933f8 | 2013-02-02 04:07:35 +0000 | [diff] [blame] | 96 | // JAL and JALX instruction format |
| 97 | // |
| 98 | class FJAL16_ins<bits<1> _X, string asmstr, |
| 99 | InstrItinClass itin>: |
| 100 | FJAL16<_X, (outs), (ins simm20:$imm), |
| 101 | !strconcat(asmstr, "\t$imm\n\tnop"),[], |
| 102 | itin> { |
| 103 | let isCodeGenOnly=1; |
| 104 | } |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 105 | // |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 106 | // EXT-I instruction format |
| 107 | // |
| 108 | class FEXT_I16_ins<bits<5> eop, string asmstr, InstrItinClass itin> : |
| 109 | FEXT_I16<eop, (outs), (ins brtarget:$imm16), |
| 110 | !strconcat(asmstr, "\t$imm16"),[], itin>; |
| 111 | |
| 112 | // |
| 113 | // EXT-I8 instruction format |
| 114 | // |
| 115 | |
| 116 | class FEXT_I816_ins_base<bits<3> _func, string asmstr, |
| 117 | string asmstr2, InstrItinClass itin>: |
Reed Kotler | d019dbf | 2012-12-20 04:07:42 +0000 | [diff] [blame] | 118 | FEXT_I816<_func, (outs), (ins simm16:$imm), !strconcat(asmstr, asmstr2), |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 119 | [], itin>; |
| 120 | |
| 121 | class FEXT_I816_ins<bits<3> _func, string asmstr, |
| 122 | InstrItinClass itin>: |
| 123 | FEXT_I816_ins_base<_func, asmstr, "\t$imm", itin>; |
| 124 | |
Reed Kotler | d019dbf | 2012-12-20 04:07:42 +0000 | [diff] [blame] | 125 | class FEXT_I816_SP_ins<bits<3> _func, string asmstr, |
| 126 | InstrItinClass itin>: |
| 127 | FEXT_I816_ins_base<_func, asmstr, "\t$$sp, $imm", itin>; |
| 128 | |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 129 | // |
Reed Kotler | 0f2e44a | 2012-10-10 01:58:16 +0000 | [diff] [blame] | 130 | // Assembler formats in alphabetical order. |
| 131 | // Natural and pseudos are mixed together. |
| 132 | // |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 133 | // Compare two registers and place result in CC |
| 134 | // Implicit use of T8 |
| 135 | // |
| 136 | // CC-RR Instruction format |
| 137 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 138 | class FCCRR16_ins<string asmstr> : |
| 139 | MipsPseudo16<(outs CPU16Regs:$cc), (ins CPU16Regs:$rx, CPU16Regs:$ry), |
| 140 | !strconcat(asmstr, "\t$rx, $ry\n\tmove\t$cc, $$t8"), []> { |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 141 | let isCodeGenOnly=1; |
Reed Kotler | bd1058a | 2013-02-25 02:25:47 +0000 | [diff] [blame] | 142 | let usesCustomInserter = 1; |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 145 | // |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 146 | // EXT-RI instruction format |
| 147 | // |
| 148 | |
| 149 | class FEXT_RI16_ins_base<bits<5> _op, string asmstr, string asmstr2, |
| 150 | InstrItinClass itin>: |
| 151 | FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins simm16:$imm), |
| 152 | !strconcat(asmstr, asmstr2), [], itin>; |
| 153 | |
| 154 | class FEXT_RI16_ins<bits<5> _op, string asmstr, |
| 155 | InstrItinClass itin>: |
| 156 | FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $imm", itin>; |
| 157 | |
Reed Kotler | 7b503c2 | 2013-02-20 05:45:15 +0000 | [diff] [blame] | 158 | class FEXT_RI16R_ins_base<bits<5> _op, string asmstr, string asmstr2, |
| 159 | InstrItinClass itin>: |
| 160 | FEXT_RI16<_op, (outs ), (ins CPU16Regs:$rx, simm16:$imm), |
| 161 | !strconcat(asmstr, asmstr2), [], itin>; |
| 162 | |
| 163 | class FEXT_RI16R_ins<bits<5> _op, string asmstr, |
| 164 | InstrItinClass itin>: |
| 165 | FEXT_RI16R_ins_base<_op, asmstr, "\t$rx, $imm", itin>; |
| 166 | |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 167 | class FEXT_RI16_PC_ins<bits<5> _op, string asmstr, InstrItinClass itin>: |
| 168 | FEXT_RI16_ins_base<_op, asmstr, "\t$rx, $$pc, $imm", itin>; |
| 169 | |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 170 | class FEXT_RI16_B_ins<bits<5> _op, string asmstr, |
| 171 | InstrItinClass itin>: |
| 172 | FEXT_RI16<_op, (outs), (ins CPU16Regs:$rx, brtarget:$imm), |
| 173 | !strconcat(asmstr, "\t$rx, $imm"), [], itin>; |
| 174 | |
Reed Kotler | 91ae982 | 2013-10-27 21:57:36 +0000 | [diff] [blame] | 175 | class FEXT_RI16_TCP_ins<bits<5> _op, string asmstr, |
| 176 | InstrItinClass itin>: |
| 177 | FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins pcrel16:$imm), |
| 178 | !strconcat(asmstr, "\t$rx, $imm"), [], itin>; |
| 179 | |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 180 | class FEXT_2RI16_ins<bits<5> _op, string asmstr, |
| 181 | InstrItinClass itin>: |
| 182 | FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_, simm16:$imm), |
| 183 | !strconcat(asmstr, "\t$rx, $imm"), [], itin> { |
| 184 | let Constraints = "$rx_ = $rx"; |
| 185 | } |
Reed Kotler | 2403221 | 2012-10-05 18:27:54 +0000 | [diff] [blame] | 186 | |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 187 | |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 188 | // this has an explicit sp argument that we ignore to work around a problem |
| 189 | // in the compiler |
| 190 | class FEXT_RI16_SP_explicit_ins<bits<5> _op, string asmstr, |
| 191 | InstrItinClass itin>: |
| 192 | FEXT_RI16<_op, (outs CPU16Regs:$rx), (ins CPUSPReg:$ry, simm16:$imm), |
Reed Kotler | 2403221 | 2012-10-05 18:27:54 +0000 | [diff] [blame] | 193 | !strconcat(asmstr, "\t$rx, $imm ( $ry ); "), [], itin>; |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 194 | |
Reed Kotler | 30cedf6 | 2013-08-04 01:13:25 +0000 | [diff] [blame] | 195 | class FEXT_RI16_SP_Store_explicit_ins<bits<5> _op, string asmstr, |
| 196 | InstrItinClass itin>: |
| 197 | FEXT_RI16<_op, (outs), (ins CPU16Regs:$rx, CPUSPReg:$ry, simm16:$imm), |
| 198 | !strconcat(asmstr, "\t$rx, $imm ( $ry ); "), [], itin>; |
| 199 | |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 200 | // |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 201 | // EXT-RRI instruction format |
| 202 | // |
| 203 | |
| 204 | class FEXT_RRI16_mem_ins<bits<5> op, string asmstr, Operand MemOpnd, |
| 205 | InstrItinClass itin>: |
| 206 | FEXT_RRI16<op, (outs CPU16Regs:$ry), (ins MemOpnd:$addr), |
| 207 | !strconcat(asmstr, "\t$ry, $addr"), [], itin>; |
| 208 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 209 | class FEXT_RRI16_mem2_ins<bits<5> op, string asmstr, Operand MemOpnd, |
| 210 | InstrItinClass itin>: |
| 211 | FEXT_RRI16<op, (outs ), (ins CPU16Regs:$ry, MemOpnd:$addr), |
| 212 | !strconcat(asmstr, "\t$ry, $addr"), [], itin>; |
| 213 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 214 | // |
Reed Kotler | 3589dd7 | 2012-10-28 06:02:37 +0000 | [diff] [blame] | 215 | // |
| 216 | // EXT-RRI-A instruction format |
| 217 | // |
| 218 | |
| 219 | class FEXT_RRI_A16_mem_ins<bits<1> op, string asmstr, Operand MemOpnd, |
| 220 | InstrItinClass itin>: |
| 221 | FEXT_RRI_A16<op, (outs CPU16Regs:$ry), (ins MemOpnd:$addr), |
| 222 | !strconcat(asmstr, "\t$ry, $addr"), [], itin>; |
| 223 | |
| 224 | // |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 225 | // EXT-SHIFT instruction format |
| 226 | // |
| 227 | class FEXT_SHIFT16_ins<bits<2> _f, string asmstr, InstrItinClass itin>: |
Akira Hatanaka | 3121353 | 2013-09-07 00:02:02 +0000 | [diff] [blame] | 228 | FEXT_SHIFT16<_f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry, uimm5:$sa), |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 229 | !strconcat(asmstr, "\t$rx, $ry, $sa"), [], itin>; |
| 230 | |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 231 | // |
| 232 | // EXT-T8I8 |
| 233 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 234 | class FEXT_T8I816_ins<string asmstr, string asmstr2>: |
| 235 | MipsPseudo16<(outs), |
| 236 | (ins CPU16Regs:$rx, CPU16Regs:$ry, brtarget:$imm), |
| 237 | !strconcat(asmstr2, !strconcat("\t$rx, $ry\n\t", |
| 238 | !strconcat(asmstr, "\t$imm"))),[]> { |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 239 | let isCodeGenOnly=1; |
Reed Kotler | e2bead7 | 2013-02-24 06:16:39 +0000 | [diff] [blame] | 240 | let usesCustomInserter = 1; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | // |
| 244 | // EXT-T8I8I |
| 245 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 246 | class FEXT_T8I8I16_ins<string asmstr, string asmstr2>: |
| 247 | MipsPseudo16<(outs), |
| 248 | (ins CPU16Regs:$rx, simm16:$imm, brtarget:$targ), |
| 249 | !strconcat(asmstr2, !strconcat("\t$rx, $imm\n\t", |
| 250 | !strconcat(asmstr, "\t$targ"))), []> { |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 251 | let isCodeGenOnly=1; |
Reed Kotler | 7a86b3d | 2013-02-24 23:17:51 +0000 | [diff] [blame] | 252 | let usesCustomInserter = 1; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 253 | } |
| 254 | // |
| 255 | |
Reed Kotler | 0f2e44a | 2012-10-10 01:58:16 +0000 | [diff] [blame] | 256 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 257 | // |
Reed Kotler | 0f2e44a | 2012-10-10 01:58:16 +0000 | [diff] [blame] | 258 | // I8_MOVR32 instruction format (used only by the MOVR32 instructio |
| 259 | // |
| 260 | class FI8_MOVR3216_ins<string asmstr, InstrItinClass itin>: |
Akira Hatanaka | 13e6ccf | 2013-08-06 23:08:38 +0000 | [diff] [blame] | 261 | FI8_MOVR3216<(outs CPU16Regs:$rz), (ins GPR32:$r32), |
Reed Kotler | 0f2e44a | 2012-10-10 01:58:16 +0000 | [diff] [blame] | 262 | !strconcat(asmstr, "\t$rz, $r32"), [], itin>; |
| 263 | |
| 264 | // |
| 265 | // I8_MOV32R instruction format (used only by MOV32R instruction) |
| 266 | // |
| 267 | |
| 268 | class FI8_MOV32R16_ins<string asmstr, InstrItinClass itin>: |
Akira Hatanaka | 13e6ccf | 2013-08-06 23:08:38 +0000 | [diff] [blame] | 269 | FI8_MOV32R16<(outs GPR32:$r32), (ins CPU16Regs:$rz), |
Reed Kotler | 0f2e44a | 2012-10-10 01:58:16 +0000 | [diff] [blame] | 270 | !strconcat(asmstr, "\t$r32, $rz"), [], itin>; |
| 271 | |
| 272 | // |
| 273 | // This are pseudo formats for multiply |
| 274 | // This first one can be changed to non pseudo now. |
| 275 | // |
| 276 | // MULT |
| 277 | // |
| 278 | class FMULT16_ins<string asmstr, InstrItinClass itin> : |
| 279 | MipsPseudo16<(outs), (ins CPU16Regs:$rx, CPU16Regs:$ry), |
| 280 | !strconcat(asmstr, "\t$rx, $ry"), []>; |
| 281 | |
| 282 | // |
| 283 | // MULT-LO |
| 284 | // |
| 285 | class FMULT16_LO_ins<string asmstr, InstrItinClass itin> : |
| 286 | MipsPseudo16<(outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry), |
| 287 | !strconcat(asmstr, "\t$rx, $ry\n\tmflo\t$rz"), []> { |
| 288 | let isCodeGenOnly=1; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | // |
Reed Kotler | 0f2e44a | 2012-10-10 01:58:16 +0000 | [diff] [blame] | 292 | // RR-type instruction format |
| 293 | // |
| 294 | |
| 295 | class FRR16_ins<bits<5> f, string asmstr, InstrItinClass itin> : |
| 296 | FRR16<f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry), |
| 297 | !strconcat(asmstr, "\t$rx, $ry"), [], itin> { |
| 298 | } |
Reed Kotler | cf11c59 | 2012-10-12 02:01:09 +0000 | [diff] [blame] | 299 | |
Reed Kotler | bb870e2 | 2013-08-07 04:00:26 +0000 | [diff] [blame] | 300 | class FRRBreakNull16_ins<string asmstr, InstrItinClass itin> : |
| 301 | FRRBreak16<(outs), (ins), asmstr, [], itin> { |
| 302 | let Code=0; |
| 303 | } |
| 304 | |
Reed Kotler | 80070bd | 2013-02-23 23:37:03 +0000 | [diff] [blame] | 305 | class FRR16R_ins<bits<5> f, string asmstr, InstrItinClass itin> : |
| 306 | FRR16<f, (outs), (ins CPU16Regs:$rx, CPU16Regs:$ry), |
| 307 | !strconcat(asmstr, "\t$rx, $ry"), [], itin> { |
| 308 | } |
| 309 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 310 | class FRRTR16_ins<string asmstr> : |
| 311 | MipsPseudo16<(outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry), |
| 312 | !strconcat(asmstr, "\t$rx, $ry\n\tmove\t$rz, $$t8"), []> ; |
Reed Kotler | 287f044 | 2012-10-26 04:46:26 +0000 | [diff] [blame] | 313 | |
Reed Kotler | cf11c59 | 2012-10-12 02:01:09 +0000 | [diff] [blame] | 314 | // |
| 315 | // maybe refactor but need a $zero as a dummy first parameter |
| 316 | // |
| 317 | class FRR16_div_ins<bits<5> f, string asmstr, InstrItinClass itin> : |
| 318 | FRR16<f, (outs ), (ins CPU16Regs:$rx, CPU16Regs:$ry), |
| 319 | !strconcat(asmstr, "\t$$zero, $rx, $ry"), [], itin> ; |
| 320 | |
Reed Kotler | 4e1c629 | 2012-10-26 16:18:19 +0000 | [diff] [blame] | 321 | class FUnaryRR16_ins<bits<5> f, string asmstr, InstrItinClass itin> : |
| 322 | FRR16<f, (outs CPU16Regs:$rx), (ins CPU16Regs:$ry), |
| 323 | !strconcat(asmstr, "\t$rx, $ry"), [], itin> ; |
| 324 | |
| 325 | |
Reed Kotler | 0f2e44a | 2012-10-10 01:58:16 +0000 | [diff] [blame] | 326 | class FRR16_M_ins<bits<5> f, string asmstr, |
| 327 | InstrItinClass itin> : |
| 328 | FRR16<f, (outs CPU16Regs:$rx), (ins), |
| 329 | !strconcat(asmstr, "\t$rx"), [], itin>; |
| 330 | |
| 331 | class FRxRxRy16_ins<bits<5> f, string asmstr, |
| 332 | InstrItinClass itin> : |
| 333 | FRR16<f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry), |
| 334 | !strconcat(asmstr, "\t$rz, $ry"), |
| 335 | [], itin> { |
| 336 | let Constraints = "$rx = $rz"; |
| 337 | } |
| 338 | |
| 339 | let rx=0 in |
| 340 | class FRR16_JALRC_RA_only_ins<bits<1> nd_, bits<1> l_, |
| 341 | string asmstr, InstrItinClass itin>: |
| 342 | FRR16_JALRC<nd_, l_, 1, (outs), (ins), !strconcat(asmstr, "\t $$ra"), |
| 343 | [], itin> ; |
| 344 | |
Reed Kotler | e6c3157 | 2012-10-28 23:08:07 +0000 | [diff] [blame] | 345 | |
| 346 | class FRR16_JALRC_ins<bits<1> nd, bits<1> l, bits<1> ra, |
| 347 | string asmstr, InstrItinClass itin>: |
Jack Carter | 7ab15fa | 2013-01-19 02:00:40 +0000 | [diff] [blame] | 348 | FRR16_JALRC<nd, l, ra, (outs), (ins CPU16Regs:$rx), |
Reed Kotler | e6c3157 | 2012-10-28 23:08:07 +0000 | [diff] [blame] | 349 | !strconcat(asmstr, "\t $rx"), [], itin> ; |
| 350 | |
Reed Kotler | 445d0ad | 2013-10-07 20:46:19 +0000 | [diff] [blame] | 351 | class FRR_SF16_ins |
| 352 | <bits<5> _funct, bits<3> _subfunc, |
| 353 | string asmstr, InstrItinClass itin>: |
| 354 | FRR_SF16<_funct, _subfunc, (outs CPU16Regs:$rx), (ins CPU16Regs:$rx_), |
| 355 | !strconcat(asmstr, "\t $rx"), |
| 356 | [], itin> { |
| 357 | let Constraints = "$rx_ = $rx"; |
| 358 | } |
Reed Kotler | 0f2e44a | 2012-10-10 01:58:16 +0000 | [diff] [blame] | 359 | // |
| 360 | // RRR-type instruction format |
| 361 | // |
| 362 | |
| 363 | class FRRR16_ins<bits<2> _f, string asmstr, InstrItinClass itin> : |
| 364 | FRRR16<_f, (outs CPU16Regs:$rz), (ins CPU16Regs:$rx, CPU16Regs:$ry), |
| 365 | !strconcat(asmstr, "\t$rz, $rx, $ry"), [], itin>; |
| 366 | |
| 367 | // |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 368 | // These Sel patterns support the generation of conditional move |
| 369 | // pseudo instructions. |
| 370 | // |
| 371 | // The nomenclature uses the components making up the pseudo and may |
| 372 | // be a bit counter intuitive when compared with the end result we seek. |
| 373 | // For example using a bqez in the example directly below results in the |
| 374 | // conditional move being done if the tested register is not zero. |
| 375 | // I considered in easier to check by keeping the pseudo consistent with |
| 376 | // it's components but it could have been done differently. |
| 377 | // |
| 378 | // The simplest case is when can test and operand directly and do the |
| 379 | // conditional move based on a simple mips16 conditional |
| 380 | // branch instruction. |
| 381 | // for example: |
| 382 | // if $op == beqz or bnez: |
| 383 | // |
| 384 | // $op1 $rt, .+4 |
| 385 | // move $rd, $rs |
| 386 | // |
| 387 | // if $op == beqz, then if $rt != 0, then the conditional assignment |
| 388 | // $rd = $rs is done. |
| 389 | |
| 390 | // if $op == bnez, then if $rt == 0, then the conditional assignment |
| 391 | // $rd = $rs is done. |
| 392 | // |
| 393 | // So this pseudo class only has one operand, i.e. op |
| 394 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 395 | class Sel<string op>: |
| 396 | MipsPseudo16<(outs CPU16Regs:$rd_), (ins CPU16Regs:$rd, CPU16Regs:$rs, |
| 397 | CPU16Regs:$rt), |
| 398 | !strconcat(op, "\t$rt, .+4\n\t\n\tmove $rd, $rs"), []> { |
| 399 | //let isCodeGenOnly=1; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 400 | let Constraints = "$rd = $rd_"; |
Reed Kotler | 97ba5f2 | 2013-02-21 04:22:38 +0000 | [diff] [blame] | 401 | let usesCustomInserter = 1; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | // |
| 405 | // The next two instruction classes allow for an operand which tests |
| 406 | // two operands and returns a value in register T8 and |
| 407 | //then does a conditional branch based on the value of T8 |
| 408 | // |
| 409 | |
| 410 | // op2 can be cmpi or slti/sltiu |
| 411 | // op1 can bteqz or btnez |
| 412 | // the operands for op2 are a register and a signed constant |
| 413 | // |
| 414 | // $op2 $t, $imm ;test register t and branch conditionally |
| 415 | // $op1 .+4 ;op1 is a conditional branch |
| 416 | // move $rd, $rs |
| 417 | // |
| 418 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 419 | class SeliT<string op1, string op2>: |
| 420 | MipsPseudo16<(outs CPU16Regs:$rd_), (ins CPU16Regs:$rd, CPU16Regs:$rs, |
| 421 | CPU16Regs:$rl, simm16:$imm), |
| 422 | !strconcat(op2, |
| 423 | !strconcat("\t$rl, $imm\n\t", |
| 424 | !strconcat(op1, "\t.+4\n\tmove $rd, $rs"))), []> { |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 425 | let isCodeGenOnly=1; |
| 426 | let Constraints = "$rd = $rd_"; |
Reed Kotler | 4416cda | 2013-02-22 05:10:51 +0000 | [diff] [blame] | 427 | let usesCustomInserter = 1; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | // |
| 431 | // op2 can be cmp or slt/sltu |
| 432 | // op1 can be bteqz or btnez |
| 433 | // the operands for op2 are two registers |
| 434 | // op1 is a conditional branch |
| 435 | // |
| 436 | // |
| 437 | // $op2 $rl, $rr ;test registers rl,rr |
| 438 | // $op1 .+4 ;op2 is a conditional branch |
| 439 | // move $rd, $rs |
| 440 | // |
| 441 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 442 | class SelT<string op1, string op2>: |
Reed Kotler | 7b503c2 | 2013-02-20 05:45:15 +0000 | [diff] [blame] | 443 | MipsPseudo16<(outs CPU16Regs:$rd_), |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 444 | (ins CPU16Regs:$rd, CPU16Regs:$rs, |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 445 | CPU16Regs:$rl, CPU16Regs:$rr), |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 446 | !strconcat(op2, |
| 447 | !strconcat("\t$rl, $rr\n\t", |
| 448 | !strconcat(op1, "\t.+4\n\tmove $rd, $rs"))), []> { |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 449 | let isCodeGenOnly=1; |
| 450 | let Constraints = "$rd = $rd_"; |
Reed Kotler | dacee2b | 2013-02-23 03:09:56 +0000 | [diff] [blame] | 451 | let usesCustomInserter = 1; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 452 | } |
| 453 | |
Reed Kotler | d019dbf | 2012-12-20 04:07:42 +0000 | [diff] [blame] | 454 | // |
| 455 | // 32 bit constant |
| 456 | // |
| 457 | def imm32: Operand<i32>; |
| 458 | |
| 459 | def Constant32: |
| 460 | MipsPseudo16<(outs), (ins imm32:$imm), "\t.word $imm", []>; |
Jack Carter | 7ab15fa | 2013-01-19 02:00:40 +0000 | [diff] [blame] | 461 | |
Reed Kotler | d019dbf | 2012-12-20 04:07:42 +0000 | [diff] [blame] | 462 | def LwConstant32: |
Reed Kotler | 91ae982 | 2013-10-27 21:57:36 +0000 | [diff] [blame] | 463 | MipsPseudo16<(outs CPU16Regs:$rx), (ins imm32:$imm, imm32:$constid), |
Reed Kotler | d019dbf | 2012-12-20 04:07:42 +0000 | [diff] [blame] | 464 | "lw\t$rx, 1f\n\tb\t2f\n\t.align\t2\n1: \t.word\t$imm\n2:", []>; |
| 465 | |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 466 | |
| 467 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 468 | // Some general instruction class info |
| 469 | // |
| 470 | // |
| 471 | |
| 472 | class ArithLogic16Defs<bit isCom=0> { |
| 473 | bits<5> shamt = 0; |
| 474 | bit isCommutable = isCom; |
| 475 | bit isReMaterializable = 1; |
| 476 | bit neverHasSideEffects = 1; |
| 477 | } |
| 478 | |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 479 | class branch16 { |
| 480 | bit isBranch = 1; |
| 481 | bit isTerminator = 1; |
| 482 | bit isBarrier = 1; |
| 483 | } |
| 484 | |
| 485 | class cbranch16 { |
| 486 | bit isBranch = 1; |
| 487 | bit isTerminator = 1; |
| 488 | } |
| 489 | |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 490 | class MayLoad { |
| 491 | bit mayLoad = 1; |
| 492 | } |
| 493 | |
| 494 | class MayStore { |
| 495 | bit mayStore = 1; |
| 496 | } |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 497 | // |
Akira Hatanaka | 64626fc | 2012-07-26 02:24:43 +0000 | [diff] [blame] | 498 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 499 | |
Akira Hatanaka | 64626fc | 2012-07-26 02:24:43 +0000 | [diff] [blame] | 500 | // Format: ADDIU rx, immediate MIPS16e |
| 501 | // Purpose: Add Immediate Unsigned Word (2-Operand, Extended) |
| 502 | // To add a constant to a 32-bit integer. |
| 503 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 504 | def AddiuRxImmX16: FEXT_RI16_ins<0b01001, "addiu", IIAlu>; |
Akira Hatanaka | 64626fc | 2012-07-26 02:24:43 +0000 | [diff] [blame] | 505 | |
Reed Kotler | b9bf8dc | 2013-02-08 21:42:56 +0000 | [diff] [blame] | 506 | def AddiuRxRxImm16: F2RI16_ins<0b01001, "addiu", IIAlu>, |
| 507 | ArithLogic16Defs<0> { |
| 508 | let AddedComplexity = 5; |
| 509 | } |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 510 | def AddiuRxRxImmX16: FEXT_2RI16_ins<0b01001, "addiu", IIAlu>, |
Reed Kotler | ec8a549 | 2013-02-14 03:05:25 +0000 | [diff] [blame] | 511 | ArithLogic16Defs<0> { |
| 512 | let isCodeGenOnly = 1; |
| 513 | } |
Akira Hatanaka | 64626fc | 2012-07-26 02:24:43 +0000 | [diff] [blame] | 514 | |
Reed Kotler | 3589dd7 | 2012-10-28 06:02:37 +0000 | [diff] [blame] | 515 | def AddiuRxRyOffMemX16: |
| 516 | FEXT_RRI_A16_mem_ins<0, "addiu", mem16_ea, IIAlu>; |
| 517 | |
Akira Hatanaka | 64626fc | 2012-07-26 02:24:43 +0000 | [diff] [blame] | 518 | // |
| 519 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 520 | // Format: ADDIU rx, pc, immediate MIPS16e |
| 521 | // Purpose: Add Immediate Unsigned Word (3-Operand, PC-Relative, Extended) |
| 522 | // To add a constant to the program counter. |
| 523 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 524 | def AddiuRxPcImmX16: FEXT_RI16_PC_ins<0b00001, "addiu", IIAlu>; |
Reed Kotler | d019dbf | 2012-12-20 04:07:42 +0000 | [diff] [blame] | 525 | |
| 526 | // |
| 527 | // Format: ADDIU sp, immediate MIPS16e |
| 528 | // Purpose: Add Immediate Unsigned Word (2-Operand, SP-Relative, Extended) |
| 529 | // To add a constant to the stack pointer. |
| 530 | // |
Reed Kotler | f662cff | 2013-02-13 20:28:27 +0000 | [diff] [blame] | 531 | def AddiuSpImm16 |
| 532 | : FI816_SP_ins<0b011, "addiu", IIAlu> { |
| 533 | let Defs = [SP]; |
| 534 | let Uses = [SP]; |
| 535 | let AddedComplexity = 5; |
| 536 | } |
| 537 | |
Reed Kotler | d019dbf | 2012-12-20 04:07:42 +0000 | [diff] [blame] | 538 | def AddiuSpImmX16 |
| 539 | : FEXT_I816_SP_ins<0b011, "addiu", IIAlu> { |
| 540 | let Defs = [SP]; |
| 541 | let Uses = [SP]; |
Jack Carter | 7ab15fa | 2013-01-19 02:00:40 +0000 | [diff] [blame] | 542 | } |
Reed Kotler | d019dbf | 2012-12-20 04:07:42 +0000 | [diff] [blame] | 543 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 544 | // |
| 545 | // Format: ADDU rz, rx, ry MIPS16e |
| 546 | // Purpose: Add Unsigned Word (3-Operand) |
| 547 | // To add 32-bit integers. |
| 548 | // |
| 549 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 550 | def AdduRxRyRz16: FRRR16_ins<01, "addu", IIAlu>, ArithLogic16Defs<1>; |
| 551 | |
| 552 | // |
| 553 | // Format: AND rx, ry MIPS16e |
| 554 | // Purpose: AND |
| 555 | // To do a bitwise logical AND. |
| 556 | |
| 557 | def AndRxRxRy16: FRxRxRy16_ins<0b01100, "and", IIAlu>, ArithLogic16Defs<1>; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 558 | |
| 559 | |
| 560 | // |
| 561 | // Format: BEQZ rx, offset MIPS16e |
Reed Kotler | 97ba5f2 | 2013-02-21 04:22:38 +0000 | [diff] [blame] | 562 | // Purpose: Branch on Equal to Zero |
| 563 | // To test a GPR then do a PC-relative conditional branch. |
| 564 | // |
| 565 | def BeqzRxImm16: FRI16_B_ins<0b00100, "beqz", IIAlu>, cbranch16; |
| 566 | |
| 567 | |
| 568 | // |
| 569 | // Format: BEQZ rx, offset MIPS16e |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 570 | // Purpose: Branch on Equal to Zero (Extended) |
| 571 | // To test a GPR then do a PC-relative conditional branch. |
| 572 | // |
| 573 | def BeqzRxImmX16: FEXT_RI16_B_ins<0b00100, "beqz", IIAlu>, cbranch16; |
| 574 | |
| 575 | // Format: B offset MIPS16e |
| 576 | // Purpose: Unconditional Branch |
| 577 | // To do an unconditional PC-relative branch. |
| 578 | // |
| 579 | def BimmX16: FEXT_I16_ins<0b00010, "b", IIAlu>, branch16; |
| 580 | |
| 581 | // |
| 582 | // Format: BNEZ rx, offset MIPS16e |
Reed Kotler | 97ba5f2 | 2013-02-21 04:22:38 +0000 | [diff] [blame] | 583 | // Purpose: Branch on Not Equal to Zero |
| 584 | // To test a GPR then do a PC-relative conditional branch. |
| 585 | // |
| 586 | def BnezRxImm16: FRI16_B_ins<0b00101, "bnez", IIAlu>, cbranch16; |
| 587 | |
| 588 | // |
| 589 | // Format: BNEZ rx, offset MIPS16e |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 590 | // Purpose: Branch on Not Equal to Zero (Extended) |
| 591 | // To test a GPR then do a PC-relative conditional branch. |
| 592 | // |
| 593 | def BnezRxImmX16: FEXT_RI16_B_ins<0b00101, "bnez", IIAlu>, cbranch16; |
| 594 | |
Reed Kotler | bb870e2 | 2013-08-07 04:00:26 +0000 | [diff] [blame] | 595 | |
| 596 | // |
| 597 | //Format: BREAK immediate |
| 598 | // Purpose: Breakpoint |
| 599 | // To cause a Breakpoint exception. |
| 600 | |
| 601 | def Break16: FRRBreakNull16_ins<"break 0", NoItinerary>; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 602 | // |
| 603 | // Format: BTEQZ offset MIPS16e |
| 604 | // Purpose: Branch on T Equal to Zero (Extended) |
| 605 | // To test special register T then do a PC-relative conditional branch. |
| 606 | // |
Reed Kotler | cb37409 | 2013-02-18 00:59:04 +0000 | [diff] [blame] | 607 | def BteqzX16: FEXT_I816_ins<0b000, "bteqz", IIAlu>, cbranch16 { |
| 608 | let Uses = [T8]; |
| 609 | } |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 610 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 611 | def BteqzT8CmpX16: FEXT_T8I816_ins<"bteqz", "cmp">, cbranch16; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 612 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 613 | def BteqzT8CmpiX16: FEXT_T8I8I16_ins<"bteqz", "cmpi">, |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 614 | cbranch16; |
| 615 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 616 | def BteqzT8SltX16: FEXT_T8I816_ins<"bteqz", "slt">, cbranch16; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 617 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 618 | def BteqzT8SltuX16: FEXT_T8I816_ins<"bteqz", "sltu">, cbranch16; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 619 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 620 | def BteqzT8SltiX16: FEXT_T8I8I16_ins<"bteqz", "slti">, cbranch16; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 621 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 622 | def BteqzT8SltiuX16: FEXT_T8I8I16_ins<"bteqz", "sltiu">, |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 623 | cbranch16; |
| 624 | |
| 625 | // |
| 626 | // Format: BTNEZ offset MIPS16e |
| 627 | // Purpose: Branch on T Not Equal to Zero (Extended) |
| 628 | // To test special register T then do a PC-relative conditional branch. |
| 629 | // |
Reed Kotler | cb37409 | 2013-02-18 00:59:04 +0000 | [diff] [blame] | 630 | def BtnezX16: FEXT_I816_ins<0b001, "btnez", IIAlu> ,cbranch16 { |
| 631 | let Uses = [T8]; |
| 632 | } |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 633 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 634 | def BtnezT8CmpX16: FEXT_T8I816_ins<"btnez", "cmp">, cbranch16; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 635 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 636 | def BtnezT8CmpiX16: FEXT_T8I8I16_ins<"btnez", "cmpi">, cbranch16; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 637 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 638 | def BtnezT8SltX16: FEXT_T8I816_ins<"btnez", "slt">, cbranch16; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 639 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 640 | def BtnezT8SltuX16: FEXT_T8I816_ins<"btnez", "sltu">, cbranch16; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 641 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 642 | def BtnezT8SltiX16: FEXT_T8I8I16_ins<"btnez", "slti">, cbranch16; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 643 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 644 | def BtnezT8SltiuX16: FEXT_T8I8I16_ins<"btnez", "sltiu">, |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 645 | cbranch16; |
| 646 | |
Reed Kotler | cf11c59 | 2012-10-12 02:01:09 +0000 | [diff] [blame] | 647 | // |
Reed Kotler | cb37409 | 2013-02-18 00:59:04 +0000 | [diff] [blame] | 648 | // Format: CMP rx, ry MIPS16e |
| 649 | // Purpose: Compare |
| 650 | // To compare the contents of two GPRs. |
| 651 | // |
Reed Kotler | 80070bd | 2013-02-23 23:37:03 +0000 | [diff] [blame] | 652 | def CmpRxRy16: FRR16R_ins<0b01010, "cmp", IIAlu> { |
Reed Kotler | cb37409 | 2013-02-18 00:59:04 +0000 | [diff] [blame] | 653 | let Defs = [T8]; |
| 654 | } |
| 655 | |
Reed Kotler | d821719 | 2013-02-19 00:20:58 +0000 | [diff] [blame] | 656 | // |
| 657 | // Format: CMPI rx, immediate MIPS16e |
| 658 | // Purpose: Compare Immediate |
| 659 | // To compare a constant with the contents of a GPR. |
| 660 | // |
Reed Kotler | 80070bd | 2013-02-23 23:37:03 +0000 | [diff] [blame] | 661 | def CmpiRxImm16: FRI16R_ins<0b01110, "cmpi", IIAlu> { |
Reed Kotler | d821719 | 2013-02-19 00:20:58 +0000 | [diff] [blame] | 662 | let Defs = [T8]; |
| 663 | } |
| 664 | |
| 665 | // |
| 666 | // Format: CMPI rx, immediate MIPS16e |
| 667 | // Purpose: Compare Immediate (Extended) |
| 668 | // To compare a constant with the contents of a GPR. |
| 669 | // |
Reed Kotler | 80070bd | 2013-02-23 23:37:03 +0000 | [diff] [blame] | 670 | def CmpiRxImmX16: FEXT_RI16R_ins<0b01110, "cmpi", IIAlu> { |
Reed Kotler | d821719 | 2013-02-19 00:20:58 +0000 | [diff] [blame] | 671 | let Defs = [T8]; |
| 672 | } |
| 673 | |
Reed Kotler | cb37409 | 2013-02-18 00:59:04 +0000 | [diff] [blame] | 674 | |
| 675 | // |
Reed Kotler | cf11c59 | 2012-10-12 02:01:09 +0000 | [diff] [blame] | 676 | // Format: DIV rx, ry MIPS16e |
| 677 | // Purpose: Divide Word |
| 678 | // To divide 32-bit signed integers. |
| 679 | // |
| 680 | def DivRxRy16: FRR16_div_ins<0b11010, "div", IIAlu> { |
Akira Hatanaka | 8002a3f | 2013-08-14 00:47:08 +0000 | [diff] [blame] | 681 | let Defs = [HI0, LO0]; |
Reed Kotler | cf11c59 | 2012-10-12 02:01:09 +0000 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | // |
| 685 | // Format: DIVU rx, ry MIPS16e |
| 686 | // Purpose: Divide Unsigned Word |
| 687 | // To divide 32-bit unsigned integers. |
| 688 | // |
| 689 | def DivuRxRy16: FRR16_div_ins<0b11011, "divu", IIAlu> { |
Akira Hatanaka | 8002a3f | 2013-08-14 00:47:08 +0000 | [diff] [blame] | 690 | let Defs = [HI0, LO0]; |
Reed Kotler | cf11c59 | 2012-10-12 02:01:09 +0000 | [diff] [blame] | 691 | } |
Reed Kotler | f8933f8 | 2013-02-02 04:07:35 +0000 | [diff] [blame] | 692 | // |
| 693 | // Format: JAL target MIPS16e |
| 694 | // Purpose: Jump and Link |
| 695 | // To execute a procedure call within the current 256 MB-aligned |
| 696 | // region and preserve the current ISA. |
| 697 | // |
Reed Kotler | cf11c59 | 2012-10-12 02:01:09 +0000 | [diff] [blame] | 698 | |
Reed Kotler | f8933f8 | 2013-02-02 04:07:35 +0000 | [diff] [blame] | 699 | def Jal16 : FJAL16_ins<0b0, "jal", IIAlu> { |
Reed Kotler | f8933f8 | 2013-02-02 04:07:35 +0000 | [diff] [blame] | 700 | let hasDelaySlot = 0; // not true, but we add the nop for now |
Reed Kotler | fd132b9 | 2013-08-01 00:59:06 +0000 | [diff] [blame] | 701 | let isCall=1; |
Reed Kotler | f8933f8 | 2013-02-02 04:07:35 +0000 | [diff] [blame] | 702 | } |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 703 | |
| 704 | // |
| 705 | // Format: JR ra MIPS16e |
| 706 | // Purpose: Jump Register Through Register ra |
| 707 | // To execute a branch to the instruction address in the return |
| 708 | // address register. |
| 709 | // |
| 710 | |
Reed Kotler | 3589dd7 | 2012-10-28 06:02:37 +0000 | [diff] [blame] | 711 | def JrRa16: FRR16_JALRC_RA_only_ins<0, 0, "jr", IIAlu> { |
| 712 | let isBranch = 1; |
| 713 | let isIndirectBranch = 1; |
| 714 | let hasDelaySlot = 1; |
| 715 | let isTerminator=1; |
| 716 | let isBarrier=1; |
| 717 | } |
Reed Kotler | e6c3157 | 2012-10-28 23:08:07 +0000 | [diff] [blame] | 718 | |
Reed Kotler | ec8a549 | 2013-02-14 03:05:25 +0000 | [diff] [blame] | 719 | def JrcRa16: FRR16_JALRC_RA_only_ins<1, 1, "jrc", IIAlu> { |
Reed Kotler | a811753 | 2012-10-30 00:54:49 +0000 | [diff] [blame] | 720 | let isBranch = 1; |
| 721 | let isIndirectBranch = 1; |
| 722 | let isTerminator=1; |
| 723 | let isBarrier=1; |
| 724 | } |
| 725 | |
Reed Kotler | e6c3157 | 2012-10-28 23:08:07 +0000 | [diff] [blame] | 726 | def JrcRx16: FRR16_JALRC_ins<1, 1, 0, "jrc", IIAlu> { |
| 727 | let isBranch = 1; |
| 728 | let isIndirectBranch = 1; |
| 729 | let isTerminator=1; |
| 730 | let isBarrier=1; |
| 731 | } |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 732 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 733 | // Format: LB ry, offset(rx) MIPS16e |
| 734 | // Purpose: Load Byte (Extended) |
| 735 | // To load a byte from memory as a signed value. |
| 736 | // |
Reed Kotler | ec8a549 | 2013-02-14 03:05:25 +0000 | [diff] [blame] | 737 | def LbRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lb", mem16, IILoad>, MayLoad{ |
| 738 | let isCodeGenOnly = 1; |
| 739 | } |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 740 | |
| 741 | // |
| 742 | // Format: LBU ry, offset(rx) MIPS16e |
| 743 | // Purpose: Load Byte Unsigned (Extended) |
| 744 | // To load a byte from memory as a unsigned value. |
| 745 | // |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 746 | def LbuRxRyOffMemX16: |
Reed Kotler | ec8a549 | 2013-02-14 03:05:25 +0000 | [diff] [blame] | 747 | FEXT_RRI16_mem_ins<0b10100, "lbu", mem16, IILoad>, MayLoad { |
| 748 | let isCodeGenOnly = 1; |
| 749 | } |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 750 | |
| 751 | // |
| 752 | // Format: LH ry, offset(rx) MIPS16e |
| 753 | // Purpose: Load Halfword signed (Extended) |
| 754 | // To load a halfword from memory as a signed value. |
| 755 | // |
Reed Kotler | ec8a549 | 2013-02-14 03:05:25 +0000 | [diff] [blame] | 756 | def LhRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10100, "lh", mem16, IILoad>, MayLoad{ |
| 757 | let isCodeGenOnly = 1; |
| 758 | } |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 759 | |
| 760 | // |
| 761 | // Format: LHU ry, offset(rx) MIPS16e |
| 762 | // Purpose: Load Halfword unsigned (Extended) |
| 763 | // To load a halfword from memory as an unsigned value. |
| 764 | // |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 765 | def LhuRxRyOffMemX16: |
Reed Kotler | ec8a549 | 2013-02-14 03:05:25 +0000 | [diff] [blame] | 766 | FEXT_RRI16_mem_ins<0b10100, "lhu", mem16, IILoad>, MayLoad { |
| 767 | let isCodeGenOnly = 1; |
| 768 | } |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 769 | |
| 770 | // |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 771 | // Format: LI rx, immediate MIPS16e |
Reed Kotler | 7b503c2 | 2013-02-20 05:45:15 +0000 | [diff] [blame] | 772 | // Purpose: Load Immediate |
| 773 | // To load a constant into a GPR. |
| 774 | // |
| 775 | def LiRxImm16: FRI16_ins<0b01101, "li", IIAlu>; |
| 776 | |
| 777 | // |
| 778 | // Format: LI rx, immediate MIPS16e |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 779 | // Purpose: Load Immediate (Extended) |
| 780 | // To load a constant into a GPR. |
| 781 | // |
| 782 | def LiRxImmX16: FEXT_RI16_ins<0b01101, "li", IIAlu>; |
| 783 | |
Reed Kotler | d6aadc7 | 2013-09-18 22:46:09 +0000 | [diff] [blame] | 784 | def LiRxImmAlignX16: FEXT_RI16_ins<0b01101, ".align 2\n\tli", IIAlu> { |
| 785 | let isCodeGenOnly = 1; |
| 786 | } |
| 787 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 788 | // |
| 789 | // Format: LW ry, offset(rx) MIPS16e |
| 790 | // Purpose: Load Word (Extended) |
| 791 | // To load a word from memory as a signed value. |
| 792 | // |
Reed Kotler | ec8a549 | 2013-02-14 03:05:25 +0000 | [diff] [blame] | 793 | def LwRxRyOffMemX16: FEXT_RRI16_mem_ins<0b10011, "lw", mem16, IILoad>, MayLoad{ |
| 794 | let isCodeGenOnly = 1; |
| 795 | } |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 796 | |
| 797 | // Format: LW rx, offset(sp) MIPS16e |
| 798 | // Purpose: Load Word (SP-Relative, Extended) |
| 799 | // To load an SP-relative word from memory as a signed value. |
| 800 | // |
Reed Kotler | 91ae982 | 2013-10-27 21:57:36 +0000 | [diff] [blame] | 801 | def LwRxSpImmX16: FEXT_RI16_SP_explicit_ins<0b10010, "lw", IILoad>, MayLoad{ |
Reed Kotler | 3aad762 | 2012-12-19 04:06:15 +0000 | [diff] [blame] | 802 | let Uses = [SP]; |
| 803 | } |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 804 | |
Reed Kotler | 91ae982 | 2013-10-27 21:57:36 +0000 | [diff] [blame] | 805 | def LwRxPcTcpX16: FEXT_RI16_TCP_ins<0b10110, "lw", IILoad>, MayLoad; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 806 | // |
| 807 | // Format: MOVE r32, rz MIPS16e |
| 808 | // Purpose: Move |
| 809 | // To move the contents of a GPR to a GPR. |
| 810 | // |
Akira Hatanaka | 0fbaec2 | 2012-09-14 03:21:56 +0000 | [diff] [blame] | 811 | def Move32R16: FI8_MOV32R16_ins<"move", IIAlu>; |
| 812 | |
| 813 | // |
| 814 | // Format: MOVE ry, r32 MIPS16e |
| 815 | //Purpose: Move |
| 816 | // To move the contents of a GPR to a GPR. |
| 817 | // |
| 818 | def MoveR3216: FI8_MOVR3216_ins<"move", IIAlu>; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 819 | |
| 820 | // |
Reed Kotler | 2403221 | 2012-10-05 18:27:54 +0000 | [diff] [blame] | 821 | // Format: MFHI rx MIPS16e |
| 822 | // Purpose: Move From HI Register |
| 823 | // To copy the special purpose HI register to a GPR. |
| 824 | // |
| 825 | def Mfhi16: FRR16_M_ins<0b10000, "mfhi", IIAlu> { |
Akira Hatanaka | 8002a3f | 2013-08-14 00:47:08 +0000 | [diff] [blame] | 826 | let Uses = [HI0]; |
Reed Kotler | 2403221 | 2012-10-05 18:27:54 +0000 | [diff] [blame] | 827 | let neverHasSideEffects = 1; |
| 828 | } |
| 829 | |
| 830 | // |
| 831 | // Format: MFLO rx MIPS16e |
| 832 | // Purpose: Move From LO Register |
| 833 | // To copy the special purpose LO register to a GPR. |
| 834 | // |
| 835 | def Mflo16: FRR16_M_ins<0b10010, "mflo", IIAlu> { |
Akira Hatanaka | 8002a3f | 2013-08-14 00:47:08 +0000 | [diff] [blame] | 836 | let Uses = [LO0]; |
Reed Kotler | 2403221 | 2012-10-05 18:27:54 +0000 | [diff] [blame] | 837 | let neverHasSideEffects = 1; |
| 838 | } |
| 839 | |
| 840 | // |
| 841 | // Pseudo Instruction for mult |
| 842 | // |
| 843 | def MultRxRy16: FMULT16_ins<"mult", IIAlu> { |
| 844 | let isCommutable = 1; |
| 845 | let neverHasSideEffects = 1; |
Akira Hatanaka | 8002a3f | 2013-08-14 00:47:08 +0000 | [diff] [blame] | 846 | let Defs = [HI0, LO0]; |
Reed Kotler | 2403221 | 2012-10-05 18:27:54 +0000 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | def MultuRxRy16: FMULT16_ins<"multu", IIAlu> { |
| 850 | let isCommutable = 1; |
| 851 | let neverHasSideEffects = 1; |
Akira Hatanaka | 8002a3f | 2013-08-14 00:47:08 +0000 | [diff] [blame] | 852 | let Defs = [HI0, LO0]; |
Reed Kotler | 2403221 | 2012-10-05 18:27:54 +0000 | [diff] [blame] | 853 | } |
| 854 | |
| 855 | // |
| 856 | // Format: MULT rx, ry MIPS16e |
| 857 | // Purpose: Multiply Word |
| 858 | // To multiply 32-bit signed integers. |
| 859 | // |
| 860 | def MultRxRyRz16: FMULT16_LO_ins<"mult", IIAlu> { |
| 861 | let isCommutable = 1; |
| 862 | let neverHasSideEffects = 1; |
Akira Hatanaka | 8002a3f | 2013-08-14 00:47:08 +0000 | [diff] [blame] | 863 | let Defs = [HI0, LO0]; |
Reed Kotler | 2403221 | 2012-10-05 18:27:54 +0000 | [diff] [blame] | 864 | } |
| 865 | |
| 866 | // |
| 867 | // Format: MULTU rx, ry MIPS16e |
| 868 | // Purpose: Multiply Unsigned Word |
| 869 | // To multiply 32-bit unsigned integers. |
| 870 | // |
| 871 | def MultuRxRyRz16: FMULT16_LO_ins<"multu", IIAlu> { |
| 872 | let isCommutable = 1; |
| 873 | let neverHasSideEffects = 1; |
Akira Hatanaka | 8002a3f | 2013-08-14 00:47:08 +0000 | [diff] [blame] | 874 | let Defs = [HI0, LO0]; |
Reed Kotler | 2403221 | 2012-10-05 18:27:54 +0000 | [diff] [blame] | 875 | } |
| 876 | |
| 877 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 878 | // Format: NEG rx, ry MIPS16e |
| 879 | // Purpose: Negate |
| 880 | // To negate an integer value. |
| 881 | // |
Reed Kotler | 4e1c629 | 2012-10-26 16:18:19 +0000 | [diff] [blame] | 882 | def NegRxRy16: FUnaryRR16_ins<0b11101, "neg", IIAlu>; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 883 | |
| 884 | // |
| 885 | // Format: NOT rx, ry MIPS16e |
| 886 | // Purpose: Not |
| 887 | // To complement an integer value |
| 888 | // |
Reed Kotler | 4e1c629 | 2012-10-26 16:18:19 +0000 | [diff] [blame] | 889 | def NotRxRy16: FUnaryRR16_ins<0b01111, "not", IIAlu>; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 890 | |
| 891 | // |
| 892 | // Format: OR rx, ry MIPS16e |
| 893 | // Purpose: Or |
| 894 | // To do a bitwise logical OR. |
| 895 | // |
| 896 | def OrRxRxRy16: FRxRxRy16_ins<0b01101, "or", IIAlu>, ArithLogic16Defs<1>; |
| 897 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 898 | // |
| 899 | // Format: RESTORE {ra,}{s0/s1/s0-1,}{framesize} |
| 900 | // (All args are optional) MIPS16e |
| 901 | // Purpose: Restore Registers and Deallocate Stack Frame |
| 902 | // To deallocate a stack frame before exit from a subroutine, |
| 903 | // restoring return address and static registers, and adjusting |
| 904 | // stack |
| 905 | // |
| 906 | |
| 907 | // fixed form for restoring RA and the frame |
| 908 | // for direct object emitter, encoding needs to be adjusted for the |
| 909 | // frame size |
| 910 | // |
Akira Hatanaka | cd04e2b | 2012-09-21 01:08:16 +0000 | [diff] [blame] | 911 | let ra=1, s=0,s0=1,s1=1 in |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 912 | def RestoreRaF16: |
| 913 | FI8_SVRS16<0b1, (outs), (ins uimm16:$frame_size), |
Reed Kotler | 9c285b3 | 2013-08-04 23:56:53 +0000 | [diff] [blame] | 914 | "restore\t$$ra, $$s0, $$s1, $$s2, $frame_size", [], IILoad >, MayLoad { |
Reed Kotler | 27a7229 | 2012-10-31 05:21:10 +0000 | [diff] [blame] | 915 | let isCodeGenOnly = 1; |
Reed Kotler | 9c285b3 | 2013-08-04 23:56:53 +0000 | [diff] [blame] | 916 | let Defs = [S0, S1, S2, RA, SP]; |
Reed Kotler | 3aad762 | 2012-12-19 04:06:15 +0000 | [diff] [blame] | 917 | let Uses = [SP]; |
Reed Kotler | 27a7229 | 2012-10-31 05:21:10 +0000 | [diff] [blame] | 918 | } |
| 919 | |
| 920 | // Use Restore to increment SP since SP is not a Mip 16 register, this |
| 921 | // is an easy way to do that which does not require a register. |
| 922 | // |
| 923 | let ra=0, s=0,s0=0,s1=0 in |
| 924 | def RestoreIncSpF16: |
| 925 | FI8_SVRS16<0b1, (outs), (ins uimm16:$frame_size), |
| 926 | "restore\t$frame_size", [], IILoad >, MayLoad { |
Akira Hatanaka | cd04e2b | 2012-09-21 01:08:16 +0000 | [diff] [blame] | 927 | let isCodeGenOnly = 1; |
Reed Kotler | 3aad762 | 2012-12-19 04:06:15 +0000 | [diff] [blame] | 928 | let Defs = [SP]; |
| 929 | let Uses = [SP]; |
Akira Hatanaka | cd04e2b | 2012-09-21 01:08:16 +0000 | [diff] [blame] | 930 | } |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 931 | |
| 932 | // |
| 933 | // Format: SAVE {ra,}{s0/s1/s0-1,}{framesize} (All arguments are optional) |
| 934 | // MIPS16e |
| 935 | // Purpose: Save Registers and Set Up Stack Frame |
| 936 | // To set up a stack frame on entry to a subroutine, |
| 937 | // saving return address and static registers, and adjusting stack |
| 938 | // |
Akira Hatanaka | cd04e2b | 2012-09-21 01:08:16 +0000 | [diff] [blame] | 939 | let ra=1, s=1,s0=1,s1=1 in |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 940 | def SaveRaF16: |
| 941 | FI8_SVRS16<0b1, (outs), (ins uimm16:$frame_size), |
Reed Kotler | 9c285b3 | 2013-08-04 23:56:53 +0000 | [diff] [blame] | 942 | "save\t$$ra, $$s0, $$s1, $$s2, $frame_size", [], IIStore >, MayStore { |
Reed Kotler | 27a7229 | 2012-10-31 05:21:10 +0000 | [diff] [blame] | 943 | let isCodeGenOnly = 1; |
Reed Kotler | 9c285b3 | 2013-08-04 23:56:53 +0000 | [diff] [blame] | 944 | let Uses = [RA, SP, S0, S1, S2]; |
Reed Kotler | 3aad762 | 2012-12-19 04:06:15 +0000 | [diff] [blame] | 945 | let Defs = [SP]; |
Reed Kotler | 27a7229 | 2012-10-31 05:21:10 +0000 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | // |
| 949 | // Use Save to decrement the SP by a constant since SP is not |
| 950 | // a Mips16 register. |
| 951 | // |
| 952 | let ra=0, s=0,s0=0,s1=0 in |
| 953 | def SaveDecSpF16: |
| 954 | FI8_SVRS16<0b1, (outs), (ins uimm16:$frame_size), |
| 955 | "save\t$frame_size", [], IIStore >, MayStore { |
Akira Hatanaka | cd04e2b | 2012-09-21 01:08:16 +0000 | [diff] [blame] | 956 | let isCodeGenOnly = 1; |
Reed Kotler | 3aad762 | 2012-12-19 04:06:15 +0000 | [diff] [blame] | 957 | let Uses = [SP]; |
| 958 | let Defs = [SP]; |
Akira Hatanaka | cd04e2b | 2012-09-21 01:08:16 +0000 | [diff] [blame] | 959 | } |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 960 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 961 | // Format: SB ry, offset(rx) MIPS16e |
| 962 | // Purpose: Store Byte (Extended) |
| 963 | // To store a byte to memory. |
| 964 | // |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 965 | def SbRxRyOffMemX16: |
| 966 | FEXT_RRI16_mem2_ins<0b11000, "sb", mem16, IIStore>, MayStore; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 967 | |
| 968 | // |
Reed Kotler | 445d0ad | 2013-10-07 20:46:19 +0000 | [diff] [blame] | 969 | // Format: SEB rx MIPS16e |
| 970 | // Purpose: Sign-Extend Byte |
| 971 | // Sign-extend least significant byte in register rx. |
| 972 | // |
| 973 | def SebRx16 |
| 974 | : FRR_SF16_ins<0b10001, 0b100, "seb", IIAlu>; |
| 975 | |
| 976 | // |
| 977 | // Format: SEH rx MIPS16e |
| 978 | // Purpose: Sign-Extend Halfword |
| 979 | // Sign-extend least significant word in register rx. |
| 980 | // |
| 981 | def SehRx16 |
| 982 | : FRR_SF16_ins<0b10001, 0b101, "seh", IIAlu>; |
| 983 | |
| 984 | // |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 985 | // The Sel(T) instructions are pseudos |
| 986 | // T means that they use T8 implicitly. |
| 987 | // |
| 988 | // |
| 989 | // Format: SelBeqZ rd, rs, rt |
| 990 | // Purpose: if rt==0, do nothing |
| 991 | // else rs = rt |
| 992 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 993 | def SelBeqZ: Sel<"beqz">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 994 | |
| 995 | // |
| 996 | // Format: SelTBteqZCmp rd, rs, rl, rr |
| 997 | // Purpose: b = Cmp rl, rr. |
| 998 | // If b==0 then do nothing. |
| 999 | // if b!=0 then rd = rs |
| 1000 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1001 | def SelTBteqZCmp: SelT<"bteqz", "cmp">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1002 | |
| 1003 | // |
| 1004 | // Format: SelTBteqZCmpi rd, rs, rl, rr |
| 1005 | // Purpose: b = Cmpi rl, imm. |
| 1006 | // If b==0 then do nothing. |
| 1007 | // if b!=0 then rd = rs |
| 1008 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1009 | def SelTBteqZCmpi: SeliT<"bteqz", "cmpi">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1010 | |
| 1011 | // |
| 1012 | // Format: SelTBteqZSlt rd, rs, rl, rr |
| 1013 | // Purpose: b = Slt rl, rr. |
| 1014 | // If b==0 then do nothing. |
| 1015 | // if b!=0 then rd = rs |
| 1016 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1017 | def SelTBteqZSlt: SelT<"bteqz", "slt">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1018 | |
| 1019 | // |
| 1020 | // Format: SelTBteqZSlti rd, rs, rl, rr |
| 1021 | // Purpose: b = Slti rl, imm. |
| 1022 | // If b==0 then do nothing. |
| 1023 | // if b!=0 then rd = rs |
| 1024 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1025 | def SelTBteqZSlti: SeliT<"bteqz", "slti">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1026 | |
| 1027 | // |
| 1028 | // Format: SelTBteqZSltu rd, rs, rl, rr |
| 1029 | // Purpose: b = Sltu rl, rr. |
| 1030 | // If b==0 then do nothing. |
| 1031 | // if b!=0 then rd = rs |
| 1032 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1033 | def SelTBteqZSltu: SelT<"bteqz", "sltu">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1034 | |
| 1035 | // |
| 1036 | // Format: SelTBteqZSltiu rd, rs, rl, rr |
| 1037 | // Purpose: b = Sltiu rl, imm. |
| 1038 | // If b==0 then do nothing. |
| 1039 | // if b!=0 then rd = rs |
| 1040 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1041 | def SelTBteqZSltiu: SeliT<"bteqz", "sltiu">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1042 | |
| 1043 | // |
| 1044 | // Format: SelBnez rd, rs, rt |
| 1045 | // Purpose: if rt!=0, do nothing |
| 1046 | // else rs = rt |
| 1047 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1048 | def SelBneZ: Sel<"bnez">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1049 | |
| 1050 | // |
| 1051 | // Format: SelTBtneZCmp rd, rs, rl, rr |
| 1052 | // Purpose: b = Cmp rl, rr. |
| 1053 | // If b!=0 then do nothing. |
| 1054 | // if b0=0 then rd = rs |
| 1055 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1056 | def SelTBtneZCmp: SelT<"btnez", "cmp">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1057 | |
| 1058 | // |
| 1059 | // Format: SelTBtnezCmpi rd, rs, rl, rr |
| 1060 | // Purpose: b = Cmpi rl, imm. |
| 1061 | // If b!=0 then do nothing. |
| 1062 | // if b==0 then rd = rs |
| 1063 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1064 | def SelTBtneZCmpi: SeliT<"btnez", "cmpi">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1065 | |
| 1066 | // |
| 1067 | // Format: SelTBtneZSlt rd, rs, rl, rr |
| 1068 | // Purpose: b = Slt rl, rr. |
| 1069 | // If b!=0 then do nothing. |
| 1070 | // if b==0 then rd = rs |
| 1071 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1072 | def SelTBtneZSlt: SelT<"btnez", "slt">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1073 | |
| 1074 | // |
| 1075 | // Format: SelTBtneZSlti rd, rs, rl, rr |
| 1076 | // Purpose: b = Slti rl, imm. |
| 1077 | // If b!=0 then do nothing. |
| 1078 | // if b==0 then rd = rs |
| 1079 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1080 | def SelTBtneZSlti: SeliT<"btnez", "slti">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1081 | |
| 1082 | // |
| 1083 | // Format: SelTBtneZSltu rd, rs, rl, rr |
| 1084 | // Purpose: b = Sltu rl, rr. |
| 1085 | // If b!=0 then do nothing. |
| 1086 | // if b==0 then rd = rs |
| 1087 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1088 | def SelTBtneZSltu: SelT<"btnez", "sltu">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1089 | |
| 1090 | // |
| 1091 | // Format: SelTBtneZSltiu rd, rs, rl, rr |
| 1092 | // Purpose: b = Slti rl, imm. |
| 1093 | // If b!=0 then do nothing. |
| 1094 | // if b==0 then rd = rs |
| 1095 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1096 | def SelTBtneZSltiu: SeliT<"btnez", "sltiu">; |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1097 | // |
| 1098 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1099 | // Format: SH ry, offset(rx) MIPS16e |
| 1100 | // Purpose: Store Halfword (Extended) |
| 1101 | // To store a halfword to memory. |
| 1102 | // |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 1103 | def ShRxRyOffMemX16: |
| 1104 | FEXT_RRI16_mem2_ins<0b11001, "sh", mem16, IIStore>, MayStore; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1105 | |
| 1106 | // |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 1107 | // Format: SLL rx, ry, sa MIPS16e |
| 1108 | // Purpose: Shift Word Left Logical (Extended) |
NAKAMURA Takumi | 8a04643 | 2013-10-28 04:07:38 +0000 | [diff] [blame^] | 1109 | // To execute a left-shift of a word by a fixed number of bits-0 to 31 bits. |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 1110 | // |
| 1111 | def SllX16: FEXT_SHIFT16_ins<0b00, "sll", IIAlu>; |
| 1112 | |
| 1113 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1114 | // Format: SLLV ry, rx MIPS16e |
| 1115 | // Purpose: Shift Word Left Logical Variable |
| 1116 | // To execute a left-shift of a word by a variable number of bits. |
| 1117 | // |
| 1118 | def SllvRxRy16 : FRxRxRy16_ins<0b00100, "sllv", IIAlu>; |
| 1119 | |
Reed Kotler | 3e457f5 | 2013-02-19 03:56:57 +0000 | [diff] [blame] | 1120 | // Format: SLTI rx, immediate MIPS16e |
| 1121 | // Purpose: Set on Less Than Immediate |
| 1122 | // To record the result of a less-than comparison with a constant. |
| 1123 | // |
| 1124 | // |
Reed Kotler | 7b503c2 | 2013-02-20 05:45:15 +0000 | [diff] [blame] | 1125 | def SltiRxImm16: FRI16R_ins<0b01010, "slti", IIAlu> { |
Reed Kotler | 3e457f5 | 2013-02-19 03:56:57 +0000 | [diff] [blame] | 1126 | let Defs = [T8]; |
| 1127 | } |
| 1128 | |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1129 | // |
| 1130 | // Format: SLTI rx, immediate MIPS16e |
| 1131 | // Purpose: Set on Less Than Immediate (Extended) |
| 1132 | // To record the result of a less-than comparison with a constant. |
| 1133 | // |
Reed Kotler | 3e457f5 | 2013-02-19 03:56:57 +0000 | [diff] [blame] | 1134 | // |
Reed Kotler | 7b503c2 | 2013-02-20 05:45:15 +0000 | [diff] [blame] | 1135 | def SltiRxImmX16: FEXT_RI16R_ins<0b01010, "slti", IIAlu> { |
Reed Kotler | 3e457f5 | 2013-02-19 03:56:57 +0000 | [diff] [blame] | 1136 | let Defs = [T8]; |
| 1137 | } |
| 1138 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1139 | def SltiCCRxImmX16: FEXT_CCRXI16_ins<"slti">; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1140 | |
Reed Kotler | 3e457f5 | 2013-02-19 03:56:57 +0000 | [diff] [blame] | 1141 | // Format: SLTIU rx, immediate MIPS16e |
| 1142 | // Purpose: Set on Less Than Immediate Unsigned |
| 1143 | // To record the result of a less-than comparison with a constant. |
| 1144 | // |
| 1145 | // |
Reed Kotler | 7b503c2 | 2013-02-20 05:45:15 +0000 | [diff] [blame] | 1146 | def SltiuRxImm16: FRI16R_ins<0b01011, "sltiu", IIAlu> { |
Reed Kotler | 3e457f5 | 2013-02-19 03:56:57 +0000 | [diff] [blame] | 1147 | let Defs = [T8]; |
| 1148 | } |
| 1149 | |
| 1150 | // |
| 1151 | // Format: SLTI rx, immediate MIPS16e |
| 1152 | // Purpose: Set on Less Than Immediate Unsigned (Extended) |
| 1153 | // To record the result of a less-than comparison with a constant. |
| 1154 | // |
| 1155 | // |
Reed Kotler | 7b503c2 | 2013-02-20 05:45:15 +0000 | [diff] [blame] | 1156 | def SltiuRxImmX16: FEXT_RI16R_ins<0b01011, "sltiu", IIAlu> { |
Reed Kotler | 3e457f5 | 2013-02-19 03:56:57 +0000 | [diff] [blame] | 1157 | let Defs = [T8]; |
| 1158 | } |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1159 | // |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1160 | // Format: SLTIU rx, immediate MIPS16e |
| 1161 | // Purpose: Set on Less Than Immediate Unsigned (Extended) |
| 1162 | // To record the result of a less-than comparison with a constant. |
| 1163 | // |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1164 | def SltiuCCRxImmX16: FEXT_CCRXI16_ins<"sltiu">; |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1165 | |
| 1166 | // |
| 1167 | // Format: SLT rx, ry MIPS16e |
| 1168 | // Purpose: Set on Less Than |
| 1169 | // To record the result of a less-than comparison. |
| 1170 | // |
Reed Kotler | 80070bd | 2013-02-23 23:37:03 +0000 | [diff] [blame] | 1171 | def SltRxRy16: FRR16R_ins<0b00010, "slt", IIAlu>{ |
Reed Kotler | 7b503c2 | 2013-02-20 05:45:15 +0000 | [diff] [blame] | 1172 | let Defs = [T8]; |
| 1173 | } |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1174 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1175 | def SltCCRxRy16: FCCRR16_ins<"slt">; |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1176 | |
| 1177 | // Format: SLTU rx, ry MIPS16e |
| 1178 | // Purpose: Set on Less Than Unsigned |
| 1179 | // To record the result of an unsigned less-than comparison. |
| 1180 | // |
Reed Kotler | 80070bd | 2013-02-23 23:37:03 +0000 | [diff] [blame] | 1181 | def SltuRxRy16: FRR16R_ins<0b00011, "sltu", IIAlu>{ |
Reed Kotler | 7b503c2 | 2013-02-20 05:45:15 +0000 | [diff] [blame] | 1182 | let Defs = [T8]; |
| 1183 | } |
Reed Kotler | 6879e56 | 2013-02-18 04:55:38 +0000 | [diff] [blame] | 1184 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1185 | def SltuRxRyRz16: FRRTR16_ins<"sltu"> { |
Reed Kotler | 287f044 | 2012-10-26 04:46:26 +0000 | [diff] [blame] | 1186 | let isCodeGenOnly=1; |
Reed Kotler | 7b503c2 | 2013-02-20 05:45:15 +0000 | [diff] [blame] | 1187 | let Defs = [T8]; |
Reed Kotler | 287f044 | 2012-10-26 04:46:26 +0000 | [diff] [blame] | 1188 | } |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1189 | |
| 1190 | |
Reed Kotler | 61b474f | 2013-02-16 23:39:52 +0000 | [diff] [blame] | 1191 | def SltuCCRxRy16: FCCRR16_ins<"sltu">; |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1192 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1193 | // Format: SRAV ry, rx MIPS16e |
| 1194 | // Purpose: Shift Word Right Arithmetic Variable |
| 1195 | // To execute an arithmetic right-shift of a word by a variable |
| 1196 | // number of bits. |
| 1197 | // |
| 1198 | def SravRxRy16: FRxRxRy16_ins<0b00111, "srav", IIAlu>; |
| 1199 | |
| 1200 | |
| 1201 | // |
| 1202 | // Format: SRA rx, ry, sa MIPS16e |
| 1203 | // Purpose: Shift Word Right Arithmetic (Extended) |
| 1204 | // To execute an arithmetic right-shift of a word by a fixed |
NAKAMURA Takumi | 8a04643 | 2013-10-28 04:07:38 +0000 | [diff] [blame^] | 1205 | // number of bits-1 to 8 bits. |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1206 | // |
| 1207 | def SraX16: FEXT_SHIFT16_ins<0b11, "sra", IIAlu>; |
| 1208 | |
| 1209 | |
| 1210 | // |
| 1211 | // Format: SRLV ry, rx MIPS16e |
| 1212 | // Purpose: Shift Word Right Logical Variable |
| 1213 | // To execute a logical right-shift of a word by a variable |
| 1214 | // number of bits. |
| 1215 | // |
| 1216 | def SrlvRxRy16: FRxRxRy16_ins<0b00110, "srlv", IIAlu>; |
| 1217 | |
| 1218 | |
| 1219 | // |
| 1220 | // Format: SRL rx, ry, sa MIPS16e |
| 1221 | // Purpose: Shift Word Right Logical (Extended) |
| 1222 | // To execute a logical right-shift of a word by a fixed |
NAKAMURA Takumi | 8a04643 | 2013-10-28 04:07:38 +0000 | [diff] [blame^] | 1223 | // number of bits-1 to 31 bits. |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1224 | // |
| 1225 | def SrlX16: FEXT_SHIFT16_ins<0b10, "srl", IIAlu>; |
| 1226 | |
| 1227 | // |
| 1228 | // Format: SUBU rz, rx, ry MIPS16e |
| 1229 | // Purpose: Subtract Unsigned Word |
| 1230 | // To subtract 32-bit integers |
| 1231 | // |
| 1232 | def SubuRxRyRz16: FRRR16_ins<0b11, "subu", IIAlu>, ArithLogic16Defs<0>; |
| 1233 | |
| 1234 | // |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 1235 | // Format: SW ry, offset(rx) MIPS16e |
| 1236 | // Purpose: Store Word (Extended) |
| 1237 | // To store a word to memory. |
| 1238 | // |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 1239 | def SwRxRyOffMemX16: |
| 1240 | FEXT_RRI16_mem2_ins<0b11011, "sw", mem16, IIStore>, MayStore; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1241 | |
| 1242 | // |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 1243 | // Format: SW rx, offset(sp) MIPS16e |
| 1244 | // Purpose: Store Word rx (SP-Relative) |
| 1245 | // To store an SP-relative word to memory. |
| 1246 | // |
Reed Kotler | 30cedf6 | 2013-08-04 01:13:25 +0000 | [diff] [blame] | 1247 | def SwRxSpImmX16: FEXT_RI16_SP_Store_explicit_ins |
| 1248 | <0b11010, "sw", IIStore>, MayStore; |
Reed Kotler | 210ebe9 | 2012-09-28 02:26:24 +0000 | [diff] [blame] | 1249 | |
| 1250 | // |
| 1251 | // |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1252 | // Format: XOR rx, ry MIPS16e |
| 1253 | // Purpose: Xor |
| 1254 | // To do a bitwise logical XOR. |
| 1255 | // |
| 1256 | def XorRxRxRy16: FRxRxRy16_ins<0b01110, "xor", IIAlu>, ArithLogic16Defs<1>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 1257 | |
Akira Hatanaka | 765c312 | 2012-06-21 20:39:10 +0000 | [diff] [blame] | 1258 | class Mips16Pat<dag pattern, dag result> : Pat<pattern, result> { |
| 1259 | let Predicates = [InMips16Mode]; |
| 1260 | } |
| 1261 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1262 | // Unary Arith/Logic |
| 1263 | // |
| 1264 | class ArithLogicU_pat<PatFrag OpNode, Instruction I> : |
| 1265 | Mips16Pat<(OpNode CPU16Regs:$r), |
| 1266 | (I CPU16Regs:$r)>; |
Akira Hatanaka | bff8e31 | 2012-05-31 02:59:44 +0000 | [diff] [blame] | 1267 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1268 | def: ArithLogicU_pat<not, NotRxRy16>; |
| 1269 | def: ArithLogicU_pat<ineg, NegRxRy16>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 1270 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1271 | class ArithLogic16_pat<SDNode OpNode, Instruction I> : |
| 1272 | Mips16Pat<(OpNode CPU16Regs:$l, CPU16Regs:$r), |
| 1273 | (I CPU16Regs:$l, CPU16Regs:$r)>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 1274 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1275 | def: ArithLogic16_pat<add, AdduRxRyRz16>; |
| 1276 | def: ArithLogic16_pat<and, AndRxRxRy16>; |
Reed Kotler | 2403221 | 2012-10-05 18:27:54 +0000 | [diff] [blame] | 1277 | def: ArithLogic16_pat<mul, MultRxRyRz16>; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1278 | def: ArithLogic16_pat<or, OrRxRxRy16>; |
| 1279 | def: ArithLogic16_pat<sub, SubuRxRyRz16>; |
| 1280 | def: ArithLogic16_pat<xor, XorRxRxRy16>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 1281 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1282 | // Arithmetic and logical instructions with 2 register operands. |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 1283 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1284 | class ArithLogicI16_pat<SDNode OpNode, PatFrag imm_type, Instruction I> : |
| 1285 | Mips16Pat<(OpNode CPU16Regs:$in, imm_type:$imm), |
| 1286 | (I CPU16Regs:$in, imm_type:$imm)>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 1287 | |
Reed Kotler | b9bf8dc | 2013-02-08 21:42:56 +0000 | [diff] [blame] | 1288 | def: ArithLogicI16_pat<add, immSExt8, AddiuRxRxImm16>; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1289 | def: ArithLogicI16_pat<add, immSExt16, AddiuRxRxImmX16>; |
| 1290 | def: ArithLogicI16_pat<shl, immZExt5, SllX16>; |
| 1291 | def: ArithLogicI16_pat<srl, immZExt5, SrlX16>; |
| 1292 | def: ArithLogicI16_pat<sra, immZExt5, SraX16>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 1293 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1294 | class shift_rotate_reg16_pat<SDNode OpNode, Instruction I> : |
| 1295 | Mips16Pat<(OpNode CPU16Regs:$r, CPU16Regs:$ra), |
| 1296 | (I CPU16Regs:$r, CPU16Regs:$ra)>; |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 1297 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1298 | def: shift_rotate_reg16_pat<shl, SllvRxRy16>; |
| 1299 | def: shift_rotate_reg16_pat<sra, SravRxRy16>; |
| 1300 | def: shift_rotate_reg16_pat<srl, SrlvRxRy16>; |
| 1301 | |
| 1302 | class LoadM16_pat<PatFrag OpNode, Instruction I> : |
Reed Kotler | 3589dd7 | 2012-10-28 06:02:37 +0000 | [diff] [blame] | 1303 | Mips16Pat<(OpNode addr16:$addr), (I addr16:$addr)>; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1304 | |
| 1305 | def: LoadM16_pat<sextloadi8, LbRxRyOffMemX16>; |
| 1306 | def: LoadM16_pat<zextloadi8, LbuRxRyOffMemX16>; |
Akira Hatanaka | 3e7ba76 | 2012-09-15 01:52:08 +0000 | [diff] [blame] | 1307 | def: LoadM16_pat<sextloadi16, LhRxRyOffMemX16>; |
| 1308 | def: LoadM16_pat<zextloadi16, LhuRxRyOffMemX16>; |
| 1309 | def: LoadM16_pat<load, LwRxRyOffMemX16>; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1310 | |
| 1311 | class StoreM16_pat<PatFrag OpNode, Instruction I> : |
Reed Kotler | 3589dd7 | 2012-10-28 06:02:37 +0000 | [diff] [blame] | 1312 | Mips16Pat<(OpNode CPU16Regs:$r, addr16:$addr), |
| 1313 | (I CPU16Regs:$r, addr16:$addr)>; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1314 | |
| 1315 | def: StoreM16_pat<truncstorei8, SbRxRyOffMemX16>; |
Akira Hatanaka | 3e7ba76 | 2012-09-15 01:52:08 +0000 | [diff] [blame] | 1316 | def: StoreM16_pat<truncstorei16, ShRxRyOffMemX16>; |
| 1317 | def: StoreM16_pat<store, SwRxRyOffMemX16>; |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1318 | |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 1319 | // Unconditional branch |
| 1320 | class UncondBranch16_pat<SDNode OpNode, Instruction I>: |
| 1321 | Mips16Pat<(OpNode bb:$imm16), (I bb:$imm16)> { |
Reed Kotler | ec60f7d | 2013-02-07 03:49:51 +0000 | [diff] [blame] | 1322 | let Predicates = [InMips16Mode]; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 1323 | } |
Akira Hatanaka | bff8e31 | 2012-05-31 02:59:44 +0000 | [diff] [blame] | 1324 | |
Reed Kotler | f8933f8 | 2013-02-02 04:07:35 +0000 | [diff] [blame] | 1325 | def : Mips16Pat<(MipsJmpLink (i32 tglobaladdr:$dst)), |
| 1326 | (Jal16 tglobaladdr:$dst)>; |
| 1327 | |
Reed Kotler | 4a230ff | 2013-02-07 04:34:51 +0000 | [diff] [blame] | 1328 | def : Mips16Pat<(MipsJmpLink (i32 texternalsym:$dst)), |
| 1329 | (Jal16 texternalsym:$dst)>; |
| 1330 | |
Reed Kotler | e6c3157 | 2012-10-28 23:08:07 +0000 | [diff] [blame] | 1331 | // Indirect branch |
| 1332 | def: Mips16Pat< |
Jack Carter | 7ab15fa | 2013-01-19 02:00:40 +0000 | [diff] [blame] | 1333 | (brind CPU16Regs:$rs), |
| 1334 | (JrcRx16 CPU16Regs:$rs)>; |
Reed Kotler | e6c3157 | 2012-10-28 23:08:07 +0000 | [diff] [blame] | 1335 | |
Akira Hatanaka | bff8e31 | 2012-05-31 02:59:44 +0000 | [diff] [blame] | 1336 | // Jump and Link (Call) |
Reed Kotler | a811753 | 2012-10-30 00:54:49 +0000 | [diff] [blame] | 1337 | let isCall=1, hasDelaySlot=0 in |
Akira Hatanaka | bff8e31 | 2012-05-31 02:59:44 +0000 | [diff] [blame] | 1338 | def JumpLinkReg16: |
Akira Hatanaka | f640f04 | 2012-07-17 22:55:34 +0000 | [diff] [blame] | 1339 | FRR16_JALRC<0, 0, 0, (outs), (ins CPU16Regs:$rs), |
Reed Kotler | a811753 | 2012-10-30 00:54:49 +0000 | [diff] [blame] | 1340 | "jalrc \t$rs", [(MipsJmpLink CPU16Regs:$rs)], IIBranch>; |
Akira Hatanaka | f640f04 | 2012-07-17 22:55:34 +0000 | [diff] [blame] | 1341 | |
Akira Hatanaka | 26e9ecb | 2012-07-23 23:45:54 +0000 | [diff] [blame] | 1342 | // Mips16 pseudos |
| 1343 | let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1, hasCtrlDep=1, |
| 1344 | hasExtraSrcRegAllocReq = 1 in |
| 1345 | def RetRA16 : MipsPseudo16<(outs), (ins), "", [(MipsRet)]>; |
| 1346 | |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 1347 | |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1348 | // setcc patterns |
| 1349 | |
| 1350 | class SetCC_R16<PatFrag cond_op, Instruction I>: |
| 1351 | Mips16Pat<(cond_op CPU16Regs:$rx, CPU16Regs:$ry), |
| 1352 | (I CPU16Regs:$rx, CPU16Regs:$ry)>; |
| 1353 | |
| 1354 | class SetCC_I16<PatFrag cond_op, PatLeaf imm_type, Instruction I>: |
| 1355 | Mips16Pat<(cond_op CPU16Regs:$rx, imm_type:$imm16), |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1356 | (I CPU16Regs:$rx, imm_type:$imm16)>; |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1357 | |
Reed Kotler | 3589dd7 | 2012-10-28 06:02:37 +0000 | [diff] [blame] | 1358 | |
| 1359 | def: Mips16Pat<(i32 addr16:$addr), |
| 1360 | (AddiuRxRyOffMemX16 addr16:$addr)>; |
| 1361 | |
| 1362 | |
Reed Kotler | e47873a | 2012-10-26 03:09:34 +0000 | [diff] [blame] | 1363 | // Large (>16 bit) immediate loads |
Reed Kotler | 91ae982 | 2013-10-27 21:57:36 +0000 | [diff] [blame] | 1364 | def : Mips16Pat<(i32 imm:$imm), (LwConstant32 imm:$imm, -1)>; |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1365 | |
Reed Kotler | 287f044 | 2012-10-26 04:46:26 +0000 | [diff] [blame] | 1366 | // Carry MipsPatterns |
| 1367 | def : Mips16Pat<(subc CPU16Regs:$lhs, CPU16Regs:$rhs), |
| 1368 | (SubuRxRyRz16 CPU16Regs:$lhs, CPU16Regs:$rhs)>; |
| 1369 | def : Mips16Pat<(addc CPU16Regs:$lhs, CPU16Regs:$rhs), |
| 1370 | (AdduRxRyRz16 CPU16Regs:$lhs, CPU16Regs:$rhs)>; |
| 1371 | def : Mips16Pat<(addc CPU16Regs:$src, immSExt16:$imm), |
| 1372 | (AddiuRxRxImmX16 CPU16Regs:$src, imm:$imm)>; |
| 1373 | |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 1374 | // |
| 1375 | // Some branch conditional patterns are not generated by llvm at this time. |
| 1376 | // Some are for seemingly arbitrary reasons not used: i.e. with signed number |
| 1377 | // comparison they are used and for unsigned a different pattern is used. |
| 1378 | // I am pushing upstream from the full mips16 port and it seemed that I needed |
| 1379 | // these earlier and the mips32 port has these but now I cannot create test |
| 1380 | // cases that use these patterns. While I sort this all out I will leave these |
| 1381 | // extra patterns commented out and if I can be sure they are really not used, |
| 1382 | // I will delete the code. I don't want to check the code in uncommented without |
| 1383 | // a valid test case. In some cases, the compiler is generating patterns with |
| 1384 | // setcc instead and earlier I had implemented setcc first so may have masked |
| 1385 | // the problem. The setcc variants are suboptimal for mips16 so I may wantto |
| 1386 | // figure out how to enable the brcond patterns or else possibly new |
| 1387 | // combinations of of brcond and setcc. |
| 1388 | // |
| 1389 | // |
| 1390 | // bcond-seteq |
| 1391 | // |
| 1392 | def: Mips16Pat |
| 1393 | <(brcond (i32 (seteq CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), |
| 1394 | (BteqzT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) |
| 1395 | >; |
| 1396 | |
| 1397 | |
| 1398 | def: Mips16Pat |
| 1399 | <(brcond (i32 (seteq CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16), |
| 1400 | (BteqzT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$targ16) |
| 1401 | >; |
| 1402 | |
| 1403 | def: Mips16Pat |
| 1404 | <(brcond (i32 (seteq CPU16Regs:$rx, 0)), bb:$targ16), |
| 1405 | (BeqzRxImmX16 CPU16Regs:$rx, bb:$targ16) |
| 1406 | >; |
| 1407 | |
| 1408 | // |
| 1409 | // bcond-setgt (do we need to have this pair of setlt, setgt??) |
| 1410 | // |
| 1411 | def: Mips16Pat |
| 1412 | <(brcond (i32 (setgt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), |
| 1413 | (BtnezT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16) |
| 1414 | >; |
| 1415 | |
| 1416 | // |
| 1417 | // bcond-setge |
| 1418 | // |
| 1419 | def: Mips16Pat |
| 1420 | <(brcond (i32 (setge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), |
| 1421 | (BteqzT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) |
| 1422 | >; |
| 1423 | |
| 1424 | // |
| 1425 | // never called because compiler transforms a >= k to a > (k-1) |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1426 | def: Mips16Pat |
| 1427 | <(brcond (i32 (setge CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16), |
| 1428 | (BteqzT8SltiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$imm16) |
| 1429 | >; |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 1430 | |
| 1431 | // |
| 1432 | // bcond-setlt |
| 1433 | // |
| 1434 | def: Mips16Pat |
| 1435 | <(brcond (i32 (setlt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), |
| 1436 | (BtnezT8SltX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) |
| 1437 | >; |
| 1438 | |
| 1439 | def: Mips16Pat |
| 1440 | <(brcond (i32 (setlt CPU16Regs:$rx, immSExt16:$imm)), bb:$imm16), |
| 1441 | (BtnezT8SltiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$imm16) |
| 1442 | >; |
| 1443 | |
| 1444 | // |
| 1445 | // bcond-setle |
| 1446 | // |
| 1447 | def: Mips16Pat |
| 1448 | <(brcond (i32 (setle CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), |
| 1449 | (BteqzT8SltX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16) |
| 1450 | >; |
| 1451 | |
| 1452 | // |
| 1453 | // bcond-setne |
| 1454 | // |
| 1455 | def: Mips16Pat |
| 1456 | <(brcond (i32 (setne CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), |
| 1457 | (BtnezT8CmpX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) |
| 1458 | >; |
| 1459 | |
| 1460 | def: Mips16Pat |
| 1461 | <(brcond (i32 (setne CPU16Regs:$rx, immZExt16:$imm)), bb:$targ16), |
| 1462 | (BtnezT8CmpiX16 CPU16Regs:$rx, immSExt16:$imm, bb:$targ16) |
| 1463 | >; |
| 1464 | |
| 1465 | def: Mips16Pat |
| 1466 | <(brcond (i32 (setne CPU16Regs:$rx, 0)), bb:$targ16), |
| 1467 | (BnezRxImmX16 CPU16Regs:$rx, bb:$targ16) |
| 1468 | >; |
| 1469 | |
| 1470 | // |
| 1471 | // This needs to be there but I forget which code will generate it |
| 1472 | // |
| 1473 | def: Mips16Pat |
| 1474 | <(brcond CPU16Regs:$rx, bb:$targ16), |
| 1475 | (BnezRxImmX16 CPU16Regs:$rx, bb:$targ16) |
| 1476 | >; |
| 1477 | |
| 1478 | // |
| 1479 | |
| 1480 | // |
| 1481 | // bcond-setugt |
| 1482 | // |
| 1483 | //def: Mips16Pat |
| 1484 | // <(brcond (i32 (setugt CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), |
| 1485 | // (BtnezT8SltuX16 CPU16Regs:$ry, CPU16Regs:$rx, bb:$imm16) |
| 1486 | // >; |
| 1487 | |
| 1488 | // |
| 1489 | // bcond-setuge |
| 1490 | // |
| 1491 | //def: Mips16Pat |
| 1492 | // <(brcond (i32 (setuge CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), |
| 1493 | // (BteqzT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) |
| 1494 | // >; |
| 1495 | |
| 1496 | |
| 1497 | // |
| 1498 | // bcond-setult |
| 1499 | // |
| 1500 | //def: Mips16Pat |
| 1501 | // <(brcond (i32 (setult CPU16Regs:$rx, CPU16Regs:$ry)), bb:$imm16), |
| 1502 | // (BtnezT8SltuX16 CPU16Regs:$rx, CPU16Regs:$ry, bb:$imm16) |
| 1503 | // >; |
| 1504 | |
| 1505 | def: UncondBranch16_pat<br, BimmX16>; |
| 1506 | |
Akira Hatanaka | 765c312 | 2012-06-21 20:39:10 +0000 | [diff] [blame] | 1507 | // Small immediates |
Reed Kotler | 6743924 | 2012-10-17 22:29:54 +0000 | [diff] [blame] | 1508 | def: Mips16Pat<(i32 immSExt16:$in), |
| 1509 | (AddiuRxRxImmX16 (Move32R16 ZERO), immSExt16:$in)>; |
| 1510 | |
Akira Hatanaka | 22bec28 | 2012-08-03 22:57:02 +0000 | [diff] [blame] | 1511 | def: Mips16Pat<(i32 immZExt16:$in), (LiRxImmX16 immZExt16:$in)>; |
Akira Hatanaka | 64626fc | 2012-07-26 02:24:43 +0000 | [diff] [blame] | 1512 | |
Reed Kotler | cf11c59 | 2012-10-12 02:01:09 +0000 | [diff] [blame] | 1513 | // |
| 1514 | // MipsDivRem |
| 1515 | // |
| 1516 | def: Mips16Pat |
Akira Hatanaka | be8612f | 2013-03-30 01:36:35 +0000 | [diff] [blame] | 1517 | <(MipsDivRem16 CPU16Regs:$rx, CPU16Regs:$ry), |
Reed Kotler | cf11c59 | 2012-10-12 02:01:09 +0000 | [diff] [blame] | 1518 | (DivRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>; |
| 1519 | |
| 1520 | // |
| 1521 | // MipsDivRemU |
| 1522 | // |
| 1523 | def: Mips16Pat |
Akira Hatanaka | be8612f | 2013-03-30 01:36:35 +0000 | [diff] [blame] | 1524 | <(MipsDivRemU16 CPU16Regs:$rx, CPU16Regs:$ry), |
Reed Kotler | cf11c59 | 2012-10-12 02:01:09 +0000 | [diff] [blame] | 1525 | (DivuRxRy16 CPU16Regs:$rx, CPU16Regs:$ry)>; |
| 1526 | |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1527 | // signed a,b |
| 1528 | // x = (a>=b)?x:y |
| 1529 | // |
| 1530 | // if !(a < b) x = y |
| 1531 | // |
| 1532 | def : Mips16Pat<(select (i32 (setge CPU16Regs:$a, CPU16Regs:$b)), |
| 1533 | CPU16Regs:$x, CPU16Regs:$y), |
| 1534 | (SelTBteqZSlt CPU16Regs:$x, CPU16Regs:$y, |
| 1535 | CPU16Regs:$a, CPU16Regs:$b)>; |
| 1536 | |
| 1537 | // signed a,b |
| 1538 | // x = (a>b)?x:y |
| 1539 | // |
| 1540 | // if (b < a) x = y |
| 1541 | // |
| 1542 | def : Mips16Pat<(select (i32 (setgt CPU16Regs:$a, CPU16Regs:$b)), |
| 1543 | CPU16Regs:$x, CPU16Regs:$y), |
| 1544 | (SelTBtneZSlt CPU16Regs:$x, CPU16Regs:$y, |
| 1545 | CPU16Regs:$b, CPU16Regs:$a)>; |
| 1546 | |
| 1547 | // unsigned a,b |
| 1548 | // x = (a>=b)?x:y |
| 1549 | // |
| 1550 | // if !(a < b) x = y; |
| 1551 | // |
| 1552 | def : Mips16Pat< |
| 1553 | (select (i32 (setuge CPU16Regs:$a, CPU16Regs:$b)), |
| 1554 | CPU16Regs:$x, CPU16Regs:$y), |
| 1555 | (SelTBteqZSltu CPU16Regs:$x, CPU16Regs:$y, |
| 1556 | CPU16Regs:$a, CPU16Regs:$b)>; |
| 1557 | |
| 1558 | // unsigned a,b |
| 1559 | // x = (a>b)?x:y |
| 1560 | // |
| 1561 | // if (b < a) x = y |
| 1562 | // |
| 1563 | def : Mips16Pat<(select (i32 (setugt CPU16Regs:$a, CPU16Regs:$b)), |
| 1564 | CPU16Regs:$x, CPU16Regs:$y), |
| 1565 | (SelTBtneZSltu CPU16Regs:$x, CPU16Regs:$y, |
| 1566 | CPU16Regs:$b, CPU16Regs:$a)>; |
| 1567 | |
| 1568 | // signed |
| 1569 | // x = (a >= k)?x:y |
| 1570 | // due to an llvm optimization, i don't think that this will ever |
| 1571 | // be used. This is transformed into x = (a > k-1)?x:y |
| 1572 | // |
| 1573 | // |
| 1574 | |
| 1575 | //def : Mips16Pat< |
| 1576 | // (select (i32 (setge CPU16Regs:$lhs, immSExt16:$rhs)), |
| 1577 | // CPU16Regs:$T, CPU16Regs:$F), |
| 1578 | // (SelTBteqZSlti CPU16Regs:$T, CPU16Regs:$F, |
| 1579 | // CPU16Regs:$lhs, immSExt16:$rhs)>; |
| 1580 | |
| 1581 | //def : Mips16Pat< |
| 1582 | // (select (i32 (setuge CPU16Regs:$lhs, immSExt16:$rhs)), |
| 1583 | // CPU16Regs:$T, CPU16Regs:$F), |
| 1584 | // (SelTBteqZSltiu CPU16Regs:$T, CPU16Regs:$F, |
| 1585 | // CPU16Regs:$lhs, immSExt16:$rhs)>; |
| 1586 | |
| 1587 | // signed |
| 1588 | // x = (a < k)?x:y |
| 1589 | // |
| 1590 | // if !(a < k) x = y; |
| 1591 | // |
| 1592 | def : Mips16Pat< |
| 1593 | (select (i32 (setlt CPU16Regs:$a, immSExt16:$b)), |
| 1594 | CPU16Regs:$x, CPU16Regs:$y), |
| 1595 | (SelTBtneZSlti CPU16Regs:$x, CPU16Regs:$y, |
| 1596 | CPU16Regs:$a, immSExt16:$b)>; |
| 1597 | |
| 1598 | |
| 1599 | // |
| 1600 | // |
| 1601 | // signed |
| 1602 | // x = (a <= b)? x : y |
| 1603 | // |
| 1604 | // if (b < a) x = y |
| 1605 | // |
| 1606 | def : Mips16Pat<(select (i32 (setle CPU16Regs:$a, CPU16Regs:$b)), |
| 1607 | CPU16Regs:$x, CPU16Regs:$y), |
| 1608 | (SelTBteqZSlt CPU16Regs:$x, CPU16Regs:$y, |
| 1609 | CPU16Regs:$b, CPU16Regs:$a)>; |
| 1610 | |
| 1611 | // |
| 1612 | // unnsigned |
| 1613 | // x = (a <= b)? x : y |
| 1614 | // |
| 1615 | // if (b < a) x = y |
| 1616 | // |
| 1617 | def : Mips16Pat<(select (i32 (setule CPU16Regs:$a, CPU16Regs:$b)), |
| 1618 | CPU16Regs:$x, CPU16Regs:$y), |
| 1619 | (SelTBteqZSltu CPU16Regs:$x, CPU16Regs:$y, |
| 1620 | CPU16Regs:$b, CPU16Regs:$a)>; |
| 1621 | |
| 1622 | // |
| 1623 | // signed/unsigned |
| 1624 | // x = (a == b)? x : y |
| 1625 | // |
| 1626 | // if (a != b) x = y |
| 1627 | // |
| 1628 | def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, CPU16Regs:$b)), |
| 1629 | CPU16Regs:$x, CPU16Regs:$y), |
| 1630 | (SelTBteqZCmp CPU16Regs:$x, CPU16Regs:$y, |
| 1631 | CPU16Regs:$b, CPU16Regs:$a)>; |
| 1632 | |
| 1633 | // |
| 1634 | // signed/unsigned |
| 1635 | // x = (a == 0)? x : y |
| 1636 | // |
| 1637 | // if (a != 0) x = y |
| 1638 | // |
| 1639 | def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, 0)), |
| 1640 | CPU16Regs:$x, CPU16Regs:$y), |
| 1641 | (SelBeqZ CPU16Regs:$x, CPU16Regs:$y, |
| 1642 | CPU16Regs:$a)>; |
| 1643 | |
| 1644 | |
| 1645 | // |
| 1646 | // signed/unsigned |
| 1647 | // x = (a == k)? x : y |
| 1648 | // |
| 1649 | // if (a != k) x = y |
| 1650 | // |
| 1651 | def : Mips16Pat<(select (i32 (seteq CPU16Regs:$a, immZExt16:$k)), |
| 1652 | CPU16Regs:$x, CPU16Regs:$y), |
| 1653 | (SelTBteqZCmpi CPU16Regs:$x, CPU16Regs:$y, |
| 1654 | CPU16Regs:$a, immZExt16:$k)>; |
| 1655 | |
| 1656 | |
| 1657 | // |
| 1658 | // signed/unsigned |
| 1659 | // x = (a != b)? x : y |
| 1660 | // |
| 1661 | // if (a == b) x = y |
| 1662 | // |
| 1663 | // |
| 1664 | def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, CPU16Regs:$b)), |
| 1665 | CPU16Regs:$x, CPU16Regs:$y), |
| 1666 | (SelTBtneZCmp CPU16Regs:$x, CPU16Regs:$y, |
| 1667 | CPU16Regs:$b, CPU16Regs:$a)>; |
| 1668 | |
| 1669 | // |
| 1670 | // signed/unsigned |
| 1671 | // x = (a != 0)? x : y |
| 1672 | // |
| 1673 | // if (a == 0) x = y |
| 1674 | // |
| 1675 | def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, 0)), |
| 1676 | CPU16Regs:$x, CPU16Regs:$y), |
| 1677 | (SelBneZ CPU16Regs:$x, CPU16Regs:$y, |
| 1678 | CPU16Regs:$a)>; |
| 1679 | |
| 1680 | // signed/unsigned |
| 1681 | // x = (a)? x : y |
| 1682 | // |
| 1683 | // if (!a) x = y |
| 1684 | // |
| 1685 | def : Mips16Pat<(select CPU16Regs:$a, |
| 1686 | CPU16Regs:$x, CPU16Regs:$y), |
| 1687 | (SelBneZ CPU16Regs:$x, CPU16Regs:$y, |
| 1688 | CPU16Regs:$a)>; |
| 1689 | |
| 1690 | |
| 1691 | // |
| 1692 | // signed/unsigned |
| 1693 | // x = (a != k)? x : y |
| 1694 | // |
| 1695 | // if (a == k) x = y |
| 1696 | // |
| 1697 | def : Mips16Pat<(select (i32 (setne CPU16Regs:$a, immZExt16:$k)), |
| 1698 | CPU16Regs:$x, CPU16Regs:$y), |
| 1699 | (SelTBtneZCmpi CPU16Regs:$x, CPU16Regs:$y, |
| 1700 | CPU16Regs:$a, immZExt16:$k)>; |
Reed Kotler | cf11c59 | 2012-10-12 02:01:09 +0000 | [diff] [blame] | 1701 | |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1702 | // |
| 1703 | // When writing C code to test setxx these patterns, |
| 1704 | // some will be transformed into |
| 1705 | // other things. So we test using C code but using -O3 and -O0 |
| 1706 | // |
| 1707 | // seteq |
| 1708 | // |
| 1709 | def : Mips16Pat |
| 1710 | <(seteq CPU16Regs:$lhs,CPU16Regs:$rhs), |
| 1711 | (SltiuCCRxImmX16 (XorRxRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs), 1)>; |
| 1712 | |
| 1713 | def : Mips16Pat |
| 1714 | <(seteq CPU16Regs:$lhs, 0), |
| 1715 | (SltiuCCRxImmX16 CPU16Regs:$lhs, 1)>; |
| 1716 | |
| 1717 | |
| 1718 | // |
| 1719 | // setge |
| 1720 | // |
| 1721 | |
| 1722 | def: Mips16Pat |
| 1723 | <(setge CPU16Regs:$lhs, CPU16Regs:$rhs), |
| 1724 | (XorRxRxRy16 (SltCCRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs), |
| 1725 | (LiRxImmX16 1))>; |
| 1726 | |
| 1727 | // |
| 1728 | // For constants, llvm transforms this to: |
| 1729 | // x > (k -1) and then reverses the operands to use setlt. So this pattern |
| 1730 | // is not used now by the compiler. (Presumably checking that k-1 does not |
| 1731 | // overflow). The compiler never uses this at a the current time, due to |
| 1732 | // other optimizations. |
| 1733 | // |
| 1734 | //def: Mips16Pat |
| 1735 | // <(setge CPU16Regs:$lhs, immSExt16:$rhs), |
| 1736 | // (XorRxRxRy16 (SltiCCRxImmX16 CPU16Regs:$lhs, immSExt16:$rhs), |
| 1737 | // (LiRxImmX16 1))>; |
| 1738 | |
| 1739 | // This catches the x >= -32768 case by transforming it to x > -32769 |
| 1740 | // |
| 1741 | def: Mips16Pat |
| 1742 | <(setgt CPU16Regs:$lhs, -32769), |
| 1743 | (XorRxRxRy16 (SltiCCRxImmX16 CPU16Regs:$lhs, -32768), |
| 1744 | (LiRxImmX16 1))>; |
| 1745 | |
| 1746 | // |
| 1747 | // setgt |
| 1748 | // |
| 1749 | // |
| 1750 | |
| 1751 | def: Mips16Pat |
| 1752 | <(setgt CPU16Regs:$lhs, CPU16Regs:$rhs), |
| 1753 | (SltCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs)>; |
| 1754 | |
| 1755 | // |
| 1756 | // setle |
| 1757 | // |
| 1758 | def: Mips16Pat |
| 1759 | <(setle CPU16Regs:$lhs, CPU16Regs:$rhs), |
Reed Kotler | 7b503c2 | 2013-02-20 05:45:15 +0000 | [diff] [blame] | 1760 | (XorRxRxRy16 (SltCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs), (LiRxImm16 1))>; |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1761 | |
| 1762 | // |
| 1763 | // setlt |
| 1764 | // |
| 1765 | def: SetCC_R16<setlt, SltCCRxRy16>; |
| 1766 | |
| 1767 | def: SetCC_I16<setlt, immSExt16, SltiCCRxImmX16>; |
| 1768 | |
| 1769 | // |
| 1770 | // setne |
| 1771 | // |
| 1772 | def : Mips16Pat |
| 1773 | <(setne CPU16Regs:$lhs,CPU16Regs:$rhs), |
| 1774 | (SltuCCRxRy16 (LiRxImmX16 0), |
| 1775 | (XorRxRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs))>; |
| 1776 | |
| 1777 | |
| 1778 | // |
| 1779 | // setuge |
| 1780 | // |
| 1781 | def: Mips16Pat |
| 1782 | <(setuge CPU16Regs:$lhs, CPU16Regs:$rhs), |
| 1783 | (XorRxRxRy16 (SltuCCRxRy16 CPU16Regs:$lhs, CPU16Regs:$rhs), |
| 1784 | (LiRxImmX16 1))>; |
| 1785 | |
| 1786 | // this pattern will never be used because the compiler will transform |
| 1787 | // x >= k to x > (k - 1) and then use SLT |
| 1788 | // |
| 1789 | //def: Mips16Pat |
| 1790 | // <(setuge CPU16Regs:$lhs, immZExt16:$rhs), |
| 1791 | // (XorRxRxRy16 (SltiuCCRxImmX16 CPU16Regs:$lhs, immZExt16:$rhs), |
Reed Kotler | 097556d | 2012-10-25 21:33:30 +0000 | [diff] [blame] | 1792 | // (LiRxImmX16 1))>; |
Reed Kotler | 164bb37 | 2012-10-23 01:35:48 +0000 | [diff] [blame] | 1793 | |
| 1794 | // |
| 1795 | // setugt |
| 1796 | // |
| 1797 | def: Mips16Pat |
| 1798 | <(setugt CPU16Regs:$lhs, CPU16Regs:$rhs), |
| 1799 | (SltuCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs)>; |
| 1800 | |
| 1801 | // |
| 1802 | // setule |
| 1803 | // |
| 1804 | def: Mips16Pat |
| 1805 | <(setule CPU16Regs:$lhs, CPU16Regs:$rhs), |
| 1806 | (XorRxRxRy16 (SltuCCRxRy16 CPU16Regs:$rhs, CPU16Regs:$lhs), (LiRxImmX16 1))>; |
| 1807 | |
| 1808 | // |
| 1809 | // setult |
| 1810 | // |
| 1811 | def: SetCC_R16<setult, SltuCCRxRy16>; |
| 1812 | |
| 1813 | def: SetCC_I16<setult, immSExt16, SltiuCCRxImmX16>; |
| 1814 | |
Reed Kotler | 7e4d996 | 2012-10-27 00:57:14 +0000 | [diff] [blame] | 1815 | def: Mips16Pat<(add CPU16Regs:$hi, (MipsLo tglobaladdr:$lo)), |
| 1816 | (AddiuRxRxImmX16 CPU16Regs:$hi, tglobaladdr:$lo)>; |
| 1817 | |
| 1818 | // hi/lo relocs |
Reed Kotler | 1b5b5c9 | 2013-10-04 22:01:40 +0000 | [diff] [blame] | 1819 | def : Mips16Pat<(MipsHi tblockaddress:$in), |
| 1820 | (SllX16 (LiRxImmX16 tblockaddress:$in), 16)>; |
Reed Kotler | 7b503c2 | 2013-02-20 05:45:15 +0000 | [diff] [blame] | 1821 | def : Mips16Pat<(MipsHi tglobaladdr:$in), |
Reed Kotler | f8933f8 | 2013-02-02 04:07:35 +0000 | [diff] [blame] | 1822 | (SllX16 (LiRxImmX16 tglobaladdr:$in), 16)>; |
Reed Kotler | 9cb8e7b | 2013-02-13 08:32:14 +0000 | [diff] [blame] | 1823 | def : Mips16Pat<(MipsHi tjumptable:$in), |
| 1824 | (SllX16 (LiRxImmX16 tjumptable:$in), 16)>; |
Jack Carter | 7ab15fa | 2013-01-19 02:00:40 +0000 | [diff] [blame] | 1825 | def : Mips16Pat<(MipsHi tglobaltlsaddr:$in), |
Reed Kotler | 7e4d996 | 2012-10-27 00:57:14 +0000 | [diff] [blame] | 1826 | (SllX16 (LiRxImmX16 tglobaltlsaddr:$in), 16)>; |
| 1827 | |
Reed Kotler | 1b5b5c9 | 2013-10-04 22:01:40 +0000 | [diff] [blame] | 1828 | def : Mips16Pat<(MipsLo tblockaddress:$in), (LiRxImmX16 tblockaddress:$in)>; |
| 1829 | |
Reed Kotler | b650f6b | 2012-10-26 22:57:32 +0000 | [diff] [blame] | 1830 | // wrapper_pic |
| 1831 | class Wrapper16Pat<SDNode node, Instruction ADDiuOp, RegisterClass RC>: |
| 1832 | Mips16Pat<(MipsWrapper RC:$gp, node:$in), |
| 1833 | (ADDiuOp RC:$gp, node:$in)>; |
| 1834 | |
| 1835 | |
Reed Kotler | 3589dd7 | 2012-10-28 06:02:37 +0000 | [diff] [blame] | 1836 | def : Wrapper16Pat<tglobaladdr, AddiuRxRxImmX16, CPU16Regs>; |
Reed Kotler | b650f6b | 2012-10-26 22:57:32 +0000 | [diff] [blame] | 1837 | def : Wrapper16Pat<tglobaltlsaddr, AddiuRxRxImmX16, CPU16Regs>; |
| 1838 | |
Reed Kotler | 740981e | 2012-10-29 19:39:04 +0000 | [diff] [blame] | 1839 | def : Mips16Pat<(i32 (extloadi8 addr16:$src)), |
| 1840 | (LbuRxRyOffMemX16 addr16:$src)>; |
| 1841 | def : Mips16Pat<(i32 (extloadi16 addr16:$src)), |
Chandler Carruth | f12e3a6 | 2012-11-30 11:45:22 +0000 | [diff] [blame] | 1842 | (LhuRxRyOffMemX16 addr16:$src)>; |
Reed Kotler | bb870e2 | 2013-08-07 04:00:26 +0000 | [diff] [blame] | 1843 | |
| 1844 | def: Mips16Pat<(trap), (Break16)>; |
| 1845 | |
Reed Kotler | 445d0ad | 2013-10-07 20:46:19 +0000 | [diff] [blame] | 1846 | def : Mips16Pat<(sext_inreg CPU16Regs:$val, i8), |
| 1847 | (SebRx16 CPU16Regs:$val)>; |
| 1848 | |
| 1849 | def : Mips16Pat<(sext_inreg CPU16Regs:$val, i16), |
| 1850 | (SehRx16 CPU16Regs:$val)>; |
| 1851 | |
Reed Kotler | d6aadc7 | 2013-09-18 22:46:09 +0000 | [diff] [blame] | 1852 | def GotPrologue16: |
| 1853 | MipsPseudo16< |
| 1854 | (outs CPU16Regs:$rh, CPU16Regs:$rl), |
| 1855 | (ins simm16:$immHi, simm16:$immLo), |
| 1856 | ".align 2\n\tli\t$rh, $immHi\n\taddiu\t$rl, $$pc, $immLo\n ",[]> ; |
Reed Kotler | 91ae982 | 2013-10-27 21:57:36 +0000 | [diff] [blame] | 1857 | |
| 1858 | // An operand for the CONSTPOOL_ENTRY pseudo-instruction. |
| 1859 | def cpinst_operand : Operand<i32> { |
| 1860 | // let PrintMethod = "printCPInstOperand"; |
| 1861 | } |
| 1862 | |
| 1863 | // CONSTPOOL_ENTRY - This instruction represents a floating constant pool in |
| 1864 | // the function. The first operand is the ID# for this instruction, the second |
| 1865 | // is the index into the MachineConstantPool that this is, the third is the |
| 1866 | // size in bytes of this constant pool entry. |
| 1867 | // |
| 1868 | let neverHasSideEffects = 1, isNotDuplicable = 1 in |
| 1869 | def CONSTPOOL_ENTRY : |
| 1870 | MipsPseudo16<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx, |
| 1871 | i32imm:$size), "foo", []>; |