llvm.org GIT mirror llvm / 8764e8a
[WebAssembly] Use bitfield types in wasm YAML representation Differential Revision: https://reviews.llvm.org/D41202 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320642 91177308-0d34-0410-b5e6-96231b3b80d8 Sam Clegg 1 year, 9 months ago
17 changed file(s) with 90 addition(s) and 53 deletion(s). Raw diff Collapse all Expand all
3333 LLVM_YAML_STRONG_TYPEDEF(uint32_t, ExportKind)
3434 LLVM_YAML_STRONG_TYPEDEF(uint32_t, Opcode)
3535 LLVM_YAML_STRONG_TYPEDEF(uint32_t, RelocType)
36 LLVM_YAML_STRONG_TYPEDEF(uint32_t, SymbolFlags);
37 LLVM_YAML_STRONG_TYPEDEF(uint32_t, SegmentFlags);
38 LLVM_YAML_STRONG_TYPEDEF(uint32_t, LimitFlags);
3639
3740 struct FileHeader {
3841 yaml::Hex32 Version;
3942 };
4043
4144 struct Limits {
42 yaml::Hex32 Flags;
45 LimitFlags Flags;
4346 yaml::Hex32 Initial;
4447 yaml::Hex32 Maximum;
4548 };
112115 uint32_t Index;
113116 StringRef Name;
114117 uint32_t Alignment;
115 uint32_t Flags;
118 SegmentFlags Flags;
116119 };
117120
118121 struct Signature {
124127
125128 struct SymbolInfo {
126129 StringRef Name;
127 uint32_t Flags;
130 SymbolFlags Flags;
128131 };
129132
130133 struct Section {
333336 static void mapping(IO &IO, WasmYAML::Global &Global);
334337 };
335338
339 template <> struct ScalarBitSetTraits {
340 static void bitset(IO &IO, WasmYAML::LimitFlags &Value);
341 };
342
343 template <> struct ScalarBitSetTraits {
344 static void bitset(IO &IO, WasmYAML::SymbolFlags &Value);
345 };
346
347 template <> struct ScalarBitSetTraits {
348 static void bitset(IO &IO, WasmYAML::SegmentFlags &Value);
349 };
350
336351 template <> struct ScalarEnumerationTraits {
337352 static void enumeration(IO &IO, WasmYAML::SectionType &Type);
338353 };
364364 IO.mapRequired("Flags", Info.Flags);
365365 }
366366
367 void ScalarBitSetTraits::bitset(
368 IO &IO, WasmYAML::LimitFlags &Value) {
369 #define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_LIMITS_FLAG_##X)
370 BCase(HAS_MAX);
371 #undef BCase
372 }
373
374 void ScalarBitSetTraits::bitset(
375 IO &IO, WasmYAML::SegmentFlags &Value) {
376 }
377
378 void ScalarBitSetTraits::bitset(
379 IO &IO, WasmYAML::SymbolFlags &Value) {
380 #define BCaseMask(M, X) IO.maskedBitSetCase(Value, #X, wasm::WASM_SYMBOL_##X, wasm::WASM_SYMBOL_##M)
381 //BCaseMask(BINDING_MASK, BINDING_GLOBAL);
382 BCaseMask(BINDING_MASK, BINDING_WEAK);
383 BCaseMask(BINDING_MASK, BINDING_LOCAL);
384 //BCaseMask(VISIBILITY_MASK, VISIBILITY_DEFAULT);
385 BCaseMask(VISIBILITY_MASK, VISIBILITY_HIDDEN);
386 #undef BCaseMask
387 }
388
367389 void ScalarEnumerationTraits::enumeration(
368390 IO &IO, WasmYAML::ValueType &Type) {
369391 #define ECase(X) IO.enumCase(Type, #X, wasm::WASM_TYPE_##X);
1616 ; CHECK-NEXT: DataSize: 2
1717 ; CHECK-NEXT: SymbolInfo:
1818 ; CHECK-NEXT: - Name: gBd
19 ; CHECK-NEXT: Flags: 4
19 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ]
2020 ; CHECK-NEXT: SegmentInfo:
2121 ; CHECK-NEXT: - Index: 0
2222 ; CHECK-NEXT: Name: .data
2323 ; CHECK-NEXT: Alignment: 1
24 ; CHECK-NEXT: Flags: 0
24 ; CHECK-NEXT: Flags: [ ]
2525 ; CHECK-NEXT: ...
7575 ; CHECK-NEXT: - Index: 0
7676 ; CHECK-NEXT: Name: .bss.g0
7777 ; CHECK-NEXT: Alignment: 4
78 ; CHECK-NEXT: Flags: 0
78 ; CHECK-NEXT: Flags: [ ]
7979 ; CHECK-NEXT: - Index: 1
8080 ; CHECK-NEXT: Name: .bss.g1
8181 ; CHECK-NEXT: Alignment: 4
82 ; CHECK-NEXT: Flags: 0
82 ; CHECK-NEXT: Flags: [ ]
8383 ; CHECK-NEXT: - Index: 2
8484 ; CHECK-NEXT: Name: .bss.foo
8585 ; CHECK-NEXT: Alignment: 1
86 ; CHECK-NEXT: Flags: 0
86 ; CHECK-NEXT: Flags: [ ]
8787 ; CHECK-NEXT: - Index: 3
8888 ; CHECK-NEXT: Name: .bss.bar
8989 ; CHECK-NEXT: Alignment: 1
90 ; CHECK-NEXT: Flags: 0
90 ; CHECK-NEXT: Flags: [ ]
9191 ; CHECK-NEXT: ...
7070 ; CHECK-NEXT: - Index: 0
7171 ; CHECK-NEXT: Name: .data.global0
7272 ; CHECK-NEXT: Alignment: 8
73 ; CHECK-NEXT: Flags: 0
73 ; CHECK-NEXT: Flags: [ ]
7474 ; CHECK-NEXT: - Index: 1
7575 ; CHECK-NEXT: Name: .sec1
7676 ; CHECK-NEXT: Alignment: 8
77 ; CHECK-NEXT: Flags: 0
77 ; CHECK-NEXT: Flags: [ ]
7878 ; CHECK-NEXT: - Index: 2
7979 ; CHECK-NEXT: Name: .sec2
8080 ; CHECK-NEXT: Alignment: 8
81 ; CHECK-NEXT: Flags: 0
81 ; CHECK-NEXT: Flags: [ ]
8282 ; CHECK-NEXT: ...
9191 ; CHECK-NEXT: - Index: 0
9292 ; CHECK-NEXT: Name: .data.global1
9393 ; CHECK-NEXT: Alignment: 8
94 ; CHECK-NEXT: Flags: 0
94 ; CHECK-NEXT: Flags: [ ]
9595 ; CHECK-NEXT: - Index: 1
9696 ; CHECK-NEXT: Name: .init_array
9797 ; CHECK-NEXT: Alignment: 4
98 ; CHECK-NEXT: Flags: 0
98 ; CHECK-NEXT: Flags: [ ]
9999 ; CHECK-NEXT: - Index: 2
100100 ; CHECK-NEXT: Name: .fini_array
101101 ; CHECK-NEXT: Alignment: 4
102 ; CHECK-NEXT: Flags: 0
102 ; CHECK-NEXT: Flags: [ ]
103103 ; CHECK-NEXT: ...
104104
8080 ; CHECK-NEXT: DataSize: 28
8181 ; CHECK-NEXT: SymbolInfo:
8282 ; CHECK-NEXT: - Name: .L.str1
83 ; CHECK-NEXT: Flags: 2
83 ; CHECK-NEXT: Flags: [ BINDING_LOCAL ]
8484 ; CHECK-NEXT: - Name: .L.str2
85 ; CHECK-NEXT: Flags: 2
85 ; CHECK-NEXT: Flags: [ BINDING_LOCAL ]
8686 ; CHECK-NEXT: SegmentInfo:
8787 ; CHECK-NEXT: - Index: 0
8888 ; CHECK-NEXT: Name: .rodata..L.str1
8989 ; CHECK-NEXT: Alignment: 1
90 ; CHECK-NEXT: Flags: 0
90 ; CHECK-NEXT: Flags: [ ]
9191 ; CHECK-NEXT: - Index: 1
9292 ; CHECK-NEXT: Name: .rodata..L.str2
9393 ; CHECK-NEXT: Alignment: 1
94 ; CHECK-NEXT: Flags: 0
94 ; CHECK-NEXT: Flags: [ ]
9595 ; CHECK-NEXT: - Index: 2
9696 ; CHECK-NEXT: Name: .data.a
9797 ; CHECK-NEXT: Alignment: 8
98 ; CHECK-NEXT: Flags: 0
98 ; CHECK-NEXT: Flags: [ ]
9999 ; CHECK-NEXT: - Index: 3
100100 ; CHECK-NEXT: Name: .data.b
101101 ; CHECK-NEXT: Alignment: 8
102 ; CHECK-NEXT: Flags: 0
102 ; CHECK-NEXT: Flags: [ ]
103103 ; CHECK_NEXT: ...
1818 ; CHECK-NEXT: DataSize: 0
1919 ; CHECK-NEXT: SymbolInfo:
2020 ; CHECK-NEXT: - Name: hiddenVis
21 ; CHECK-NEXT: Flags: 4
21 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ]
2222 ; CHECK-NEXT: ...
108108 ; CHECK-NEXT: DataSize: 12
109109 ; CHECK-NEXT: SymbolInfo:
110110 ; CHECK-NEXT: - Name: call_alias
111 ; CHECK-NEXT: Flags: 4
111 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ]
112112 ; CHECK-NEXT: - Name: foo
113 ; CHECK-NEXT: Flags: 4
113 ; CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN ]
114114 ; CHECK-NEXT: - Name: foo_alias
115 ; CHECK-NEXT: Flags: 5
115 ; CHECK-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN ]
116116 ; CHECK-NEXT: - Name: bar_alias
117 ; CHECK-NEXT: Flags: 5
117 ; CHECK-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN ]
118118 ; CHECK-NEXT: SegmentInfo:
119119 ; CHECK-NEXT: - Index: 0
120120 ; CHECK-NEXT: Name: .data.bar
121121 ; CHECK-NEXT: Alignment: 8
122 ; CHECK-NEXT: Flags: 0
122 ; CHECK-NEXT: Flags: [ ]
123123 ; CHECK-NEXT: - Index: 1
124124 ; CHECK-NEXT: Name: .data.bar_alias_address
125125 ; CHECK-NEXT: Alignment: 8
126 ; CHECK-NEXT: Flags: 0
126 ; CHECK-NEXT: Flags: [ ]
127127 ; CHECK-NEXT: ...
128128
129129 ; CHECK-SYMS: SYMBOL TABLE:
3232 ; CHECK-NEXT: DataSize: 0
3333 ; CHECK-NEXT: SymbolInfo:
3434 ; CHECK-NEXT: - Name: weak_external_data
35 ; CHECK-NEXT: Flags: 1
35 ; CHECK-NEXT: Flags: [ BINDING_WEAK ]
3636 ; CHECK-NEXT: - Name: weak_function
37 ; CHECK-NEXT: Flags: 5
37 ; CHECK-NEXT: Flags: [ BINDING_WEAK, VISIBILITY_HIDDEN ]
3838 ; CHECK-NEXT: ...
66 Tables:
77 - ElemType: ANYFUNC
88 Limits:
9 Flags: 0x00000001
9 Flags: [ HAS_MAX ]
1010 Initial: 0x00000010
1111 Maximum: 0x00000011
1212 - Type: ELEM
2222 Field: imported_memory
2323 Kind: MEMORY
2424 Memory:
25 Flags: 0x00000001
25 Flags: [ HAS_MAX ]
2626 Initial: 0x00000010
2727 Maximum: 0x00000011
2828 - Module: foo
3131 Table:
3232 ElemType: ANYFUNC
3333 Limits:
34 Flags: 0x00000001
34 Flags: [ HAS_MAX ]
3535 Initial: 0x00000020
3636 Maximum: 0x00000022
3737 ...
5454 # CHECK: Field: imported_memory
5555 # CHECK: Kind: MEMORY
5656 # CHECK: Memory:
57 # CHECK: Flags: 0x00000001
57 # CHECK: Flags: [ HAS_MAX ]
5858 # CHECK: Initial: 0x00000010
5959 # CHECK: Maximum: 0x00000011
6060 # CHECK: - Module: foo
6363 # CHECK: Table:
6464 # CHECK: ElemType: ANYFUNC
6565 # CHECK: Limits:
66 # CHECK: Flags: 0x00000001
66 # CHECK: Flags: [ HAS_MAX ]
6767 # CHECK: Initial: 0x00000020
6868 # CHECK: Maximum: 0x00000022
6969 # CHECK: ...
3030 DataSize: 999
3131 SymbolInfo:
3232 - Name: bar
33 Flags: 1
33 Flags: [ BINDING_WEAK ]
3434 SegmentInfo:
3535 - Index: 0
3636 Alignment: 4
37 Flags: 0
37 Flags: [ ]
3838 Name: mydata
3939 - Index: 1
4040 Alignment: 2
41 Flags: 1
41 Flags: [ ]
4242 Name: moredata
4343 ...
4444 # CHECK: - Type: CUSTOM
4646 # CHECK-NEXT: DataSize: 999
4747 # CHECK-NEXT: SymbolInfo:
4848 # CHECK-NEXT: - Name: bar
49 # CHECK-NEXT: Flags: 1
49 # CHECK-NEXT: Flags: [ BINDING_WEAK ]
5050 # CHECK-NEXT: SegmentInfo:
5151 # CHECK-NEXT: - Index: 0
5252 # CHECK-NEXT: Name: mydata
5353 # CHECK-NEXT: Alignment: 4
54 # CHECK-NEXT: Flags: 0
54 # CHECK-NEXT: Flags: [ ]
5555 # CHECK-NEXT: - Index: 1
5656 # CHECK-NEXT: Name: moredata
5757 # CHECK-NEXT: Alignment: 2
58 # CHECK-NEXT: Flags: 1
58 # CHECK-NEXT: Flags: [ ]
5959 # CHECK-NEXT: ...
44 Sections:
55 - Type: MEMORY
66 Memories:
7 - Flags: 0x00000001
7 - Flags: [ HAS_MAX ]
88 Initial: 0x00000002
99 Maximum: 0x000000FF
1010 - Initial: 0x00000003
1515 # CHECK: Sections:
1616 # CHECK: - Type: MEMORY
1717 # CHECK: Memories:
18 # CHECK: - Flags: 0x00000001
18 # CHECK: - Flags: [ HAS_MAX ]
1919 # CHECK: Initial: 0x00000002
2020 # CHECK: Maximum: 0x000000FF
2121 # CHECK: - Initial: 0x00000003
66 Tables:
77 - ElemType: ANYFUNC
88 Limits:
9 Flags: 0x00000001
9 Flags: [ HAS_MAX ]
1010 Initial: 0x00000010
1111 Maximum: 0x00000011
1212 ...
1818 # CHECK: Tables:
1919 # CHECK: - ElemType: ANYFUNC
2020 # CHECK: Limits:
21 # CHECK: Flags: 0x00000001
21 # CHECK: Flags: [ HAS_MAX ]
2222 # CHECK: Initial: 0x00000010
2323 # CHECK: Maximum: 0x00000011
2424 # CHECK: ...
2828 DataSize: 10
2929 SymbolInfo:
3030 - Name: function_export
31 Flags: 1
31 Flags: [ BINDING_WEAK ]
3232 - Name: global_export
33 Flags: 1
33 Flags: [ BINDING_WEAK ]
3434 ...
3535 # CHECK: --- !WASM
3636 # CHECK: FileHeader:
4949 # CHECK: DataSize: 10
5050 # CHECK: SymbolInfo:
5151 # CHECK: - Name: function_export
52 # CHECK: Flags: 1
52 # CHECK: Flags: [ BINDING_WEAK ]
5353 # CHECK: - Name: global_export
54 # CHECK: Flags: 1
54 # CHECK: Flags: [ BINDING_WEAK ]
5454 DataSize: 0
5555 SymbolInfo:
5656 - Name: weak_global_func
57 Flags: 1
57 Flags: [ BINDING_WEAK ]
5858 - Name: weak_global_data
59 Flags: 1
59 Flags: [ BINDING_WEAK ]
6060 - Name: weak_import_func
61 Flags: 1
61 Flags: [ BINDING_WEAK ]
6262 - Name: weak_import_data
63 Flags: 1
63 Flags: [ BINDING_WEAK ]
6464
6565 # CHECK: 00000400 W weak_global_data
6666 # CHECK: 00000004 W weak_global_func