forked from OSchip/llvm-project
AMDGPU: Fix parsing of 32-bit literals with sign bit set
llvm-svn: 251132
This commit is contained in:
parent
a745ddd9a7
commit
382557ec72
|
@ -987,13 +987,11 @@ AMDGPUAsmParser::parseOperand(OperandVector &Operands, StringRef Mnemonic) {
|
|||
int64_t IntVal;
|
||||
if (getParser().parseAbsoluteExpression(IntVal))
|
||||
return MatchOperand_ParseFail;
|
||||
APInt IntVal32(32, IntVal);
|
||||
if (IntVal32.getSExtValue() != IntVal) {
|
||||
if (!isInt<32>(IntVal) && !isUInt<32>(IntVal)) {
|
||||
Error(S, "invalid immediate: only 32-bit values are legal");
|
||||
return MatchOperand_ParseFail;
|
||||
}
|
||||
|
||||
IntVal = IntVal32.getSExtValue();
|
||||
if (Negate)
|
||||
IntVal *= -1;
|
||||
Operands.push_back(AMDGPUOperand::CreateImm(IntVal, S));
|
||||
|
|
|
@ -283,8 +283,13 @@ void AMDGPUInstPrinter::printImmediate64(uint64_t Imm, raw_ostream &O) {
|
|||
O << "4.0";
|
||||
else if (Imm == DoubleToBits(-4.0))
|
||||
O << "-4.0";
|
||||
else
|
||||
llvm_unreachable("64-bit literal constants not supported");
|
||||
else {
|
||||
assert(isUInt<32>(Imm));
|
||||
|
||||
// In rare situations, we will have a 32-bit literal in a 64-bit
|
||||
// operand. This is technically allowed for the encoding of s_mov_b64.
|
||||
O << formatHex(static_cast<uint64_t>(Imm));
|
||||
}
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||
|
|
|
@ -33,5 +33,14 @@ s_mov_b32 s1, 0xfffffffff
|
|||
s_mov_b64 s[0:1], 0xfffffffff
|
||||
// CHECK: error: invalid immediate: only 32-bit values are legal
|
||||
|
||||
s_mov_b64 s[0:1], 0xfffffffff
|
||||
// CHECK: error: invalid immediate: only 32-bit values are legal
|
||||
|
||||
s_mov_b64 s[0:1], 0xfffffffff
|
||||
// CHECK: error: invalid immediate: only 32-bit values are legal
|
||||
|
||||
s_mov_b64 s[0:1], 0x0000000200000000
|
||||
// CHECK: error: invalid immediate: only 32-bit values are legal
|
||||
|
||||
// Out of range register
|
||||
s_mov_b32 s
|
||||
|
|
|
@ -10,12 +10,26 @@ s_mov_b32 s1, 1
|
|||
s_mov_b32 s1, 100
|
||||
// CHECK: s_mov_b32 s1, 0x64 ; encoding: [0xff,0x03,0x81,0xbe,0x64,0x00,0x00,0x00]
|
||||
|
||||
// Literal constant sign bit
|
||||
s_mov_b32 s1, 0x80000000
|
||||
// CHECK: s_mov_b32 s1, 0x80000000 ; encoding: [0xff,0x03,0x81,0xbe,0x00,0x00,0x00,0x80]
|
||||
|
||||
// Negative 32-bit constant
|
||||
s_mov_b32 s0, 0xfe5163ab
|
||||
// CHECK: s_mov_b32 s0, 0xfe5163ab ; encoding: [0xff,0x03,0x80,0xbe,0xab,0x63,0x51,0xfe]
|
||||
|
||||
s_mov_b64 s[2:3], s[4:5]
|
||||
// CHECK: s_mov_b64 s[2:3], s[4:5] ; encoding: [0x04,0x04,0x82,0xbe]
|
||||
|
||||
s_mov_b64 s[2:3], 0xffffffffffffffff
|
||||
// CHECK: s_mov_b64 s[2:3], -1 ; encoding: [0xc1,0x04,0x82,0xbe]
|
||||
|
||||
s_mov_b64 s[2:3], 0xffffffff
|
||||
// CHECK: s_mov_b64 s[2:3], 0xffffffff ; encoding: [0xff,0x04,0x82,0xbe,0xff,0xff,0xff,0xff]
|
||||
|
||||
s_mov_b64 s[0:1], 0x80000000
|
||||
// CHECK: s_mov_b64 s[0:1], 0x80000000 ; encoding: [0xff,0x04,0x80,0xbe,0x00,0x00,0x00,0x80]
|
||||
|
||||
s_cmov_b32 s1, 200
|
||||
// CHECK: s_cmov_b32 s1, 0xc8 ; encoding: [0xff,0x05,0x81,0xbe,0xc8,0x00,0x00,0x00]
|
||||
|
||||
|
|
Loading…
Reference in New Issue