1 /*
2 * Copyright (C) 2021 Collabora, Ltd.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 #include "agx_test.h"
25
26 #include <gtest/gtest.h>
27
28 #define CASE(instr, expected) INSTRUCTION_CASE(instr, expected, agx_lower_pseudo)
29 #define NEGCASE(instr) CASE(instr, instr)
30
31 class LowerPseudo : public testing::Test {
32 protected:
LowerPseudo()33 LowerPseudo() {
34 mem_ctx = ralloc_context(NULL);
35
36 wx = agx_register(0, AGX_SIZE_32);
37 wy = agx_register(2, AGX_SIZE_32);
38 wz = agx_register(4, AGX_SIZE_32);
39 }
40
~LowerPseudo()41 ~LowerPseudo() {
42 ralloc_free(mem_ctx);
43 }
44
45 void *mem_ctx;
46 agx_index wx, wy, wz;
47 };
48
TEST_F(LowerPseudo,Move)49 TEST_F(LowerPseudo, Move) {
50 CASE(agx_mov_to(b, wx, wy), agx_bitop_to(b, wx, wy, agx_zero(), 0xA));
51 }
52
TEST_F(LowerPseudo,Not)53 TEST_F(LowerPseudo, Not) {
54 CASE(agx_not_to(b, wx, wy), agx_bitop_to(b, wx, wy, agx_zero(), 0x5));
55 }
56
TEST_F(LowerPseudo,BinaryBitwise)57 TEST_F(LowerPseudo, BinaryBitwise) {
58 CASE(agx_and_to(b, wx, wy, wz), agx_bitop_to(b, wx, wy, wz, 0x8));
59 CASE(agx_xor_to(b, wx, wy, wz), agx_bitop_to(b, wx, wy, wz, 0x6));
60 CASE(agx_or_to(b, wx, wy, wz), agx_bitop_to(b, wx, wy, wz, 0xE));
61 }
62