Index: include/llvm/ObjectYAML/WasmYAML.h =================================================================== --- include/llvm/ObjectYAML/WasmYAML.h +++ include/llvm/ObjectYAML/WasmYAML.h @@ -34,13 +34,16 @@ LLVM_YAML_STRONG_TYPEDEF(uint32_t, ExportKind) LLVM_YAML_STRONG_TYPEDEF(uint32_t, Opcode) LLVM_YAML_STRONG_TYPEDEF(uint32_t, RelocType) +LLVM_YAML_STRONG_TYPEDEF(uint32_t, SymbolFlags); +LLVM_YAML_STRONG_TYPEDEF(uint32_t, SegmentFlags); +LLVM_YAML_STRONG_TYPEDEF(uint32_t, LimitFlags); struct FileHeader { yaml::Hex32 Version; }; struct Limits { - yaml::Hex32 Flags; + LimitFlags Flags; yaml::Hex32 Initial; yaml::Hex32 Maximum; }; @@ -113,7 +116,7 @@ uint32_t Index; StringRef Name; uint32_t Alignment; - uint32_t Flags; + SegmentFlags Flags; }; struct Signature { @@ -125,7 +128,7 @@ struct SymbolInfo { StringRef Name; - uint32_t Flags; + SymbolFlags Flags; }; struct Section { @@ -334,6 +337,18 @@ static void mapping(IO &IO, WasmYAML::Global &Global); }; +template <> struct ScalarBitSetTraits { + static void bitset(IO &IO, WasmYAML::LimitFlags &Value); +}; + +template <> struct ScalarBitSetTraits { + static void bitset(IO &IO, WasmYAML::SymbolFlags &Value); +}; + +template <> struct ScalarBitSetTraits { + static void bitset(IO &IO, WasmYAML::SegmentFlags &Value); +}; + template <> struct ScalarEnumerationTraits { static void enumeration(IO &IO, WasmYAML::SectionType &Type); }; Index: lib/ObjectYAML/WasmYAML.cpp =================================================================== --- lib/ObjectYAML/WasmYAML.cpp +++ lib/ObjectYAML/WasmYAML.cpp @@ -365,6 +365,28 @@ IO.mapRequired("Flags", Info.Flags); } +void ScalarBitSetTraits::bitset( + IO &IO, WasmYAML::LimitFlags &Value) { +#define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_LIMITS_FLAG_##X) + BCase(HAS_MAX); +#undef BCase +} + +void ScalarBitSetTraits::bitset( + IO &IO, WasmYAML::SegmentFlags &Value) { +} + +void ScalarBitSetTraits::bitset( + IO &IO, WasmYAML::SymbolFlags &Value) { +#define BCaseMask(M, X) IO.maskedBitSetCase(Value, #X, wasm::WASM_SYMBOL_##X, wasm::WASM_SYMBOL_##M) + //BCaseMask(BINDING_MASK, BINDING_GLOBAL); + BCaseMask(BINDING_MASK, BINDING_WEAK); + BCaseMask(BINDING_MASK, BINDING_LOCAL); + //BCaseMask(VISIBILITY_MASK, VISIBILITY_DEFAULT); + BCaseMask(VISIBILITY_MASK, VISIBILITY_HIDDEN); +#undef BCaseMask +} + void ScalarEnumerationTraits::enumeration( IO &IO, WasmYAML::ValueType &Type) { #define ECase(X) IO.enumCase(Type, #X, wasm::WASM_TYPE_##X); Index: test/MC/WebAssembly/array-fill.ll =================================================================== --- test/MC/WebAssembly/array-fill.ll +++ test/MC/WebAssembly/array-fill.ll @@ -17,10 +17,10 @@ ; CHECK-NEXT: DataSize: 2 ; CHECK-NEXT: SymbolInfo: ; CHECK-NEXT: - Name: gBd -; CHECK-NEXT: Flags: 4 +; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] ; CHECK-NEXT: SegmentInfo: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Name: .data ; CHECK-NEXT: Alignment: 1 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: ... Index: test/MC/WebAssembly/bss.ll =================================================================== --- test/MC/WebAssembly/bss.ll +++ test/MC/WebAssembly/bss.ll @@ -76,17 +76,17 @@ ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Name: .bss.g0 ; CHECK-NEXT: Alignment: 4 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: .bss.g1 ; CHECK-NEXT: Alignment: 4 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: .bss.foo ; CHECK-NEXT: Alignment: 1 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Name: .bss.bar ; CHECK-NEXT: Alignment: 1 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: ... Index: test/MC/WebAssembly/explicit-sections.ll =================================================================== --- test/MC/WebAssembly/explicit-sections.ll +++ test/MC/WebAssembly/explicit-sections.ll @@ -71,13 +71,13 @@ ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Name: .data.global0 ; CHECK-NEXT: Alignment: 8 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: .sec1 ; CHECK-NEXT: Alignment: 8 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: .sec2 ; CHECK-NEXT: Alignment: 8 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: ... Index: test/MC/WebAssembly/init-fini-array.ll =================================================================== --- test/MC/WebAssembly/init-fini-array.ll +++ test/MC/WebAssembly/init-fini-array.ll @@ -92,14 +92,14 @@ ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Name: .data.global1 ; CHECK-NEXT: Alignment: 8 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: .init_array ; CHECK-NEXT: Alignment: 4 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: .fini_array ; CHECK-NEXT: Alignment: 4 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: ... Index: test/MC/WebAssembly/unnamed-data.ll =================================================================== --- test/MC/WebAssembly/unnamed-data.ll +++ test/MC/WebAssembly/unnamed-data.ll @@ -81,24 +81,24 @@ ; CHECK-NEXT: DataSize: 28 ; CHECK-NEXT: SymbolInfo: ; CHECK-NEXT: - Name: .L.str1 -; CHECK-NEXT: Flags: 2 +; CHECK-NEXT: Flags: [ BINDING_LOCAL ] ; CHECK-NEXT: - Name: .L.str2 -; CHECK-NEXT: Flags: 2 +; CHECK-NEXT: Flags: [ BINDING_LOCAL ] ; CHECK-NEXT: SegmentInfo: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Name: .rodata..L.str1 ; CHECK-NEXT: Alignment: 1 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: .rodata..L.str2 ; CHECK-NEXT: Alignment: 1 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Name: .data.a ; CHECK-NEXT: Alignment: 8 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Name: .data.b ; CHECK-NEXT: Alignment: 8 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK_NEXT: ... Index: test/MC/WebAssembly/visibility.ll =================================================================== --- test/MC/WebAssembly/visibility.ll +++ test/MC/WebAssembly/visibility.ll @@ -19,5 +19,5 @@ ; CHECK-NEXT: DataSize: 0 ; CHECK-NEXT: SymbolInfo: ; CHECK-NEXT: - Name: hiddenVis -; CHECK-NEXT: Flags: 4 +; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] ; CHECK-NEXT: ... Index: test/MC/WebAssembly/weak-alias.ll =================================================================== --- test/MC/WebAssembly/weak-alias.ll +++ test/MC/WebAssembly/weak-alias.ll @@ -109,22 +109,22 @@ ; CHECK-NEXT: DataSize: 12 ; CHECK-NEXT: SymbolInfo: ; CHECK-NEXT: - Name: call_alias -; CHECK-NEXT: Flags: 4 +; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] ; CHECK-NEXT: - Name: foo -; CHECK-NEXT: Flags: 4 +; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ] ; CHECK-NEXT: - Name: foo_alias -; CHECK-NEXT: Flags: 5 +; CHECK-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN ] ; CHECK-NEXT: - Name: bar_alias -; CHECK-NEXT: Flags: 5 +; CHECK-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN ] ; CHECK-NEXT: SegmentInfo: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Name: .data.bar ; CHECK-NEXT: Alignment: 8 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Name: .data.bar_alias_address ; CHECK-NEXT: Alignment: 8 -; CHECK-NEXT: Flags: 0 +; CHECK-NEXT: Flags: [ ] ; CHECK-NEXT: ... ; CHECK-SYMS: SYMBOL TABLE: Index: test/MC/WebAssembly/weak.ll =================================================================== --- test/MC/WebAssembly/weak.ll +++ test/MC/WebAssembly/weak.ll @@ -33,7 +33,7 @@ ; CHECK-NEXT: DataSize: 0 ; CHECK-NEXT: SymbolInfo: ; CHECK-NEXT: - Name: weak_external_data -; CHECK-NEXT: Flags: 1 +; CHECK-NEXT: Flags: [ BINDING_WEAK ] ; CHECK-NEXT: - Name: weak_function -; CHECK-NEXT: Flags: 5 +; CHECK-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN ] ; CHECK-NEXT: ... Index: test/ObjectYAML/wasm/elem_section.yaml =================================================================== --- test/ObjectYAML/wasm/elem_section.yaml +++ test/ObjectYAML/wasm/elem_section.yaml @@ -7,7 +7,7 @@ Tables: - ElemType: ANYFUNC Limits: - Flags: 0x00000001 + Flags: [ HAS_MAX ] Initial: 0x00000010 Maximum: 0x00000011 - Type: ELEM Index: test/ObjectYAML/wasm/import_section.yaml =================================================================== --- test/ObjectYAML/wasm/import_section.yaml +++ test/ObjectYAML/wasm/import_section.yaml @@ -23,7 +23,7 @@ Field: imported_memory Kind: MEMORY Memory: - Flags: 0x00000001 + Flags: [ HAS_MAX ] Initial: 0x00000010 Maximum: 0x00000011 - Module: foo @@ -32,7 +32,7 @@ Table: ElemType: ANYFUNC Limits: - Flags: 0x00000001 + Flags: [ HAS_MAX ] Initial: 0x00000020 Maximum: 0x00000022 ... @@ -55,7 +55,7 @@ # CHECK: Field: imported_memory # CHECK: Kind: MEMORY # CHECK: Memory: -# CHECK: Flags: 0x00000001 +# CHECK: Flags: [ HAS_MAX ] # CHECK: Initial: 0x00000010 # CHECK: Maximum: 0x00000011 # CHECK: - Module: foo @@ -64,7 +64,7 @@ # CHECK: Table: # CHECK: ElemType: ANYFUNC # CHECK: Limits: -# CHECK: Flags: 0x00000001 +# CHECK: Flags: [ HAS_MAX ] # CHECK: Initial: 0x00000020 # CHECK: Maximum: 0x00000022 # CHECK: ... Index: test/ObjectYAML/wasm/linking_section.yaml =================================================================== --- test/ObjectYAML/wasm/linking_section.yaml +++ test/ObjectYAML/wasm/linking_section.yaml @@ -31,15 +31,15 @@ DataSize: 999 SymbolInfo: - Name: bar - Flags: 1 + Flags: [ BINDING_WEAK ] SegmentInfo: - Index: 0 Alignment: 4 - Flags: 0 + Flags: [ ] Name: mydata - Index: 1 Alignment: 2 - Flags: 1 + Flags: [ ] Name: moredata ... # CHECK: - Type: CUSTOM @@ -47,14 +47,14 @@ # CHECK-NEXT: DataSize: 999 # CHECK-NEXT: SymbolInfo: # CHECK-NEXT: - Name: bar -# CHECK-NEXT: Flags: 1 +# CHECK-NEXT: Flags: [ BINDING_WEAK ] # CHECK-NEXT: SegmentInfo: # CHECK-NEXT: - Index: 0 # CHECK-NEXT: Name: mydata # CHECK-NEXT: Alignment: 4 -# CHECK-NEXT: Flags: 0 +# CHECK-NEXT: Flags: [ ] # CHECK-NEXT: - Index: 1 # CHECK-NEXT: Name: moredata # CHECK-NEXT: Alignment: 2 -# CHECK-NEXT: Flags: 1 +# CHECK-NEXT: Flags: [ ] # CHECK-NEXT: ... Index: test/ObjectYAML/wasm/memory_section.yaml =================================================================== --- test/ObjectYAML/wasm/memory_section.yaml +++ test/ObjectYAML/wasm/memory_section.yaml @@ -5,7 +5,7 @@ Sections: - Type: MEMORY Memories: - - Flags: 0x00000001 + - Flags: [ HAS_MAX ] Initial: 0x00000002 Maximum: 0x000000FF - Initial: 0x00000003 @@ -16,7 +16,7 @@ # CHECK: Sections: # CHECK: - Type: MEMORY # CHECK: Memories: -# CHECK: - Flags: 0x00000001 +# CHECK: - Flags: [ HAS_MAX ] # CHECK: Initial: 0x00000002 # CHECK: Maximum: 0x000000FF # CHECK: - Initial: 0x00000003 Index: test/ObjectYAML/wasm/table_section.yaml =================================================================== --- test/ObjectYAML/wasm/table_section.yaml +++ test/ObjectYAML/wasm/table_section.yaml @@ -7,7 +7,7 @@ Tables: - ElemType: ANYFUNC Limits: - Flags: 0x00000001 + Flags: [ HAS_MAX ] Initial: 0x00000010 Maximum: 0x00000011 ... @@ -19,7 +19,7 @@ # CHECK: Tables: # CHECK: - ElemType: ANYFUNC # CHECK: Limits: -# CHECK: Flags: 0x00000001 +# CHECK: Flags: [ HAS_MAX ] # CHECK: Initial: 0x00000010 # CHECK: Maximum: 0x00000011 # CHECK: ... Index: test/ObjectYAML/wasm/weak_symbols.yaml =================================================================== --- test/ObjectYAML/wasm/weak_symbols.yaml +++ test/ObjectYAML/wasm/weak_symbols.yaml @@ -29,9 +29,9 @@ DataSize: 10 SymbolInfo: - Name: function_export - Flags: 1 + Flags: [ BINDING_WEAK ] - Name: global_export - Flags: 1 + Flags: [ BINDING_WEAK ] ... # CHECK: --- !WASM # CHECK: FileHeader: @@ -50,6 +50,6 @@ # CHECK: DataSize: 10 # CHECK: SymbolInfo: # CHECK: - Name: function_export -# CHECK: Flags: 1 +# CHECK: Flags: [ BINDING_WEAK ] # CHECK: - Name: global_export -# CHECK: Flags: 1 +# CHECK: Flags: [ BINDING_WEAK ] Index: test/tools/llvm-nm/wasm/weak-symbols.yaml =================================================================== --- test/tools/llvm-nm/wasm/weak-symbols.yaml +++ test/tools/llvm-nm/wasm/weak-symbols.yaml @@ -55,13 +55,13 @@ DataSize: 0 SymbolInfo: - Name: weak_global_func - Flags: 1 + Flags: [ BINDING_WEAK ] - Name: weak_global_data - Flags: 1 + Flags: [ BINDING_WEAK ] - Name: weak_import_func - Flags: 1 + Flags: [ BINDING_WEAK ] - Name: weak_import_data - Flags: 1 + Flags: [ BINDING_WEAK ] # CHECK: 00000400 W weak_global_data # CHECK: 00000004 W weak_global_func