Path: blob/21.2-virgl/src/compiler/nir/nir_intrinsics_h.py
4546 views
1template = """\2/* Copyright (C) 2018 Red Hat3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING20* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS21* IN THE SOFTWARE.22*/2324#ifndef _NIR_INTRINSICS_25#define _NIR_INTRINSICS_2627<% opcode_names = sorted(INTR_OPCODES) %>2829typedef enum {30% for name in opcode_names:31nir_intrinsic_${name},32% endfor3334nir_last_intrinsic = nir_intrinsic_${opcode_names[-1]},35nir_num_intrinsics = nir_last_intrinsic + 136} nir_intrinsic_op;3738typedef enum {39% for index in INTR_INDICES:40NIR_INTRINSIC_${index.name.upper()},41% endfor42NIR_INTRINSIC_NUM_INDEX_FLAGS,43} nir_intrinsic_index_flag;4445extern const char *nir_intrinsic_index_names[NIR_INTRINSIC_NUM_INDEX_FLAGS];4647#endif /* _NIR_INTRINSICS_ */"""4849from nir_intrinsics import INTR_OPCODES, INTR_INDICES50from mako.template import Template51import argparse52import os535455def main():56parser = argparse.ArgumentParser()57parser.add_argument('--outdir', required=True,58help='Directory to put the generated files in')5960args = parser.parse_args()6162path = os.path.join(args.outdir, 'nir_intrinsics.h')63with open(path, 'wb') as f:64f.write(Template(template, output_encoding='utf-8').render(INTR_OPCODES=INTR_OPCODES, INTR_INDICES=INTR_INDICES))6566if __name__ == '__main__':67main()68697071