From 93c17d11f968ed61a53ccfcfff811e402e028f45 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Wed, 31 Oct 2018 04:26:35 -0300 Subject: [PATCH] Add OpUndef --- include/sirit/sirit.h | 5 +++++ src/CMakeLists.txt | 1 + src/insts/misc.cpp | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 src/insts/misc.cpp diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 3387ac0..3456110 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -219,6 +219,11 @@ class Module { spv::Decoration decoration, const std::vector& literals = {}); + // Misc + + /// Make an intermediate object whose value is undefined. + Ref Undef(Ref result_type); + private: Ref AddCode(Op* op); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index db94e83..08fa9be 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,6 +20,7 @@ add_library(sirit insts/debug.cpp insts/memory.cpp insts/annotation.cpp + insts/misc.cpp ) target_include_directories(sirit PUBLIC ../include diff --git a/src/insts/misc.cpp b/src/insts/misc.cpp new file mode 100644 index 0000000..e21d00e --- /dev/null +++ b/src/insts/misc.cpp @@ -0,0 +1,17 @@ +/* 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" +#include + +namespace Sirit { + +Ref Module::Undef(Ref result_type) { + return AddCode(new Op(spv::Op::OpUndef, bound++, result_type)); +} + +} // namespace Sirit