forked from OSchip/llvm-project
[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 llvm-svn: 292224
This commit is contained in:
parent
8b2996fe1a
commit
9dffada98b
|
@ -1031,6 +1031,12 @@ bool AMDGPUOperand::isInlinableImm(MVT type) const {
|
|||
if (!canLosslesslyConvertToFPType(FPLiteral, type))
|
||||
return false;
|
||||
|
||||
if (type.getScalarSizeInBits() == 16) {
|
||||
return AMDGPU::isInlinableLiteral16(
|
||||
static_cast<int32_t>(FPLiteral.bitcastToAPInt().getZExtValue()),
|
||||
AsmParser->hasInv2PiInlineImm());
|
||||
}
|
||||
|
||||
// Check if single precision literal is inlinable
|
||||
return AMDGPU::isInlinableLiteral32(
|
||||
static_cast<int32_t>(FPLiteral.bitcastToAPInt().getZExtValue()),
|
||||
|
@ -3547,6 +3553,7 @@ void AMDGPUAsmParser::cvtSdwaVOPC(MCInst &Inst, const OperandVector &Operands) {
|
|||
|
||||
void AMDGPUAsmParser::cvtSDWA(MCInst &Inst, const OperandVector &Operands,
|
||||
uint64_t BasicInstType) {
|
||||
using namespace llvm::AMDGPU::SDWA;
|
||||
OptionalImmIndexMap OptionalIdx;
|
||||
|
||||
unsigned I = 1;
|
||||
|
@ -3581,21 +3588,21 @@ void AMDGPUAsmParser::cvtSDWA(MCInst &Inst, const OperandVector &Operands,
|
|||
// V_NOP_sdwa_vi has no optional sdwa arguments
|
||||
switch (BasicInstType) {
|
||||
case SIInstrFlags::VOP1:
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstSel, 6);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstUnused, 2);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc0Sel, 6);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstSel, SdwaSel::DWORD);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstUnused, DstUnused::UNUSED_PRESERVE);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc0Sel, SdwaSel::DWORD);
|
||||
break;
|
||||
|
||||
case SIInstrFlags::VOP2:
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstSel, 6);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstUnused, 2);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc0Sel, 6);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc1Sel, 6);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstSel, SdwaSel::DWORD);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaDstUnused, DstUnused::UNUSED_PRESERVE);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc0Sel, SdwaSel::DWORD);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc1Sel, SdwaSel::DWORD);
|
||||
break;
|
||||
|
||||
case SIInstrFlags::VOPC:
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc0Sel, 6);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc1Sel, 6);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc0Sel, SdwaSel::DWORD);
|
||||
addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTySdwaSrc1Sel, SdwaSel::DWORD);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -440,7 +440,8 @@ bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi) {
|
|||
}
|
||||
|
||||
bool isInlinableLiteral16(int16_t Literal, bool HasInv2Pi) {
|
||||
assert(HasInv2Pi);
|
||||
if (!HasInv2Pi)
|
||||
return false;
|
||||
|
||||
if (Literal >= -16 && Literal <= 64)
|
||||
return true;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
// RUN: not llvm-mc -arch=amdgcn -show-encoding %s | FileCheck %s --check-prefix=SICI
|
||||
// RUN: llvm-mc -arch=amdgcn -mcpu=hawaii -show-encoding %s | FileCheck %s --check-prefix=CI
|
||||
// RUN: not llvm-mc -arch=amdgcn -mcpu=hawaii -show-encoding %s | FileCheck %s --check-prefix=CI
|
||||
// RUN: not llvm-mc -arch=amdgcn -mcpu=tonga -show-encoding %s | FileCheck %s --check-prefix=VI
|
||||
|
||||
// RUN: not llvm-mc -arch=amdgcn -show-encoding %s 2>&1 | FileCheck %s --check-prefix=NOSI
|
||||
// RUN: not llvm-mc -arch=amdgcn -mcpu=tonga -show-encoding %s 2>&1 | FileCheck %s -check-prefix=NOVI
|
||||
// RUN: not llvm-mc -arch=amdgcn -show-encoding %s 2>&1 | FileCheck %s --check-prefix=NOSI --check-prefix=NOSICI
|
||||
// RUN: not llvm-mc -arch=amdgcn -mcpu=hawaii -show-encoding %s 2>&1 | FileCheck %s --check-prefix=NOSICI
|
||||
// RUN: not llvm-mc -arch=amdgcn -mcpu=tonga -show-encoding %s 2>&1 | FileCheck %s --check-prefix=NOVI
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -258,6 +259,18 @@ v_mac_f32_e64 v0, -v1, |v2|
|
|||
// SICI: v_mac_f32_e64 v0, -v1, |v2| ; encoding: [0x00,0x02,0x3e,0xd2,0x01,0x05,0x02,0x20]
|
||||
// VI: v_mac_f32_e64 v0, -v1, |v2| ; encoding: [0x00,0x02,0x16,0xd1,0x01,0x05,0x02,0x20]
|
||||
|
||||
v_mac_f16_e64 v0, 0.5, flat_scratch_lo
|
||||
// NOSICI: error:
|
||||
// VI: v_mac_f16_e64 v0, 0.5, flat_scratch_lo ; encoding: [0x00,0x00,0x23,0xd1,0xf0,0xcc,0x00,0x00]
|
||||
|
||||
v_mac_f16_e64 v0, -4.0, flat_scratch_lo
|
||||
// NOSICI: error:
|
||||
// VI: v_mac_f16_e64 v0, -4.0, flat_scratch_lo ; encoding: [0x00,0x00,0x23,0xd1,0xf6,0xcc,0x00,0x20]
|
||||
|
||||
v_mac_f16_e64 v0, flat_scratch_lo, -4.0
|
||||
// NOSICI: error:
|
||||
// VI: v_mac_f16_e64 v0, flat_scratch_lo, -4.0 ; encoding: [0x00,0x00,0x23,0xd1,0x66,0xec,0x01,0x40]
|
||||
|
||||
///===---------------------------------------------------------------------===//
|
||||
// VOP3 Instructions
|
||||
///===---------------------------------------------------------------------===//
|
||||
|
|
Loading…
Reference in New Issue