| 1 |
# Copyright © 2024 Imagination Technologies Ltd. |
| 2 |
# SPDX-License-Identifier: MIT |
| 3 |
|
| 4 |
from mako.template import Template, exceptions |
| 5 |
from pco_ops import * |
| 6 |
|
| 7 |
template = """/* |
| 8 |
* Copyright © 2024 Imagination Technologies Ltd. |
| 9 |
* |
| 10 |
* SPDX-License-Identifier: MIT |
| 11 |
*/ |
| 12 |
|
| 13 |
#ifndef PCO_OPS_H |
| 14 |
#define PCO_OPS_H |
| 15 |
|
| 16 |
/** |
| 17 |
* \\file pco_ops.h |
| 18 |
* |
| 19 |
* \\brief PCO op definitions and functions. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "util/macros.h" |
| 23 |
|
| 24 |
#include <assert.h> |
| 25 |
#include <stdbool.h> |
| 26 |
#include <stdint.h> |
| 27 |
|
| 28 |
#define _PCO_OP_MAX_DESTS ${max([op.num_dests for op in ops.values()])}U |
| 29 |
#define _PCO_OP_MAX_SRCS ${max([op.num_srcs for op in ops.values()])}U |
| 30 |
#define _PCO_OP_MAX_MODS ${max([len(op.op_mods) for op in ops.values()])}U |
| 31 |
|
| 32 |
/** Ops. */ |
| 33 |
#define _PCO_OP_COUNT ${len(ops) + 1}U |
| 34 |
enum pco_op { |
| 35 |
PCO_OP_NONE, |
| 36 |
% for op in ops.values(): |
| 37 |
${op.cname.upper()}, |
| 38 |
% endfor |
| 39 |
}; |
| 40 |
|
| 41 |
/** Op mods. */ |
| 42 |
#define _PCO_OP_MOD_COUNT ${len(op_mods) + 1}U |
| 43 |
enum pco_op_mod { |
| 44 |
PCO_OP_MOD_NONE, |
| 45 |
% for op_mod in op_mods.values(): |
| 46 |
${op_mod.cname}, |
| 47 |
% endfor |
| 48 |
}; |
| 49 |
|
| 50 |
/** Ref mods. */ |
| 51 |
#define _PCO_REF_MOD_COUNT ${len(ref_mods) + 1}U |
| 52 |
enum pco_ref_mod { |
| 53 |
PCO_REF_MOD_NONE, |
| 54 |
% for ref_mod in ref_mods.values(): |
| 55 |
${ref_mod.cname}, |
| 56 |
% endfor |
| 57 |
}; |
| 58 |
#endif /* PCO_OPS_H */""" |
| 59 |
|
| 60 |
def main(): |
| 61 |
try: |
| 62 |
print(Template(template).render(ops=ops, op_mods=op_mods, ref_mods=ref_mods)) |
| 63 |
except: |
| 64 |
raise Exception(exceptions.text_error_template().render()) |
| 65 |
|
| 66 |
if __name__ == '__main__': |
| 67 |
main() |