Debian Codegraph @

src/asahi/compiler/agx_opcodes.c.py

raw
1 template = """/*
2 * Copyright 2021 Alyssa Rosenzweig
3 * SPDX-License-Identifier: MIT
4 */
5
6 #include "agx_opcodes.h"
7
8 <%
9 def make_encoding(encoding):
10 if encoding is None:
11 return "{ 0 }"
12
13 return "{{ {}, {}, {} }}".format(hex(encoding.exact), encoding.length_short, int(encoding.extensible))
14 %>
15
16 const struct agx_opcode_info agx_opcodes_info[AGX_NUM_OPCODES] = {
17 % for opcode in opcodes:
18 <%
19 op = opcodes[opcode]
20 imms = ["AGX_IMMEDIATE_" + imm.name.upper() for imm in op.imms]
21 if len(imms) == 0:
22 imms = ["0"]
23 %>
24 [AGX_OPCODE_${opcode.upper()}] = {
25 "${opcode}", ${op.srcs}, ${op.dests}, ${" | ".join(imms)},
26 ${make_encoding(op.encoding)},
27 AGX_SCHEDULE_CLASS_${op.schedule_class.upper()},
28 ${int(op.is_float)},
29 ${int(op.can_eliminate)},
30 ${int(op.can_reorder)},
31 },
32 % endfor
33 };
34 """
35
36 from mako.template import Template
37 from agx_opcodes import opcodes
38
39 print(Template(template).render(opcodes=opcodes))