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