encoding |= opcode << 22;
encoding |= instr->definitions.size() ? instr->definitions[0].physReg() << 15 : 0;
encoding |= instr->operands.size() ? (instr->operands[0].physReg() >> 1) << 9 : 0;
- if (!instr->operands[1].isConstant() || instr->operands[1].constantValue() >= 1024) {
- encoding |= instr->operands[1].physReg().reg;
- } else {
- encoding |= instr->operands[1].constantValue() >> 2;
- encoding |= 1 << 8;
+ if (instr->operands.size() >= 2) {
+ if (!instr->operands[1].isConstant() || instr->operands[1].constantValue() >= 1024) {
+ encoding |= instr->operands[1].physReg().reg;
+ } else {
+ encoding |= instr->operands[1].constantValue() >> 2;
+ encoding |= 1 << 8;
+ }
}
out.push_back(encoding);
/* SMRD instructions can take a literal on GFX6 & GFX7 */
- if (instr->operands[1].isConstant() && instr->operands[1].constantValue() >= 1024)
+ if (instr->operands.size() >= 2 && instr->operands[1].isConstant() && instr->operands[1].constantValue() >= 1024)
out.push_back(instr->operands[1].constantValue() >> 2);
return;
}