2 * Copyright 2012 Vadim Girlin <vadimgirlin@gmail.com>
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.
27 #include "r600_pipe.h"
30 int r600_isa_init(struct r600_context
*ctx
, struct r600_isa
*isa
) {
33 assert(ctx
->b
.chip_class
>= R600
&& ctx
->b
.chip_class
<= CAYMAN
);
34 isa
->hw_class
= ctx
->b
.chip_class
- R600
;
36 /* reverse lookup maps are required for bytecode parsing */
38 isa
->alu_op2_map
= calloc(256, sizeof(unsigned));
39 if (!isa
->alu_op2_map
)
41 isa
->alu_op3_map
= calloc(256, sizeof(unsigned));
42 if (!isa
->alu_op3_map
)
44 isa
->fetch_map
= calloc(256, sizeof(unsigned));
47 isa
->cf_map
= calloc(256, sizeof(unsigned));
51 for (i
= 0; i
< TABLE_SIZE(alu_op_table
); ++i
) {
52 const struct alu_op_info
*op
= &alu_op_table
[i
];
54 if (op
->flags
& AF_LDS
|| op
->slots
[isa
->hw_class
] == 0)
56 opc
= op
->opcode
[isa
->hw_class
>> 1];
58 if (op
->src_count
== 3)
59 isa
->alu_op3_map
[opc
] = i
+ 1;
61 isa
->alu_op2_map
[opc
] = i
+ 1;
64 for (i
= 0; i
< TABLE_SIZE(fetch_op_table
); ++i
) {
65 const struct fetch_op_info
*op
= &fetch_op_table
[i
];
66 unsigned opc
= op
->opcode
[isa
->hw_class
];
67 if ((op
->flags
& FF_GDS
) || ((opc
& 0xFF) != opc
))
68 continue; /* ignore GDS ops and INST_MOD versions for now */
69 isa
->fetch_map
[opc
] = i
+ 1;
72 for (i
= 0; i
< TABLE_SIZE(cf_op_table
); ++i
) {
73 const struct cf_op_info
*op
= &cf_op_table
[i
];
74 unsigned opc
= op
->opcode
[isa
->hw_class
];
77 /* using offset for CF_ALU_xxx opcodes because they overlap with other
78 * CF opcodes (they use different encoding in hw) */
79 if (op
->flags
& CF_ALU
)
81 isa
->cf_map
[opc
] = i
+ 1;
87 int r600_isa_destroy(struct r600_isa
*isa
) {
93 free(isa
->alu_op2_map
);
95 free(isa
->alu_op3_map
);