aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/instructions/atomic.cpp
blob: cee8849f5714b7f7381f752a000952b09e38c748 (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* 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 {

Id Module::OpAtomicLoad(Id result_type, Id pointer, Id memory, Id semantics) {
    code->Reserve(6);
    return *code << OpId{spv::Op::OpAtomicLoad, result_type} << pointer << memory << semantics
                 << EndOp{};
}

Id Module::OpAtomicStore(Id pointer, Id memory, Id semantics, Id value) {
    code->Reserve(5);
    return *code << OpId{spv::Op::OpAtomicStore} << pointer << memory << semantics << value
                 << EndOp{};
}

Id Module::OpAtomicExchange(Id result_type, Id pointer, Id memory, Id semantics, Id value) {
    code->Reserve(7);
    return *code << OpId{spv::Op::OpAtomicExchange, result_type} << pointer << memory << semantics
                 << value << EndOp{};
}

Id Module::OpAtomicCompareExchange(Id result_type, Id pointer, Id memory, Id equal, Id unequal,
                                   Id value, Id comparator) {
    code->Reserve(9);
    return *code << OpId{spv::Op::OpAtomicCompareExchange, result_type} << pointer << memory
                 << equal << unequal << value << comparator << EndOp{};
}

Id Module::OpAtomicIIncrement(Id result_type, Id pointer, Id memory, Id semantics) {
    code->Reserve(6);
    return *code << OpId{spv::Op::OpAtomicIIncrement, result_type} << pointer << memory << semantics
                 << EndOp{};
}

Id Module::OpAtomicIDecrement(Id result_type, Id pointer, Id memory, Id semantics) {
    code->Reserve(6);
    return *code << OpId{spv::Op::OpAtomicIDecrement, result_type} << pointer << memory << semantics
                 << EndOp{};
}

Id Module::OpAtomicIAdd(Id result_type, Id pointer, Id memory, Id semantics, Id value) {
    code->Reserve(7);
    return *code << OpId{spv::Op::OpAtomicIAdd, result_type} << pointer << memory << semantics
                 << value << EndOp{};
}

Id Module::OpAtomicISub(Id result_type, Id pointer, Id memory, Id semantics, Id value) {
    code->Reserve(7);
    return *code << OpId{spv::Op::OpAtomicISub, result_type} << pointer << memory << semantics
                 << value << EndOp{};
}

Id Module::OpAtomicSMin(Id result_type, Id pointer, Id memory, Id semantics, Id value) {
    code->Reserve(7);
    return *code << OpId{spv::Op::OpAtomicSMin, result_type} << pointer << memory << semantics
                 << value << EndOp{};
}

Id Module::OpAtomicUMin(Id result_type, Id pointer, Id memory, Id semantics, Id value) {
    code->Reserve(7);
    return *code << OpId{spv::Op::OpAtomicUMin, result_type} << pointer << memory << semantics
                 << value << EndOp{};
}

Id Module::OpAtomicSMax(Id result_type, Id pointer, Id memory, Id semantics, Id value) {
    code->Reserve(7);
    return *code << OpId{spv::Op::OpAtomicSMax, result_type} << pointer << memory << semantics
                 << value << EndOp{};
}

Id Module::OpAtomicUMax(Id result_type, Id pointer, Id memory, Id semantics, Id value) {
    code->Reserve(7);
    return *code << OpId{spv::Op::OpAtomicUMax, result_type} << pointer << memory << semantics
                 << value << EndOp{};
}

Id Module::OpAtomicAnd(Id result_type, Id pointer, Id memory, Id semantics, Id value) {
    code->Reserve(7);
    return *code << OpId{spv::Op::OpAtomicAnd, result_type} << pointer << memory << semantics
                 << value << EndOp{};
}

Id Module::OpAtomicOr(Id result_type, Id pointer, Id memory, Id semantics, Id value) {
    code->Reserve(7);
    return *code << OpId{spv::Op::OpAtomicOr, result_type} << pointer << memory << semantics
                 << value << EndOp{};
}

Id Module::OpAtomicXor(Id result_type, Id pointer, Id memory, Id semantics, Id value) {
    code->Reserve(7);
    return *code << OpId{spv::Op::OpAtomicXor, result_type} << pointer << memory << semantics
                 << value << EndOp{};
}

} // namespace Sirit