Add OpArithmetic

This commit is contained in:
ReinUsesLisp 2018-11-02 23:49:41 -03:00
parent c29314ad14
commit 15a4d3c0d4
3 changed files with 27 additions and 0 deletions

View file

@ -262,6 +262,11 @@ class Module {
/// The least-significant bits will be zero filled. /// The least-significant bits will be zero filled.
Id OpShiftLeftLogical(Id result_type, Id base, Id shift); 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: private:
Id AddCode(std::unique_ptr<Op> op); Id AddCode(std::unique_ptr<Op> op);

View file

@ -23,6 +23,7 @@ add_library(sirit
insts/logical.cpp insts/logical.cpp
insts/conversion.cpp insts/conversion.cpp
insts/bit.cpp insts/bit.cpp
insts/arithmetic.cpp
) )
target_include_directories(sirit target_include_directories(sirit
PUBLIC ../include PUBLIC ../include

21
src/insts/arithmetic.cpp Normal file
View file

@ -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 <memory>
namespace Sirit {
Id Module::OpUDiv(Id result_type, Id operand_1, Id operand_2) {
auto op{std::make_unique<Op>(spv::Op::OpUDiv, bound++, result_type)};
op->Add(operand_1);
op->Add(operand_2);
return AddCode(std::move(op));
}
} // namespace Sirit