Line data Source code
1 : // Copyright 2018 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef WASM_ATOMICOP_UTILS_H
6 : #define WASM_ATOMICOP_UTILS_H
7 :
8 : #include "test/cctest/cctest.h"
9 : #include "test/cctest/compiler/value-helper.h"
10 : #include "test/cctest/wasm/wasm-run-utils.h"
11 :
12 : namespace v8 {
13 : namespace internal {
14 : namespace wasm {
15 :
16 : #define OPERATION_LIST(V) \
17 : V(Add) \
18 : V(Sub) \
19 : V(And) \
20 : V(Or) \
21 : V(Xor) \
22 : V(Exchange)
23 :
24 : using Uint64BinOp = uint64_t (*)(uint64_t, uint64_t);
25 : using Uint32BinOp = uint32_t (*)(uint32_t, uint32_t);
26 : using Uint16BinOp = uint16_t (*)(uint16_t, uint16_t);
27 : using Uint8BinOp = uint8_t (*)(uint8_t, uint8_t);
28 :
29 : template <typename T>
30 163404 : T Add(T a, T b) {
31 163404 : return a + b;
32 : }
33 :
34 : template <typename T>
35 163404 : T Sub(T a, T b) {
36 163404 : return a - b;
37 : }
38 :
39 : template <typename T>
40 163404 : T And(T a, T b) {
41 163404 : return a & b;
42 : }
43 :
44 : template <typename T>
45 163404 : T Or(T a, T b) {
46 163404 : return a | b;
47 : }
48 :
49 : template <typename T>
50 163404 : T Xor(T a, T b) {
51 163404 : return a ^ b;
52 : }
53 :
54 : template <typename T>
55 163404 : T Exchange(T a, T b) {
56 163404 : return b;
57 : }
58 :
59 : template <typename T>
60 : T CompareExchange(T initial, T a, T b) {
61 : if (initial == a) return b;
62 : return a;
63 : }
64 :
65 : } // namespace wasm
66 : } // namespace internal
67 : } // namespace v8
68 :
69 : #endif
|