From 01c658b8915e7ad9e92e9f681abf7781d1e867a7 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Wed, 31 Oct 2018 04:16:26 -0300 Subject: [PATCH] Add OpLoad --- include/sirit/sirit.h | 4 ++++ src/insts/memory.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index b54699f..3387ac0 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -200,6 +200,10 @@ class Module { Ref Variable(Ref result_type, spv::StorageClass storage_class, Ref initializer = nullptr); + /// Load through a pointer. + Ref Load(Ref result_type, Ref pointer, + std::optional memory_access = {}); + /// Create a pointer into a composite object that can be used with OpLoad /// and OpStore. Ref AccessChain(Ref result_type, Ref base, diff --git a/src/insts/memory.cpp b/src/insts/memory.cpp index b3e55b8..bf0147d 100644 --- a/src/insts/memory.cpp +++ b/src/insts/memory.cpp @@ -20,6 +20,16 @@ Ref Module::Variable(Ref result_type, spv::StorageClass storage_class, return AddCode(op); } +Ref Module::Load(Ref result_type, Ref pointer, + std::optional memory_access) { + auto op{new Op(spv::Op::OpLoad, bound++, result_type)}; + op->Add(pointer); + if (memory_access) { + AddEnum(op, *memory_access); + } + return AddCode(op); +} + Ref Module::AccessChain(Ref result_type, Ref base, const std::vector& indexes) { assert(indexes.size() > 0);