Rev 4358 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4358 | Rev 4401 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright 2013 Advanced Micro Devices, Inc. |
2 | * Copyright 2013 Advanced Micro Devices, Inc. |
3 | * |
3 | * |
4 | * Permission is hereby granted, free of charge, to any person obtaining a |
4 | * Permission is hereby granted, free of charge, to any person obtaining a |
5 | * copy of this software and associated documentation files (the "Software"), |
5 | * copy of this software and associated documentation files (the "Software"), |
6 | * to deal in the Software without restriction, including without limitation |
6 | * to deal in the Software without restriction, including without limitation |
7 | * on the rights to use, copy, modify, merge, publish, distribute, sub |
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 |
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: |
9 | * the Software is furnished to do so, subject to the following conditions: |
10 | * |
10 | * |
11 | * The above copyright notice and this permission notice (including the next |
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 |
12 | * paragraph) shall be included in all copies or substantial portions of the |
13 | * Software. |
13 | * Software. |
14 | * |
14 | * |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
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, |
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
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, |
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 |
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 |
20 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
21 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
21 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | * |
22 | * |
23 | * Author: Tom Stellard |
23 | * Author: Tom Stellard |
24 | */ |
24 | */ |
25 | 25 | ||
26 | #include "radeon_program_pair.h" |
26 | #include "radeon_program_pair.h" |
27 | 27 | ||
28 | #include "r300_compiler_tests.h" |
28 | #include "r300_compiler_tests.h" |
29 | #include "rc_test_helpers.h" |
29 | #include "rc_test_helpers.h" |
30 | #include "unit_test.h" |
30 | #include "unit_test.h" |
31 | 31 | ||
32 | static void dummy_allocate_hw_inputs( |
32 | static void dummy_allocate_hw_inputs( |
33 | struct r300_fragment_program_compiler * c, |
33 | struct r300_fragment_program_compiler * c, |
34 | void (*allocate)(void * data, unsigned input, unsigned hwreg), |
34 | void (*allocate)(void * data, unsigned input, unsigned hwreg), |
35 | void * mydata) |
35 | void * mydata) |
36 | { |
36 | { |
37 | unsigned i; |
37 | unsigned i; |
38 | for (i = 0; i < 10; i++) { |
38 | for (i = 0; i < 10; i++) { |
39 | allocate(mydata, i, i); |
39 | allocate(mydata, i, i); |
40 | } |
40 | } |
41 | } |
41 | } |
42 | 42 | ||
43 | static void test_runner_rc_regalloc( |
43 | static void test_runner_rc_regalloc( |
44 | struct test_result *result, |
44 | struct test_result *result, |
45 | struct radeon_compiler *c, |
45 | struct radeon_compiler *c, |
46 | const char *filename) |
46 | const char *filename) |
47 | { |
47 | { |
48 | struct rc_test_file test_file; |
48 | struct rc_test_file test_file; |
49 | unsigned optimizations = 1; |
49 | unsigned optimizations = 1; |
50 | unsigned do_full_regalloc = 1; |
50 | unsigned do_full_regalloc = 1; |
51 | struct rc_instruction *inst; |
51 | struct rc_instruction *inst; |
52 | unsigned pass = 1; |
52 | unsigned pass = 1; |
53 | 53 | ||
54 | test_begin(result); |
54 | test_begin(result); |
55 | 55 | ||
56 | if (!load_program(c, &test_file, filename)) { |
56 | if (!load_program(c, &test_file, filename)) { |
57 | fprintf(stderr, "Failed to load program\n"); |
57 | fprintf(stderr, "Failed to load program\n"); |
58 | } |
58 | } |
59 | 59 | ||
60 | rc_pair_translate(c, NULL); |
60 | rc_pair_translate(c, NULL); |
61 | rc_pair_schedule(c, &optimizations); |
61 | rc_pair_schedule(c, &optimizations); |
62 | rc_pair_remove_dead_sources(c, NULL); |
62 | rc_pair_remove_dead_sources(c, NULL); |
63 | rc_pair_regalloc(c, &do_full_regalloc); |
63 | rc_pair_regalloc(c, &do_full_regalloc); |
64 | 64 | ||
65 | for(inst = c->Program.Instructions.Next; |
65 | for(inst = c->Program.Instructions.Next; |
66 | inst != &c->Program.Instructions; |
66 | inst != &c->Program.Instructions; |
67 | inst = inst->Next) { |
67 | inst = inst->Next) { |
68 | if (inst->Type == RC_INSTRUCTION_NORMAL && |
68 | if (inst->Type == RC_INSTRUCTION_NORMAL && |
69 | inst->U.I.Opcode != RC_OPCODE_BEGIN_TEX) { |
69 | inst->U.I.Opcode != RC_OPCODE_BEGIN_TEX) { |
70 | if (GET_SWZ(inst->U.I.SrcReg[0].Swizzle, 0) |
70 | if (GET_SWZ(inst->U.I.SrcReg[0].Swizzle, 0) |
71 | != RC_SWIZZLE_X) { |
71 | != RC_SWIZZLE_X) { |
72 | pass = 0; |
72 | pass = 0; |
73 | } |
73 | } |
74 | } |
74 | } |
75 | } |
75 | } |
76 | 76 | ||
77 | test_check(result, pass); |
77 | test_check(result, pass); |
78 | } |
78 | } |
79 | 79 | ||
80 | static void tex_1d_swizzle(struct test_result *result) |
80 | static void tex_1d_swizzle(struct test_result *result) |
81 | { |
81 | { |
82 | struct radeon_compiler c; |
82 | struct r300_fragment_program_compiler c; |
- | 83 | ||
83 | 84 | memset(&c, 0, sizeof(c)); |
|
84 | init_compiler(&c, RC_FRAGMENT_PROGRAM, 0, 0); |
- | |
85 | struct r300_fragment_program_compiler *cc = |
- | |
86 | (struct r300_fragment_program_compiler*)&c; |
85 | init_compiler(&c.Base, RC_FRAGMENT_PROGRAM, 0, 0); |
87 | cc->AllocateHwInputs = dummy_allocate_hw_inputs; |
86 | c.AllocateHwInputs = dummy_allocate_hw_inputs; |
88 | 87 | ||
89 | test_runner_rc_regalloc(result, &c, "regalloc_tex_1d_swizzle.test"); |
88 | test_runner_rc_regalloc(result, &c.Base, "regalloc_tex_1d_swizzle.test"); |
90 | } |
89 | } |
91 | 90 | ||
92 | unsigned radeon_compiler_regalloc_run_tests() |
91 | unsigned radeon_compiler_regalloc_run_tests() |
93 | { |
92 | { |
94 | static struct test tests[] = { |
93 | static struct test tests[] = { |
95 | {"rc_pair_regalloc() => TEX 1D Swizzle - r300", tex_1d_swizzle }, |
94 | {"rc_pair_regalloc() => TEX 1D Swizzle - r300", tex_1d_swizzle }, |
96 | {NULL, NULL} |
95 | {NULL, NULL} |
97 | }; |
96 | }; |
98 | return run_tests(tests); |
97 | return run_tests(tests); |
99 | }> |
98 | }> |