mirror of
https://github.com/yuzu-emu/sirit
synced 2024-11-22 17:53:54 +00:00
Move type opcodes to their own file
This commit is contained in:
parent
479f76f61b
commit
3bd3688567
6 changed files with 49 additions and 68 deletions
|
@ -8,6 +8,8 @@ add_library(sirit
|
|||
operand.cpp
|
||||
operand.h
|
||||
common_types.h
|
||||
opcodes.h
|
||||
opcodes_type.cpp
|
||||
)
|
||||
target_include_directories(sirit
|
||||
PUBLIC ../include
|
||||
|
|
15
src/impl.h
15
src/impl.h
|
@ -1,15 +0,0 @@
|
|||
/* This file is part of the sirit project.
|
||||
* Copyright (c) 2018 ReinUsesLisp
|
||||
* This software may be used and distributed according to the terms of the GNU
|
||||
* General Public License version 2 or any later version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
struct Impl final {
|
||||
public:
|
||||
explicit Impl();
|
||||
~Impl();
|
||||
|
||||
private:
|
||||
};
|
21
src/opcodes.h
Normal file
21
src/opcodes.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* This file is part of the sirit project.
|
||||
* Copyright (c) 2018 ReinUsesLisp
|
||||
* This software may be used and distributed according to the terms of the GNU
|
||||
* General Public License version 2 or any later version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "stream.h"
|
||||
#include "op.h"
|
||||
|
||||
namespace Sirit {
|
||||
|
||||
template<typename T>
|
||||
inline void WriteEnum(Stream& stream, spv::Op opcode, T value) {
|
||||
Op op{opcode};
|
||||
op.Add(static_cast<u32>(value));
|
||||
op.Write(stream);
|
||||
}
|
||||
|
||||
} // namespace Sirit
|
25
src/opcodes_type.cpp
Normal file
25
src/opcodes_type.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* This file is part of the sirit project.
|
||||
* Copyright (c) 2018 ReinUsesLisp
|
||||
* This software may be used and distributed according to the terms of the GNU
|
||||
* General Public License version 2 or any later version.
|
||||
*/
|
||||
|
||||
#include "sirit/sirit.h"
|
||||
#include "opcodes.h"
|
||||
|
||||
namespace Sirit {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
} // namespace Sirit
|
|
@ -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);
|
||||
|
|
33
src/type.h
33
src/type.h
|
@ -1,33 +0,0 @@
|
|||
/* This file is part of the sirit project.
|
||||
* Copyright (c) 2018 ReinUsesLisp
|
||||
* This software may be used and distributed according to the terms of the GNU
|
||||
* General Public License version 2 or any later version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "sirit/sirit.h"
|
||||
#include "ref.h"
|
||||
|
||||
namespace Sirit {
|
||||
|
||||
class TypeConstant : public Ref {
|
||||
public:
|
||||
Type(spv::Op opcode, u32 id, std::);
|
||||
~Type();
|
||||
|
||||
bool operator==(const Type& other) const;
|
||||
|
||||
private:
|
||||
/// Arguments can be type references or constants
|
||||
std::vector<Operand> args;
|
||||
|
||||
friend Type;
|
||||
};
|
||||
|
||||
using Type = TypeConstant;
|
||||
|
||||
using Constant = TypeConstant;
|
||||
|
||||
} // namespace Sirit
|
Loading…
Reference in a new issue