aboutsummaryrefslogtreecommitdiff
path: root/externals/sirit/src/instructions/logical.cpp
blob: 4d7292bf021bce2d078c71141553c67bf10a4647 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* This file is part of the sirit project.
 * Copyright (c) 2019 sirit
 * This software may be used and distributed according to the terms of the
 * 3-Clause BSD License
 */

#include "sirit/sirit.h"

#include "stream.h"

namespace Sirit {

#define DEFINE_UNARY(opcode)                                                                       \
    Id Module::opcode(Id result_type, Id operand) {                                                \
        code->Reserve(4);                                                                          \
        return *code << OpId{spv::Op::opcode, result_type} << operand << EndOp{};                  \
    }

#define DEFINE_BINARY(opcode)                                                                      \
    Id Module::opcode(Id result_type, Id operand_1, Id operand_2) {                                \
        code->Reserve(5);                                                                          \
        return *code << OpId{spv::Op::opcode, result_type} << operand_1 << operand_2 << EndOp{};   \
    }

#define DEFINE_TRINARY(opcode)                                                                     \
    Id Module::opcode(Id result_type, Id operand_1, Id operand_2, Id operand_3) {                  \
        code->Reserve(6);                                                                          \
        return *code << OpId{spv::Op::opcode, result_type} << operand_1 << operand_2 << operand_3  \
                     << EndOp{};                                                                   \
    }

DEFINE_UNARY(OpAny)
DEFINE_UNARY(OpAll)
DEFINE_UNARY(OpIsNan)
DEFINE_UNARY(OpIsInf)
DEFINE_BINARY(OpLogicalEqual)
DEFINE_BINARY(OpLogicalNotEqual)
DEFINE_BINARY(OpLogicalOr)
DEFINE_BINARY(OpLogicalAnd)
DEFINE_UNARY(OpLogicalNot)
DEFINE_TRINARY(OpSelect)
DEFINE_BINARY(OpIEqual)
DEFINE_BINARY(OpINotEqual)
DEFINE_BINARY(OpUGreaterThan)
DEFINE_BINARY(OpSGreaterThan)
DEFINE_BINARY(OpUGreaterThanEqual)
DEFINE_BINARY(OpSGreaterThanEqual)
DEFINE_BINARY(OpULessThan)
DEFINE_BINARY(OpSLessThan)
DEFINE_BINARY(OpULessThanEqual)
DEFINE_BINARY(OpSLessThanEqual)
DEFINE_BINARY(OpFOrdEqual)
DEFINE_BINARY(OpFUnordEqual)
DEFINE_BINARY(OpFOrdNotEqual)
DEFINE_BINARY(OpFUnordNotEqual)
DEFINE_BINARY(OpFOrdLessThan)
DEFINE_BINARY(OpFUnordLessThan)
DEFINE_BINARY(OpFOrdGreaterThan)
DEFINE_BINARY(OpFUnordGreaterThan)
DEFINE_BINARY(OpFOrdLessThanEqual)
DEFINE_BINARY(OpFUnordLessThanEqual)
DEFINE_BINARY(OpFOrdGreaterThanEqual)
DEFINE_BINARY(OpFUnordGreaterThanEqual)

} // namespace Sirit