aboutsummaryrefslogtreecommitdiffhomepage
path: root/externals/biscuit/tests/src/assembler_zacas_tests.cpp
blob: f0891fba9a109eea98395811ed2b9ba93904d8d3 (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
#include <catch/catch.hpp>

#include <biscuit/assembler.hpp>

#include "assembler_test_utils.hpp"

using namespace biscuit;

TEST_CASE("AMOCAS.D", "[Zacas]") {
    uint32_t value = 0;
    auto as = MakeAssembler64(value);

    as.AMOCAS_D(Ordering::None, x31, x7, x15);
    REQUIRE(value == 0x2877BFAF);

    as.RewindBuffer();

    as.AMOCAS_D(Ordering::AQ, x31, x7, x15);
    REQUIRE(value == 0x2C77BFAF);

    as.RewindBuffer();

    as.AMOCAS_D(Ordering::RL, x31, x7, x15);
    REQUIRE(value == 0x2A77BFAF);

    as.RewindBuffer();

    as.AMOCAS_D(Ordering::AQRL, x31, x7, x15);
    REQUIRE(value == 0x2E77BFAF);
}

TEST_CASE("AMOCAS.Q", "[Zacas]") {
    uint32_t value = 0;
    auto as = MakeAssembler64(value);

    as.AMOCAS_Q(Ordering::None, x30, x6, x14);
    REQUIRE(value == 0x28674F2F);

    as.RewindBuffer();

    as.AMOCAS_Q(Ordering::AQ, x30, x6, x14);
    REQUIRE(value == 0x2C674F2F);

    as.RewindBuffer();

    as.AMOCAS_Q(Ordering::RL, x30, x6, x14);
    REQUIRE(value == 0x2A674F2F);

    as.RewindBuffer();

    as.AMOCAS_Q(Ordering::AQRL, x30, x6, x14);
    REQUIRE(value == 0x2E674F2F);
}

TEST_CASE("AMOCAS.W", "[Zacas]") {
    uint32_t value = 0;
    auto as = MakeAssembler64(value);

    as.AMOCAS_W(Ordering::None, x31, x7, x15);
    REQUIRE(value == 0x2877AFAF);

    as.RewindBuffer();

    as.AMOCAS_W(Ordering::AQ, x31, x7, x15);
    REQUIRE(value == 0x2C77AFAF);

    as.RewindBuffer();

    as.AMOCAS_W(Ordering::RL, x31, x7, x15);
    REQUIRE(value == 0x2A77AFAF);

    as.RewindBuffer();

    as.AMOCAS_W(Ordering::AQRL, x31, x7, x15);
    REQUIRE(value == 0x2E77AFAF);
}