Skip to content

Commit 657b1cb

Browse files
committed
R600/SI: Don't crash when getting immediate operand size
llvm-svn: 230147
1 parent 70120fa commit 657b1cb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvm/lib/Target/R600/SIInstrInfo.h

+7
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,13 @@ class SIInstrInfo : public AMDGPUInstrInfo {
254254
// instruction opcode.
255255
unsigned getOpSize(uint16_t Opcode, unsigned OpNo) const {
256256
const MCOperandInfo &OpInfo = get(Opcode).OpInfo[OpNo];
257+
258+
if (OpInfo.RegClass == -1) {
259+
// If this is an immediate operand, this must be a 32-bit literal.
260+
assert(OpInfo.OperandType == MCOI::OPERAND_IMMEDIATE);
261+
return 4;
262+
}
263+
257264
return RI.getRegClass(OpInfo.RegClass)->getSize();
258265
}
259266

0 commit comments

Comments
 (0)