mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-30 06:50:06 +00:00
Add another construtor for opt::ir::Instruction
This commit is contained in:
parent
4987ae6549
commit
c814911904
@ -27,6 +27,7 @@
|
|||||||
#include "instruction.h"
|
#include "instruction.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
#include "reflect.h"
|
#include "reflect.h"
|
||||||
|
|
||||||
@ -50,6 +51,20 @@ Instruction::Instruction(const spv_parsed_instruction_t& inst,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
Instruction::Instruction(Instruction&& that)
|
||||||
: opcode_(that.opcode_),
|
: opcode_(that.opcode_),
|
||||||
type_id_(that.type_id_),
|
type_id_(that.type_id_),
|
||||||
|
@ -62,6 +62,9 @@ struct Operand {
|
|||||||
Operand(spv_operand_type_t t, std::vector<uint32_t>&& w)
|
Operand(spv_operand_type_t t, std::vector<uint32_t>&& w)
|
||||||
: type(t), words(std::move(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.
|
spv_operand_type_t type; // Type of this logical operand.
|
||||||
std::vector<uint32_t> words; // Binary segments of this logical operand.
|
std::vector<uint32_t> words; // Binary segments of this logical operand.
|
||||||
|
|
||||||
@ -85,6 +88,11 @@ class Instruction {
|
|||||||
Instruction(const spv_parsed_instruction_t& inst,
|
Instruction(const spv_parsed_instruction_t& inst,
|
||||||
std::vector<Instruction>&& dbg_line = {});
|
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(const Instruction&) = default;
|
||||||
Instruction& operator=(const Instruction&) = default;
|
Instruction& operator=(const Instruction&) = default;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user