From 9c7f96a8098eb50cf4a76cdcd8c84f9025a9c3e9 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Fri, 2 Nov 2018 23:24:10 -0300 Subject: [PATCH] Add OpLogicalNot and OpBitcast --- include/sirit/sirit.h | 5 +++++ src/CMakeLists.txt | 1 + src/insts/conversion.cpp | 20 ++++++++++++++++++++ src/insts/logical.cpp | 20 ++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 src/insts/conversion.cpp create mode 100644 src/insts/logical.cpp diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index c729595..7d2ae11 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -243,6 +243,11 @@ class Module { /// Result is true if Operand is false. Result is false if Operand is true. Id OpLogicalNot(Id result_type, Id operand); + // Conversion + + /// Bit pattern-preserving type conversion. + Id OpBitcast(Id result_type, Id operand); + private: Id AddCode(std::unique_ptr op); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b48292f..c7fbfd3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,6 +21,7 @@ add_library(sirit insts/annotation.cpp insts/misc.cpp insts/logical.cpp + insts/conversion.cpp ) target_include_directories(sirit PUBLIC ../include diff --git a/src/insts/conversion.cpp b/src/insts/conversion.cpp new file mode 100644 index 0000000..4f13bf1 --- /dev/null +++ b/src/insts/conversion.cpp @@ -0,0 +1,20 @@ +/* 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 "common_types.h" +#include "op.h" +#include "sirit/sirit.h" +#include + +namespace Sirit { + +Id Module::OpBitcast(Id result_type, Id operand) { + auto op{std::make_unique(spv::Op::OpBitcast, bound++, result_type)}; + op->Add(operand); + return AddCode(std::move(op)); +} + +} // namespace Sirit \ No newline at end of file diff --git a/src/insts/logical.cpp b/src/insts/logical.cpp new file mode 100644 index 0000000..41b73a1 --- /dev/null +++ b/src/insts/logical.cpp @@ -0,0 +1,20 @@ +/* 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 "common_types.h" +#include "op.h" +#include "sirit/sirit.h" +#include + +namespace Sirit { + +Id Module::OpLogicalNot(Id result_type, Id operand) { + auto op{std::make_unique(spv::Op::OpLogicalNot, bound++, result_type)}; + op->Add(operand); + return AddCode(std::move(op)); +} + +} // namespace Sirit \ No newline at end of file