mirror of
https://git.suyu.dev/suyu/sirit.git
synced 2025-12-21 21:36:17 +01:00
Rename "insts" directory to "instructions"
This commit is contained in:
parent
f5944d61a6
commit
f259019494
15 changed files with 14 additions and 14 deletions
58
src/instructions/arithmetic.cpp
Normal file
58
src/instructions/arithmetic.cpp
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/* 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 3 or any later version.
|
||||
*/
|
||||
|
||||
#include "common_types.h"
|
||||
#include "op.h"
|
||||
#include "sirit/sirit.h"
|
||||
#include <memory>
|
||||
|
||||
namespace Sirit {
|
||||
|
||||
#define DEFINE_UNARY(funcname, opcode) \
|
||||
Id Module::funcname(Id result_type, Id operand) { \
|
||||
auto op{std::make_unique<Op>(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<Op>(opcode, bound++, result_type)}; \
|
||||
op->Add(operand_1); \
|
||||
op->Add(operand_2); \
|
||||
return AddCode(std::move(op)); \
|
||||
}
|
||||
|
||||
#define DEFINE_TRINARY(funcname, opcode) \
|
||||
Id Module::funcname(Id result_type, Id operand_1, Id operand_2, \
|
||||
Id operand_3) { \
|
||||
auto op{std::make_unique<Op>(opcode, bound++, result_type)}; \
|
||||
op->Add(operand_1); \
|
||||
op->Add(operand_2); \
|
||||
op->Add(operand_3); \
|
||||
return AddCode(std::move(op)); \
|
||||
}
|
||||
|
||||
DEFINE_UNARY(OpSNegate, spv::Op::OpSNegate)
|
||||
DEFINE_UNARY(OpFNegate, spv::Op::OpFNegate)
|
||||
|
||||
DEFINE_BINARY(OpIAdd, spv::Op::OpIAdd)
|
||||
DEFINE_BINARY(OpFAdd, spv::Op::OpFAdd)
|
||||
DEFINE_BINARY(OpISub, spv::Op::OpISub)
|
||||
DEFINE_BINARY(OpFSub, spv::Op::OpFSub)
|
||||
DEFINE_BINARY(OpIMul, spv::Op::OpIMul)
|
||||
DEFINE_BINARY(OpFMul, spv::Op::OpFMul)
|
||||
DEFINE_BINARY(OpUDiv, spv::Op::OpUDiv)
|
||||
DEFINE_BINARY(OpSDiv, spv::Op::OpSDiv)
|
||||
DEFINE_BINARY(OpFDiv, spv::Op::OpFDiv)
|
||||
DEFINE_BINARY(OpUMod, spv::Op::OpUMod)
|
||||
DEFINE_BINARY(OpSMod, spv::Op::OpSMod)
|
||||
DEFINE_BINARY(OpFMod, spv::Op::OpFMod)
|
||||
DEFINE_BINARY(OpSRem, spv::Op::OpSRem)
|
||||
DEFINE_BINARY(OpFRem, spv::Op::OpFRem)
|
||||
|
||||
|
||||
} // namespace Sirit
|
||||
Loading…
Add table
Add a link
Reference in a new issue