mirror of
https://github.com/yuzu-emu/sirit.git
synced 2024-11-29 09:04:18 +01:00
Add OpVariable
This commit is contained in:
parent
c0aaf8989e
commit
a3022e4969
@ -191,6 +191,12 @@ class Module {
|
|||||||
/// @return target
|
/// @return target
|
||||||
Ref Name(Ref target, const std::string& name);
|
Ref Name(Ref target, const std::string& name);
|
||||||
|
|
||||||
|
// Memory
|
||||||
|
|
||||||
|
/// Allocate an object in memory, resulting in a copy to it.
|
||||||
|
Ref Variable(Ref result_type, spv::StorageClass storage_class,
|
||||||
|
Ref initializer = nullptr);
|
||||||
|
|
||||||
// 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);
|
||||||
|
@ -19,6 +19,7 @@ add_library(sirit
|
|||||||
insts/function.cpp
|
insts/function.cpp
|
||||||
insts/flow.cpp
|
insts/flow.cpp
|
||||||
insts/debug.cpp
|
insts/debug.cpp
|
||||||
|
insts/memory.cpp
|
||||||
)
|
)
|
||||||
target_include_directories(sirit
|
target_include_directories(sirit
|
||||||
PUBLIC ../include
|
PUBLIC ../include
|
||||||
|
22
src/insts/memory.cpp
Normal file
22
src/insts/memory.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/* 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::Variable(Ref result_type, spv::StorageClass storage_class,
|
||||||
|
Ref initializer) {
|
||||||
|
auto const op{new Op(spv::Op::OpVariable, bound++, result_type)};
|
||||||
|
AddEnum(op, storage_class);
|
||||||
|
if (initializer) {
|
||||||
|
op->Add(initializer);
|
||||||
|
}
|
||||||
|
return AddCode(op);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Sirit
|
Loading…
Reference in New Issue
Block a user