mirror of
https://github.com/yuzu-emu/sirit.git
synced 2024-11-26 04:15:40 +01:00
Add OpDecorate
This commit is contained in:
parent
54cc7d06ce
commit
1458bd2c1c
@ -204,6 +204,12 @@ class Module {
|
|||||||
Ref Variable(Ref result_type, spv::StorageClass storage_class,
|
Ref Variable(Ref result_type, spv::StorageClass storage_class,
|
||||||
Ref initializer = nullptr);
|
Ref initializer = nullptr);
|
||||||
|
|
||||||
|
// Annotation
|
||||||
|
|
||||||
|
/// Add a decoration to target.
|
||||||
|
Ref Decorate(Ref target, spv::Decoration decoration,
|
||||||
|
const std::vector<Operand*>& literals = {});
|
||||||
|
|
||||||
// Literals
|
// Literals
|
||||||
static Operand* Literal(std::uint32_t value);
|
static Operand* Literal(std::uint32_t value);
|
||||||
static Operand* Literal(std::uint64_t value);
|
static Operand* Literal(std::uint64_t value);
|
||||||
@ -219,6 +225,8 @@ class Module {
|
|||||||
|
|
||||||
Ref AddDeclaration(Op* op);
|
Ref AddDeclaration(Op* op);
|
||||||
|
|
||||||
|
Ref AddAnnotation(Op* op);
|
||||||
|
|
||||||
std::uint32_t bound{1};
|
std::uint32_t bound{1};
|
||||||
|
|
||||||
std::set<spv::Capability> capabilities;
|
std::set<spv::Capability> capabilities;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
add_library(sirit
|
add_library(sirit
|
||||||
../include/sirit/sirit.h
|
../include/sirit/sirit.h
|
||||||
sirit.cpp
|
sirit.cpp
|
||||||
op.cpp
|
op.cpp
|
||||||
op.h
|
op.h
|
||||||
stream.cpp
|
stream.cpp
|
||||||
stream.h
|
stream.h
|
||||||
operand.cpp
|
operand.cpp
|
||||||
@ -12,7 +12,7 @@ add_library(sirit
|
|||||||
lnumber.h
|
lnumber.h
|
||||||
lstring.cpp
|
lstring.cpp
|
||||||
lstring.h
|
lstring.h
|
||||||
common_types.h
|
common_types.h
|
||||||
insts.h
|
insts.h
|
||||||
insts/type.cpp
|
insts/type.cpp
|
||||||
insts/constant.cpp
|
insts/constant.cpp
|
||||||
@ -20,6 +20,7 @@ add_library(sirit
|
|||||||
insts/flow.cpp
|
insts/flow.cpp
|
||||||
insts/debug.cpp
|
insts/debug.cpp
|
||||||
insts/memory.cpp
|
insts/memory.cpp
|
||||||
|
insts/annotation.cpp
|
||||||
)
|
)
|
||||||
target_include_directories(sirit
|
target_include_directories(sirit
|
||||||
PUBLIC ../include
|
PUBLIC ../include
|
||||||
|
21
src/insts/annotation.cpp
Normal file
21
src/insts/annotation.cpp
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
|
||||||
|
* Lesser General Public License version 2.1 or any later version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "insts.h"
|
||||||
|
#include "sirit/sirit.h"
|
||||||
|
|
||||||
|
namespace Sirit {
|
||||||
|
|
||||||
|
Ref Module::Decorate(Ref target, spv::Decoration decoration,
|
||||||
|
const std::vector<Operand*>& literals) {
|
||||||
|
auto const op{new Op(spv::Op::OpDecorate)};
|
||||||
|
op->Add(target);
|
||||||
|
AddEnum(op, decoration);
|
||||||
|
op->Add(literals);
|
||||||
|
return AddAnnotation(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Sirit
|
@ -77,6 +77,12 @@ void Op::Add(const std::vector<Ref>& ids) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Op::Add(const std::vector<Operand*>& operands) {
|
||||||
|
for (Operand* operand : operands) {
|
||||||
|
Add(operand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
u16 Op::WordCount() const {
|
u16 Op::WordCount() const {
|
||||||
u16 count{1};
|
u16 count{1};
|
||||||
if (result_type) {
|
if (result_type) {
|
||||||
|
2
src/op.h
2
src/op.h
@ -37,6 +37,8 @@ class Op : public Operand {
|
|||||||
|
|
||||||
void Add(const std::vector<Ref>& ids);
|
void Add(const std::vector<Ref>& ids);
|
||||||
|
|
||||||
|
void Add(const std::vector<Operand*>& operands);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u16 WordCount() const;
|
u16 WordCount() const;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ std::vector<u8> Module::Assemble() const {
|
|||||||
WriteSet(stream, entry_points);
|
WriteSet(stream, entry_points);
|
||||||
// TODO write execution mode
|
// TODO write execution mode
|
||||||
WriteSet(stream, debug);
|
WriteSet(stream, debug);
|
||||||
// TODO write annotations
|
WriteSet(stream, annotations);
|
||||||
WriteSet(stream, declarations);
|
WriteSet(stream, declarations);
|
||||||
WriteSet(stream, global_variables);
|
WriteSet(stream, global_variables);
|
||||||
WriteSet(stream, code);
|
WriteSet(stream, code);
|
||||||
@ -99,6 +99,7 @@ Ref Module::AddGlobalVariable(Ref variable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ref Module::AddCode(Op* op) {
|
Ref Module::AddCode(Op* op) {
|
||||||
|
assert(op);
|
||||||
code_store.push_back(std::unique_ptr<Op>(op));
|
code_store.push_back(std::unique_ptr<Op>(op));
|
||||||
return op;
|
return op;
|
||||||
}
|
}
|
||||||
@ -121,4 +122,10 @@ Ref Module::AddDeclaration(Op* op) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref Module::AddAnnotation(Op* op) {
|
||||||
|
assert(op);
|
||||||
|
annotations.push_back(std::unique_ptr<Op>(op));
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Sirit
|
} // namespace Sirit
|
||||||
|
Loading…
Reference in New Issue
Block a user