Skip to content

Commit 506fee4

Browse files
authored
generate_grammar_tables.py: remove unused option to emit C enums (#6094)
* generate_grammar_tables.py: remove unused option to emit C enums Remove the ability to emit C declarations for core instruction and operand tables. Non-functional change * Update build_defs.bzl
1 parent 898ed77 commit 506fee4

5 files changed

Lines changed: 13 additions & 50 deletions

File tree

Android.mk

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ $(1)/opencl.std.insts.inc \
228228
--core-insts-output=$(1)/core.insts-unified1.inc \
229229
--glsl-insts-output=$(1)/glsl.std.450.insts.inc \
230230
--opencl-insts-output=$(1)/opencl.std.insts.inc \
231-
--operand-kinds-output=$(1)/operand.kinds-unified1.inc \
232-
--output-language=c++
231+
--operand-kinds-output=$(1)/operand.kinds-unified1.inc
233232
@echo "[$(TARGET_ARCH_ABI)] Grammar (from unified1) : instructions & operands <= grammar JSON files"
234233
$(LOCAL_PATH)/source/opcode.cpp: $(1)/core.insts-unified1.inc
235234
$(LOCAL_PATH)/source/operand.cpp: $(1)/operand.kinds-unified1.inc
@@ -304,8 +303,7 @@ $(1)/extension_enum.inc $(1)/enum_string_mapping.inc: \
304303
--extinst-debuginfo-grammar=$(SPV_DEBUGINFO_GRAMMAR) \
305304
--extinst-cldebuginfo100-grammar=$(SPV_CLDEBUGINFO100_GRAMMAR) \
306305
--extension-enum-output=$(1)/extension_enum.inc \
307-
--enum-string-mapping-output=$(1)/enum_string_mapping.inc \
308-
--output-language=c++
306+
--enum-string-mapping-output=$(1)/enum_string_mapping.inc
309307
@echo "[$(TARGET_ARCH_ABI)] Generate enum<->string mapping <= grammar JSON files"
310308
# Generated header extension_enum.inc is transitively included by table.h, which is
311309
# used pervasively. Capture the pervasive dependency.

BUILD.gn

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ template("spvtools_core_tables") {
6868
"--extinst-cldebuginfo100-grammar",
6969
rebase_path(cldebuginfo100_insts_file, root_build_dir),
7070
"--operand-kinds-output",
71-
rebase_path(operand_kinds_file, root_build_dir),
72-
"--output-language",
73-
"c++"
71+
rebase_path(operand_kinds_file, root_build_dir)
7472
]
7573
}
7674
}
@@ -102,9 +100,7 @@ template("spvtools_core_enums") {
102100
"--extension-enum-output",
103101
rebase_path(extension_enum_file, root_build_dir),
104102
"--enum-string-mapping-output",
105-
rebase_path(extension_map_file, root_build_dir),
106-
"--output-language",
107-
"c++"
103+
rebase_path(extension_map_file, root_build_dir)
108104
]
109105
inputs = [
110106
core_json_file,
@@ -145,9 +141,7 @@ template("spvtools_glsl_tables") {
145141
"--extinst-glsl-grammar",
146142
rebase_path(glsl_json_file, root_build_dir),
147143
"--glsl-insts-output",
148-
rebase_path(glsl_insts_file, root_build_dir),
149-
"--output-language",
150-
"c++"
144+
rebase_path(glsl_insts_file, root_build_dir)
151145
]
152146
inputs = [
153147
core_json_file,

build_defs.bzl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ def generate_core_tables(version):
7878
" --extinst-debuginfo-grammar=$(location {debuginfo_grammar})" +
7979
" --extinst-cldebuginfo100-grammar=$(location {cldebuginfo_grammar})" +
8080
" --core-insts-output=$(location {core_insts_output})" +
81-
" --operand-kinds-output=$(location {operand_kinds_output})" +
82-
" --output-language=c++"
81+
" --operand-kinds-output=$(location {operand_kinds_output})"
8382
).format(**_merge_dicts([grammars, outs]))
8483

8584
native.genrule(
@@ -113,8 +112,7 @@ def generate_enum_string_mapping(version):
113112
" --extinst-debuginfo-grammar=$(location {debuginfo_grammar})" +
114113
" --extinst-cldebuginfo100-grammar=$(location {cldebuginfo_grammar})" +
115114
" --extension-enum-output=$(location {extension_enum_ouput})" +
116-
" --enum-string-mapping-output=$(location {enum_string_mapping_output})" +
117-
" --output-language=c++"
115+
" --enum-string-mapping-output=$(location {enum_string_mapping_output})"
118116
).format(**_merge_dicts([grammars, outs]))
119117

120118
native.genrule(
@@ -169,8 +167,7 @@ def generate_glsl_tables(version):
169167
cmd = (
170168
"$(location :generate_grammar_tables)" +
171169
" --extinst-glsl-grammar=$(location {gsls_grammar})" +
172-
" --glsl-insts-output=$(location {gsls_insts_outs})" +
173-
" --output-language=c++"
170+
" --glsl-insts-output=$(location {gsls_insts_outs})"
174171
).format(**_merge_dicts([grammars, outs]))
175172

176173
native.genrule(

source/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ macro(spvtools_core_tables CONFIG_VERSION)
3737
--extinst-cldebuginfo100-grammar=${CLDEBUGINFO100_GRAMMAR_JSON_FILE}
3838
--core-insts-output=${GRAMMAR_INSTS_INC_FILE}
3939
--operand-kinds-output=${GRAMMAR_KINDS_INC_FILE}
40-
--output-language=c++
4140
DEPENDS ${GRAMMAR_PROCESSING_SCRIPT}
4241
${GRAMMAR_JSON_FILE}
4342
${DEBUGINFO_GRAMMAR_JSON_FILE}
@@ -59,7 +58,6 @@ macro(spvtools_enum_string_mapping CONFIG_VERSION)
5958
--extinst-cldebuginfo100-grammar=${CLDEBUGINFO100_GRAMMAR_JSON_FILE}
6059
--extension-enum-output=${GRAMMAR_EXTENSION_ENUM_INC_FILE}
6160
--enum-string-mapping-output=${GRAMMAR_ENUM_STRING_MAPPING_INC_FILE}
62-
--output-language=c++
6361
DEPENDS ${GRAMMAR_PROCESSING_SCRIPT}
6462
${GRAMMAR_JSON_FILE}
6563
${DEBUGINFO_GRAMMAR_JSON_FILE}
@@ -94,7 +92,6 @@ macro(spvtools_glsl_tables CONFIG_VERSION)
9492
COMMAND Python3::Interpreter ${GRAMMAR_PROCESSING_SCRIPT}
9593
--extinst-glsl-grammar=${GLSL_GRAMMAR_JSON_FILE}
9694
--glsl-insts-output=${GRAMMAR_INC_FILE}
97-
--output-language=c++
9895
DEPENDS ${GRAMMAR_PROCESSING_SCRIPT} ${CORE_GRAMMAR_JSON_FILE} ${GLSL_GRAMMAR_JSON_FILE}
9996
COMMENT "Generate info tables for GLSL extended instructions and operands v${CONFIG_VERSION}.")
10097
list(APPEND EXTINST_CPP_DEPENDS ${GRAMMAR_INC_FILE})

utils/generate_grammar_tables.py

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
SPV_EXT_relaxed_printf_string_address_space
3535
"""
3636

37-
OUTPUT_LANGUAGE = 'c'
38-
3937
def make_path_to_file(f):
4038
"""Makes all ancestor directories to the given file, if they don't yet
4139
exist.
@@ -113,10 +111,7 @@ def compose_capability_list(caps):
113111
Returns:
114112
a string containing the braced list of SpvCapability* or spv::Capability:: enums named by caps.
115113
"""
116-
base_string = 'SpvCapability'
117-
global OUTPUT_LANGUAGE
118-
if OUTPUT_LANGUAGE == 'c++':
119-
base_string = 'spv::Capability::'
114+
base_string = 'spv::Capability::'
120115

121116
return '{' + ', '.join([(base_string + '{}').format(c) for c in caps]) + '}'
122117

@@ -139,10 +134,7 @@ def generate_capability_arrays(caps):
139134
- caps: a sequence of sequence of capability names
140135
"""
141136
caps = sorted(set([tuple(c) for c in caps if c]))
142-
cap_str = 'SpvCapability'
143-
global OUTPUT_LANGUAGE
144-
if OUTPUT_LANGUAGE == 'c++':
145-
cap_str = 'spv::Capability'
137+
cap_str = 'spv::Capability'
146138
arrays = [
147139
'static const ' + cap_str + ' {}[] = {};'.format(
148140
get_capability_array_name(c), compose_capability_list(c))
@@ -302,11 +294,7 @@ def fix_syntax(self):
302294
self.operands.pop()
303295

304296
def __str__(self):
305-
global OUTPUT_LANGUAGE
306-
base_str = 'SpvOp'
307-
if OUTPUT_LANGUAGE == 'c++':
308-
base_str = 'spv::Op::Op'
309-
297+
base_str = 'spv::Op::Op'
310298
template = ['{{"{opname}"', base_str + '{opname}',
311299
'{num_aliases}', '{aliases_mask}',
312300
'{num_caps}', '{caps_mask}',
@@ -709,12 +697,8 @@ def generate_capability_to_string_mapping(operand_kinds):
709697
710698
We take care to avoid emitting duplicate values.
711699
"""
712-
cap_str = 'SpvCapability'
713-
cap_join = ''
714-
global OUTPUT_LANGUAGE
715-
if OUTPUT_LANGUAGE == 'c++':
716-
cap_str = 'spv::Capability'
717-
cap_join = '::'
700+
cap_str = 'spv::Capability'
701+
cap_join = '::'
718702

719703
function = 'const char* CapabilityToString(' + cap_str + ' capability) {\n'
720704
function += ' switch (capability) {\n'
@@ -816,10 +800,6 @@ def main():
816800
type=str, required=False, default=None,
817801
help='input JSON grammar file for OpenCL extended '
818802
'instruction set')
819-
parser.add_argument('--output-language',
820-
type=str, required=False, default='c',
821-
choices=['c','c++'],
822-
help='specify output language type')
823803

824804
parser.add_argument('--core-insts-output', metavar='<path>',
825805
type=str, required=False, default=None,
@@ -851,9 +831,6 @@ def main():
851831
help='prefix for operand kinds (to disambiguate operand type enums)')
852832
args = parser.parse_args()
853833

854-
global OUTPUT_LANGUAGE
855-
OUTPUT_LANGUAGE = args.output_language
856-
857834
# The GN build system needs this because it doesn't handle quoting
858835
# empty string arguments well.
859836
if args.vendor_operand_kind_prefix == "...nil...":

0 commit comments

Comments
 (0)