mirror of
https://git.suyu.dev/suyu/sirit.git
synced 2024-12-22 20:22:02 +00:00
Add OpArithmetic
This commit is contained in:
parent
c29314ad14
commit
15a4d3c0d4
3 changed files with 27 additions and 0 deletions
|
@ -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> op);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
21
src/insts/arithmetic.cpp
Normal file
21
src/insts/arithmetic.cpp
Normal 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
|
Loading…
Reference in a new issue