• 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 * This file was generated by aco_opcodes_cpp.py
26 */
27
28#include "aco_ir.h"
29
30namespace aco {
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   {
41      % for name in opcode_names:
42      ${opcodes[name].opcode_gfx7},
43      % endfor
44   },
45   {
46      % for name in opcode_names:
47      ${opcodes[name].opcode_gfx9},
48      % endfor
49   },
50   {
51      % for name in opcode_names:
52      ${opcodes[name].opcode_gfx10},
53      % endfor
54   },
55   {
56      % for name in opcode_names:
57      ${opcodes[name].opcode_gfx11},
58      % endfor
59   },
60   std::bitset<${len(opcode_names)}>("${can_use_input_modifiers}"),
61   std::bitset<${len(opcode_names)}>("${can_use_output_modifiers}"),
62   std::bitset<${len(opcode_names)}>("${is_atomic}"),
63   {
64      % for name in opcode_names:
65      "${name}",
66      % endfor
67   },
68   {
69      % for name in opcode_names:
70      aco::Format::${str(opcodes[name].format.name)},
71      % endfor
72   },
73   {
74      % for name in opcode_names:
75      ${opcodes[name].operand_size},
76      % endfor
77   },
78   {
79      % for name in opcode_names:
80      instr_class::${opcodes[name].cls.value},
81      % endfor
82   },
83   {
84      % for name in opcode_names:
85      ${hex(opcodes[name].definitions)},
86      % endfor
87   },
88   {
89      % for name in opcode_names:
90      ${hex(opcodes[name].operands)},
91      % endfor
92   },
93};
94
95}
96"""
97
98from aco_opcodes import opcodes
99from mako.template import Template
100
101print(Template(template).render(opcodes=opcodes))
102