diff options
| author | Lei Zhang <antiagainst@google.com> | 2019-06-10 15:12:04 -0700 |
|---|---|---|
| committer | Mehdi Amini <joker.eph@gmail.com> | 2019-06-11 10:13:20 -0700 |
| commit | eb3ed07cd1af4606d74cf0294fa7972ae828c0dd (patch) | |
| tree | dcde8690bd736caff2ee3fc6791658d98c25ec4f /mlir/utils | |
| parent | 5392d3badfa95da86915d6b2e3100c1fe6ffe009 (diff) | |
| download | bcm5719-llvm-eb3ed07cd1af4606d74cf0294fa7972ae828c0dd.tar.gz bcm5719-llvm-eb3ed07cd1af4606d74cf0294fa7972ae828c0dd.zip | |
[spirv] Add values for enum cases and generate the enum utilities
PiperOrigin-RevId: 252494957
Diffstat (limited to 'mlir/utils')
| -rwxr-xr-x | mlir/utils/spirv/gen_spirv_dialect.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/mlir/utils/spirv/gen_spirv_dialect.py b/mlir/utils/spirv/gen_spirv_dialect.py index 1ad93123f84..f815ae37397 100755 --- a/mlir/utils/spirv/gen_spirv_dialect.py +++ b/mlir/utils/spirv/gen_spirv_dialect.py @@ -96,10 +96,15 @@ def gen_operand_kind_enum_attr(operand_kind): # Generate the definition for each enum case fmt_str = 'def SPV_{acronym}_{symbol} {colon:>{offset}} '\ - 'EnumAttrCase<"{symbol}">;' - case_defs = [fmt_str.format(acronym=kind_acronym, symbol=case[0], - colon=':', offset=(max_len + 1 - len(case[0]))) - for case in kind_cases] + 'EnumAttrCase<"{symbol}", {value}>;' + case_defs = [ + fmt_str.format( + acronym=kind_acronym, + symbol=case[0], + value=case[1], + colon=':', + offset=(max_len + 1 - len(case[0]))) for case in kind_cases + ] case_defs = '\n'.join(case_defs) # Generate the list of enum case names @@ -115,7 +120,9 @@ def gen_operand_kind_enum_attr(operand_kind): # Generate the enum attribute definition enum_attr = 'def SPV_{name}Attr :\n '\ - 'EnumAttr<"{name}", "valid SPIR-V {name}", [\n{cases}\n ]>;'.format( + 'EnumAttr<"{name}", "valid SPIR-V {name}", [\n{cases}\n ]> {{\n'\ + ' let cppNamespace = "::mlir::spirv";\n'\ + ' let underlyingType = "uint32_t";\n}}'.format( name=kind_name, cases=case_names) return kind_name, case_defs + '\n' + enum_attr |

