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"
|
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.
|
|
|
|
|
2017-07-13 00:16:51 +00:00
|
|
|
inline bool IsDebug1Inst(SpvOp opcode) {
|
|
|
|
return (opcode >= SpvOpSourceContinued && opcode <= SpvOpSourceExtension) ||
|
2017-10-23 14:53:28 +00:00
|
|
|
opcode == SpvOpString;
|
2017-07-13 00:16:51 +00:00
|
|
|
}
|
|
|
|
inline bool IsDebug2Inst(SpvOp opcode) {
|
2017-10-23 14:53:28 +00:00
|
|
|
return opcode == SpvOpName || opcode == SpvOpMemberName;
|
2017-10-20 22:04:20 +00:00
|
|
|
}
|
|
|
|
inline bool IsDebug3Inst(SpvOp opcode) {
|
|
|
|
return opcode == SpvOpModuleProcessed;
|
2016-05-22 18:11:24 +00:00
|
|
|
}
|
|
|
|
inline bool IsDebugLineInst(SpvOp opcode) {
|
|
|
|
return opcode == SpvOpLine || opcode == SpvOpNoLine;
|
|
|
|
}
|
|
|
|
inline bool IsAnnotationInst(SpvOp opcode) {
|
2017-12-24 10:15:14 +00:00
|
|
|
return (opcode >= SpvOpDecorate && opcode <= SpvOpGroupMemberDecorate) ||
|
2018-03-05 18:34:13 +00:00
|
|
|
opcode == SpvOpDecorateId || opcode == SpvOpDecorateStringGOOGLE ||
|
|
|
|
opcode == SpvOpMemberDecorateStringGOOGLE;
|
2016-05-22 18:11:24 +00:00
|
|
|
}
|
|
|
|
inline bool IsTypeInst(SpvOp opcode) {
|
|
|
|
return (opcode >= SpvOpTypeVoid && opcode <= SpvOpTypeForwardPointer) ||
|
2018-12-12 00:03:55 +00:00
|
|
|
opcode == SpvOpTypePipeStorage || opcode == SpvOpTypeNamedBarrier ||
|
|
|
|
opcode == SpvOpTypeAccelerationStructureNV;
|
2016-05-22 18:11:24 +00:00
|
|
|
}
|
|
|
|
inline bool IsConstantInst(SpvOp opcode) {
|
|
|
|
return opcode >= SpvOpConstantTrue && opcode <= SpvOpSpecConstantOp;
|
|
|
|
}
|
2017-11-30 22:03:06 +00:00
|
|
|
inline bool IsCompileTimeConstantInst(SpvOp opcode) {
|
|
|
|
return opcode >= SpvOpConstantTrue && opcode <= SpvOpConstantNull;
|
|
|
|
}
|
|
|
|
inline bool IsSpecConstantInst(SpvOp opcode) {
|
|
|
|
return opcode >= SpvOpSpecConstantTrue && opcode <= SpvOpSpecConstantOp;
|
|
|
|
}
|
2016-05-22 18:11:24 +00:00
|
|
|
inline bool IsTerminatorInst(SpvOp opcode) {
|
|
|
|
return opcode >= SpvOpBranch && opcode <= SpvOpUnreachable;
|
|
|
|
}
|
|
|
|
|
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_
|