2019-09-17 13:22:17 +02:00
|
|
|
|
|
|
|
|
template = """\
|
2022-05-25 10:41:28 +02:00
|
|
|
/*
|
2019-09-17 13:22:17 +02:00
|
|
|
* Copyright (c) 2018 Valve Corporation
|
|
|
|
|
*
|
2024-04-08 09:02:30 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2019-09-17 13:22:17 +02:00
|
|
|
*
|
2021-06-09 17:54:53 +02:00
|
|
|
* This file was generated by aco_opcodes_cpp.py
|
2019-09-17 13:22:17 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "aco_ir.h"
|
|
|
|
|
|
|
|
|
|
namespace aco {
|
|
|
|
|
|
|
|
|
|
<%
|
2024-03-05 14:43:12 +00:00
|
|
|
opcode_names = sorted(instructions.keys())
|
|
|
|
|
is_atomic = "".join([instructions[name].is_atomic for name in reversed(opcode_names)])
|
2025-04-29 15:55:47 +02:00
|
|
|
# Record which operand of each instruction can use modifiers.
|
|
|
|
|
operand_mods = dict();
|
|
|
|
|
for name in opcode_names:
|
|
|
|
|
op_mods = 0
|
|
|
|
|
for operand in reversed(instructions[name].operands):
|
|
|
|
|
op_mods <<= 1
|
|
|
|
|
op_mods |= int(operand.mods)
|
|
|
|
|
operand_mods[name] = op_mods
|
2019-09-17 13:22:17 +02:00
|
|
|
%>
|
|
|
|
|
|
|
|
|
|
extern const aco::Info instr_info = {
|
2022-04-04 10:54:07 +02:00
|
|
|
{
|
2019-11-04 18:02:47 +01:00
|
|
|
% for name in opcode_names:
|
2024-02-15 16:24:07 +00:00
|
|
|
${instructions[name].op.gfx7},
|
2019-11-04 18:02:47 +01:00
|
|
|
% endfor
|
|
|
|
|
},
|
2022-04-04 10:54:07 +02:00
|
|
|
{
|
2019-09-17 13:22:17 +02:00
|
|
|
% for name in opcode_names:
|
2024-02-15 16:24:07 +00:00
|
|
|
${instructions[name].op.gfx9},
|
2019-09-17 13:22:17 +02:00
|
|
|
% endfor
|
|
|
|
|
},
|
2022-04-04 10:54:07 +02:00
|
|
|
{
|
2019-09-17 13:22:17 +02:00
|
|
|
% for name in opcode_names:
|
2024-02-15 16:24:07 +00:00
|
|
|
${instructions[name].op.gfx10},
|
2019-09-17 13:22:17 +02:00
|
|
|
% endfor
|
|
|
|
|
},
|
2022-06-16 18:15:16 +01:00
|
|
|
{
|
|
|
|
|
% for name in opcode_names:
|
2024-02-15 16:24:07 +00:00
|
|
|
${instructions[name].op.gfx11},
|
2022-06-16 18:15:16 +01:00
|
|
|
% endfor
|
|
|
|
|
},
|
2024-05-01 19:43:01 +01:00
|
|
|
{
|
|
|
|
|
% for name in opcode_names:
|
|
|
|
|
${instructions[name].op.gfx12},
|
|
|
|
|
% endfor
|
|
|
|
|
},
|
2022-04-04 10:54:07 +02:00
|
|
|
std::bitset<${len(opcode_names)}>("${is_atomic}"),
|
|
|
|
|
{
|
2019-09-17 13:22:17 +02:00
|
|
|
% for name in opcode_names:
|
|
|
|
|
"${name}",
|
|
|
|
|
% endfor
|
|
|
|
|
},
|
2022-04-04 10:54:07 +02:00
|
|
|
{
|
2019-09-17 13:22:17 +02:00
|
|
|
% for name in opcode_names:
|
2024-03-05 14:43:12 +00:00
|
|
|
aco::Format::${str(instructions[name].format.name)},
|
2019-09-17 13:22:17 +02:00
|
|
|
% endfor
|
|
|
|
|
},
|
2022-04-04 10:54:07 +02:00
|
|
|
{
|
2021-02-03 14:47:24 +00:00
|
|
|
% for name in opcode_names:
|
2024-03-05 14:43:12 +00:00
|
|
|
instr_class::${instructions[name].cls.value},
|
2021-02-03 14:47:24 +00:00
|
|
|
% endfor
|
|
|
|
|
},
|
2023-11-10 13:09:12 +01:00
|
|
|
{
|
|
|
|
|
% for name in opcode_names:
|
2025-04-29 15:55:47 +02:00
|
|
|
{ // ${name}
|
|
|
|
|
${len(instructions[name].operands)},
|
|
|
|
|
${len(instructions[name].definitions)},
|
|
|
|
|
${operand_mods[name]},
|
|
|
|
|
${int(instructions[name].definitions[0].mods) if len(instructions[name].definitions) > 0 else 0},
|
|
|
|
|
{
|
|
|
|
|
% for operand in instructions[name].operands:
|
|
|
|
|
{
|
|
|
|
|
${operand.base_type.name},
|
|
|
|
|
${operand.num_components},
|
|
|
|
|
${operand.bit_size},
|
|
|
|
|
},
|
|
|
|
|
% endfor
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
% for definition in instructions[name].definitions:
|
|
|
|
|
{
|
|
|
|
|
${definition.base_type.name},
|
|
|
|
|
${definition.num_components},
|
|
|
|
|
${definition.bit_size},
|
|
|
|
|
},
|
|
|
|
|
% endfor
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
% for operand in instructions[name].operands:
|
|
|
|
|
${operand.fixed_reg.name},
|
|
|
|
|
% endfor
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
% for definition in instructions[name].definitions:
|
|
|
|
|
${definition.fixed_reg.name},
|
|
|
|
|
% endfor
|
|
|
|
|
},
|
|
|
|
|
},
|
2023-11-10 13:09:12 +01:00
|
|
|
% endfor
|
|
|
|
|
},
|
2019-09-17 13:22:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
|
2024-03-05 14:43:12 +00:00
|
|
|
from aco_opcodes import instructions
|
2019-09-17 13:22:17 +02:00
|
|
|
from mako.template import Template
|
|
|
|
|
|
2024-03-05 14:43:12 +00:00
|
|
|
print(Template(template).render(instructions=instructions))
|