diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 6056248..5cf61a0 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -262,6 +262,11 @@ class Module { /// The least-significant bits will be zero filled. Id OpShiftLeftLogical(Id result_type, Id base, Id shift); + // Arithmetic + + /// Unsigned-integer division of Operand 1 divided by Operand 2. + Id OpUDiv(Id result_type, Id operand_1, Id operand_2); + private: Id AddCode(std::unique_ptr op); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d8e9a79..b3d717e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,7 @@ add_library(sirit insts/logical.cpp insts/conversion.cpp insts/bit.cpp + insts/arithmetic.cpp ) target_include_directories(sirit PUBLIC ../include diff --git a/src/insts/arithmetic.cpp b/src/insts/arithmetic.cpp new file mode 100644 index 0000000..30363e0 --- /dev/null +++ b/src/insts/arithmetic.cpp @@ -0,0 +1,21 @@ +/* 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::OpUDiv(Id result_type, Id operand_1, Id operand_2) { + auto op{std::make_unique(spv::Op::OpUDiv, bound++, result_type)}; + op->Add(operand_1); + op->Add(operand_2); + return AddCode(std::move(op)); +} + +} // namespace Sirit \ No newline at end of file