2016-05-22 18:11:24 +00:00
|
|
|
// Copyright (c) 2016 Google Inc.
|
|
|
|
//
|
2016-09-01 19:33:59 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
2016-05-22 18:11:24 +00:00
|
|
|
//
|
2016-09-01 19:33:59 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2016-05-22 18:11:24 +00:00
|
|
|
//
|
2016-09-01 19:33:59 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2016-05-22 18:11:24 +00:00
|
|
|
|
2018-08-03 12:05:33 +00:00
|
|
|
#ifndef SOURCE_OPT_REFLECT_H_
|
|
|
|
#define SOURCE_OPT_REFLECT_H_
|
2016-05-22 18:11:24 +00:00
|
|
|
|
2018-08-03 19:06:09 +00:00
|
|
|
#include "source/latest_version_spirv_header.h"
|
2023-02-24 18:21:53 +00:00
|
|
|
#include "source/opcode.h"
|
2016-05-22 18:11:24 +00:00
|
|
|
|
|
|
|
namespace spvtools {
|
2018-07-09 15:32:29 +00:00
|
|
|
namespace opt {
|
2016-05-22 18:11:24 +00:00
|
|
|
|
|
|
|
// Note that as SPIR-V evolves over time, new opcodes may appear. So the
|
|
|
|
// following functions tend to be outdated and should be updated when SPIR-V
|
|
|
|
// version bumps.
|
|
|
|
|
2022-11-04 21:27:10 +00:00
|
|
|
inline bool IsDebug1Inst(spv::Op opcode) {
|
|
|
|
return (opcode >= spv::Op::OpSourceContinued &&
|
|
|
|
opcode <= spv::Op::OpSourceExtension) ||
|
|
|
|
opcode == spv::Op::OpString;
|
2017-07-13 00:16:51 +00:00
|
|
|
}
|
2022-11-04 21:27:10 +00:00
|
|
|
inline bool IsDebug2Inst(spv::Op opcode) {
|
|
|
|
return opcode == spv::Op::OpName || opcode == spv::Op::OpMemberName;
|
2017-10-20 22:04:20 +00:00
|
|
|
}
|
2022-11-04 21:27:10 +00:00
|
|
|
inline bool IsDebug3Inst(spv::Op opcode) {
|
|
|
|
return opcode == spv::Op::OpModuleProcessed;
|
2016-05-22 18:11:24 +00:00
|
|
|
}
|
2022-11-04 21:27:10 +00:00
|
|
|
inline bool IsOpLineInst(spv::Op opcode) {
|
|
|
|
return opcode == spv::Op::OpLine || opcode == spv::Op::OpNoLine;
|
2016-05-22 18:11:24 +00:00
|
|
|
}
|
2022-11-04 21:27:10 +00:00
|
|
|
inline bool IsAnnotationInst(spv::Op opcode) {
|
|
|
|
return (opcode >= spv::Op::OpDecorate &&
|
|
|
|
opcode <= spv::Op::OpGroupMemberDecorate) ||
|
|
|
|
opcode == spv::Op::OpDecorateId ||
|
|
|
|
opcode == spv::Op::OpDecorateStringGOOGLE ||
|
|
|
|
opcode == spv::Op::OpMemberDecorateStringGOOGLE;
|
2016-05-22 18:11:24 +00:00
|
|
|
}
|
2022-11-04 21:27:10 +00:00
|
|
|
inline bool IsTypeInst(spv::Op opcode) {
|
2023-02-15 20:09:55 +00:00
|
|
|
return spvOpcodeGeneratesType(opcode) ||
|
|
|
|
opcode == spv::Op::OpTypeForwardPointer;
|
2016-05-22 18:11:24 +00:00
|
|
|
}
|
2022-11-04 21:27:10 +00:00
|
|
|
inline bool IsConstantInst(spv::Op opcode) {
|
2023-02-15 20:09:55 +00:00
|
|
|
return spvOpcodeIsConstant(opcode);
|
2017-11-30 22:03:06 +00:00
|
|
|
}
|
2022-11-04 21:27:10 +00:00
|
|
|
inline bool IsSpecConstantInst(spv::Op opcode) {
|
2023-02-15 20:09:55 +00:00
|
|
|
return spvOpcodeIsSpecConstant(opcode);
|
2017-11-30 22:03:06 +00:00
|
|
|
}
|
2016-05-22 18:11:24 +00:00
|
|
|
|
2018-07-09 15:32:29 +00:00
|
|
|
} // namespace opt
|
2016-05-22 18:11:24 +00:00
|
|
|
} // namespace spvtools
|
|
|
|
|
2018-08-03 12:05:33 +00:00
|
|
|
#endif // SOURCE_OPT_REFLECT_H_
|