llvm.org GIT mirror llvm / 9298246
[AMDGPU] Assembler: fix v_mac_f16 immediates Reviewers: vpykhtin, artem.tamazov, tstellarAMD Subscribers: arsenm, kzhuravl, wdng, nhaehnle, yaxunl, tony-tye Differential Revision: https://reviews.llvm.org/D28802 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292224 91177308-0d34-0410-b5e6-96231b3b80d8 Sam Kolton 3 years ago
3 changed file(s) with 34 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
10291029 APFloat FPLiteral(APFloat::IEEEdouble(), APInt(64, Imm.Val));
10301030 if (!canLosslesslyConvertToFPType(FPLiteral, type))
10311031 return false;
1032
1033 if (type.getScalarSizeInBits() == 16) {
1034 return AMDGPU::isInlinableLiteral16(
1035 static_cast(FPLiteral.bitcastToAPInt().getZExtValue()),
1036 AsmParser->hasInv2PiInlineImm());
1037 }
10321038
10331039 // Check if single precision literal is inlinable
10341040 return AMDGPU::isInlinableLiteral32(
35463552
35473553 void AMDGPUAsmParser::cvtSDWA(MCInst &Inst, const OperandVector &Operands,
35483554 uint64_t BasicInstType) {
3555 using namespace llvm::AMDGPU::SDWA;
35493556 OptionalImmIndexMap OptionalIdx;
35503557
35513558 unsigned I = 1;
35803587 // V_NOP_sdwa_vi has no optional sdwa arguments
35813588 switch (BasicInstType) {
35823589 case SIInstrFlags::VOP1:
3583 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstSel, 6);
3584 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstUnused, 2);
3585 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc0Sel, 6);
3590 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstSel, SdwaSel::DWORD);
3591 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstUnused, DstUnused::UNUSED_PRESERVE);
3592 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc0Sel, SdwaSel::DWORD);
35863593 break;
35873594
35883595 case SIInstrFlags::VOP2:
3589 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstSel, 6);
3590 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstUnused, 2);
3591 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc0Sel, 6);
3592 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc1Sel, 6);
3596 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstSel, SdwaSel::DWORD);
3597 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstUnused, DstUnused::UNUSED_PRESERVE);
3598 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc0Sel, SdwaSel::DWORD);
3599 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc1Sel, SdwaSel::DWORD);
35933600 break;
35943601
35953602 case SIInstrFlags::VOPC:
3596 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc0Sel, 6);
3597 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc1Sel, 6);
3603 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc0Sel, SdwaSel::DWORD);
3604 addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc1Sel, SdwaSel::DWORD);
35983605 break;
35993606
36003607 default:
439439 }
440440
441441 bool isInlinableLiteral16(int16_t Literal, bool HasInv2Pi) {
442 assert(HasInv2Pi);
442 if (!HasInv2Pi)
443 return false;
443444
444445 if (Literal >= -16 && Literal <= 64)
445446 return true;
0 // RUN: not llvm-mc -arch=amdgcn -show-encoding %s | FileCheck %s --check-prefix=SICI
1 // RUN: llvm-mc -arch=amdgcn -mcpu=hawaii -show-encoding %s | FileCheck %s --check-prefix=CI
1 // RUN: not llvm-mc -arch=amdgcn -mcpu=hawaii -show-encoding %s | FileCheck %s --check-prefix=CI
22 // RUN: not llvm-mc -arch=amdgcn -mcpu=tonga -show-encoding %s | FileCheck %s --check-prefix=VI
33
4 // RUN: not llvm-mc -arch=amdgcn -show-encoding %s 2>&1 | FileCheck %s --check-prefix=NOSI
5 // RUN: not llvm-mc -arch=amdgcn -mcpu=tonga -show-encoding %s 2>&1 | FileCheck %s -check-prefix=NOVI
4 // RUN: not llvm-mc -arch=amdgcn -show-encoding %s 2>&1 | FileCheck %s --check-prefix=NOSI --check-prefix=NOSICI
5 // RUN: not llvm-mc -arch=amdgcn -mcpu=hawaii -show-encoding %s 2>&1 | FileCheck %s --check-prefix=NOSICI
6 // RUN: not llvm-mc -arch=amdgcn -mcpu=tonga -show-encoding %s 2>&1 | FileCheck %s --check-prefix=NOVI
67
78
89 //===----------------------------------------------------------------------===//
256257 v_mac_f32_e64 v0, -v1, |v2|
257258 // SICI: v_mac_f32_e64 v0, -v1, |v2| ; encoding: [0x00,0x02,0x3e,0xd2,0x01,0x05,0x02,0x20]
258259 // VI: v_mac_f32_e64 v0, -v1, |v2| ; encoding: [0x00,0x02,0x16,0xd1,0x01,0x05,0x02,0x20]
260
261 v_mac_f16_e64 v0, 0.5, flat_scratch_lo
262 // NOSICI: error:
263 // VI: v_mac_f16_e64 v0, 0.5, flat_scratch_lo ; encoding: [0x00,0x00,0x23,0xd1,0xf0,0xcc,0x00,0x00]
264
265 v_mac_f16_e64 v0, -4.0, flat_scratch_lo
266 // NOSICI: error:
267 // VI: v_mac_f16_e64 v0, -4.0, flat_scratch_lo ; encoding: [0x00,0x00,0x23,0xd1,0xf6,0xcc,0x00,0x20]
268
269 v_mac_f16_e64 v0, flat_scratch_lo, -4.0
270 // NOSICI: error:
271 // VI: v_mac_f16_e64 v0, flat_scratch_lo, -4.0 ; encoding: [0x00,0x00,0x23,0xd1,0x66,0xec,0x01,0x40]
259272
260273 ///===---------------------------------------------------------------------===//
261274 // VOP3 Instructions