Fix generation of Vim syntax file
authorDavid Neto <dneto@google.com>
Thu, 8 Feb 2018 17:05:40 +0000 (12:05 -0500)
committerDavid Neto <dneto@google.com>
Fri, 9 Feb 2018 22:47:51 +0000 (17:47 -0500)
source/CMakeLists.txt
utils/generate_vim_syntax.py

index b01edf5..7512dc7 100644 (file)
@@ -66,7 +66,7 @@ macro(spvtools_vimsyntax VERSION CLVERSION)
   add_custom_command(OUTPUT ${VIMSYNTAX_FILE}
       COMMAND ${PYTHON_EXECUTABLE} ${VIMSYNTAX_PROCESSING_SCRIPT}
       --spirv-core-grammar=${GRAMMAR_JSON_FILE}
-      --exinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE}
+      --extinst-debuginfo-grammar=${DEBUGINFO_GRAMMAR_JSON_FILE}
       --extinst-glsl-grammar=${GLSL_GRAMMAR_JSON_FILE}
       --extinst-opencl-grammar=${OPENCL_GRAMMAR_JSON_FILE}
       >${VIMSYNTAX_FILE}
index 837afa6..03c0b47 100755 (executable)
@@ -150,6 +150,10 @@ def main():
                         type=str, required=False, default=None,
                         help='input JSON grammar file for OpenGL extended '
                         'instruction set')
+    parser.add_argument('--extinst-debuginfo-grammar', metavar='<path>',
+                        type=str, required=False, default=None,
+                        help='input JSON grammar file for DebugInfo extended '
+                        'instruction set')
     args = parser.parse_args()
 
     # Generate the syntax rules.
@@ -179,6 +183,17 @@ def main():
         for inst in opencl["instructions"]:
             EmitAsEnumerant(inst['opname'])
 
+    if args.extinst_debuginfo_grammar is not None:
+        print('\n" DebugInfo extended instructions')
+        debuginfo = json.loads(open(args.extinst_debuginfo_grammar).read())
+        for inst in debuginfo["instructions"]:
+            EmitAsEnumerant(inst['opname'])
+        print('\n" DebugInfo operand enums')
+        for operand_kind in debuginfo["operand_kinds"]:
+            if 'enumerants' in operand_kind:
+                for e in operand_kind['enumerants']:
+                    EmitAsEnumerant(e['enumerant'])
+
     print('\n" OpSpecConstantOp opcodes')
     for word in SPEC_CONSTANT_OP_OPCODES.split(' '):
         stripped = word.strip('\n,')