@@ -2097,6 +2097,10 @@ bool AMDGPUOperand::isInlinableImm(MVT type) const {
2097
2097
// Only plain immediates are inlinable (e.g. "clamp" attribute is not)
2098
2098
return false ;
2099
2099
}
2100
+
2101
+ if (getModifiers ().Lit != LitModifier::None)
2102
+ return false ;
2103
+
2100
2104
// TODO: We should avoid using host float here. It would be better to
2101
2105
// check the float bit values which is what a few other places do.
2102
2106
// We've had bot failures before due to weird NaN support on mips hosts.
@@ -2341,7 +2345,8 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2341
2345
case AMDGPU::OPERAND_REG_INLINE_C_INT64:
2342
2346
case AMDGPU::OPERAND_REG_INLINE_C_FP64:
2343
2347
case AMDGPU::OPERAND_REG_INLINE_AC_FP64:
2344
- if (AMDGPU::isInlinableLiteral64 (Literal.getZExtValue (),
2348
+ if (Lit == LitModifier::None &&
2349
+ AMDGPU::isInlinableLiteral64 (Literal.getZExtValue (),
2345
2350
AsmParser->hasInv2PiInlineImm ())) {
2346
2351
Inst.addOperand (MCOperand::createImm (Literal.getZExtValue ()));
2347
2352
return ;
@@ -2378,14 +2383,7 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2378
2383
Val = Hi_32 (Val);
2379
2384
}
2380
2385
}
2381
-
2382
- if (Lit != LitModifier::None) {
2383
- Inst.addOperand (
2384
- MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2385
- } else {
2386
- Inst.addOperand (MCOperand::createImm (Val));
2387
- }
2388
- return ;
2386
+ break ;
2389
2387
}
2390
2388
2391
2389
// We don't allow fp literals in 64-bit integer instructions. It is
@@ -2397,20 +2395,14 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2397
2395
if (CanUse64BitLiterals && Lit == LitModifier::None &&
2398
2396
(isInt<32 >(Val) || isUInt<32 >(Val)))
2399
2397
Lit = LitModifier::Lit64;
2400
-
2401
- if (Lit != LitModifier::None) {
2402
- Inst.addOperand (
2403
- MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2404
- } else {
2405
- Inst.addOperand (MCOperand::createImm (Val));
2406
- }
2407
- return ;
2398
+ break ;
2408
2399
2409
2400
case AMDGPU::OPERAND_REG_IMM_BF16:
2410
2401
case AMDGPU::OPERAND_REG_INLINE_C_BF16:
2411
2402
case AMDGPU::OPERAND_REG_INLINE_C_V2BF16:
2412
2403
case AMDGPU::OPERAND_REG_IMM_V2BF16:
2413
- if (AsmParser->hasInv2PiInlineImm () && Literal == 0x3fc45f306725feed ) {
2404
+ if (Lit == LitModifier::None && AsmParser->hasInv2PiInlineImm () &&
2405
+ Literal == 0x3fc45f306725feed ) {
2414
2406
// This is the 1/(2*pi) which is going to be truncated to bf16 with the
2415
2407
// loss of precision. The constant represents ideomatic fp32 value of
2416
2408
// 1/(2*pi) = 0.15915494 since bf16 is in fact fp32 with cleared low 16
@@ -2448,14 +2440,19 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2448
2440
// We allow precision lost but not overflow or underflow. This should be
2449
2441
// checked earlier in isLiteralImm()
2450
2442
2451
- uint64_t ImmVal = FPLiteral.bitcastToAPInt ().getZExtValue ();
2452
- Inst.addOperand (MCOperand::createImm (ImmVal));
2453
- return ;
2443
+ Val = FPLiteral.bitcastToAPInt ().getZExtValue ();
2444
+ break ;
2454
2445
}
2455
2446
default :
2456
2447
llvm_unreachable (" invalid operand size" );
2457
2448
}
2458
2449
2450
+ if (Lit != LitModifier::None) {
2451
+ Inst.addOperand (
2452
+ MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2453
+ } else {
2454
+ Inst.addOperand (MCOperand::createImm (Val));
2455
+ }
2459
2456
return ;
2460
2457
}
2461
2458
@@ -2475,12 +2472,12 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2475
2472
case AMDGPU::OPERAND_REG_IMM_V2INT32:
2476
2473
case AMDGPU::OPERAND_INLINE_SPLIT_BARRIER_INT32:
2477
2474
case AMDGPU::OPERAND_REG_IMM_NOINLINE_V2FP16:
2478
- Inst.addOperand (MCOperand::createImm (Val));
2479
- return ;
2475
+ break ;
2480
2476
2481
2477
case AMDGPU::OPERAND_REG_IMM_INT64:
2482
2478
case AMDGPU::OPERAND_REG_INLINE_C_INT64:
2483
- if (AMDGPU::isInlinableLiteral64 (Val, AsmParser->hasInv2PiInlineImm ())) {
2479
+ if (Lit == LitModifier::None &&
2480
+ AMDGPU::isInlinableLiteral64 (Val, AsmParser->hasInv2PiInlineImm ())) {
2484
2481
Inst.addOperand (MCOperand::createImm (Val));
2485
2482
return ;
2486
2483
}
@@ -2491,19 +2488,13 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2491
2488
// LSBs.
2492
2489
if (!AsmParser->has64BitLiterals () || Lit == LitModifier::Lit)
2493
2490
Val = Lo_32 (Val);
2494
-
2495
- if (Lit != LitModifier::None) {
2496
- Inst.addOperand (
2497
- MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2498
- } else {
2499
- Inst.addOperand (MCOperand::createImm (Val));
2500
- }
2501
- return ;
2491
+ break ;
2502
2492
2503
2493
case AMDGPU::OPERAND_REG_IMM_FP64:
2504
2494
case AMDGPU::OPERAND_REG_INLINE_C_FP64:
2505
2495
case AMDGPU::OPERAND_REG_INLINE_AC_FP64:
2506
- if (AMDGPU::isInlinableLiteral64 (Val, AsmParser->hasInv2PiInlineImm ())) {
2496
+ if (Lit == LitModifier::None &&
2497
+ AMDGPU::isInlinableLiteral64 (Val, AsmParser->hasInv2PiInlineImm ())) {
2507
2498
Inst.addOperand (MCOperand::createImm (Val));
2508
2499
return ;
2509
2500
}
@@ -2526,14 +2517,7 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2526
2517
// For FP64 operands lit() specifies the high half of the value.
2527
2518
if (Lit == LitModifier::Lit)
2528
2519
Val = Hi_32 (Val);
2529
-
2530
- if (Lit != LitModifier::None) {
2531
- Inst.addOperand (
2532
- MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2533
- } else {
2534
- Inst.addOperand (MCOperand::createImm (Val));
2535
- }
2536
- return ;
2520
+ break ;
2537
2521
2538
2522
case AMDGPU::OPERAND_REG_IMM_INT16:
2539
2523
case AMDGPU::OPERAND_REG_INLINE_C_INT16:
@@ -2546,24 +2530,23 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2546
2530
case AMDGPU::OPERAND_REG_INLINE_C_V2BF16:
2547
2531
case AMDGPU::OPERAND_KIMM32:
2548
2532
case AMDGPU::OPERAND_KIMM16:
2549
- Inst.addOperand (MCOperand::createImm (Val));
2550
- return ;
2533
+ break ;
2551
2534
2552
2535
case AMDGPU::OPERAND_KIMM64:
2553
2536
if ((isInt<32 >(Val) || isUInt<32 >(Val)) && Lit != LitModifier::Lit64)
2554
2537
Val <<= 32 ;
2555
-
2556
- if (Lit != LitModifier::None) {
2557
- Inst.addOperand (
2558
- MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2559
- } else {
2560
- Inst.addOperand (MCOperand::createImm (Val));
2561
- }
2562
- return ;
2538
+ break ;
2563
2539
2564
2540
default :
2565
2541
llvm_unreachable (" invalid operand type" );
2566
2542
}
2543
+
2544
+ if (Lit != LitModifier::None) {
2545
+ Inst.addOperand (
2546
+ MCOperand::createExpr (AMDGPUMCExpr::createLit (Lit, Val, Ctx)));
2547
+ } else {
2548
+ Inst.addOperand (MCOperand::createImm (Val));
2549
+ }
2567
2550
}
2568
2551
2569
2552
void AMDGPUOperand::addRegOperands (MCInst &Inst, unsigned N) const {
0 commit comments