@@ -2105,6 +2105,10 @@ bool AMDGPUOperand::isInlinableImm(MVT type) const {
2105
2105
// Only plain immediates are inlinable (e.g. "clamp" attribute is not)
2106
2106
return false ;
2107
2107
}
2108
+
2109
+ if (getModifiers ().Lit != LitModifier::None)
2110
+ return false ;
2111
+
2108
2112
// TODO: We should avoid using host float here. It would be better to
2109
2113
// check the float bit values which is what a few other places do.
2110
2114
// We've had bot failures before due to weird NaN support on mips hosts.
@@ -2349,7 +2353,8 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2349
2353
case AMDGPU::OPERAND_REG_INLINE_C_INT64:
2350
2354
case AMDGPU::OPERAND_REG_INLINE_C_FP64:
2351
2355
case AMDGPU::OPERAND_REG_INLINE_AC_FP64:
2352
- if (AMDGPU::isInlinableLiteral64 (Literal.getZExtValue (),
2356
+ if (Lit == LitModifier::None &&
2357
+ AMDGPU::isInlinableLiteral64 (Literal.getZExtValue (),
2353
2358
AsmParser->hasInv2PiInlineImm ())) {
2354
2359
Inst.addOperand (MCOperand::createImm (Literal.getZExtValue ()));
2355
2360
return ;
@@ -2386,14 +2391,7 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2386
2391
Val = Hi_32 (Val);
2387
2392
}
2388
2393
}
2389
-
2390
- if (Lit != LitModifier::None) {
2391
- Inst.addOperand (
2392
- MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2393
- } else {
2394
- Inst.addOperand (MCOperand::createImm (Val));
2395
- }
2396
- return ;
2394
+ break ;
2397
2395
}
2398
2396
2399
2397
// We don't allow fp literals in 64-bit integer instructions. It is
@@ -2405,20 +2403,14 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2405
2403
if (CanUse64BitLiterals && Lit == LitModifier::None &&
2406
2404
(isInt<32 >(Val) || isUInt<32 >(Val)))
2407
2405
Lit = LitModifier::Lit64;
2408
-
2409
- if (Lit != LitModifier::None) {
2410
- Inst.addOperand (
2411
- MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2412
- } else {
2413
- Inst.addOperand (MCOperand::createImm (Val));
2414
- }
2415
- return ;
2406
+ break ;
2416
2407
2417
2408
case AMDGPU::OPERAND_REG_IMM_BF16:
2418
2409
case AMDGPU::OPERAND_REG_INLINE_C_BF16:
2419
2410
case AMDGPU::OPERAND_REG_INLINE_C_V2BF16:
2420
2411
case AMDGPU::OPERAND_REG_IMM_V2BF16:
2421
- if (AsmParser->hasInv2PiInlineImm () && Literal == 0x3fc45f306725feed ) {
2412
+ if (Lit == LitModifier::None && AsmParser->hasInv2PiInlineImm () &&
2413
+ Literal == 0x3fc45f306725feed ) {
2422
2414
// This is the 1/(2*pi) which is going to be truncated to bf16 with the
2423
2415
// loss of precision. The constant represents ideomatic fp32 value of
2424
2416
// 1/(2*pi) = 0.15915494 since bf16 is in fact fp32 with cleared low 16
@@ -2456,14 +2448,19 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2456
2448
// We allow precision lost but not overflow or underflow. This should be
2457
2449
// checked earlier in isLiteralImm()
2458
2450
2459
- uint64_t ImmVal = FPLiteral.bitcastToAPInt ().getZExtValue ();
2460
- Inst.addOperand (MCOperand::createImm (ImmVal));
2461
- return ;
2451
+ Val = FPLiteral.bitcastToAPInt ().getZExtValue ();
2452
+ break ;
2462
2453
}
2463
2454
default :
2464
2455
llvm_unreachable (" invalid operand size" );
2465
2456
}
2466
2457
2458
+ if (Lit != LitModifier::None) {
2459
+ Inst.addOperand (
2460
+ MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2461
+ } else {
2462
+ Inst.addOperand (MCOperand::createImm (Val));
2463
+ }
2467
2464
return ;
2468
2465
}
2469
2466
@@ -2483,12 +2480,12 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2483
2480
case AMDGPU::OPERAND_REG_IMM_V2INT32:
2484
2481
case AMDGPU::OPERAND_INLINE_SPLIT_BARRIER_INT32:
2485
2482
case AMDGPU::OPERAND_REG_IMM_NOINLINE_V2FP16:
2486
- Inst.addOperand (MCOperand::createImm (Val));
2487
- return ;
2483
+ break ;
2488
2484
2489
2485
case AMDGPU::OPERAND_REG_IMM_INT64:
2490
2486
case AMDGPU::OPERAND_REG_INLINE_C_INT64:
2491
- if (AMDGPU::isInlinableLiteral64 (Val, AsmParser->hasInv2PiInlineImm ())) {
2487
+ if (Lit == LitModifier::None &&
2488
+ AMDGPU::isInlinableLiteral64 (Val, AsmParser->hasInv2PiInlineImm ())) {
2492
2489
Inst.addOperand (MCOperand::createImm (Val));
2493
2490
return ;
2494
2491
}
@@ -2499,19 +2496,13 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2499
2496
// LSBs.
2500
2497
if (!AsmParser->has64BitLiterals () || Lit == LitModifier::Lit)
2501
2498
Val = Lo_32 (Val);
2502
-
2503
- if (Lit != LitModifier::None) {
2504
- Inst.addOperand (
2505
- MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2506
- } else {
2507
- Inst.addOperand (MCOperand::createImm (Val));
2508
- }
2509
- return ;
2499
+ break ;
2510
2500
2511
2501
case AMDGPU::OPERAND_REG_IMM_FP64:
2512
2502
case AMDGPU::OPERAND_REG_INLINE_C_FP64:
2513
2503
case AMDGPU::OPERAND_REG_INLINE_AC_FP64:
2514
- if (AMDGPU::isInlinableLiteral64 (Val, AsmParser->hasInv2PiInlineImm ())) {
2504
+ if (Lit == LitModifier::None &&
2505
+ AMDGPU::isInlinableLiteral64 (Val, AsmParser->hasInv2PiInlineImm ())) {
2515
2506
Inst.addOperand (MCOperand::createImm (Val));
2516
2507
return ;
2517
2508
}
@@ -2534,14 +2525,7 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2534
2525
// For FP64 operands lit() specifies the high half of the value.
2535
2526
if (Lit == LitModifier::Lit)
2536
2527
Val = Hi_32 (Val);
2537
-
2538
- if (Lit != LitModifier::None) {
2539
- Inst.addOperand (
2540
- MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2541
- } else {
2542
- Inst.addOperand (MCOperand::createImm (Val));
2543
- }
2544
- return ;
2528
+ break ;
2545
2529
2546
2530
case AMDGPU::OPERAND_REG_IMM_INT16:
2547
2531
case AMDGPU::OPERAND_REG_INLINE_C_INT16:
@@ -2554,24 +2538,23 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2554
2538
case AMDGPU::OPERAND_REG_INLINE_C_V2BF16:
2555
2539
case AMDGPU::OPERAND_KIMM32:
2556
2540
case AMDGPU::OPERAND_KIMM16:
2557
- Inst.addOperand (MCOperand::createImm (Val));
2558
- return ;
2541
+ break ;
2559
2542
2560
2543
case AMDGPU::OPERAND_KIMM64:
2561
2544
if ((isInt<32 >(Val) || isUInt<32 >(Val)) && Lit != LitModifier::Lit64)
2562
2545
Val <<= 32 ;
2563
-
2564
- if (Lit != LitModifier::None) {
2565
- Inst.addOperand (
2566
- MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2567
- } else {
2568
- Inst.addOperand (MCOperand::createImm (Val));
2569
- }
2570
- return ;
2546
+ break ;
2571
2547
2572
2548
default :
2573
2549
llvm_unreachable (" invalid operand type" );
2574
2550
}
2551
+
2552
+ if (Lit != LitModifier::None) {
2553
+ Inst.addOperand (
2554
+ MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2555
+ } else {
2556
+ Inst.addOperand (MCOperand::createImm (Val));
2557
+ }
2575
2558
}
2576
2559
2577
2560
void AMDGPUOperand::addRegOperands (MCInst &Inst, unsigned N) const {
0 commit comments