/src/spirv-tools/source/opt/reflect.h
Line | Count | Source |
1 | | // Copyright (c) 2016 Google Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | #ifndef SOURCE_OPT_REFLECT_H_ |
16 | | #define SOURCE_OPT_REFLECT_H_ |
17 | | |
18 | | #include "source/latest_version_spirv_header.h" |
19 | | #include "source/opcode.h" |
20 | | |
21 | | namespace spvtools { |
22 | | namespace opt { |
23 | | |
24 | | // Note that as SPIR-V evolves over time, new opcodes may appear. So the |
25 | | // following functions tend to be outdated and should be updated when SPIR-V |
26 | | // version bumps. |
27 | | |
28 | 20.5M | inline bool IsDebug1Inst(spv::Op opcode) { |
29 | 20.5M | return (opcode >= spv::Op::OpSourceContinued && |
30 | 20.5M | opcode <= spv::Op::OpSourceExtension) || |
31 | 20.5M | opcode == spv::Op::OpString; |
32 | 20.5M | } |
33 | 20.5M | inline bool IsDebug2Inst(spv::Op opcode) { |
34 | 20.5M | return opcode == spv::Op::OpName || opcode == spv::Op::OpMemberName; |
35 | 20.5M | } |
36 | 20.3M | inline bool IsDebug3Inst(spv::Op opcode) { |
37 | 20.3M | return opcode == spv::Op::OpModuleProcessed; |
38 | 20.3M | } |
39 | 27.9M | inline bool IsOpLineInst(spv::Op opcode) { |
40 | 27.9M | return opcode == spv::Op::OpLine || opcode == spv::Op::OpNoLine; |
41 | 27.9M | } |
42 | 21.5M | inline bool IsAnnotationInst(spv::Op opcode) { |
43 | 21.5M | return (opcode >= spv::Op::OpDecorate && |
44 | 19.5M | opcode <= spv::Op::OpGroupMemberDecorate) || |
45 | 2.10M | opcode == spv::Op::OpDecorateId || |
46 | 2.10M | opcode == spv::Op::OpDecorateStringGOOGLE || |
47 | 2.10M | opcode == spv::Op::OpMemberDecorateStringGOOGLE || |
48 | 2.10M | opcode == spv::Op::OpMemberDecorateIdEXT; |
49 | 21.5M | } |
50 | 9.75M | inline bool IsTypeInst(spv::Op opcode) { |
51 | 9.75M | return spvOpcodeGeneratesType(opcode) || |
52 | 8.28M | opcode == spv::Op::OpTypeForwardPointer; |
53 | 9.75M | } |
54 | 31.4M | inline bool IsConstantInst(spv::Op opcode) { |
55 | 31.4M | return spvOpcodeIsConstant(opcode); |
56 | 31.4M | } |
57 | 306k | inline bool IsSpecConstantInst(spv::Op opcode) { |
58 | 306k | return spvOpcodeIsSpecConstant(opcode); |
59 | 306k | } |
60 | | |
61 | | } // namespace opt |
62 | | } // namespace spvtools |
63 | | |
64 | | #endif // SOURCE_OPT_REFLECT_H_ |