#include "instruction.h"
#include <cassert>
+#include <initializer_list>
#include "reflect.h"
}
}
+Instruction::Instruction(SpvOp op, uint32_t ty_id, uint32_t res_id,
+ const std::vector<Operand>& in_operands)
+ : opcode_(op), type_id_(ty_id), result_id_(res_id), operands_() {
+ if (type_id_ != 0) {
+ operands_.emplace_back(spv_operand_type_t::SPV_OPERAND_TYPE_TYPE_ID,
+ std::initializer_list<uint32_t>{type_id_});
+ }
+ if (result_id_ != 0) {
+ operands_.emplace_back(spv_operand_type_t::SPV_OPERAND_TYPE_RESULT_ID,
+ std::initializer_list<uint32_t>{result_id_});
+ }
+ operands_.insert(operands_.end(), in_operands.begin(), in_operands.end());
+}
+
Instruction::Instruction(Instruction&& that)
: opcode_(that.opcode_),
type_id_(that.type_id_),
Operand(spv_operand_type_t t, std::vector<uint32_t>&& w)
: type(t), words(std::move(w)) {}
+ Operand(spv_operand_type_t t, const std::vector<uint32_t>& w)
+ : type(t), words(w) {}
+
spv_operand_type_t type; // Type of this logical operand.
std::vector<uint32_t> words; // Binary segments of this logical operand.
Instruction(const spv_parsed_instruction_t& inst,
std::vector<Instruction>&& dbg_line = {});
+ // Creates an instruction with the given opcode |op|, type id: |ty_id|,
+ // result id: |res_id| and input operands: |in_operands|.
+ Instruction(SpvOp op, uint32_t ty_id, uint32_t res_id,
+ const std::vector<Operand>& in_operands);
+
Instruction(const Instruction&) = default;
Instruction& operator=(const Instruction&) = default;