aco: Initial GFX7 Support
[mesa.git] / src / amd / compiler / aco_opcodes_cpp.py
1
2 template = """\
3 /*
4 * Copyright (c) 2018 Valve Corporation
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 * IN THE SOFTWARE.
24 *
25 */
26
27 #include "aco_ir.h"
28
29 namespace aco {
30
31
32 <%
33 opcode_names = sorted(opcodes.keys())
34 can_use_input_modifiers = "".join([opcodes[name].input_mod for name in reversed(opcode_names)])
35 can_use_output_modifiers = "".join([opcodes[name].output_mod for name in reversed(opcode_names)])
36 %>
37
38 extern const aco::Info instr_info = {
39 .opcode_gfx7 = {
40 % for name in opcode_names:
41 ${opcodes[name].opcode_gfx7},
42 % endfor
43 },
44 .opcode_gfx9 = {
45 % for name in opcode_names:
46 ${opcodes[name].opcode_gfx9},
47 % endfor
48 },
49 .opcode_gfx10 = {
50 % for name in opcode_names:
51 ${opcodes[name].opcode_gfx10},
52 % endfor
53 },
54 .can_use_input_modifiers = std::bitset<${len(opcode_names)}>("${can_use_input_modifiers}"),
55 .can_use_output_modifiers = std::bitset<${len(opcode_names)}>("${can_use_output_modifiers}"),
56 .name = {
57 % for name in opcode_names:
58 "${name}",
59 % endfor
60 },
61 .format = {
62 % for name in opcode_names:
63 aco::Format::${str(opcodes[name].format.name)},
64 % endfor
65 },
66 };
67
68 }
69 """
70
71 from aco_opcodes import opcodes
72 from mako.template import Template
73
74 print(Template(template).render(opcodes=opcodes))