Skip to content

Commit 78f9e7f

Browse files
committed
Encoding fixes
1 parent d731b2e commit 78f9e7f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVMCCodeEmitter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ void SPIRVMCCodeEmitter::encodeUnknownType(const MCInst &MI,
114114
// Encode the first 32 SPIR-V bytes with the number of args and the opcode.
115115
const uint64_t OpCode = MI.getOperand(1).getImm();
116116
const uint32_t NumWords = MI.getNumOperands();
117-
const uint32_t FirstWord = (NumWords << 16) | OpCode;
117+
const uint32_t FirstWord = (0xFF & NumWords) << 16 | (0xFF & OpCode);
118+
119+
// encoding: <opcode+len> <result type> [<operand0> <operand1> ...]
118120
support::endian::write(CB, FirstWord, llvm::endianness::little);
119121

120122
emitOperand(MI.getOperand(0), CB);

0 commit comments

Comments
 (0)