• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2template = """\
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
29namespace aco {
30
31
32<%
33opcode_names = sorted(opcodes.keys())
34can_use_input_modifiers = "".join([opcodes[name].input_mod for name in reversed(opcode_names)])
35can_use_output_modifiers = "".join([opcodes[name].output_mod for name in reversed(opcode_names)])
36is_atomic = "".join([opcodes[name].is_atomic for name in reversed(opcode_names)])
37%>
38
39extern const aco::Info instr_info = {
40   .opcode_gfx7 = {
41      % for name in opcode_names:
42      ${opcodes[name].opcode_gfx7},
43      % endfor
44   },
45   .opcode_gfx9 = {
46      % for name in opcode_names:
47      ${opcodes[name].opcode_gfx9},
48      % endfor
49   },
50   .opcode_gfx10 = {
51      % for name in opcode_names:
52      ${opcodes[name].opcode_gfx10},
53      % endfor
54   },
55   .can_use_input_modifiers = std::bitset<${len(opcode_names)}>("${can_use_input_modifiers}"),
56   .can_use_output_modifiers = std::bitset<${len(opcode_names)}>("${can_use_output_modifiers}"),
57   .is_atomic = std::bitset<${len(opcode_names)}>("${is_atomic}"),
58   .name = {
59      % for name in opcode_names:
60      "${name}",
61      % endfor
62   },
63   .format = {
64      % for name in opcode_names:
65      aco::Format::${str(opcodes[name].format.name)},
66      % endfor
67   },
68   .operand_size = {
69      % for name in opcode_names:
70      ${opcodes[name].operand_size},
71      % endfor
72   },
73   .definition_size = {
74      % for name in opcode_names:
75      ${opcodes[name].definition_size},
76      % endfor
77   },
78};
79
80}
81"""
82
83from aco_opcodes import opcodes
84from mako.template import Template
85
86print(Template(template).render(opcodes=opcodes))
87