2016-01-07 18:44:22 +00:00
|
|
|
// Copyright (c) 2015-2016 The Khronos Group Inc.
|
2015-10-06 20:22:00 +00:00
|
|
|
//
|
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
|
2015-10-06 20:22:00 +00:00
|
|
|
//
|
2016-09-01 19:33:59 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2015-10-06 20:22:00 +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.
|
2015-10-06 20:22:00 +00:00
|
|
|
|
2015-10-27 20:27:05 +00:00
|
|
|
#ifndef LIBSPIRV_INSTRUCTION_H_
|
|
|
|
#define LIBSPIRV_INSTRUCTION_H_
|
2015-10-06 20:22:00 +00:00
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-08-06 17:25:02 +00:00
|
|
|
#include "spirv-tools/libspirv.h"
|
2017-03-14 16:43:41 +00:00
|
|
|
#include "spirv/1.2/spirv.h"
|
2015-10-06 20:22:00 +00:00
|
|
|
|
|
|
|
// Describes an instruction.
|
|
|
|
struct spv_instruction_t {
|
|
|
|
// Normally, both opcode and extInstType contain valid data.
|
|
|
|
// However, when the assembler parses !<number> as the first word in
|
|
|
|
// an instruction and opcode and extInstType are invalid.
|
2015-10-28 17:40:52 +00:00
|
|
|
SpvOp opcode;
|
2015-10-06 20:22:00 +00:00
|
|
|
spv_ext_inst_type_t extInstType;
|
|
|
|
|
2015-09-29 15:28:34 +00:00
|
|
|
// The Id of the result type, if this instruction has one. Zero otherwise.
|
|
|
|
uint32_t resultTypeId;
|
|
|
|
|
2015-10-06 20:22:00 +00:00
|
|
|
// The instruction, as a sequence of 32-bit words.
|
|
|
|
// For a regular instruction the opcode and word count are combined
|
|
|
|
// in words[0], as described in the SPIR-V spec.
|
|
|
|
// Otherwise, the first token was !<number>, and that number appears
|
|
|
|
// in words[0]. Subsequent elements are the result of parsing
|
|
|
|
// tokens in the alternate parsing mode as described in syntax.md.
|
|
|
|
std::vector<uint32_t> words;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Appends a word to an instruction, without checking for overflow.
|
2016-10-28 02:47:20 +00:00
|
|
|
inline void spvInstructionAddWord(spv_instruction_t* inst, uint32_t value) {
|
|
|
|
inst->words.push_back(value);
|
|
|
|
}
|
2015-10-06 20:22:00 +00:00
|
|
|
|
2015-10-27 20:27:05 +00:00
|
|
|
#endif // LIBSPIRV_INSTRUCTION_H_
|