| 1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
| 2 | |* *| |
| 3 | |* Pseudo-instruction MC lowering Source Fragment *| |
| 4 | |* *| |
| 5 | |* Automatically generated file, do not edit! *| |
| 6 | |* *| |
| 7 | \*===----------------------------------------------------------------------===*/ |
| 8 | |
| 9 | bool RISCVAsmPrinter:: |
| 10 | lowerPseudoInstExpansion(const MachineInstr *MI, MCInst &Inst) { |
| 11 | Inst.clear(); |
| 12 | switch (MI->getOpcode()) { |
| 13 | default: return false; |
| 14 | case RISCV::ClearFCSR: { |
| 15 | MCOperand MCOp; |
| 16 | Inst.setOpcode(RISCV::CSRRC); |
| 17 | // Operand: rd |
| 18 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 19 | // Operand: imm12 |
| 20 | Inst.addOperand(Op: MCOperand::createImm(Val: 3)); |
| 21 | // Operand: rs1 |
| 22 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 23 | Inst.addOperand(Op: MCOp); |
| 24 | break; |
| 25 | } |
| 26 | case RISCV::ClearFCSRImm: { |
| 27 | MCOperand MCOp; |
| 28 | Inst.setOpcode(RISCV::CSRRCI); |
| 29 | // Operand: rd |
| 30 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 31 | // Operand: imm12 |
| 32 | Inst.addOperand(Op: MCOperand::createImm(Val: 3)); |
| 33 | // Operand: rs1 |
| 34 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 35 | Inst.addOperand(Op: MCOp); |
| 36 | break; |
| 37 | } |
| 38 | case RISCV::PseudoBR: { |
| 39 | MCOperand MCOp; |
| 40 | Inst.setOpcode(RISCV::JAL); |
| 41 | // Operand: rd |
| 42 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 43 | // Operand: imm20 |
| 44 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 45 | Inst.addOperand(Op: MCOp); |
| 46 | break; |
| 47 | } |
| 48 | case RISCV::PseudoBRIND: { |
| 49 | MCOperand MCOp; |
| 50 | Inst.setOpcode(RISCV::JALR); |
| 51 | // Operand: rd |
| 52 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 53 | // Operand: rs1 |
| 54 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 55 | Inst.addOperand(Op: MCOp); |
| 56 | // Operand: imm12 |
| 57 | lowerOperand(MO: MI->getOperand(i: 1), MCOp); |
| 58 | Inst.addOperand(Op: MCOp); |
| 59 | break; |
| 60 | } |
| 61 | case RISCV::PseudoBRINDX7: { |
| 62 | MCOperand MCOp; |
| 63 | Inst.setOpcode(RISCV::JALR); |
| 64 | // Operand: rd |
| 65 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 66 | // Operand: rs1 |
| 67 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 68 | Inst.addOperand(Op: MCOp); |
| 69 | // Operand: imm12 |
| 70 | lowerOperand(MO: MI->getOperand(i: 1), MCOp); |
| 71 | Inst.addOperand(Op: MCOp); |
| 72 | break; |
| 73 | } |
| 74 | case RISCV::PseudoCALLIndirect: { |
| 75 | MCOperand MCOp; |
| 76 | Inst.setOpcode(RISCV::JALR); |
| 77 | // Operand: rd |
| 78 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X1)); |
| 79 | // Operand: rs1 |
| 80 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 81 | Inst.addOperand(Op: MCOp); |
| 82 | // Operand: imm12 |
| 83 | Inst.addOperand(Op: MCOperand::createImm(Val: 0)); |
| 84 | break; |
| 85 | } |
| 86 | case RISCV::PseudoCALLIndirectX7: { |
| 87 | MCOperand MCOp; |
| 88 | Inst.setOpcode(RISCV::JALR); |
| 89 | // Operand: rd |
| 90 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X1)); |
| 91 | // Operand: rs1 |
| 92 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 93 | Inst.addOperand(Op: MCOp); |
| 94 | // Operand: imm12 |
| 95 | Inst.addOperand(Op: MCOperand::createImm(Val: 0)); |
| 96 | break; |
| 97 | } |
| 98 | case RISCV::PseudoClearFPR32: { |
| 99 | MCOperand MCOp; |
| 100 | Inst.setOpcode(RISCV::FMV_W_X); |
| 101 | // Operand: rd |
| 102 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 103 | Inst.addOperand(Op: MCOp); |
| 104 | // Operand: rs1 |
| 105 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 106 | break; |
| 107 | } |
| 108 | case RISCV::PseudoClearFPR128: { |
| 109 | MCOperand MCOp; |
| 110 | Inst.setOpcode(RISCV::FCVT_Q_W); |
| 111 | // Operand: rd |
| 112 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 113 | Inst.addOperand(Op: MCOp); |
| 114 | // Operand: rs1 |
| 115 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 116 | // Operand: frm |
| 117 | Inst.addOperand(Op: MCOperand::createImm(Val: 0)); |
| 118 | break; |
| 119 | } |
| 120 | case RISCV::PseudoClearGPR: { |
| 121 | MCOperand MCOp; |
| 122 | Inst.setOpcode(RISCV::ADDI); |
| 123 | // Operand: rd |
| 124 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 125 | Inst.addOperand(Op: MCOp); |
| 126 | // Operand: rs1 |
| 127 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 128 | // Operand: imm12 |
| 129 | Inst.addOperand(Op: MCOperand::createImm(Val: 0)); |
| 130 | break; |
| 131 | } |
| 132 | case RISCV::PseudoRET: { |
| 133 | MCOperand MCOp; |
| 134 | Inst.setOpcode(RISCV::JALR); |
| 135 | // Operand: rd |
| 136 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 137 | // Operand: rs1 |
| 138 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X1)); |
| 139 | // Operand: imm12 |
| 140 | Inst.addOperand(Op: MCOperand::createImm(Val: 0)); |
| 141 | break; |
| 142 | } |
| 143 | case RISCV::PseudoReadVL: { |
| 144 | MCOperand MCOp; |
| 145 | Inst.setOpcode(RISCV::CSRRS); |
| 146 | // Operand: rd |
| 147 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 148 | Inst.addOperand(Op: MCOp); |
| 149 | // Operand: imm12 |
| 150 | Inst.addOperand(Op: MCOperand::createImm(Val: 3104)); |
| 151 | // Operand: rs1 |
| 152 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 153 | break; |
| 154 | } |
| 155 | case RISCV::PseudoReadVLENB: { |
| 156 | MCOperand MCOp; |
| 157 | Inst.setOpcode(RISCV::CSRRS); |
| 158 | // Operand: rd |
| 159 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 160 | Inst.addOperand(Op: MCOp); |
| 161 | // Operand: imm12 |
| 162 | Inst.addOperand(Op: MCOperand::createImm(Val: 3106)); |
| 163 | // Operand: rs1 |
| 164 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 165 | break; |
| 166 | } |
| 167 | case RISCV::PseudoSF_VSETTK: { |
| 168 | MCOperand MCOp; |
| 169 | Inst.setOpcode(RISCV::SF_VSETTK); |
| 170 | // Operand: rd |
| 171 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 172 | Inst.addOperand(Op: MCOp); |
| 173 | // Operand: rs1 |
| 174 | lowerOperand(MO: MI->getOperand(i: 1), MCOp); |
| 175 | Inst.addOperand(Op: MCOp); |
| 176 | break; |
| 177 | } |
| 178 | case RISCV::PseudoSF_VSETTM: { |
| 179 | MCOperand MCOp; |
| 180 | Inst.setOpcode(RISCV::SF_VSETTM); |
| 181 | // Operand: rd |
| 182 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 183 | Inst.addOperand(Op: MCOp); |
| 184 | // Operand: rs1 |
| 185 | lowerOperand(MO: MI->getOperand(i: 1), MCOp); |
| 186 | Inst.addOperand(Op: MCOp); |
| 187 | break; |
| 188 | } |
| 189 | case RISCV::PseudoSF_VSETTNT: { |
| 190 | MCOperand MCOp; |
| 191 | Inst.setOpcode(RISCV::VSETVLI); |
| 192 | // Operand: rd |
| 193 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 194 | Inst.addOperand(Op: MCOp); |
| 195 | // Operand: rs1 |
| 196 | lowerOperand(MO: MI->getOperand(i: 1), MCOp); |
| 197 | Inst.addOperand(Op: MCOp); |
| 198 | // Operand: vtypei |
| 199 | lowerOperand(MO: MI->getOperand(i: 2), MCOp); |
| 200 | Inst.addOperand(Op: MCOp); |
| 201 | break; |
| 202 | } |
| 203 | case RISCV::PseudoSF_VSETTNTX0: { |
| 204 | MCOperand MCOp; |
| 205 | Inst.setOpcode(RISCV::VSETVLI); |
| 206 | // Operand: rd |
| 207 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 208 | Inst.addOperand(Op: MCOp); |
| 209 | // Operand: rs1 |
| 210 | lowerOperand(MO: MI->getOperand(i: 1), MCOp); |
| 211 | Inst.addOperand(Op: MCOp); |
| 212 | // Operand: vtypei |
| 213 | lowerOperand(MO: MI->getOperand(i: 2), MCOp); |
| 214 | Inst.addOperand(Op: MCOp); |
| 215 | break; |
| 216 | } |
| 217 | case RISCV::PseudoSF_VSETTNTX0X0: { |
| 218 | MCOperand MCOp; |
| 219 | Inst.setOpcode(RISCV::VSETVLI); |
| 220 | // Operand: rd |
| 221 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 222 | Inst.addOperand(Op: MCOp); |
| 223 | // Operand: rs1 |
| 224 | lowerOperand(MO: MI->getOperand(i: 1), MCOp); |
| 225 | Inst.addOperand(Op: MCOp); |
| 226 | // Operand: vtypei |
| 227 | lowerOperand(MO: MI->getOperand(i: 2), MCOp); |
| 228 | Inst.addOperand(Op: MCOp); |
| 229 | break; |
| 230 | } |
| 231 | case RISCV::PseudoTAILIndirect: { |
| 232 | MCOperand MCOp; |
| 233 | Inst.setOpcode(RISCV::JALR); |
| 234 | // Operand: rd |
| 235 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 236 | // Operand: rs1 |
| 237 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 238 | Inst.addOperand(Op: MCOp); |
| 239 | // Operand: imm12 |
| 240 | Inst.addOperand(Op: MCOperand::createImm(Val: 0)); |
| 241 | break; |
| 242 | } |
| 243 | case RISCV::PseudoTAILIndirectX7: { |
| 244 | MCOperand MCOp; |
| 245 | Inst.setOpcode(RISCV::JALR); |
| 246 | // Operand: rd |
| 247 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 248 | // Operand: rs1 |
| 249 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 250 | Inst.addOperand(Op: MCOp); |
| 251 | // Operand: imm12 |
| 252 | Inst.addOperand(Op: MCOperand::createImm(Val: 0)); |
| 253 | break; |
| 254 | } |
| 255 | case RISCV::PseudoVSETIVLI: { |
| 256 | MCOperand MCOp; |
| 257 | Inst.setOpcode(RISCV::VSETIVLI); |
| 258 | // Operand: rd |
| 259 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 260 | Inst.addOperand(Op: MCOp); |
| 261 | // Operand: uimm |
| 262 | lowerOperand(MO: MI->getOperand(i: 1), MCOp); |
| 263 | Inst.addOperand(Op: MCOp); |
| 264 | // Operand: vtypei |
| 265 | lowerOperand(MO: MI->getOperand(i: 2), MCOp); |
| 266 | Inst.addOperand(Op: MCOp); |
| 267 | break; |
| 268 | } |
| 269 | case RISCV::PseudoVSETVLI: { |
| 270 | MCOperand MCOp; |
| 271 | Inst.setOpcode(RISCV::VSETVLI); |
| 272 | // Operand: rd |
| 273 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 274 | Inst.addOperand(Op: MCOp); |
| 275 | // Operand: rs1 |
| 276 | lowerOperand(MO: MI->getOperand(i: 1), MCOp); |
| 277 | Inst.addOperand(Op: MCOp); |
| 278 | // Operand: vtypei |
| 279 | lowerOperand(MO: MI->getOperand(i: 2), MCOp); |
| 280 | Inst.addOperand(Op: MCOp); |
| 281 | break; |
| 282 | } |
| 283 | case RISCV::PseudoVSETVLIX0: { |
| 284 | MCOperand MCOp; |
| 285 | Inst.setOpcode(RISCV::VSETVLI); |
| 286 | // Operand: rd |
| 287 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 288 | Inst.addOperand(Op: MCOp); |
| 289 | // Operand: rs1 |
| 290 | lowerOperand(MO: MI->getOperand(i: 1), MCOp); |
| 291 | Inst.addOperand(Op: MCOp); |
| 292 | // Operand: vtypei |
| 293 | lowerOperand(MO: MI->getOperand(i: 2), MCOp); |
| 294 | Inst.addOperand(Op: MCOp); |
| 295 | break; |
| 296 | } |
| 297 | case RISCV::PseudoVSETVLIX0X0: { |
| 298 | MCOperand MCOp; |
| 299 | Inst.setOpcode(RISCV::VSETVLI); |
| 300 | // Operand: rd |
| 301 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 302 | Inst.addOperand(Op: MCOp); |
| 303 | // Operand: rs1 |
| 304 | lowerOperand(MO: MI->getOperand(i: 1), MCOp); |
| 305 | Inst.addOperand(Op: MCOp); |
| 306 | // Operand: vtypei |
| 307 | lowerOperand(MO: MI->getOperand(i: 2), MCOp); |
| 308 | Inst.addOperand(Op: MCOp); |
| 309 | break; |
| 310 | } |
| 311 | case RISCV::ReadFCSR: { |
| 312 | MCOperand MCOp; |
| 313 | Inst.setOpcode(RISCV::CSRRS); |
| 314 | // Operand: rd |
| 315 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 316 | Inst.addOperand(Op: MCOp); |
| 317 | // Operand: imm12 |
| 318 | Inst.addOperand(Op: MCOperand::createImm(Val: 3)); |
| 319 | // Operand: rs1 |
| 320 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 321 | break; |
| 322 | } |
| 323 | case RISCV::ReadFFLAGS: { |
| 324 | MCOperand MCOp; |
| 325 | Inst.setOpcode(RISCV::CSRRS); |
| 326 | // Operand: rd |
| 327 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 328 | Inst.addOperand(Op: MCOp); |
| 329 | // Operand: imm12 |
| 330 | Inst.addOperand(Op: MCOperand::createImm(Val: 1)); |
| 331 | // Operand: rs1 |
| 332 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 333 | break; |
| 334 | } |
| 335 | case RISCV::ReadFRM: { |
| 336 | MCOperand MCOp; |
| 337 | Inst.setOpcode(RISCV::CSRRS); |
| 338 | // Operand: rd |
| 339 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 340 | Inst.addOperand(Op: MCOp); |
| 341 | // Operand: imm12 |
| 342 | Inst.addOperand(Op: MCOperand::createImm(Val: 2)); |
| 343 | // Operand: rs1 |
| 344 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 345 | break; |
| 346 | } |
| 347 | case RISCV::SetFCSR: { |
| 348 | MCOperand MCOp; |
| 349 | Inst.setOpcode(RISCV::CSRRS); |
| 350 | // Operand: rd |
| 351 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 352 | // Operand: imm12 |
| 353 | Inst.addOperand(Op: MCOperand::createImm(Val: 3)); |
| 354 | // Operand: rs1 |
| 355 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 356 | Inst.addOperand(Op: MCOp); |
| 357 | break; |
| 358 | } |
| 359 | case RISCV::SetFCSRImm: { |
| 360 | MCOperand MCOp; |
| 361 | Inst.setOpcode(RISCV::CSRRSI); |
| 362 | // Operand: rd |
| 363 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 364 | // Operand: imm12 |
| 365 | Inst.addOperand(Op: MCOperand::createImm(Val: 3)); |
| 366 | // Operand: rs1 |
| 367 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 368 | Inst.addOperand(Op: MCOp); |
| 369 | break; |
| 370 | } |
| 371 | case RISCV::SwapFRMImm: { |
| 372 | MCOperand MCOp; |
| 373 | Inst.setOpcode(RISCV::CSRRWI); |
| 374 | // Operand: rd |
| 375 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 376 | Inst.addOperand(Op: MCOp); |
| 377 | // Operand: imm12 |
| 378 | Inst.addOperand(Op: MCOperand::createImm(Val: 2)); |
| 379 | // Operand: rs1 |
| 380 | lowerOperand(MO: MI->getOperand(i: 1), MCOp); |
| 381 | Inst.addOperand(Op: MCOp); |
| 382 | break; |
| 383 | } |
| 384 | case RISCV::WriteFCSR: { |
| 385 | MCOperand MCOp; |
| 386 | Inst.setOpcode(RISCV::CSRRW); |
| 387 | // Operand: rd |
| 388 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 389 | // Operand: imm12 |
| 390 | Inst.addOperand(Op: MCOperand::createImm(Val: 3)); |
| 391 | // Operand: rs1 |
| 392 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 393 | Inst.addOperand(Op: MCOp); |
| 394 | break; |
| 395 | } |
| 396 | case RISCV::WriteFCSRImm: { |
| 397 | MCOperand MCOp; |
| 398 | Inst.setOpcode(RISCV::CSRRWI); |
| 399 | // Operand: rd |
| 400 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 401 | // Operand: imm12 |
| 402 | Inst.addOperand(Op: MCOperand::createImm(Val: 3)); |
| 403 | // Operand: rs1 |
| 404 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 405 | Inst.addOperand(Op: MCOp); |
| 406 | break; |
| 407 | } |
| 408 | case RISCV::WriteFFLAGS: { |
| 409 | MCOperand MCOp; |
| 410 | Inst.setOpcode(RISCV::CSRRW); |
| 411 | // Operand: rd |
| 412 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 413 | // Operand: imm12 |
| 414 | Inst.addOperand(Op: MCOperand::createImm(Val: 1)); |
| 415 | // Operand: rs1 |
| 416 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 417 | Inst.addOperand(Op: MCOp); |
| 418 | break; |
| 419 | } |
| 420 | case RISCV::WriteFRM: { |
| 421 | MCOperand MCOp; |
| 422 | Inst.setOpcode(RISCV::CSRRW); |
| 423 | // Operand: rd |
| 424 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 425 | // Operand: imm12 |
| 426 | Inst.addOperand(Op: MCOperand::createImm(Val: 2)); |
| 427 | // Operand: rs1 |
| 428 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 429 | Inst.addOperand(Op: MCOp); |
| 430 | break; |
| 431 | } |
| 432 | case RISCV::WriteFRMImm: { |
| 433 | MCOperand MCOp; |
| 434 | Inst.setOpcode(RISCV::CSRRWI); |
| 435 | // Operand: rd |
| 436 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 437 | // Operand: imm12 |
| 438 | Inst.addOperand(Op: MCOperand::createImm(Val: 2)); |
| 439 | // Operand: rs1 |
| 440 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 441 | Inst.addOperand(Op: MCOp); |
| 442 | break; |
| 443 | } |
| 444 | case RISCV::WriteVXRMImm: { |
| 445 | MCOperand MCOp; |
| 446 | Inst.setOpcode(RISCV::CSRRWI); |
| 447 | // Operand: rd |
| 448 | Inst.addOperand(Op: MCOperand::createReg(Reg: RISCV::X0)); |
| 449 | // Operand: imm12 |
| 450 | Inst.addOperand(Op: MCOperand::createImm(Val: 10)); |
| 451 | // Operand: rs1 |
| 452 | lowerOperand(MO: MI->getOperand(i: 0), MCOp); |
| 453 | Inst.addOperand(Op: MCOp); |
| 454 | break; |
| 455 | } |
| 456 | } |
| 457 | return true; |
| 458 | } |
| 459 | |
| 460 | |