2 * Copyright 2013 Advanced Micro Devices, Inc.
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 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
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
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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
23 * Author: Tom Stellard <thomas.stellard@amd.com>
26 #include "radeon_program_pair.h"
28 #include "r300_compiler_tests.h"
29 #include "rc_test_helpers.h"
30 #include "unit_test.h"
32 static void dummy_allocate_hw_inputs(
33 struct r300_fragment_program_compiler
* c
,
34 void (*allocate
)(void * data
, unsigned input
, unsigned hwreg
),
38 for (i
= 0; i
< 10; i
++) {
39 allocate(mydata
, i
, i
);
43 static void test_runner_rc_regalloc(
44 struct test_result
*result
,
45 struct radeon_compiler
*c
,
48 struct rc_test_file test_file
;
49 unsigned optimizations
= 1;
50 unsigned do_full_regalloc
= 1;
51 struct rc_instruction
*inst
;
56 if (!load_program(c
, &test_file
, filename
)) {
57 fprintf(stderr
, "Failed to load program\n");
60 rc_pair_translate(c
, NULL
);
61 rc_pair_schedule(c
, &optimizations
);
62 rc_pair_remove_dead_sources(c
, NULL
);
63 rc_pair_regalloc(c
, &do_full_regalloc
);
65 for(inst
= c
->Program
.Instructions
.Next
;
66 inst
!= &c
->Program
.Instructions
;
68 if (inst
->Type
== RC_INSTRUCTION_NORMAL
&&
69 inst
->U
.I
.Opcode
!= RC_OPCODE_BEGIN_TEX
) {
70 if (GET_SWZ(inst
->U
.I
.SrcReg
[0].Swizzle
, 0)
77 test_check(result
, pass
);
80 static void tex_1d_swizzle(struct test_result
*result
)
82 struct r300_fragment_program_compiler c
;
84 memset(&c
, 0, sizeof(c
));
85 init_compiler(&c
.Base
, RC_FRAGMENT_PROGRAM
, 0, 0);
86 c
.AllocateHwInputs
= dummy_allocate_hw_inputs
;
88 test_runner_rc_regalloc(result
, &c
.Base
, "regalloc_tex_1d_swizzle.test");
91 unsigned radeon_compiler_regalloc_run_tests()
93 static struct test tests
[] = {
94 {"rc_pair_regalloc() => TEX 1D Swizzle - r300", tex_1d_swizzle
},
97 return run_tests(tests
);