Remove duplicate lists of constant and type opcodes Adding a new type instruction required making the same change in two places. Also remove IsCompileTimeConstantInst that was used in a single place and replace its use by an expression that better conveys the intent. Change-Id: I49330b74bd34a35db6369c438c053224805c18e0 Signed-off-by: Kevin Petit <kevin.petit@arm.com>
diff --git a/source/opcode.cpp b/source/opcode.cpp index b1785cc..d26024a 100644 --- a/source/opcode.cpp +++ b/source/opcode.cpp
@@ -240,6 +240,7 @@ case spv::Op::OpConstantComposite: case spv::Op::OpConstantSampler: case spv::Op::OpConstantNull: + case spv::Op::OpConstantFunctionPointerINTEL: case spv::Op::OpSpecConstantTrue: case spv::Op::OpSpecConstantFalse: case spv::Op::OpSpecConstant:
diff --git a/source/opt/instruction.h b/source/opt/instruction.h index 22736bf..d50e625 100644 --- a/source/opt/instruction.h +++ b/source/opt/instruction.h
@@ -906,7 +906,7 @@ bool Instruction::IsAtomicOp() const { return spvOpcodeIsAtomicOp(opcode()); } bool Instruction::IsConstant() const { - return IsCompileTimeConstantInst(opcode()); + return IsConstantInst(opcode()) && !IsSpecConstantInst(opcode()); } } // namespace opt } // namespace spvtools
diff --git a/source/opt/reflect.h b/source/opt/reflect.h index 45bb5c5..aaa4c63 100644 --- a/source/opt/reflect.h +++ b/source/opt/reflect.h
@@ -46,27 +46,14 @@ opcode == spv::Op::OpMemberDecorateStringGOOGLE; } inline bool IsTypeInst(spv::Op opcode) { - return (opcode >= spv::Op::OpTypeVoid && - opcode <= spv::Op::OpTypeForwardPointer) || - opcode == spv::Op::OpTypePipeStorage || - opcode == spv::Op::OpTypeNamedBarrier || - opcode == spv::Op::OpTypeAccelerationStructureNV || - opcode == spv::Op::OpTypeAccelerationStructureKHR || - opcode == spv::Op::OpTypeRayQueryKHR || - opcode == spv::Op::OpTypeCooperativeMatrixNV || - opcode == spv::Op::OpTypeHitObjectNV; + return spvOpcodeGeneratesType(opcode) || + opcode == spv::Op::OpTypeForwardPointer; } inline bool IsConstantInst(spv::Op opcode) { - return (opcode >= spv::Op::OpConstantTrue && - opcode <= spv::Op::OpSpecConstantOp) || - opcode == spv::Op::OpConstantFunctionPointerINTEL; -} -inline bool IsCompileTimeConstantInst(spv::Op opcode) { - return opcode >= spv::Op::OpConstantTrue && opcode <= spv::Op::OpConstantNull; + return spvOpcodeIsConstant(opcode); } inline bool IsSpecConstantInst(spv::Op opcode) { - return opcode >= spv::Op::OpSpecConstantTrue && - opcode <= spv::Op::OpSpecConstantOp; + return spvOpcodeIsSpecConstant(opcode); } } // namespace opt