<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Jul 14, 2017 at 6:39 PM, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>><br>
<br>
The old table based spirv_*_to_string functions would return NULL for<br>
any values "inside" the table that didn't have entries.  The tables also<br>
needed to be updated by hand each time a new spirv.h was imported.<br>
Generate the file instead.<br></blockquote><div><br></div><div>Thanks for working on this!  This is way better than having a hand-rolled table that requires updating.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>><br>
Suggested-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>><br>
---<br>
I am pretty sure the scons changes are bogus... halp, plz?<br></blockquote><div><br></div><div>I'm going to let Emil review your autotools and write you some Android.mk.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 src/compiler/Makefile.am           |   2 +<br>
 src/compiler/<a href="http://Makefile.nir.am" rel="noreferrer" target="_blank">Makefile.nir.am</a>       |   1 +<br>
 src/compiler/Makefile.<wbr>sources      |   4 +-<br>
 src/compiler/<a href="http://Makefile.spirv.am" rel="noreferrer" target="_blank">Makefile.spirv.<wbr>am</a>     |  31 ++++++++<br>
 src/compiler/SConscript            |   1 +<br>
 src/compiler/SConscript.<wbr>spirv      |  32 ++++++++<br>
 src/compiler/spirv/spirv_<wbr>info.c    | 156 ------------------------------<wbr>-------<br>
 src/compiler/spirv/spirv_<wbr>info_c.py |  90 +++++++++++++++++++++<br>
 8 files changed, 160 insertions(+), 157 deletions(-)<br>
 create mode 100644 src/compiler/<a href="http://Makefile.spirv.am" rel="noreferrer" target="_blank">Makefile.spirv.am</a><br>
 create mode 100644 src/compiler/SConscript.spirv<br>
 delete mode 100644 src/compiler/spirv/spirv_info.<wbr>c<br>
 create mode 100644 src/compiler/spirv/spirv_info_<wbr>c.py<br>
<br>
diff --git a/src/compiler/Makefile.am b/src/compiler/Makefile.am<br>
index 4c83365..b8f6697 100644<br>
--- a/src/compiler/Makefile.am<br>
+++ b/src/compiler/Makefile.am<br>
@@ -63,3 +63,5 @@ PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)<br>
 include <a href="http://Makefile.glsl.am" rel="noreferrer" target="_blank">Makefile.glsl.am</a><br>
<br>
 include <a href="http://Makefile.nir.am" rel="noreferrer" target="_blank">Makefile.nir.am</a><br>
+<br>
+include <a href="http://Makefile.spirv.am" rel="noreferrer" target="_blank">Makefile.spirv.am</a><br>
diff --git a/src/compiler/<a href="http://Makefile.nir.am" rel="noreferrer" target="_blank">Makefile.nir.am</a> b/src/compiler/<a href="http://Makefile.nir.am" rel="noreferrer" target="_blank">Makefile.nir.am</a><br>
index 13f02a7..d10f173 100644<br>
--- a/src/compiler/<a href="http://Makefile.nir.am" rel="noreferrer" target="_blank">Makefile.nir.am</a><br>
+++ b/src/compiler/<a href="http://Makefile.nir.am" rel="noreferrer" target="_blank">Makefile.nir.am</a><br>
@@ -29,6 +29,7 @@ nir_libnir_la_LIBADD = \<br>
 nir_libnir_la_SOURCES =                                        \<br>
        $(NIR_FILES)                                    \<br>
        $(SPIRV_FILES)                                  \<br>
+       $(SPIRV_GENERATED_FILES)                        \<br>
        $(NIR_GENERATED_FILES)<br>
<br>
 nir/nir_builder_opcodes.h: nir/nir_opcodes.py nir/nir_builder_opcodes_h.py<br>
diff --git a/src/compiler/Makefile.source<wbr>s b/src/compiler/Makefile.source<wbr>s<br>
index d3447fb..785782b 100644<br>
--- a/src/compiler/Makefile.source<wbr>s<br>
+++ b/src/compiler/Makefile.source<wbr>s<br>
@@ -277,12 +277,14 @@ NIR_FILES = \<br>
        nir/nir_worklist.c \<br>
        nir/nir_worklist.h<br>
<br>
+SPIRV_GENERATED_FILES = \<br>
+       spirv/spirv_info.c<br>
+<br>
 SPIRV_FILES = \<br>
        spirv/GLSL.std.450.h \<br>
        spirv/nir_spirv.h \<br>
        spirv/spirv.h \<br>
        spirv/spirv_info.h \<br>
-       spirv/spirv_info.c \<br>
        spirv/spirv_to_nir.c \<br>
        spirv/vtn_alu.c \<br>
        spirv/vtn_cfg.c \<br>
diff --git a/src/compiler/<a href="http://Makefile.spirv.am" rel="noreferrer" target="_blank">Makefile.spirv.<wbr>am</a> b/src/compiler/<a href="http://Makefile.spirv.am" rel="noreferrer" target="_blank">Makefile.spirv.<wbr>am</a><br>
new file mode 100644<br>
index 0000000..6d5dfc0<br>
--- /dev/null<br>
+++ b/src/compiler/<a href="http://Makefile.spirv.am" rel="noreferrer" target="_blank">Makefile.spirv.<wbr>am</a><br>
@@ -0,0 +1,31 @@<br>
+# Copyright (C) 2017 Intel Corporation<br>
+#<br>
+# Permission is hereby granted, free of charge, to any person obtaining a<br>
+# copy of this software and associated documentation files (the "Software"),<br>
+# to deal in the Software without restriction, including without limitation<br>
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+# and/or sell copies of the Software, and to permit persons to whom the<br>
+# Software is furnished to do so, subject to the following conditions:<br>
+#<br>
+# The above copyright notice and this permission notice (including the next<br>
+# paragraph) shall be included in all copies or substantial portions of the<br>
+# Software.<br>
+#<br>
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+# IN THE SOFTWARE.<br>
+<br>
+spirv/spirv_info.c: spirv/spirv_info_c.py spirv/spirv.core.grammar.json<br>
+       $(MKDIR_GEN)<br>
+       $(PYTHON_GEN) $(srcdir)/spirv/spirv_info_c.p<wbr>y > $@ || ($(RM) $@; false)<br></blockquote><div><br></div><div>I'm sorry for all the pain I'm sure this caused you...  Being the first one to add auto-generation to a directory is the worst...<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+BUILT_SOURCES += $(SPIRV_GENERATED_FILES)<br>
+CLEANFILES += $(SPIRV_GENERATED_FILES)<br>
+<br>
+EXTRA_DIST += \<br>
+       spirv/spirv_info_c.py \<br>
+       spirv/spirv.core.grammar.json<br>
diff --git a/src/compiler/SConscript b/src/compiler/SConscript<br>
index 44509a9..2797abe 100644<br>
--- a/src/compiler/SConscript<br>
+++ b/src/compiler/SConscript<br>
@@ -26,4 +26,5 @@ compiler = env.ConvenienceLibrary(<br>
 Export('compiler')<br>
<br>
 SConscript('SConscript.glsl')<br>
+SConscript('SConscript.spirv'<wbr>)<br>
 SConscript('SConscript.nir')<br>
diff --git a/src/compiler/SConscript.spir<wbr>v b/src/compiler/SConscript.spir<wbr>v<br>
new file mode 100644<br>
index 0000000..8a90c2f<br>
--- /dev/null<br>
+++ b/src/compiler/SConscript.spir<wbr>v<br>
@@ -0,0 +1,32 @@<br>
+import common<br>
+<br>
+Import('*')<br>
+<br>
+from sys import executable as python_cmd<br>
+<br>
+env = env.Clone()<br>
+<br>
+env.MSVC2013Compat()<br>
+<br>
+env.Prepend(CPPPATH = [<br>
+    '#include',<br>
+    '#src',<br>
+    '#src/mapi',<br>
+    '#src/mesa',<br>
+    '#src/gallium/include',<br>
+    '#src/gallium/auxiliary',<br>
+    '#src/compiler/nir',<br>
+])<br>
+<br>
+# Make generated headers reachable from the include path.<br>
+env.Prepend(CPPPATH = [Dir('.').abspath, Dir('glsl').abspath])<br>
+env.Prepend(CPPPATH = [Dir('.').abspath, Dir('nir').abspath])<br>
+<br>
+# SPIR-V generated sources<br>
+<br>
+spirv_info_c = env.CodeGenerate(<br>
+    target = 'spirv/spirv_info.c',<br>
+    script = 'spirv/spirv_info_c.py',<br>
+    source = [],<br>
+    command = python_cmd + ' $SCRIPT > $TARGET'<br>
+)<br>
diff --git a/src/compiler/spirv/spirv_inf<wbr>o.c b/src/compiler/spirv/spirv_inf<wbr>o.c<br>
deleted file mode 100644<br>
index 1036b41..0000000<br>
--- a/src/compiler/spirv/spirv_inf<wbr>o.c<br>
+++ /dev/null<br>
@@ -1,156 +0,0 @@<br>
-/*<br>
- * Copyright © 2016 Intel Corporation<br>
- *<br>
- * Permission is hereby granted, free of charge, to any person obtaining a<br>
- * copy of this software and associated documentation files (the "Software"),<br>
- * to deal in the Software without restriction, including without limitation<br>
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
- * and/or sell copies of the Software, and to permit persons to whom the<br>
- * Software is furnished to do so, subject to the following conditions:<br>
- *<br>
- * The above copyright notice and this permission notice (including the next<br>
- * paragraph) shall be included in all copies or substantial portions of the<br>
- * Software.<br>
- *<br>
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
- * IN THE SOFTWARE.<br>
- */<br>
-<br>
-#include "spirv_info.h"<br>
-#include "util/macros.h"<br>
-<br>
-#define CAPABILITY(cap) [SpvCapability##cap] = #cap<br>
-static const char * const capability_to_string[] = {<br>
-   CAPABILITY(Matrix),<br>
-   CAPABILITY(Shader),<br>
-   CAPABILITY(Geometry),<br>
-   CAPABILITY(Tessellation),<br>
-   CAPABILITY(Addresses),<br>
-   CAPABILITY(Linkage),<br>
-   CAPABILITY(Kernel),<br>
-   CAPABILITY(Vector16),<br>
-   CAPABILITY(Float16Buffer),<br>
-   CAPABILITY(Float16),<br>
-   CAPABILITY(Float64),<br>
-   CAPABILITY(Int64),<br>
-   CAPABILITY(Int64Atomics),<br>
-   CAPABILITY(ImageBasic),<br>
-   CAPABILITY(ImageReadWrite),<br>
-   CAPABILITY(ImageMipmap),<br>
-   CAPABILITY(Pipes),<br>
-   CAPABILITY(Groups),<br>
-   CAPABILITY(DeviceEnqueue),<br>
-   CAPABILITY(LiteralSampler),<br>
-   CAPABILITY(AtomicStorage),<br>
-   CAPABILITY(Int16),<br>
-   CAPABILITY(TessellationPointS<wbr>ize),<br>
-   CAPABILITY(GeometryPointSize)<wbr>,<br>
-   CAPABILITY(ImageGatherExtende<wbr>d),<br>
-   CAPABILITY(StorageImageMultis<wbr>ample),<br>
-   CAPABILITY(UniformBufferArray<wbr>DynamicIndexing),<br>
-   CAPABILITY(SampledImageArrayD<wbr>ynamicIndexing),<br>
-   CAPABILITY(StorageBufferArray<wbr>DynamicIndexing),<br>
-   CAPABILITY(StorageImageArrayD<wbr>ynamicIndexing),<br>
-   CAPABILITY(ClipDistance),<br>
-   CAPABILITY(CullDistance),<br>
-   CAPABILITY(ImageCubeArray),<br>
-   CAPABILITY(SampleRateShading)<wbr>,<br>
-   CAPABILITY(ImageRect),<br>
-   CAPABILITY(SampledRect),<br>
-   CAPABILITY(GenericPointer),<br>
-   CAPABILITY(Int8),<br>
-   CAPABILITY(InputAttachment),<br>
-   CAPABILITY(SparseResidency),<br>
-   CAPABILITY(MinLod),<br>
-   CAPABILITY(Sampled1D),<br>
-   CAPABILITY(Image1D),<br>
-   CAPABILITY(SampledCubeArray),<br>
-   CAPABILITY(SampledBuffer),<br>
-   CAPABILITY(ImageBuffer),<br>
-   CAPABILITY(ImageMSArray),<br>
-   CAPABILITY(StorageImageExtend<wbr>edFormats),<br>
-   CAPABILITY(ImageQuery),<br>
-   CAPABILITY(DerivativeControl)<wbr>,<br>
-   CAPABILITY(InterpolationFunct<wbr>ion),<br>
-   CAPABILITY(TransformFeedback)<wbr>,<br>
-   CAPABILITY(GeometryStreams),<br>
-   CAPABILITY(StorageImageReadWi<wbr>thoutFormat),<br>
-   CAPABILITY(StorageImageWriteW<wbr>ithoutFormat),<br>
-   CAPABILITY(MultiViewport),<br>
-   CAPABILITY(SubgroupDispatch),<br>
-   CAPABILITY(NamedBarrier),<br>
-   CAPABILITY(PipeStorage),<br>
-   CAPABILITY(SubgroupBallotKHR)<wbr>,<br>
-   CAPABILITY(DrawParameters),<br>
-};<br>
-<br>
-const char *<br>
-spirv_capability_to_string(Sp<wbr>vCapability cap)<br>
-{<br>
-   if (cap < ARRAY_SIZE(capability_to_strin<wbr>g))<br>
-      return capability_to_string[cap];<br>
-   else<br>
-      return "unknown";<br>
-}<br>
-<br>
-#define DECORATION(dec) [SpvDecoration##dec] = #dec<br>
-static const char * const decoration_to_string[] = {<br>
-   DECORATION(RelaxedPrecision),<br>
-   DECORATION(SpecId),<br>
-   DECORATION(Block),<br>
-   DECORATION(BufferBlock),<br>
-   DECORATION(RowMajor),<br>
-   DECORATION(ColMajor),<br>
-   DECORATION(ArrayStride),<br>
-   DECORATION(MatrixStride),<br>
-   DECORATION(GLSLShared),<br>
-   DECORATION(GLSLPacked),<br>
-   DECORATION(CPacked),<br>
-   DECORATION(BuiltIn),<br>
-   DECORATION(NoPerspective),<br>
-   DECORATION(Flat),<br>
-   DECORATION(Patch),<br>
-   DECORATION(Centroid),<br>
-   DECORATION(Sample),<br>
-   DECORATION(Invariant),<br>
-   DECORATION(Restrict),<br>
-   DECORATION(Aliased),<br>
-   DECORATION(Volatile),<br>
-   DECORATION(Constant),<br>
-   DECORATION(Coherent),<br>
-   DECORATION(NonWritable),<br>
-   DECORATION(NonReadable),<br>
-   DECORATION(Uniform),<br>
-   DECORATION(SaturatedConversio<wbr>n),<br>
-   DECORATION(Stream),<br>
-   DECORATION(Location),<br>
-   DECORATION(Component),<br>
-   DECORATION(Index),<br>
-   DECORATION(Binding),<br>
-   DECORATION(DescriptorSet),<br>
-   DECORATION(Offset),<br>
-   DECORATION(XfbBuffer),<br>
-   DECORATION(XfbStride),<br>
-   DECORATION(FuncParamAttr),<br>
-   DECORATION(FPRoundingMode),<br>
-   DECORATION(FPFastMathMode),<br>
-   DECORATION(LinkageAttributes)<wbr>,<br>
-   DECORATION(NoContraction),<br>
-   DECORATION(InputAttachmentInd<wbr>ex),<br>
-   DECORATION(Alignment),<br>
-   DECORATION(MaxByteOffset),<br>
-};<br>
-<br>
-const char *<br>
-spirv_decoration_to_string(Sp<wbr>vDecoration dec)<br>
-{<br>
-   if (dec < ARRAY_SIZE(decoration_to_strin<wbr>g))<br>
-      return decoration_to_string[dec];<br>
-   else<br>
-      return "unknown";<br>
-}<br>
diff --git a/src/compiler/spirv/spirv_inf<wbr>o_c.py b/src/compiler/spirv/spirv_inf<wbr>o_c.py<br>
new file mode 100644<br>
index 0000000..5af832e<br>
--- /dev/null<br>
+++ b/src/compiler/spirv/spirv_inf<wbr>o_c.py<br>
@@ -0,0 +1,90 @@<br>
+# -*- coding: utf-8 -*-<br>
+<br>
+# Copyright © 2017 Intel Corporation<br>
+#<br>
+# Permission is hereby granted, free of charge, to any person obtaining a<br>
+# copy of this software and associated documentation files (the "Software"),<br>
+# to deal in the Software without restriction, including without limitation<br>
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+# and/or sell copies of the Software, and to permit persons to whom the<br>
+# Software is furnished to do so, subject to the following conditions:<br>
+#<br>
+# The above copyright notice and this permission notice (including the next<br>
+# paragraph) shall be included in all copies or substantial portions of the<br>
+# Software.<br>
+#<br>
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+# IN THE SOFTWARE.<br></blockquote><div><br></div><div>What you have is fine here but I've been really liking the style that's used in mesa/main/format_fallbacks.py and the anv_extensions.py that I sent out which does<br><br></div><div>COPYRIGHT="""<br></div><div>\* The usual C copyright<br> */<br>"""<br><br></div><div>and then maybe some functions and then<br><br></div><div>TEMPLATE = mako.template.Template(<wbr>COPYRIGHT + """<br></div><div>/* My template goes here */<br></div><div>""")<br><br></div><div>Followed by the main function.  Putting the template inside the main function (or if statement in this case) means the indentation gets really weird.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+import json<br>
+import mako.template<br>
+<br>
+def collect_data(spirv, kind):<br>
+    for x in spirv["operand_kinds"]:<br>
+        if x["kind"] == kind:<br>
+            operands = x<br></blockquote><div><br></div><div>break?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+    # There are some duplicate values in some of the tables (thanks guys!), so<br>
+    # filter them out.<br></blockquote><div><br></div><div>That's unfortunate...<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+    last_value = -1<br>
+    values = []<br>
+    for x in operands["enumerants"]:<br>
+        if x["value"] != last_value:<br>
+            last_value = x["value"]<br>
+            values.append(x["enumerant"])<br></blockquote><div><br></div><div>This assumes that the duplicate values will be sequential.  Is that always the case?  I suppose it isn't since the C compiles.  Maybe better to use a set and do<br><br></div><div>if x["value"] not in seen_values:<br></div><div>   seen_values.add(x["value"])<br><br></div><div>What you have here works though so we can always make that change later if it's ever a problem.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+    return (kind, values)<br>
+<br>
+if __name__ == "__main__":<br>
+    t = mako.template.Template("""/*<br>
+ * Copyright (C) 2017 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
+ * DEALINGS IN THE SOFTWARE.<br>
+ */<br>
+<br>
+#include "spirv_info.h"<br>
+    % for kind,values in info:<br></blockquote><div><br></div><div>Dylan will probably tell you to indent your C code along with the mako.  I, personally, don't care.  If anything, I would just dedent all the mako by a step.  But I don't really care all that much.  It's readable as-is and we don't really have a mako style guide.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+const char *<br>
+spirv_${kind.lower()}_to_stri<wbr>ng(Spv${kind} v)<br>
+{<br>
+   switch (v) {<br>
+        % for name in values:<br>
+   case Spv${kind}${name}: return "Spv${kind}${name}";<br>
+        % endfor<br>
+   case Spv${kind}Max: break; /* silence warnings about unhandled enums. */<br>
+   }<br>
+<br>
+   return "unknown";<br>
+}<br>
+    % endfor<br>
+""")<br>
+<br>
+    spirv_info = json.JSONDecoder().decode(open<wbr>("spirv/spirv.core.grammar.<wbr>json", "r").read())<br>
+<br>
+    capabilities = collect_data(spirv_info, "Capability")<br>
+    decorations = collect_data(spirv_info, "Decoration")<br>
+<br>
+    print(t.render(info=[capabilit<wbr>ies, decorations]))<span class="m_4698223410079117902HOEnZb"></span></blockquote><div><br></div><div>The more recent generators have started using python's argparse and have --xml (or --json in this case) parameter for the input and --out for the output.  Take a look at mesa/main/format_fallbacks.py for an example.  Having the generator write the output file makes adding it to automake a bit easier to do correctly.<br><br></div><div>--Jason <br></div></div></div></div>