Path: blob/21.2-virgl/src/asahi/compiler/agx_opcodes.h.py
4564 views
template = """/*1* Copyright (C) 2021 Alyssa Rosenzweig <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*/2223#ifndef _AGX_OPCODES_24#define _AGX_OPCODES_2526#include <stdbool.h>27#include <stdint.h>2829/* Listing of opcodes */3031enum agx_opcode {32% for op in opcodes:33AGX_OPCODE_${op.upper()},34% endfor35AGX_NUM_OPCODES36};3738% for name in enums:39enum agx_${name} {40% for k in enums[name]:41AGX_${name.upper()}_${enums[name][k].replace('.', '_').upper()} = ${k},42% endfor43};44% endfor4546/* Runtime accessible info on each defined opcode */4748<% assert(len(immediates) < 32); %>4950enum agx_immediate {51% for i, imm in enumerate(immediates):52AGX_IMMEDIATE_${imm.upper()} = (1 << ${i}),53% endfor54};5556struct agx_encoding {57uint64_t exact;58unsigned length_short : 4;59bool extensible : 1;60};6162struct agx_opcode_info {63const char *name;64unsigned nr_srcs;65unsigned nr_dests;66enum agx_immediate immediates;67struct agx_encoding encoding;68struct agx_encoding encoding_16;69bool is_float : 1;70bool can_eliminate : 1;71};7273extern const struct agx_opcode_info agx_opcodes_info[AGX_NUM_OPCODES];7475#endif76"""7778from mako.template import Template79from agx_opcodes import opcodes, immediates, enums8081print(Template(template).render(opcodes=opcodes, immediates=immediates,82enums=enums))838485