Move type opcodes to their own file

This commit is contained in:
ReinUsesLisp 2018-08-26 04:49:16 -03:00
parent 479f76f61b
commit 3bd3688567
6 changed files with 49 additions and 68 deletions

View file

@ -10,16 +10,10 @@
#include "common_types.h"
#include "op.h"
#include "stream.h"
#include "opcodes.h"
namespace Sirit {
template<typename T>
static void WriteEnum(Stream& stream, spv::Op opcode, T value) {
Op op{opcode};
op.Add(static_cast<u32>(value));
op.Write(stream);
}
Module::Module() {}
Module::~Module() = default;
@ -89,19 +83,6 @@ void Module::AddEntryPoint(spv::ExecutionModel execution_model, const Op* entry_
entry_points.push_back(std::unique_ptr<Op>(op));
}
const Op* Module::TypeVoid() {
return AddDeclaration(new Op(spv::Op::OpTypeVoid, bound));
}
const Op* Module::TypeFunction(const Op* return_type, const std::vector<const Op*>& arguments) {
Op* type_func{new Op(spv::Op::OpTypeFunction, bound)};
type_func->Add(return_type);
for (const Op* arg : arguments) {
type_func->Add(arg);
}
return AddDeclaration(type_func);
}
const Op* Module::Emit(const Op* op) {
assert(op);
code.push_back(op);