1 //===- RISCVMatInt.cpp - Immediate materialisation -------------*- C++ -*--===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "RISCVMatInt.h" 10 #include "MCTargetDesc/RISCVMCTargetDesc.h" 11 #include "llvm/ADT/APInt.h" 12 #include "llvm/MC/MCInstBuilder.h" 13 #include "llvm/Support/MathExtras.h" 14 using namespace llvm; 15 16 static int getInstSeqCost(RISCVMatInt::InstSeq &Res, bool HasRVC) { 17 if (!HasRVC) 18 return Res.size(); 19 20 int Cost = 0; 21 for (auto Instr : Res) { 22 // Assume instructions that aren't listed aren't compressible. 23 bool Compressed = false; 24 switch (Instr.getOpcode()) { 25 case RISCV::SLLI: 26 case RISCV::SRLI: 27 Compressed = true; 28 break; 29 case RISCV::ADDI: 30 case RISCV::ADDIW: 31 case RISCV::LUI: 32 Compressed = isInt<6>(Instr.getImm()); 33 break; 34 } 35 // Two RVC instructions take the same space as one RVI instruction, but 36 // can take longer to execute than the single RVI instruction. Thus, we 37 // consider that two RVC instruction are slightly more costly than one 38 // RVI instruction. For longer sequences of RVC instructions the space 39 // savings can be worth it, though. The costs below try to model that. 40 if (!Compressed) 41 Cost += 100; // Baseline cost of one RVI instruction: 100%. 42 else 43 Cost += 70; // 70% cost of baseline. 44 } 45 return Cost; 46 } 47 48 // Recursively generate a sequence for materializing an integer. 49 static void generateInstSeqImpl(int64_t Val, const MCSubtargetInfo &STI, 50 RISCVMatInt::InstSeq &Res) { 51 bool IsRV64 = STI.hasFeature(RISCV::Feature64Bit); 52 53 // Use BSETI for a single bit that can't be expressed by a single LUI or ADDI. 54 if (STI.hasFeature(RISCV::FeatureStdExtZbs) && isPowerOf2_64(Val) && 55 (!isInt<32>(Val) || Val == 0x800)) { 56 Res.emplace_back(RISCV::BSETI, Log2_64(Val)); 57 return; 58 } 59 60 if (isInt<32>(Val)) { 61 // Depending on the active bits in the immediate Value v, the following 62 // instruction sequences are emitted: 63 // 64 // v == 0 : ADDI 65 // v[0,12) != 0 && v[12,32) == 0 : ADDI 66 // v[0,12) == 0 && v[12,32) != 0 : LUI 67 // v[0,32) != 0 : LUI+ADDI(W) 68 int64_t Hi20 = ((Val + 0x800) >> 12) & 0xFFFFF; 69 int64_t Lo12 = SignExtend64<12>(Val); 70 71 if (Hi20) 72 Res.emplace_back(RISCV::LUI, Hi20); 73 74 if (Lo12 || Hi20 == 0) { 75 unsigned AddiOpc = (IsRV64 && Hi20) ? RISCV::ADDIW : RISCV::ADDI; 76 Res.emplace_back(AddiOpc, Lo12); 77 } 78 return; 79 } 80 81 assert(IsRV64 && "Can't emit >32-bit imm for non-RV64 target"); 82 83 // In the worst case, for a full 64-bit constant, a sequence of 8 instructions 84 // (i.e., LUI+ADDIW+SLLI+ADDI+SLLI+ADDI+SLLI+ADDI) has to be emitted. Note 85 // that the first two instructions (LUI+ADDIW) can contribute up to 32 bits 86 // while the following ADDI instructions contribute up to 12 bits each. 87 // 88 // On the first glance, implementing this seems to be possible by simply 89 // emitting the most significant 32 bits (LUI+ADDIW) followed by as many left 90 // shift (SLLI) and immediate additions (ADDI) as needed. However, due to the 91 // fact that ADDI performs a sign extended addition, doing it like that would 92 // only be possible when at most 11 bits of the ADDI instructions are used. 93 // Using all 12 bits of the ADDI instructions, like done by GAS, actually 94 // requires that the constant is processed starting with the least significant 95 // bit. 96 // 97 // In the following, constants are processed from LSB to MSB but instruction 98 // emission is performed from MSB to LSB by recursively calling 99 // generateInstSeq. In each recursion, first the lowest 12 bits are removed 100 // from the constant and the optimal shift amount, which can be greater than 101 // 12 bits if the constant is sparse, is determined. Then, the shifted 102 // remaining constant is processed recursively and gets emitted as soon as it 103 // fits into 32 bits. The emission of the shifts and additions is subsequently 104 // performed when the recursion returns. 105 106 int64_t Lo12 = SignExtend64<12>(Val); 107 Val = (uint64_t)Val - (uint64_t)Lo12; 108 109 int ShiftAmount = 0; 110 bool Unsigned = false; 111 112 // Val might now be valid for LUI without needing a shift. 113 if (!isInt<32>(Val)) { 114 ShiftAmount = llvm::countr_zero((uint64_t)Val); 115 Val >>= ShiftAmount; 116 117 // If the remaining bits don't fit in 12 bits, we might be able to reduce 118 // the shift amount in order to use LUI which will zero the lower 12 bits. 119 if (ShiftAmount > 12 && !isInt<12>(Val)) { 120 if (isInt<32>(Val << 12)) { 121 // Reduce the shift amount and add zeros to the LSBs so it will match 122 // LUI. 123 ShiftAmount -= 12; 124 Val = Val << 12; 125 } else if (isUInt<32>(Val << 12) && 126 STI.hasFeature(RISCV::FeatureStdExtZba)) { 127 // Reduce the shift amount and add zeros to the LSBs so it will match 128 // LUI, then shift left with SLLI.UW to clear the upper 32 set bits. 129 ShiftAmount -= 12; 130 Val = SignExtend64<32>(Val << 12); 131 Unsigned = true; 132 } 133 } 134 135 // Try to use SLLI_UW for Val when it is uint32 but not int32. 136 if (isUInt<32>(Val) && !isInt<32>(Val) && 137 STI.hasFeature(RISCV::FeatureStdExtZba)) { 138 // Use LUI+ADDI(W) or LUI to compose, then clear the upper 32 bits with 139 // SLLI_UW. 140 Val = SignExtend64<32>(Val); 141 Unsigned = true; 142 } 143 } 144 145 generateInstSeqImpl(Val, STI, Res); 146 147 // Skip shift if we were able to use LUI directly. 148 if (ShiftAmount) { 149 unsigned Opc = Unsigned ? RISCV::SLLI_UW : RISCV::SLLI; 150 Res.emplace_back(Opc, ShiftAmount); 151 } 152 153 if (Lo12) 154 Res.emplace_back(RISCV::ADDI, Lo12); 155 } 156 157 static unsigned extractRotateInfo(int64_t Val) { 158 // for case: 0b111..1..xxxxxx1..1.. 159 unsigned LeadingOnes = llvm::countl_one((uint64_t)Val); 160 unsigned TrailingOnes = llvm::countr_one((uint64_t)Val); 161 if (TrailingOnes > 0 && TrailingOnes < 64 && 162 (LeadingOnes + TrailingOnes) > (64 - 12)) 163 return 64 - TrailingOnes; 164 165 // for case: 0bxxx1..1..1...xxx 166 unsigned UpperTrailingOnes = llvm::countr_one(Hi_32(Val)); 167 unsigned LowerLeadingOnes = llvm::countl_one(Lo_32(Val)); 168 if (UpperTrailingOnes < 32 && 169 (UpperTrailingOnes + LowerLeadingOnes) > (64 - 12)) 170 return 32 - UpperTrailingOnes; 171 172 return 0; 173 } 174 175 static void generateInstSeqLeadingZeros(int64_t Val, const MCSubtargetInfo &STI, 176 RISCVMatInt::InstSeq &Res) { 177 assert(Val > 0 && "Expected postive val"); 178 179 unsigned LeadingZeros = llvm::countl_zero((uint64_t)Val); 180 uint64_t ShiftedVal = (uint64_t)Val << LeadingZeros; 181 // Fill in the bits that will be shifted out with 1s. An example where this 182 // helps is trailing one masks with 32 or more ones. This will generate 183 // ADDI -1 and an SRLI. 184 ShiftedVal |= maskTrailingOnes<uint64_t>(LeadingZeros); 185 186 RISCVMatInt::InstSeq TmpSeq; 187 generateInstSeqImpl(ShiftedVal, STI, TmpSeq); 188 189 // Keep the new sequence if it is an improvement or the original is empty. 190 if ((TmpSeq.size() + 1) < Res.size() || 191 (Res.empty() && TmpSeq.size() < 8)) { 192 TmpSeq.emplace_back(RISCV::SRLI, LeadingZeros); 193 Res = TmpSeq; 194 } 195 196 // Some cases can benefit from filling the lower bits with zeros instead. 197 ShiftedVal &= maskTrailingZeros<uint64_t>(LeadingZeros); 198 TmpSeq.clear(); 199 generateInstSeqImpl(ShiftedVal, STI, TmpSeq); 200 201 // Keep the new sequence if it is an improvement or the original is empty. 202 if ((TmpSeq.size() + 1) < Res.size() || 203 (Res.empty() && TmpSeq.size() < 8)) { 204 TmpSeq.emplace_back(RISCV::SRLI, LeadingZeros); 205 Res = TmpSeq; 206 } 207 208 // If we have exactly 32 leading zeros and Zba, we can try using zext.w at 209 // the end of the sequence. 210 if (LeadingZeros == 32 && STI.hasFeature(RISCV::FeatureStdExtZba)) { 211 // Try replacing upper bits with 1. 212 uint64_t LeadingOnesVal = Val | maskLeadingOnes<uint64_t>(LeadingZeros); 213 TmpSeq.clear(); 214 generateInstSeqImpl(LeadingOnesVal, STI, TmpSeq); 215 216 // Keep the new sequence if it is an improvement. 217 if ((TmpSeq.size() + 1) < Res.size() || 218 (Res.empty() && TmpSeq.size() < 8)) { 219 TmpSeq.emplace_back(RISCV::ADD_UW, 0); 220 Res = TmpSeq; 221 } 222 } 223 } 224 225 namespace llvm::RISCVMatInt { 226 InstSeq generateInstSeq(int64_t Val, const MCSubtargetInfo &STI) { 227 RISCVMatInt::InstSeq Res; 228 generateInstSeqImpl(Val, STI, Res); 229 230 // If the low 12 bits are non-zero, the first expansion may end with an ADDI 231 // or ADDIW. If there are trailing zeros, try generating a sign extended 232 // constant with no trailing zeros and use a final SLLI to restore them. 233 if ((Val & 0xfff) != 0 && (Val & 1) == 0 && Res.size() >= 2) { 234 unsigned TrailingZeros = llvm::countr_zero((uint64_t)Val); 235 int64_t ShiftedVal = Val >> TrailingZeros; 236 // If we can use C.LI+C.SLLI instead of LUI+ADDI(W) prefer that since 237 // its more compressible. But only if LUI+ADDI(W) isn't fusable. 238 // NOTE: We don't check for C extension to minimize differences in generated 239 // code. 240 bool IsShiftedCompressible = 241 isInt<6>(ShiftedVal) && !STI.hasFeature(RISCV::TuneLUIADDIFusion); 242 RISCVMatInt::InstSeq TmpSeq; 243 generateInstSeqImpl(ShiftedVal, STI, TmpSeq); 244 245 // Keep the new sequence if it is an improvement. 246 if ((TmpSeq.size() + 1) < Res.size() || IsShiftedCompressible) { 247 TmpSeq.emplace_back(RISCV::SLLI, TrailingZeros); 248 Res = TmpSeq; 249 } 250 } 251 252 // If we have a 1 or 2 instruction sequence this is the best we can do. This 253 // will always be true for RV32 and will often be true for RV64. 254 if (Res.size() <= 2) 255 return Res; 256 257 assert(STI.hasFeature(RISCV::Feature64Bit) && 258 "Expected RV32 to only need 2 instructions"); 259 260 // If the lower 13 bits are something like 0x17ff, try to add 1 to change the 261 // lower 13 bits to 0x1800. We can restore this with an ADDI of -1 at the end 262 // of the sequence. Call generateInstSeqImpl on the new constant which may 263 // subtract 0xfffffffffffff800 to create another ADDI. This will leave a 264 // constant with more than 12 trailing zeros for the next recursive step. 265 if ((Val & 0xfff) != 0 && (Val & 0x1800) == 0x1000) { 266 int64_t Imm12 = -(0x800 - (Val & 0xfff)); 267 int64_t AdjustedVal = Val - Imm12; 268 RISCVMatInt::InstSeq TmpSeq; 269 generateInstSeqImpl(AdjustedVal, STI, TmpSeq); 270 271 // Keep the new sequence if it is an improvement. 272 if ((TmpSeq.size() + 1) < Res.size()) { 273 TmpSeq.emplace_back(RISCV::ADDI, Imm12); 274 Res = TmpSeq; 275 } 276 } 277 278 // If the constant is positive we might be able to generate a shifted constant 279 // with no leading zeros and use a final SRLI to restore them. 280 if (Val > 0 && Res.size() > 2) { 281 generateInstSeqLeadingZeros(Val, STI, Res); 282 } 283 284 // If the constant is negative, trying inverting and using our trailing zero 285 // optimizations. Use an xori to invert the final value. 286 if (Val < 0 && Res.size() > 3) { 287 uint64_t InvertedVal = ~(uint64_t)Val; 288 RISCVMatInt::InstSeq TmpSeq; 289 generateInstSeqLeadingZeros(InvertedVal, STI, TmpSeq); 290 291 // Keep it if we found a sequence that is smaller after inverting. 292 if (!TmpSeq.empty() && (TmpSeq.size() + 1) < Res.size()) { 293 TmpSeq.emplace_back(RISCV::XORI, -1); 294 Res = TmpSeq; 295 } 296 } 297 298 // If the Low and High halves are the same, use pack. The pack instruction 299 // packs the XLEN/2-bit lower halves of rs1 and rs2 into rd, with rs1 in the 300 // lower half and rs2 in the upper half. 301 if (Res.size() > 2 && STI.hasFeature(RISCV::FeatureStdExtZbkb)) { 302 int64_t LoVal = SignExtend64<32>(Val); 303 int64_t HiVal = SignExtend64<32>(Val >> 32); 304 if (LoVal == HiVal) { 305 RISCVMatInt::InstSeq TmpSeq; 306 generateInstSeqImpl(LoVal, STI, TmpSeq); 307 if ((TmpSeq.size() + 1) < Res.size()) { 308 TmpSeq.emplace_back(RISCV::PACK, 0); 309 Res = TmpSeq; 310 } 311 } 312 } 313 314 // Perform optimization with BSETI in the Zbs extension. 315 if (Res.size() > 2 && STI.hasFeature(RISCV::FeatureStdExtZbs)) { 316 // Create a simm32 value for LUI+ADDIW by forcing the upper 33 bits to zero. 317 // Xor that with original value to get which bits should be set by BSETI. 318 uint64_t Lo = Val & 0x7fffffff; 319 uint64_t Hi = Val ^ Lo; 320 assert(Hi != 0); 321 RISCVMatInt::InstSeq TmpSeq; 322 323 if (Lo != 0) 324 generateInstSeqImpl(Lo, STI, TmpSeq); 325 326 if (TmpSeq.size() + llvm::popcount(Hi) < Res.size()) { 327 do { 328 TmpSeq.emplace_back(RISCV::BSETI, llvm::countr_zero(Hi)); 329 Hi &= (Hi - 1); // Clear lowest set bit. 330 } while (Hi != 0); 331 Res = TmpSeq; 332 } 333 } 334 335 // Perform optimization with BCLRI in the Zbs extension. 336 if (Res.size() > 2 && STI.hasFeature(RISCV::FeatureStdExtZbs)) { 337 // Create a simm32 value for LUI+ADDIW by forcing the upper 33 bits to one. 338 // Xor that with original value to get which bits should be cleared by 339 // BCLRI. 340 uint64_t Lo = Val | 0xffffffff80000000; 341 uint64_t Hi = Val ^ Lo; 342 assert(Hi != 0); 343 344 RISCVMatInt::InstSeq TmpSeq; 345 generateInstSeqImpl(Lo, STI, TmpSeq); 346 347 if (TmpSeq.size() + llvm::popcount(Hi) < Res.size()) { 348 do { 349 TmpSeq.emplace_back(RISCV::BCLRI, llvm::countr_zero(Hi)); 350 Hi &= (Hi - 1); // Clear lowest set bit. 351 } while (Hi != 0); 352 Res = TmpSeq; 353 } 354 } 355 356 // Perform optimization with SH*ADD in the Zba extension. 357 if (Res.size() > 2 && STI.hasFeature(RISCV::FeatureStdExtZba)) { 358 int64_t Div = 0; 359 unsigned Opc = 0; 360 RISCVMatInt::InstSeq TmpSeq; 361 // Select the opcode and divisor. 362 if ((Val % 3) == 0 && isInt<32>(Val / 3)) { 363 Div = 3; 364 Opc = RISCV::SH1ADD; 365 } else if ((Val % 5) == 0 && isInt<32>(Val / 5)) { 366 Div = 5; 367 Opc = RISCV::SH2ADD; 368 } else if ((Val % 9) == 0 && isInt<32>(Val / 9)) { 369 Div = 9; 370 Opc = RISCV::SH3ADD; 371 } 372 // Build the new instruction sequence. 373 if (Div > 0) { 374 generateInstSeqImpl(Val / Div, STI, TmpSeq); 375 if ((TmpSeq.size() + 1) < Res.size()) { 376 TmpSeq.emplace_back(Opc, 0); 377 Res = TmpSeq; 378 } 379 } else { 380 // Try to use LUI+SH*ADD+ADDI. 381 int64_t Hi52 = ((uint64_t)Val + 0x800ull) & ~0xfffull; 382 int64_t Lo12 = SignExtend64<12>(Val); 383 Div = 0; 384 if (isInt<32>(Hi52 / 3) && (Hi52 % 3) == 0) { 385 Div = 3; 386 Opc = RISCV::SH1ADD; 387 } else if (isInt<32>(Hi52 / 5) && (Hi52 % 5) == 0) { 388 Div = 5; 389 Opc = RISCV::SH2ADD; 390 } else if (isInt<32>(Hi52 / 9) && (Hi52 % 9) == 0) { 391 Div = 9; 392 Opc = RISCV::SH3ADD; 393 } 394 // Build the new instruction sequence. 395 if (Div > 0) { 396 // For Val that has zero Lo12 (implies Val equals to Hi52) should has 397 // already been processed to LUI+SH*ADD by previous optimization. 398 assert(Lo12 != 0 && 399 "unexpected instruction sequence for immediate materialisation"); 400 assert(TmpSeq.empty() && "Expected empty TmpSeq"); 401 generateInstSeqImpl(Hi52 / Div, STI, TmpSeq); 402 if ((TmpSeq.size() + 2) < Res.size()) { 403 TmpSeq.emplace_back(Opc, 0); 404 TmpSeq.emplace_back(RISCV::ADDI, Lo12); 405 Res = TmpSeq; 406 } 407 } 408 } 409 } 410 411 // Perform optimization with rori in the Zbb and th.srri in the XTheadBb 412 // extension. 413 if (Res.size() > 2 && (STI.hasFeature(RISCV::FeatureStdExtZbb) || 414 STI.hasFeature(RISCV::FeatureVendorXTHeadBb))) { 415 if (unsigned Rotate = extractRotateInfo(Val)) { 416 RISCVMatInt::InstSeq TmpSeq; 417 uint64_t NegImm12 = llvm::rotl<uint64_t>(Val, Rotate); 418 assert(isInt<12>(NegImm12)); 419 TmpSeq.emplace_back(RISCV::ADDI, NegImm12); 420 TmpSeq.emplace_back(STI.hasFeature(RISCV::FeatureStdExtZbb) 421 ? RISCV::RORI 422 : RISCV::TH_SRRI, 423 Rotate); 424 Res = TmpSeq; 425 } 426 } 427 return Res; 428 } 429 430 void generateMCInstSeq(int64_t Val, const MCSubtargetInfo &STI, 431 MCRegister DestReg, SmallVectorImpl<MCInst> &Insts) { 432 RISCVMatInt::InstSeq Seq = RISCVMatInt::generateInstSeq(Val, STI); 433 434 MCRegister SrcReg = RISCV::X0; 435 for (RISCVMatInt::Inst &Inst : Seq) { 436 switch (Inst.getOpndKind()) { 437 case RISCVMatInt::Imm: 438 Insts.push_back(MCInstBuilder(Inst.getOpcode()) 439 .addReg(DestReg) 440 .addImm(Inst.getImm())); 441 break; 442 case RISCVMatInt::RegX0: 443 Insts.push_back(MCInstBuilder(Inst.getOpcode()) 444 .addReg(DestReg) 445 .addReg(SrcReg) 446 .addReg(RISCV::X0)); 447 break; 448 case RISCVMatInt::RegReg: 449 Insts.push_back(MCInstBuilder(Inst.getOpcode()) 450 .addReg(DestReg) 451 .addReg(SrcReg) 452 .addReg(SrcReg)); 453 break; 454 case RISCVMatInt::RegImm: 455 Insts.push_back(MCInstBuilder(Inst.getOpcode()) 456 .addReg(DestReg) 457 .addReg(SrcReg) 458 .addImm(Inst.getImm())); 459 break; 460 } 461 462 // Only the first instruction has X0 as its source. 463 SrcReg = DestReg; 464 } 465 } 466 467 InstSeq generateTwoRegInstSeq(int64_t Val, const MCSubtargetInfo &STI, 468 unsigned &ShiftAmt, unsigned &AddOpc) { 469 int64_t LoVal = SignExtend64<32>(Val); 470 if (LoVal == 0) 471 return RISCVMatInt::InstSeq(); 472 473 // Subtract the LoVal to emulate the effect of the final ADD. 474 uint64_t Tmp = (uint64_t)Val - (uint64_t)LoVal; 475 assert(Tmp != 0); 476 477 // Use trailing zero counts to figure how far we need to shift LoVal to line 478 // up with the remaining constant. 479 // TODO: This algorithm assumes all non-zero bits in the low 32 bits of the 480 // final constant come from LoVal. 481 unsigned TzLo = llvm::countr_zero((uint64_t)LoVal); 482 unsigned TzHi = llvm::countr_zero(Tmp); 483 assert(TzLo < 32 && TzHi >= 32); 484 ShiftAmt = TzHi - TzLo; 485 AddOpc = RISCV::ADD; 486 487 if (Tmp == ((uint64_t)LoVal << ShiftAmt)) 488 return RISCVMatInt::generateInstSeq(LoVal, STI); 489 490 // If we have Zba, we can use (ADD_UW X, (SLLI X, 32)). 491 if (STI.hasFeature(RISCV::FeatureStdExtZba) && Lo_32(Val) == Hi_32(Val)) { 492 ShiftAmt = 32; 493 AddOpc = RISCV::ADD_UW; 494 return RISCVMatInt::generateInstSeq(LoVal, STI); 495 } 496 497 return RISCVMatInt::InstSeq(); 498 } 499 500 int getIntMatCost(const APInt &Val, unsigned Size, const MCSubtargetInfo &STI, 501 bool CompressionCost) { 502 bool IsRV64 = STI.hasFeature(RISCV::Feature64Bit); 503 bool HasRVC = CompressionCost && (STI.hasFeature(RISCV::FeatureStdExtC) || 504 STI.hasFeature(RISCV::FeatureStdExtZca)); 505 int PlatRegSize = IsRV64 ? 64 : 32; 506 507 // Split the constant into platform register sized chunks, and calculate cost 508 // of each chunk. 509 int Cost = 0; 510 for (unsigned ShiftVal = 0; ShiftVal < Size; ShiftVal += PlatRegSize) { 511 APInt Chunk = Val.ashr(ShiftVal).sextOrTrunc(PlatRegSize); 512 InstSeq MatSeq = generateInstSeq(Chunk.getSExtValue(), STI); 513 Cost += getInstSeqCost(MatSeq, HasRVC); 514 } 515 return std::max(1, Cost); 516 } 517 518 OpndKind Inst::getOpndKind() const { 519 switch (Opc) { 520 default: 521 llvm_unreachable("Unexpected opcode!"); 522 case RISCV::LUI: 523 return RISCVMatInt::Imm; 524 case RISCV::ADD_UW: 525 return RISCVMatInt::RegX0; 526 case RISCV::SH1ADD: 527 case RISCV::SH2ADD: 528 case RISCV::SH3ADD: 529 case RISCV::PACK: 530 return RISCVMatInt::RegReg; 531 case RISCV::ADDI: 532 case RISCV::ADDIW: 533 case RISCV::XORI: 534 case RISCV::SLLI: 535 case RISCV::SRLI: 536 case RISCV::SLLI_UW: 537 case RISCV::RORI: 538 case RISCV::BSETI: 539 case RISCV::BCLRI: 540 case RISCV::TH_SRRI: 541 return RISCVMatInt::RegImm; 542 } 543 } 544 545 } // namespace llvm::RISCVMatInt 546