xref: /aosp_15_r20/external/mesa3d/src/asahi/compiler/test/test-lower-pseudo.cpp (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright 2021 Collabora, Ltd.
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #include "agx_test.h"
7 
8 #include <gtest/gtest.h>
9 
10 #define CASE(instr, expected)                                                  \
11    INSTRUCTION_CASE(instr, expected, agx_lower_pseudo)
12 #define NEGCASE(instr) CASE(instr, instr)
13 
14 class LowerPseudo : public testing::Test {
15  protected:
LowerPseudo()16    LowerPseudo()
17    {
18       mem_ctx = ralloc_context(NULL);
19 
20       wx = agx_register(0, AGX_SIZE_32);
21       wy = agx_register(2, AGX_SIZE_32);
22       wz = agx_register(4, AGX_SIZE_32);
23    }
24 
~LowerPseudo()25    ~LowerPseudo()
26    {
27       ralloc_free(mem_ctx);
28    }
29 
30    void *mem_ctx;
31    agx_index wx, wy, wz;
32 };
33 
TEST_F(LowerPseudo,Move)34 TEST_F(LowerPseudo, Move)
35 {
36    CASE(agx_mov_to(b, wx, wy), agx_bitop_to(b, wx, wy, agx_zero(), 0xA));
37 }
38 
TEST_F(LowerPseudo,Not)39 TEST_F(LowerPseudo, Not)
40 {
41    CASE(agx_not_to(b, wx, wy), agx_bitop_to(b, wx, wy, agx_zero(), 0x5));
42 }
43