Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/asahi/compiler/agx_opcodes.h.py
4564 views
1
template = """/*
2
* Copyright (C) 2021 Alyssa Rosenzweig <[email protected]>
3
*
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
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
* and/or sell copies of the Software, and to permit persons to whom the
9
* Software is furnished to do so, subject to the following conditions:
10
*
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
13
* Software.
14
*
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 NONINFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
* SOFTWARE.
22
*/
23
24
#ifndef _AGX_OPCODES_
25
#define _AGX_OPCODES_
26
27
#include <stdbool.h>
28
#include <stdint.h>
29
30
/* Listing of opcodes */
31
32
enum agx_opcode {
33
% for op in opcodes:
34
AGX_OPCODE_${op.upper()},
35
% endfor
36
AGX_NUM_OPCODES
37
};
38
39
% for name in enums:
40
enum agx_${name} {
41
% for k in enums[name]:
42
AGX_${name.upper()}_${enums[name][k].replace('.', '_').upper()} = ${k},
43
% endfor
44
};
45
% endfor
46
47
/* Runtime accessible info on each defined opcode */
48
49
<% assert(len(immediates) < 32); %>
50
51
enum agx_immediate {
52
% for i, imm in enumerate(immediates):
53
AGX_IMMEDIATE_${imm.upper()} = (1 << ${i}),
54
% endfor
55
};
56
57
struct agx_encoding {
58
uint64_t exact;
59
unsigned length_short : 4;
60
bool extensible : 1;
61
};
62
63
struct agx_opcode_info {
64
const char *name;
65
unsigned nr_srcs;
66
unsigned nr_dests;
67
enum agx_immediate immediates;
68
struct agx_encoding encoding;
69
struct agx_encoding encoding_16;
70
bool is_float : 1;
71
bool can_eliminate : 1;
72
};
73
74
extern const struct agx_opcode_info agx_opcodes_info[AGX_NUM_OPCODES];
75
76
#endif
77
"""
78
79
from mako.template import Template
80
from agx_opcodes import opcodes, immediates, enums
81
82
print(Template(template).render(opcodes=opcodes, immediates=immediates,
83
enums=enums))
84
85