@@ -2436,17 +2436,8 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2436
2436
case AMDGPU::OPERAND_REG_IMM_V2FP32:
2437
2437
case AMDGPU::OPERAND_REG_IMM_V2INT32:
2438
2438
case AMDGPU::OPERAND_INLINE_SPLIT_BARRIER_INT32:
2439
- if (isSafeTruncation (Val, 32 ) &&
2440
- AMDGPU::isInlinableLiteral32 (static_cast <int32_t >(Val),
2441
- AsmParser->hasInv2PiInlineImm ())) {
2442
- Inst.addOperand (MCOperand::createImm (Val));
2443
- return ;
2444
- }
2445
- [[fallthrough]];
2446
-
2447
2439
case AMDGPU::OPERAND_REG_IMM_NOINLINE_V2FP16:
2448
-
2449
- Inst.addOperand (MCOperand::createImm (Lo_32 (Val)));
2440
+ Inst.addOperand (MCOperand::createImm (Val));
2450
2441
return ;
2451
2442
2452
2443
case AMDGPU::OPERAND_REG_IMM_INT64:
@@ -2494,77 +2485,27 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
2494
2485
2495
2486
case AMDGPU::OPERAND_REG_IMM_INT16:
2496
2487
case AMDGPU::OPERAND_REG_INLINE_C_INT16:
2497
- if (isSafeTruncation (Val, 16 ) &&
2498
- AMDGPU::isInlinableIntLiteral (static_cast <int16_t >(Val))) {
2499
- Inst.addOperand (MCOperand::createImm (Lo_32 (Val)));
2500
- return ;
2501
- }
2502
-
2503
- Inst.addOperand (MCOperand::createImm (Val & 0xffff ));
2504
- return ;
2505
-
2506
2488
case AMDGPU::OPERAND_REG_INLINE_C_FP16:
2507
2489
case AMDGPU::OPERAND_REG_IMM_FP16:
2508
- if (isSafeTruncation (Val, 16 ) &&
2509
- AMDGPU::isInlinableLiteralFP16 (static_cast <int16_t >(Val),
2510
- AsmParser->hasInv2PiInlineImm ())) {
2511
- Inst.addOperand (MCOperand::createImm (Val));
2512
- return ;
2513
- }
2514
-
2515
- Inst.addOperand (MCOperand::createImm (Val & 0xffff ));
2516
- return ;
2517
-
2518
2490
case AMDGPU::OPERAND_REG_IMM_BF16:
2519
2491
case AMDGPU::OPERAND_REG_INLINE_C_BF16:
2520
- if (isSafeTruncation (Val, 16 ) &&
2521
- AMDGPU::isInlinableLiteralBF16 (static_cast <int16_t >(Val),
2522
- AsmParser->hasInv2PiInlineImm ())) {
2523
- Inst.addOperand (MCOperand::createImm (Val));
2524
- return ;
2525
- }
2526
-
2527
- Inst.addOperand (MCOperand::createImm (Val & 0xffff ));
2528
- return ;
2529
-
2530
- case AMDGPU::OPERAND_REG_INLINE_C_V2INT16: {
2531
- assert (isSafeTruncation (Val, 16 ));
2532
- assert (AMDGPU::isInlinableIntLiteral (static_cast <int16_t >(Val)));
2533
- Inst.addOperand (MCOperand::createImm (Val));
2534
- return ;
2535
- }
2536
- case AMDGPU::OPERAND_REG_INLINE_C_V2FP16: {
2537
- assert (isSafeTruncation (Val, 16 ));
2538
- assert (AMDGPU::isInlinableLiteralFP16 (static_cast <int16_t >(Val),
2539
- AsmParser->hasInv2PiInlineImm ()));
2540
-
2541
- Inst.addOperand (MCOperand::createImm (Val));
2542
- return ;
2543
- }
2544
-
2545
- case AMDGPU::OPERAND_REG_INLINE_C_V2BF16: {
2546
- assert (isSafeTruncation (Val, 16 ));
2547
- assert (AMDGPU::isInlinableLiteralBF16 (static_cast <int16_t >(Val),
2548
- AsmParser->hasInv2PiInlineImm ()));
2549
-
2550
- Inst.addOperand (MCOperand::createImm (Val));
2551
- return ;
2552
- }
2553
-
2492
+ case AMDGPU::OPERAND_REG_INLINE_C_V2INT16:
2493
+ case AMDGPU::OPERAND_REG_INLINE_C_V2FP16:
2494
+ case AMDGPU::OPERAND_REG_INLINE_C_V2BF16:
2554
2495
case AMDGPU::OPERAND_KIMM32:
2555
- Inst.addOperand (MCOperand::createImm (Literal.getLoBits (32 ).getZExtValue ()));
2556
- return ;
2557
2496
case AMDGPU::OPERAND_KIMM16:
2558
- Inst.addOperand (MCOperand::createImm (Literal. getLoBits ( 16 ). getZExtValue () ));
2497
+ Inst.addOperand (MCOperand::createImm (Val ));
2559
2498
return ;
2499
+
2560
2500
case AMDGPU::OPERAND_KIMM64:
2561
2501
if ((isInt<32 >(Val) || isUInt<32 >(Val)) && !getModifiers ().Lit64 )
2562
2502
Val <<= 32 ;
2563
2503
2564
2504
Inst.addOperand (MCOperand::createImm (Val));
2565
2505
return ;
2506
+
2566
2507
default :
2567
- llvm_unreachable (" invalid operand size " );
2508
+ llvm_unreachable (" invalid operand type " );
2568
2509
}
2569
2510
}
2570
2511
@@ -4830,7 +4771,7 @@ bool AMDGPUAsmParser::validateSOPLiteral(const MCInst &Inst,
4830
4771
4831
4772
unsigned NumExprs = 0 ;
4832
4773
unsigned NumLiterals = 0 ;
4833
- uint64_t LiteralValue;
4774
+ int64_t LiteralValue;
4834
4775
4835
4776
for (int OpIdx : OpIndices) {
4836
4777
if (OpIdx == -1 ) break ;
@@ -4839,7 +4780,9 @@ bool AMDGPUAsmParser::validateSOPLiteral(const MCInst &Inst,
4839
4780
// Exclude special imm operands (like that used by s_set_gpr_idx_on)
4840
4781
if (AMDGPU::isSISrcOperand (Desc, OpIdx)) {
4841
4782
if (MO.isImm () && !isInlineConstant (Inst, OpIdx)) {
4842
- uint64_t Value = static_cast <uint64_t >(MO.getImm ());
4783
+ auto OpType = static_cast <AMDGPU::OperandType>(
4784
+ Desc.operands ()[OpIdx].OperandType );
4785
+ int64_t Value = encode32BitLiteral (MO.getImm (), OpType);
4843
4786
if (NumLiterals == 0 || LiteralValue != Value) {
4844
4787
LiteralValue = Value;
4845
4788
++NumLiterals;
0 commit comments