From e474c4e3aadc22a1b9f9b006104409f10936244f Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Tue, 16 Feb 2021 11:48:21 -0800 Subject: Add an accessor for IRInst opcode (#1707) * Add an accessor for IRInst opcode This main changing is renaming `IRInst::op` over to `IRInst::m_op` and then adds an accessor `IRInst::getOp()` to read it. The rest of the changes are just changing use sites to `getOp` (or to `m_op` in the limited cases where we write to it). This work is in anticipation of a future change that might need to store an extra bit in the same field as the opcode. It seemed better to do this massive refactoring as a separate PR. * fixup --- source/slang/slang-serialize-ir.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/slang/slang-serialize-ir.cpp') diff --git a/source/slang/slang-serialize-ir.cpp b/source/slang/slang-serialize-ir.cpp index e5fbdcc04..96818a130 100644 --- a/source/slang/slang-serialize-ir.cpp +++ b/source/slang/slang-serialize-ir.cpp @@ -190,7 +190,7 @@ Result IRSerialWriter::write(IRModule* module, SerialSourceLocWriter* sourceLocW IRInst* srcInst = m_insts[i]; Ser::Inst& dstInst = m_serialData->m_insts[i]; - dstInst.m_op = uint16_t(srcInst->op & kIROpMeta_OpMask); + dstInst.m_op = uint16_t(srcInst->getOp() & kIROpMeta_OpMask); dstInst.m_payloadType = PayloadType::Empty; dstInst.m_resultTypeIndex = getInstIndex(srcInst->getFullType()); @@ -198,7 +198,7 @@ Result IRSerialWriter::write(IRModule* module, SerialSourceLocWriter* sourceLocW IRConstant* irConst = as(srcInst); if (irConst) { - switch (srcInst->op) + switch (srcInst->getOp()) { // Special handling for the ir const derived types case kIROp_StringLit: @@ -245,7 +245,7 @@ Result IRSerialWriter::write(IRModule* module, SerialSourceLocWriter* sourceLocW if (textureBase) { dstInst.m_payloadType = PayloadType::OperandAndUInt32; - dstInst.m_payload.m_operandAndUInt32.m_uint32 = uint32_t(srcInst->op) >> kIROpMeta_OtherShift; + dstInst.m_payload.m_operandAndUInt32.m_uint32 = uint32_t(srcInst->getOp()) >> kIROpMeta_OtherShift; dstInst.m_payload.m_operandAndUInt32.m_operand = getInstIndex(textureBase->getElementType()); continue; } @@ -793,7 +793,7 @@ Result IRSerialReader::read(const IRSerialData& data, Session* session, SerialSo // Reintroduce the texture type bits into the the const uint32_t other = srcInst.m_payload.m_operandAndUInt32.m_uint32; - inst->op = IROp(uint32_t(inst->op) | (other << kIROpMeta_OtherShift)); + inst->m_op = IROp(uint32_t(inst->getOp()) | (other << kIROpMeta_OtherShift)); insts[i] = inst; } -- cgit v1.2.3