aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/obj2yaml/wasm2yaml.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2021-10-01 19:07:41 -0700
committerHeejin Ahn <aheejin@gmail.com>2021-10-05 17:11:22 -0700
commit3ec1760d91a38e30d9535c313e4231e332910dd3 (patch)
tree9b060fbb8da43ced700af5b9332543822c395761 /llvm/tools/obj2yaml/wasm2yaml.cpp
parentd51f57c23ca95f4b9b383f0942fee2957d36fd4f (diff)
downloadllvm-3ec1760d91a38e30d9535c313e4231e332910dd3.zip
llvm-3ec1760d91a38e30d9535c313e4231e332910dd3.tar.gz
llvm-3ec1760d91a38e30d9535c313e4231e332910dd3.tar.bz2
[WebAssembly] Remove WasmTagType
This removes `WasmTagType`. `WasmTagType` contained an attribute and a signature index: ``` struct WasmTagType { uint8_t Attribute; uint32_t SigIndex; }; ``` Currently the attribute field is not used and reserved for future use, and always 0. And that this class contains `SigIndex` as its property is a little weird in the place, because the tag type's signature index is not an inherent property of a tag but rather a reference to another section that changes after linking. This makes tag handling in the linker also weird that tag-related methods are taking both `WasmTagType` and `WasmSignature` even though `WasmTagType` contains a signature index. This is because the signature index changes in linking so it doesn't have any info at this point. This instead moves `SigIndex` to `struct WasmTag` itself, as we did for `struct WasmFunction` in D111104. In this CL, in lib/MC and lib/Object, this now treats tag types in the same way as function types. Also in YAML, this removes `struct Tag`, because now it only contains the tag index. Also tags set `SigIndex` in `WasmImport` union, as functions do. I think this makes things simpler and makes tag handling more in line with function handling. These two shares similar properties in that both of them have signatures, but they are kind of nominal so having the same signature doesn't mean they are the same element. Also a drive-by fix: the reserved 'attirubute' part's encoding changed from uleb32 to uint8 a while ago. This was fixed in lib/MC and lib/Object but not in YAML. This doesn't change object files because the field's value is always 0 and its encoding is the same for the both encoding. This is effectively NFC; I didn't mark it as such just because it changed YAML test results. Reviewed By: sbc100, tlively Differential Revision: https://reviews.llvm.org/D111086
Diffstat (limited to 'llvm/tools/obj2yaml/wasm2yaml.cpp')
-rw-r--r--llvm/tools/obj2yaml/wasm2yaml.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/llvm/tools/obj2yaml/wasm2yaml.cpp b/llvm/tools/obj2yaml/wasm2yaml.cpp
index 61a48c5..189ca0b 100644
--- a/llvm/tools/obj2yaml/wasm2yaml.cpp
+++ b/llvm/tools/obj2yaml/wasm2yaml.cpp
@@ -241,8 +241,7 @@ ErrorOr<WasmYAML::Object *> WasmDumper::dump() {
Im.GlobalImport.Mutable = Import.Global.Mutable;
break;
case wasm::WASM_EXTERNAL_TAG:
- Im.TagImport.Attribute = Import.Tag.Attribute;
- Im.TagImport.SigIndex = Import.Tag.SigIndex;
+ Im.SigIndex = Import.SigIndex;
break;
case wasm::WASM_EXTERNAL_TABLE:
// FIXME: Currently we always output an index of 0 for any imported
@@ -285,11 +284,7 @@ ErrorOr<WasmYAML::Object *> WasmDumper::dump() {
case wasm::WASM_SEC_TAG: {
auto TagSec = std::make_unique<WasmYAML::TagSection>();
for (auto &Tag : Obj.tags()) {
- WasmYAML::Tag T;
- T.Index = Tag.Index;
- T.Attribute = Tag.Type.Attribute;
- T.SigIndex = Tag.Type.SigIndex;
- TagSec->Tags.push_back(T);
+ TagSec->TagTypes.push_back(Tag.SigIndex);
}
S = std::move(TagSec);
break;