Use JSON grammar files to generate extended instruction sets.
authorLei Zhang <antiagainst@google.com>
Mon, 4 Apr 2016 18:30:56 +0000 (14:30 -0400)
committerLei Zhang <antiagainst@google.com>
Mon, 4 Apr 2016 20:13:06 +0000 (16:13 -0400)
CMakeLists.txt
source/ext_inst.cpp
source/extinst.glsl.std.450.grammar.json [new file with mode: 0644]
source/extinst.opencl.std.grammar.json [new file with mode: 0644]
source/opcode.cpp
source/opencl_std_ext_inst.inc [deleted file]
source/operand.cpp
utils/generate_grammar_tables.py

index 1bf8352..bd80545 100644 (file)
@@ -140,9 +140,13 @@ add_custom_target(spirv-tools-build-version
 add_custom_target(spirv-tools-build-tables
   ${PYTHON_EXECUTABLE}
   ${CMAKE_CURRENT_SOURCE_DIR}/utils/generate_grammar_tables.py
-  ${spirv-tools_SOURCE_DIR}/source/spirv.core.grammar.json
-  --opcode-file=${spirv-tools_BINARY_DIR}/opcode.inc
-  --operand-file=${spirv-tools_BINARY_DIR}/operand.inc
+  --spirv-core-grammar=${spirv-tools_SOURCE_DIR}/source/spirv.core.grammar.json
+  --extinst-glsl-grammar=${spirv-tools_SOURCE_DIR}/source/extinst.glsl.std.450.grammar.json
+  --extinst-opencl-grammar=${spirv-tools_SOURCE_DIR}/source/extinst.opencl.std.grammar.json
+  --core-insts-output=${spirv-tools_BINARY_DIR}/core.insts.inc
+  --glsl-insts-output=${spirv-tools_BINARY_DIR}/glsl.std.450.insts.inc
+  --opencl-insts-output=${spirv-tools_BINARY_DIR}/opencl.std.insts.inc
+  --operand-kinds-output=${spirv-tools_BINARY_DIR}/operand.kinds.inc
   COMMENT "Generate info tables for SPIR-V instructions and operands.")
 
 # Defaults to OFF if the user didn't set it.
index 67366de..f612fa9 100644 (file)
 #include "spirv/OpenCL.std.h"
 #include "spirv_definition.h"
 
-/// Generate a spv_ext_inst_desc_t literal for a GLSL std450 extended
-/// instruction with one/two/three <id> parameter(s).
-#define GLSL450Inst1(name) \
-  #name, GLSLstd450::GLSLstd450##name, 0, { SPV_OPERAND_TYPE_ID }
-#define GLSL450Inst1Cap(name, cap)                  \
-  #name, GLSLstd450::GLSLstd450##name,              \
-      SPV_CAPABILITY_AS_MASK(SpvCapability##cap), { \
-    SPV_OPERAND_TYPE_ID                             \
-  }
-#define GLSL450Inst2(name)                   \
-  #name, GLSLstd450::GLSLstd450##name, 0, {  \
-    SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID \
-  }
-#define GLSL450Inst2Cap(name, cap)                  \
-  #name, GLSLstd450::GLSLstd450##name,              \
-      SPV_CAPABILITY_AS_MASK(SpvCapability##cap), { \
-    SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID        \
-  }
-#define GLSL450Inst3(name)                                        \
-  #name, GLSLstd450::GLSLstd450##name, 0, {                       \
-    SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID, SPV_OPERAND_TYPE_ID \
-  }
-
 static const spv_ext_inst_desc_t glslStd450Entries[] = {
-    {GLSL450Inst1(Round)},
-    {GLSL450Inst1(RoundEven)},
-    {GLSL450Inst1(Trunc)},
-    {GLSL450Inst1(FAbs)},
-    {GLSL450Inst1(SAbs)},
-    {GLSL450Inst1(FSign)},
-    {GLSL450Inst1(SSign)},
-    {GLSL450Inst1(Floor)},
-    {GLSL450Inst1(Ceil)},
-    {GLSL450Inst1(Fract)},
-    {GLSL450Inst1(Radians)},
-    {GLSL450Inst1(Degrees)},
-    {GLSL450Inst1(Sin)},
-    {GLSL450Inst1(Cos)},
-    {GLSL450Inst1(Tan)},
-    {GLSL450Inst1(Asin)},
-    {GLSL450Inst1(Acos)},
-    {GLSL450Inst1(Atan)},
-    {GLSL450Inst1(Sinh)},
-    {GLSL450Inst1(Cosh)},
-    {GLSL450Inst1(Tanh)},
-    {GLSL450Inst1(Asinh)},
-    {GLSL450Inst1(Acosh)},
-    {GLSL450Inst1(Atanh)},
-    {GLSL450Inst2(Atan2)},
-    {GLSL450Inst2(Pow)},
-    {GLSL450Inst1(Exp)},
-    {GLSL450Inst1(Log)},
-    {GLSL450Inst1(Exp2)},
-    {GLSL450Inst1(Log2)},
-    {GLSL450Inst1(Sqrt)},
-    {GLSL450Inst1(InverseSqrt)},
-    {GLSL450Inst1(Determinant)},
-    {GLSL450Inst1(MatrixInverse)},
-    {GLSL450Inst2(Modf)},
-    {GLSL450Inst1(ModfStruct)},
-    {GLSL450Inst2(FMin)},
-    {GLSL450Inst2(UMin)},
-    {GLSL450Inst2(SMin)},
-    {GLSL450Inst2(FMax)},
-    {GLSL450Inst2(UMax)},
-    {GLSL450Inst2(SMax)},
-    {GLSL450Inst3(FClamp)},
-    {GLSL450Inst3(UClamp)},
-    {GLSL450Inst3(SClamp)},
-    {GLSL450Inst3(FMix)},
-    {GLSL450Inst3(IMix)},
-    {GLSL450Inst2(Step)},
-    {GLSL450Inst3(SmoothStep)},
-    {GLSL450Inst3(Fma)},
-    {GLSL450Inst2(Frexp)},
-    {GLSL450Inst1(FrexpStruct)},
-    {GLSL450Inst2(Ldexp)},
-    {GLSL450Inst1(PackSnorm4x8)},
-    {GLSL450Inst1(PackUnorm4x8)},
-    {GLSL450Inst1(PackSnorm2x16)},
-    {GLSL450Inst1(PackUnorm2x16)},
-    {GLSL450Inst1(PackHalf2x16)},
-    {GLSL450Inst1Cap(PackDouble2x32, Float64)},
-    {GLSL450Inst1(UnpackSnorm2x16)},
-    {GLSL450Inst1(UnpackUnorm2x16)},
-    {GLSL450Inst1(UnpackHalf2x16)},
-    {GLSL450Inst1(UnpackSnorm4x8)},
-    {GLSL450Inst1(UnpackUnorm4x8)},
-    {GLSL450Inst1(UnpackDouble2x32)},
-    {GLSL450Inst1(Length)},
-    {GLSL450Inst2(Distance)},
-    {GLSL450Inst2(Cross)},
-    {GLSL450Inst1(Normalize)},
-    {GLSL450Inst3(FaceForward)},
-    {GLSL450Inst2(Reflect)},
-    {GLSL450Inst3(Refract)},
-    {GLSL450Inst1(FindILsb)},
-    {GLSL450Inst1(FindSMsb)},
-    {GLSL450Inst1(FindUMsb)},
-    {GLSL450Inst1Cap(InterpolateAtCentroid, InterpolationFunction)},
-    {GLSL450Inst2Cap(InterpolateAtSample, InterpolationFunction)},
-    {GLSL450Inst2Cap(InterpolateAtOffset, InterpolationFunction)},
-    {GLSL450Inst2(NMin)},
-    {GLSL450Inst2(NMax)},
-    {GLSL450Inst2(NClamp)},
+#include "glsl.std.450.insts.inc"
 };
 
 static const spv_ext_inst_desc_t openclEntries[] = {
-#define ExtInst(Name, Opcode, OperandList) {#Name, Opcode, 0, OperandList},
-#define EmptyList \
-  {}
-#define List(...) \
-  { __VA_ARGS__ }
-#define OperandId SPV_OPERAND_TYPE_ID
-#define OperandLiteralNumber SPV_OPERAND_TYPE_LITERAL_INTEGER
-#define OperandFPRoundingMode SPV_OPERAND_TYPE_FP_ROUNDING_MODE
-#define OperandVariableIds SPV_OPERAND_TYPE_VARIABLE_ID
-#include "opencl_std_ext_inst.inc"
-#undef ExtList
-#undef EmptyList
-#undef List
-#undef OperandId
-#undef OperandLiteralNumber
-#undef OperandFPRoundingMode
-#undef OperandVariableIds
+#include "opencl.std.insts.inc"
 };
 
 spv_result_t spvExtInstTableGet(spv_ext_inst_table* pExtInstTable) {
diff --git a/source/extinst.glsl.std.450.grammar.json b/source/extinst.glsl.std.450.grammar.json
new file mode 100644 (file)
index 0000000..b39142f
--- /dev/null
@@ -0,0 +1,640 @@
+{
+  "copyright" : [
+    "Copyright (c) 2014-2016 The Khronos Group Inc.",
+    "",
+    "Permission is hereby granted, free of charge, to any person obtaining a copy",
+    "of this software and/or associated documentation files (the \"Materials\"),",
+    "to deal in the Materials without restriction, including without limitation",
+    "the rights to use, copy, modify, merge, publish, distribute, sublicense,",
+    "and/or sell copies of the Materials, and to permit persons to whom the",
+    "Materials are furnished to do so, subject to the following conditions:",
+    "",
+    "The above copyright notice and this permission notice shall be included in",
+    "all copies or substantial portions of the Materials.",
+    "",
+    "MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS",
+    "STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND",
+    "HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ ",
+    "",
+    "THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS",
+    "OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
+    "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL",
+    "THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
+    "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING",
+    "FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS",
+    "IN THE MATERIALS."
+  ],
+  "version" : 100,
+  "revision" : 2,
+  "instructions" : [
+    {
+      "opname" : "Round",
+      "opcode" : 1,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "RoundEven",
+      "opcode" : 2,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Trunc",
+      "opcode" : 3,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "FAbs",
+      "opcode" : 4,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "SAbs",
+      "opcode" : 5,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "FSign",
+      "opcode" : 6,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "SSign",
+      "opcode" : 7,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Floor",
+      "opcode" : 8,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Ceil",
+      "opcode" : 9,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Fract",
+      "opcode" : 10,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Radians",
+      "opcode" : 11,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Degrees",
+      "opcode" : 12,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Sin",
+      "opcode" : 13,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Cos",
+      "opcode" : 14,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Tan",
+      "opcode" : 15,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Asin",
+      "opcode" : 16,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Acos",
+      "opcode" : 17,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Atan",
+      "opcode" : 18,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Sinh",
+      "opcode" : 19,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Cosh",
+      "opcode" : 20,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Tanh",
+      "opcode" : 21,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Asinh",
+      "opcode" : 22,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Acosh",
+      "opcode" : 23,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Atanh",
+      "opcode" : 24,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Atan2",
+      "opcode" : 25,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Pow",
+      "opcode" : 26,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Exp",
+      "opcode" : 27,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Log",
+      "opcode" : 28,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Exp2",
+      "opcode" : 29,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Log2",
+      "opcode" : 30,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Sqrt",
+      "opcode" : 31,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "InverseSqrt",
+      "opcode" : 32,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Determinant",
+      "opcode" : 33,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "MatrixInverse",
+      "opcode" : 34,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Modf",
+      "opcode" : 35,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "ModfStruct",
+      "opcode" : 36,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "FMin",
+      "opcode" : 37,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "UMin",
+      "opcode" : 38,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "SMin",
+      "opcode" : 39,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "FMax",
+      "opcode" : 40,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "UMax",
+      "opcode" : 41,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "SMax",
+      "opcode" : 42,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "FClamp",
+      "opcode" : 43,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "UClamp",
+      "opcode" : 44,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "SClamp",
+      "opcode" : 45,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "FMix",
+      "opcode" : 46,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "IMix",
+      "opcode" : 47,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Step",
+      "opcode" : 48,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "SmoothStep",
+      "opcode" : 49,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Fma",
+      "opcode" : 50,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Frexp",
+      "opcode" : 51,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "FrexpStruct",
+      "opcode" : 52,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Ldexp",
+      "opcode" : 53,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "PackSnorm4x8",
+      "opcode" : 54,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "PackUnorm4x8",
+      "opcode" : 55,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "PackSnorm2x16",
+      "opcode" : 56,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "PackUnorm2x16",
+      "opcode" : 57,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "PackHalf2x16",
+      "opcode" : 58,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "PackDouble2x32",
+      "opcode" : 59,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ],
+      "capabilities" : [ "Float64" ]
+    },
+    {
+      "opname" : "UnpackSnorm2x16",
+      "opcode" : 60,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "UnpackUnorm2x16",
+      "opcode" : 61,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "UnpackHalf2x16",
+      "opcode" : 62,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "UnpackSnorm4x8",
+      "opcode" : 63,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "UnpackUnorm4x8",
+      "opcode" : 64,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "UnpackDouble2x32",
+      "opcode" : 65,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Length",
+      "opcode" : 66,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Distance",
+      "opcode" : 67,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Cross",
+      "opcode" : 68,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Normalize",
+      "opcode" : 69,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "FaceForward",
+      "opcode" : 70,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Reflect",
+      "opcode" : 71,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "Refract",
+      "opcode" : 72,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "FindILsb",
+      "opcode" : 73,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "FindSMsb",
+      "opcode" : 74,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "FindUMsb",
+      "opcode" : 75,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "InterpolateAtCentroid",
+      "opcode" : 76,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ],
+      "capabilities" : [ "InterpolationFunction" ]
+    },
+    {
+      "opname" : "InterpolateAtSample",
+      "opcode" : 77,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ],
+      "capabilities" : [ "InterpolationFunction" ]
+    },
+    {
+      "opname" : "InterpolateAtOffset",
+      "opcode" : 78,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ],
+      "capabilities" : [ "InterpolationFunction" ]
+    },
+    {
+      "opname" : "NMin",
+      "opcode" : 79,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "NMax",
+      "opcode" : 80,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "NClamp",
+      "opcode" : 81,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    }
+  ]
+}
diff --git a/source/extinst.opencl.std.grammar.json b/source/extinst.opencl.std.grammar.json
new file mode 100644 (file)
index 0000000..1145a47
--- /dev/null
@@ -0,0 +1,1277 @@
+{
+  "copyright" : [
+    "Copyright (c) 2014-2016 The Khronos Group Inc.",
+    "",
+    "Permission is hereby granted, free of charge, to any person obtaining a copy",
+    "of this software and/or associated documentation files (the \"Materials\"),",
+    "to deal in the Materials without restriction, including without limitation",
+    "the rights to use, copy, modify, merge, publish, distribute, sublicense,",
+    "and/or sell copies of the Materials, and to permit persons to whom the",
+    "Materials are furnished to do so, subject to the following conditions:",
+    "",
+    "The above copyright notice and this permission notice shall be included in",
+    "all copies or substantial portions of the Materials.",
+    "",
+    "MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS",
+    "STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND",
+    "HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ ",
+    "",
+    "THE MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS",
+    "OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
+    "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL",
+    "THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
+    "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING",
+    "FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS",
+    "IN THE MATERIALS."
+  ],
+  "instructions" : [
+    {
+      "opname" : "acos",
+      "opcode" : 0,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "acosh",
+      "opcode" : 1,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "acospi",
+      "opcode" : 2,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "asin",
+      "opcode" : 3,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "asinh",
+      "opcode" : 4,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "asinpi",
+      "opcode" : 5,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "atan",
+      "opcode" : 6,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "atan2",
+      "opcode" : 7,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "atanh",
+      "opcode" : 8,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "atanpi",
+      "opcode" : 9,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "atan2pi",
+      "opcode" : 10,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "cbrt",
+      "opcode" : 11,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "ceil",
+      "opcode" : 12,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "copysign",
+      "opcode" : 13,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "cos",
+      "opcode" : 14,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "cosh",
+      "opcode" : 15,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "cospi",
+      "opcode" : 16,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "erfc",
+      "opcode" : 17,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "erf",
+      "opcode" : 18,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "exp",
+      "opcode" : 19,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "exp2",
+      "opcode" : 20,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "exp10",
+      "opcode" : 21,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "expm1",
+      "opcode" : 22,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "fabs",
+      "opcode" : 23,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "fdim",
+      "opcode" : 24,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "floor",
+      "opcode" : 25,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "fma",
+      "opcode" : 26,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "fmax",
+      "opcode" : 27,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "fmin",
+      "opcode" : 28,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "fmod",
+      "opcode" : 29,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "fract",
+      "opcode" : 30,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "frexp",
+      "opcode" : 31,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "hypot",
+      "opcode" : 32,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "ilogb",
+      "opcode" : 33,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "ldexp",
+      "opcode" : 34,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "lgamma",
+      "opcode" : 35,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "lgamma_r",
+      "opcode" : 36,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "log",
+      "opcode" : 37,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "log2",
+      "opcode" : 38,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "log10",
+      "opcode" : 39,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "log1p",
+      "opcode" : 40,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "logb",
+      "opcode" : 41,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "mad",
+      "opcode" : 42,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "maxmag",
+      "opcode" : 43,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "minmag",
+      "opcode" : 44,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "modf",
+      "opcode" : 45,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "nan",
+      "opcode" : 46,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "nextafter",
+      "opcode" : 47,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "pow",
+      "opcode" : 48,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "pown",
+      "opcode" : 49,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "powr",
+      "opcode" : 50,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "remainder",
+      "opcode" : 51,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "remquo",
+      "opcode" : 52,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "rint",
+      "opcode" : 53,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "rootn",
+      "opcode" : 54,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "round",
+      "opcode" : 55,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "rsqrt",
+      "opcode" : 56,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "sin",
+      "opcode" : 57,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "sincos",
+      "opcode" : 58,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "sinh",
+      "opcode" : 59,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "sinpi",
+      "opcode" : 60,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "sqrt",
+      "opcode" : 61,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "tan",
+      "opcode" : 62,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "tanh",
+      "opcode" : 63,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "tanpi",
+      "opcode" : 64,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "tgamma",
+      "opcode" : 65,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "trunc",
+      "opcode" : 66,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_cos",
+      "opcode" : 67,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_divide",
+      "opcode" : 68,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_exp",
+      "opcode" : 69,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_exp2",
+      "opcode" : 70,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_exp10",
+      "opcode" : 71,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_log",
+      "opcode" : 72,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_log2",
+      "opcode" : 73,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_log10",
+      "opcode" : 74,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_powr",
+      "opcode" : 75,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_recip",
+      "opcode" : 76,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_rsqrt",
+      "opcode" : 77,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_sin",
+      "opcode" : 78,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_sqrt",
+      "opcode" : 79,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "half_tan",
+      "opcode" : 80,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_cos",
+      "opcode" : 81,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_divide",
+      "opcode" : 82,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_exp",
+      "opcode" : 83,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_exp2",
+      "opcode" : 84,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_exp10",
+      "opcode" : 85,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_log",
+      "opcode" : 86,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_log2",
+      "opcode" : 87,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_log10",
+      "opcode" : 88,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_powr",
+      "opcode" : 89,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_recip",
+      "opcode" : 90,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_rsqrt",
+      "opcode" : 91,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_sin",
+      "opcode" : 92,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_sqrt",
+      "opcode" : 93,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "native_tan",
+      "opcode" : 94,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "fclamp",
+      "opcode" : 95,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "degrees",
+      "opcode" : 96,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "fmax_common",
+      "opcode" : 97,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "fmin_common",
+      "opcode" : 98,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "mix",
+      "opcode" : 99,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "radians",
+      "opcode" : 100,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "step",
+      "opcode" : 101,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "smoothstep",
+      "opcode" : 102,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "sign",
+      "opcode" : 103,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "cross",
+      "opcode" : 104,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "distance",
+      "opcode" : 105,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "length",
+      "opcode" : 106,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "normalize",
+      "opcode" : 107,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "fast_distance",
+      "opcode" : 108,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "fast_length",
+      "opcode" : 109,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "fast_normalize",
+      "opcode" : 110,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_abs",
+      "opcode" : 141,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_abs_diff",
+      "opcode" : 142,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_add_sat",
+      "opcode" : 143,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_add_sat",
+      "opcode" : 144,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_hadd",
+      "opcode" : 145,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_hadd",
+      "opcode" : 146,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_rhadd",
+      "opcode" : 147,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_rhadd",
+      "opcode" : 148,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_clamp",
+      "opcode" : 149,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_clamp",
+      "opcode" : 150,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "clz",
+      "opcode" : 151,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "ctz",
+      "opcode" : 152,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_mad_hi",
+      "opcode" : 153,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_mad_sat",
+      "opcode" : 154,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_mad_sat",
+      "opcode" : 155,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_max",
+      "opcode" : 156,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_max",
+      "opcode" : 157,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_min",
+      "opcode" : 158,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_min",
+      "opcode" : 159,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_mul_hi",
+      "opcode" : 160,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "rotate",
+      "opcode" : 161,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_sub_sat",
+      "opcode" : 162,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_sub_sat",
+      "opcode" : 163,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_upsample",
+      "opcode" : 164,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_upsample",
+      "opcode" : 165,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "popcount",
+      "opcode" : 166,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_mad24",
+      "opcode" : 167,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_mad24",
+      "opcode" : 168,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "s_mul24",
+      "opcode" : 169,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_mul24",
+      "opcode" : 170,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "vloadn",
+      "opcode" : 171,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "LiteralInteger" }
+      ]
+    },
+    {
+      "opname" : "vstoren",
+      "opcode" : 172,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "vload_half",
+      "opcode" : 173,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "vload_halfn",
+      "opcode" : 174,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "LiteralInteger" }
+      ]
+    },
+    {
+      "opname" : "vstore_half",
+      "opcode" : 175,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "vstore_half_r",
+      "opcode" : 176,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "FPRoundingMode" }
+      ]
+    },
+    {
+      "opname" : "vstore_halfn",
+      "opcode" : 177,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "vstore_halfn_r",
+      "opcode" : 178,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "FPRoundingMode" }
+      ]
+    },
+    {
+      "opname" : "vloada_halfn",
+      "opcode" : 179,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "LiteralInteger" }
+      ]
+    },
+    {
+      "opname" : "vstorea_halfn",
+      "opcode" : 180,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "vstorea_halfn_r",
+      "opcode" : 181,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "FPRoundingMode" }
+      ]
+    },
+    {
+      "opname" : "shuffle",
+      "opcode" : 182,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "shuffle2",
+      "opcode" : 183,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "printf",
+      "opcode" : 184,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef", "quantifier" : "*" }
+      ]
+    },
+    {
+      "opname" : "prefetch",
+      "opcode" : 185,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "bitselect",
+      "opcode" : 186,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "select",
+      "opcode" : 187,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_abs",
+      "opcode" : 201,
+      "operands" : [
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_abs_diff",
+      "opcode" : 202,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_mul_hi",
+      "opcode" : 203,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    },
+    {
+      "opname" : "u_mad_hi",
+      "opcode" : 204,
+      "operands" : [
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" },
+        { "kind" : "IdRef" }
+      ]
+    }
+  ]
+}
index 6560a5a..518da26 100644 (file)
@@ -48,7 +48,7 @@ namespace {
 // TODO(dneto): Some of the macros are quite unreadable.  We could make
 // good use of constexpr functions, but some compilers don't support that yet.
 const spv_opcode_desc_t opcodeTableEntries[] = {
-#include "opcode.inc"
+#include "core.insts.inc"
 };
 
 }  // anonymous namespace
diff --git a/source/opencl_std_ext_inst.inc b/source/opencl_std_ext_inst.inc
deleted file mode 100644 (file)
index c9ad7a4..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-
-// OpenCL extended instructions table, one instruction per line.
-// All instructions have a result type and a result ID.
-// Fields in this file are:
-//  - name
-//  - extended instruction index
-//  - EmptyList, or List of operand classes.
-ExtInst(acos, 0, List(OperandId))
-ExtInst(acosh, 1, List(OperandId))
-ExtInst(acospi, 2, List(OperandId))
-ExtInst(asin, 3, List(OperandId))
-ExtInst(asinh, 4, List(OperandId))
-ExtInst(asinpi, 5, List(OperandId))
-ExtInst(atan, 6, List(OperandId))
-ExtInst(atan2, 7, List(OperandId, OperandId))
-ExtInst(atanh, 8, List(OperandId))
-ExtInst(atanpi, 9, List(OperandId))
-ExtInst(atan2pi, 10, List(OperandId, OperandId))
-ExtInst(cbrt, 11, List(OperandId))
-ExtInst(ceil, 12, List(OperandId))
-ExtInst(copysign, 13, List(OperandId, OperandId))
-ExtInst(cos, 14, List(OperandId))
-ExtInst(cosh, 15, List(OperandId))
-ExtInst(cospi, 16, List(OperandId))
-ExtInst(erfc, 17, List(OperandId))
-ExtInst(erf, 18, List(OperandId))
-ExtInst(exp, 19, List(OperandId))
-ExtInst(exp2, 20, List(OperandId))
-ExtInst(exp10, 21, List(OperandId))
-ExtInst(expm1, 22, List(OperandId))
-ExtInst(fabs, 23, List(OperandId))
-ExtInst(fdim, 24, List(OperandId, OperandId))
-ExtInst(floor, 25, List(OperandId))
-ExtInst(fma, 26, List(OperandId, OperandId, OperandId))
-ExtInst(fmax, 27, List(OperandId, OperandId))
-ExtInst(fmin, 28, List(OperandId, OperandId))
-ExtInst(fmod, 29, List(OperandId, OperandId))
-ExtInst(fract, 30, List(OperandId, OperandId))
-ExtInst(frexp, 31, List(OperandId, OperandId))
-ExtInst(hypot, 32, List(OperandId, OperandId))
-ExtInst(ilogb, 33, List(OperandId))
-ExtInst(ldexp, 34, List(OperandId, OperandId))
-ExtInst(lgamma, 35, List(OperandId))
-ExtInst(lgamma_r, 36, List(OperandId, OperandId))
-ExtInst(log, 37, List(OperandId))
-ExtInst(log2, 38, List(OperandId))
-ExtInst(log10, 39, List(OperandId))
-ExtInst(log1p, 40, List(OperandId))
-ExtInst(logb, 41, List(OperandId))
-ExtInst(mad, 42, List(OperandId, OperandId, OperandId))
-ExtInst(maxmag, 43, List(OperandId, OperandId))
-ExtInst(minmag, 44, List(OperandId, OperandId))
-ExtInst(modf, 45, List(OperandId, OperandId))
-ExtInst(nan, 46, List(OperandId))
-ExtInst(nextafter, 47, List(OperandId, OperandId))
-ExtInst(pow, 48, List(OperandId, OperandId, OperandId))
-ExtInst(pown, 49, List(OperandId))
-ExtInst(powr, 50, List(OperandId, OperandId))
-ExtInst(remainder, 51, List(OperandId, OperandId))
-ExtInst(remquo, 52, List(OperandId, OperandId, OperandId))
-ExtInst(rint, 53, List(OperandId))
-ExtInst(rootn, 54, List(OperandId, OperandId))
-ExtInst(round, 55, List(OperandId))
-ExtInst(rsqrt, 56, List(OperandId))
-ExtInst(sin, 57, List(OperandId))
-ExtInst(sincos, 58, List(OperandId, OperandId))
-ExtInst(sinh, 59, List(OperandId))
-ExtInst(sinpi, 60, List(OperandId))
-ExtInst(sqrt, 61, List(OperandId))
-ExtInst(tan, 62, List(OperandId))
-ExtInst(tanh, 63, List(OperandId))
-ExtInst(tanpi, 64, List(OperandId))
-ExtInst(tgamma, 65, List(OperandId))
-ExtInst(trunc, 66, List(OperandId))
-ExtInst(half_cos, 67, List(OperandId))
-ExtInst(half_divide, 68, List(OperandId, OperandId))
-ExtInst(half_exp, 69, List(OperandId))
-ExtInst(half_exp2, 70, List(OperandId))
-ExtInst(half_exp10, 71, List(OperandId))
-ExtInst(half_log, 72, List(OperandId))
-ExtInst(half_log2, 73, List(OperandId))
-ExtInst(half_log10, 74, List(OperandId))
-ExtInst(half_powr, 75, List(OperandId, OperandId))
-ExtInst(half_recip, 76, List(OperandId))
-ExtInst(half_rsqrt, 77, List(OperandId))
-ExtInst(half_sin, 78, List(OperandId))
-ExtInst(half_sqrt, 79, List(OperandId))
-ExtInst(half_tan, 80, List(OperandId))
-ExtInst(native_cos, 81, List(OperandId))
-ExtInst(native_divide, 82, List(OperandId, OperandId))
-ExtInst(native_exp, 83, List(OperandId))
-ExtInst(native_exp2, 84, List(OperandId))
-ExtInst(native_exp10, 85, List(OperandId))
-ExtInst(native_log, 86, List(OperandId))
-ExtInst(native_log2, 87, List(OperandId))
-ExtInst(native_log10, 88, List(OperandId))
-ExtInst(native_powr, 89, List(OperandId, OperandId))
-ExtInst(native_recip, 90, List(OperandId))
-ExtInst(native_rsqrt, 91, List(OperandId))
-ExtInst(native_sin, 92, List(OperandId))
-ExtInst(native_sqrt, 93, List(OperandId))
-ExtInst(native_tan, 94, List(OperandId))
-ExtInst(fclamp, 95, List(OperandId, OperandId, OperandId))
-ExtInst(degrees, 96, List(OperandId))
-ExtInst(fmax_common, 97, List(OperandId, OperandId))
-ExtInst(fmin_common, 98, List(OperandId, OperandId))
-ExtInst(mix, 99, List(OperandId, OperandId, OperandId))
-ExtInst(radians, 100, List(OperandId))
-ExtInst(step, 101, List(OperandId, OperandId))
-ExtInst(smoothstep, 102, List(OperandId, OperandId, OperandId))
-ExtInst(sign, 103, List(OperandId))
-ExtInst(cross, 104, List(OperandId, OperandId))
-ExtInst(distance, 105, List(OperandId, OperandId))
-ExtInst(length, 106, List(OperandId))
-ExtInst(normalize, 107, List(OperandId))
-ExtInst(fast_distance, 108, List(OperandId, OperandId))
-ExtInst(fast_length, 109, List(OperandId))
-ExtInst(fast_normalize, 110, List(OperandId))
-ExtInst(s_abs, 141, List(OperandId))
-ExtInst(s_abs_diff, 142, List(OperandId, OperandId))
-ExtInst(s_add_sat, 143, List(OperandId, OperandId))
-ExtInst(u_add_sat, 144, List(OperandId, OperandId))
-ExtInst(s_hadd, 145, List(OperandId, OperandId))
-ExtInst(u_hadd, 146, List(OperandId, OperandId))
-ExtInst(s_rhadd, 147, List(OperandId, OperandId))
-ExtInst(u_rhadd, 148, List(OperandId, OperandId))
-ExtInst(s_clamp, 149, List(OperandId, OperandId, OperandId))
-ExtInst(u_clamp, 150, List(OperandId, OperandId, OperandId))
-ExtInst(clz, 151, List(OperandId))
-ExtInst(ctz, 152, List(OperandId))
-ExtInst(s_mad_hi, 153, List(OperandId, OperandId, OperandId))
-ExtInst(u_mad_sat, 154, List(OperandId, OperandId, OperandId))
-ExtInst(s_mad_sat, 155, List(OperandId, OperandId, OperandId))
-ExtInst(s_max, 156, List(OperandId, OperandId))
-ExtInst(u_max, 157, List(OperandId, OperandId))
-ExtInst(s_min, 158, List(OperandId, OperandId))
-ExtInst(u_min, 159, List(OperandId, OperandId))
-ExtInst(s_mul_hi, 160, List(OperandId, OperandId))
-ExtInst(rotate, 161, List(OperandId, OperandId))
-ExtInst(s_sub_sat, 162, List(OperandId, OperandId))
-ExtInst(u_sub_sat, 163, List(OperandId, OperandId))
-ExtInst(u_upsample, 164, List(OperandId, OperandId))
-ExtInst(s_upsample, 165, List(OperandId, OperandId))
-ExtInst(popcount, 166, List(OperandId))
-ExtInst(s_mad24, 167, List(OperandId, OperandId, OperandId))
-ExtInst(u_mad24, 168, List(OperandId, OperandId, OperandId))
-ExtInst(s_mul24, 169, List(OperandId, OperandId))
-ExtInst(u_mul24, 170, List(OperandId, OperandId))
-ExtInst(vloadn, 171, List(OperandId, OperandId, OperandLiteralNumber))
-ExtInst(vstoren, 172, List(OperandId, OperandId, OperandId))
-ExtInst(vload_half, 173, List(OperandId, OperandId))
-ExtInst(vload_halfn, 174, List(OperandId, OperandId, OperandLiteralNumber))
-ExtInst(vstore_half, 175, List(OperandId, OperandId, OperandId))
-ExtInst(vstore_half_r, 176, List(OperandId, OperandId, OperandId, OperandFPRoundingMode))
-ExtInst(vstore_halfn, 177, List(OperandId, OperandId, OperandId))
-ExtInst(vstore_halfn_r, 178, List(OperandId, OperandId, OperandId, OperandFPRoundingMode))
-ExtInst(vloada_halfn, 179, List(OperandId, OperandId, OperandLiteralNumber))
-ExtInst(vstorea_halfn, 180, List(OperandId, OperandId, OperandId))
-ExtInst(vstorea_halfn_r, 181, List(OperandId, OperandId, OperandId, OperandFPRoundingMode))
-ExtInst(shuffle, 182, List(OperandId, OperandId))
-ExtInst(shuffle2, 183, List(OperandId, OperandId, OperandId))
-ExtInst(printf, 184, List(OperandId, OperandVariableIds))
-ExtInst(prefetch, 185, List(OperandId, OperandId))
-ExtInst(bitselect, 186, List(OperandId, OperandId, OperandId))
-ExtInst(select, 187, List(OperandId, OperandId, OperandId))
-ExtInst(u_abs, 201, List(OperandId))
-ExtInst(u_abs_diff, 202, List(OperandId, OperandId))
-ExtInst(u_mul_hi, 203, List(OperandId, OperandId))
-ExtInst(u_mad_hi, 204, List(OperandId, OperandId, OperandId))
index d1cf830..5de3f43 100644 (file)
@@ -36,7 +36,7 @@
 #define ARRAY_SIZE(A) (static_cast<uint32_t>(sizeof(A) / sizeof(A[0])))
 
 // Pull in operand info tables automatically generated from JSON grammar.
-#include "operand.inc"
+#include "operand.kinds.inc"
 
 spv_result_t spvOperandTableGet(spv_operand_table* pOperandTable) {
   if (!pOperandTable) return SPV_ERROR_INVALID_POINTER;
index 4b720ce..aff5129 100755 (executable)
@@ -102,7 +102,8 @@ def convert_operand_kind(operand_tuple):
 
 
 class InstInitializer(object):
-    """Prints a SPIR-V instruction as the initializer for spv_opcode_desc_t."""
+    """Instances holds a SPIR-V instruction suitable for printing as
+    the initializer for spv_opcode_desc_t."""
 
     def __init__(self, opname, caps, operands):
         """Initialization.
@@ -134,32 +135,71 @@ class InstInitializer(object):
             ref_type_id=(1 if self.ref_type_id else 0))
 
 
-def generate_instruction(inst):
+class ExtInstInitializer(object):
+    """Instances holds a SPIR-V extended instruction suitable for printing as
+    the initializer for spv_ext_inst_desc_t."""
+
+    def __init__(self, opname, opcode, caps, operands):
+        """Initialization.
+
+        Arguments:
+          - opname: opcode name
+          - opcode: enumerant value for this opcode
+          - caps: a sequence of capability names required by this opcode
+          - operands: a sequence of (operand-kind, operand-quantifier) tuples
+        """
+        self.opname = opname
+        self.opcode = opcode
+        self.caps_mask = compose_capability_mask(caps)
+        self.operands = [convert_operand_kind(o) for o in operands]
+        self.operands.append('SPV_OPERAND_TYPE_NONE')
+
+    def __str__(self):
+        template = ['{{"{opname}"', '{opcode}', '{caps_mask}',
+                    '{{{operands}}}}}']
+        return ', '.join(template).format(
+            opname=self.opname,
+            opcode=self.opcode,
+            caps_mask=self.caps_mask,
+            operands=', '.join(self.operands))
+
+
+def generate_instruction(inst, is_ext_inst):
     """Returns the C initializer for the given SPIR-V instruction.
 
     Arguments:
       - inst: a dict containing information about a SPIR-V instruction
+      - is_ext_inst: a bool indicating whether |inst| is an extended
+                     instruction.
 
     Returns:
-      a string containing the C initializer for spv_opcode_desc_t
+      a string containing the C initializer for spv_opcode_desc_t or
+      spv_ext_inst_desc_t
     """
     opname = inst.get('opname')
+    opcode = inst.get('opcode')
     caps = inst.get('capabilities', [])
     operands = inst.get('operands', {})
     operands = [(o['kind'], o.get('quantifier', '')) for o in operands]
 
     assert opname is not None
 
-    return str(InstInitializer(opname, caps, operands))
+    if is_ext_inst:
+        return str(ExtInstInitializer(opname, opcode, caps, operands))
+    else:
+        return str(InstInitializer(opname, caps, operands))
 
 
-def generate_instruction_table(inst_table):
+def generate_instruction_table(inst_table, is_ext_inst):
     """Returns the info table containing all SPIR-V instructions.
 
     Arguments:
       - inst_table: a dict containing all SPIR-V instructions.
+      - is_ext_inst: a bool indicating whether |inst_table| is for
+                     an extended instruction set.
     """
-    return ',\n'.join([generate_instruction(inst) for inst in inst_table])
+    return ',\n'.join([generate_instruction(inst, is_ext_inst)
+                       for inst in inst_table])
 
 
 class EnumerantInitializer(object):
@@ -264,17 +304,33 @@ def generate_operand_kind_table(enums):
 def main():
     import argparse
     parser = argparse.ArgumentParser(description='Generate SPIR-V info tables')
-    parser.add_argument('grammar', metavar='<json-grammar-path>', type=str,
-                        help='input JSON file path for SPIR-V grammar')
-    parser.add_argument('--opcode-file', dest='opcode', metavar='<path>',
+    parser.add_argument('--spirv-core-grammar', metavar='<path>',
+                        type=str, required=True,
+                        help='input JSON grammar file for core SPIR-V '
+                        'instructions')
+    parser.add_argument('--extinst-glsl-grammar', metavar='<path>',
+                        type=str, required=True,
+                        help='input JSON grammar file for GLSL extended '
+                        'instruction set')
+    parser.add_argument('--extinst-opencl-grammar', metavar='<path>',
+                        type=str, required=True,
+                        help='input JSON grammar file for OpenGL extended '
+                        'instruction set')
+    parser.add_argument('--core-insts-output', metavar='<path>',
+                        type=str, required=True,
+                        help='output file for core SPIR-V instructions')
+    parser.add_argument('--glsl-insts-output', metavar='<path>',
                         type=str, required=True,
-                        help='output file path for SPIR-V instructions')
-    parser.add_argument('--operand-file', dest='operand', metavar='<path>',
+                        help='output file for GLSL extended instruction set')
+    parser.add_argument('--opencl-insts-output', metavar='<path>',
                         type=str, required=True,
-                        help='output file path for SPIR-V operands')
+                        help='output file for OpenCL extended instruction set')
+    parser.add_argument('--operand-kinds-output', metavar='<path>',
+                        type=str, required=True,
+                        help='output file for operand kinds')
     args = parser.parse_args()
 
-    with open(args.grammar) as json_file:
+    with open(args.spirv_core_grammar) as json_file:
         grammar = json.loads(json_file.read())
 
         # Get the dict for the Capability operand kind.
@@ -283,10 +339,21 @@ def main():
         assert len(cap_dict) == 1
         populate_capability_bit_mapping_dict(cap_dict[0])
 
-        print(generate_instruction_table(grammar['instructions']),
-              file=open(args.opcode, 'w'))
+        print(generate_instruction_table(grammar['instructions'], False),
+              file=open(args.core_insts_output, 'w'))
         print(generate_operand_kind_table(grammar['operand_kinds']),
-              file=open(args.operand, 'w'))
+              file=open(args.operand_kinds_output, 'w'))
+
+    with open(args.extinst_glsl_grammar) as json_file:
+        grammar = json.loads(json_file.read())
+        print(generate_instruction_table(grammar['instructions'], True),
+              file=open(args.glsl_insts_output, 'w'))
+
+    with open(args.extinst_opencl_grammar) as json_file:
+        grammar = json.loads(json_file.read())
+        print(generate_instruction_table(grammar['instructions'], True),
+              file=open(args.opencl_insts_output, 'w'))
+
 
 if __name__ == '__main__':
     main()