From 27a0b4f17ecb938e4026f172fdbbe73fd072e122 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Sun, 4 Nov 2018 03:11:25 -0300 Subject: [PATCH] Add OpFNegate --- include/sirit/sirit.h | 3 +++ src/insts/arithmetic.cpp | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 892158e..c4ae703 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -286,6 +286,9 @@ class Module { // Arithmetic + /// Floating-point subtract of Operand from zero. + Id OpFNegate(Id result_type, Id operand); + /// Unsigned-integer division of Operand 1 divided by Operand 2. Id OpUDiv(Id result_type, Id operand_1, Id operand_2); diff --git a/src/insts/arithmetic.cpp b/src/insts/arithmetic.cpp index e785188..f002b0f 100644 --- a/src/insts/arithmetic.cpp +++ b/src/insts/arithmetic.cpp @@ -11,6 +11,13 @@ namespace Sirit { +#define DEFINE_UNARY(funcname, opcode) \ + Id Module::funcname(Id result_type, Id operand) { \ + auto op{std::make_unique(opcode, bound++, result_type)}; \ + op->Add(operand); \ + return AddCode(std::move(op)); \ + } + #define DEFINE_BINARY(funcname, opcode) \ Id Module::funcname(Id result_type, Id operand_1, Id operand_2) { \ auto op{std::make_unique(opcode, bound++, result_type)}; \ @@ -19,6 +26,8 @@ namespace Sirit { return AddCode(std::move(op)); \ } +DEFINE_UNARY(OpFNegate, spv::Op::OpFNegate); + DEFINE_BINARY(OpUDiv, spv::Op::OpUDiv) DEFINE_BINARY(OpIAdd, spv::Op::OpIAdd)