1#!/usr/bin/env python3
2"""Generate C headers for certain extended instruction sets"""
3
4import subprocess
5import os
6
7# Assume we are running from the tools/buildHeaders directory
8os.chdir('../../include/spirv/unified1')
9
10def mk_extinst(name, grammar_file):
11  """Generate one C header from a grammar"""
12  script = '../../../tools/buildHeaders/bin/generate_language_headers.py'
13  subprocess.check_call(['python3',
14                         script,
15                         '--extinst-name=' + name,
16                         '--extinst-grammar=' + grammar_file,
17                         '--extinst-output-base=' + name])
18  subprocess.check_call(['dos2unix', name + '.h'])
19
20
21mk_extinst('DebugInfo', 'extinst.debuginfo.grammar.json')
22mk_extinst('OpenCLDebugInfo100', 'extinst.opencl.debuginfo.100.grammar.json')
23mk_extinst('AMD_gcn_shader', 'extinst.spv-amd-gcn-shader.grammar.json')
24mk_extinst('AMD_shader_ballot', 'extinst.spv-amd-shader-ballot.grammar.json')
25mk_extinst('AMD_shader_explicit_vertex_parameter', 'extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json')
26mk_extinst('AMD_shader_trinary_minmax', 'extinst.spv-amd-shader-trinary-minmax.grammar.json')
27mk_extinst('NonSemanticDebugPrintf', 'extinst.nonsemantic.debugprintf.grammar.json')
28mk_extinst('NonSemanticClspvReflection', 'extinst.nonsemantic.clspvreflection.grammar.json')
29