This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Make segment/size/type directives optional in asm
ClosedPublic

Authored by aardappel on Jan 31 2019, 2:43 PM.

Details

Summary

These were "boilerplate" that repeated information already present
in .functype and end_function, that needed to be repeated to Please
the particular way our object writing works, and missing them would
generate errors.

Instead, we generate the information for these automatically so the
user can concern itself with writing more canonical wasm functions
that always work as expected.

Diff Detail

Repository
rL LLVM

Event Timeline

aardappel created this revision.Jan 31 2019, 2:43 PM
sbc100 accepted this revision.Jan 31 2019, 3:00 PM
sbc100 added inline comments.
lib/MC/MCParser/WasmAsmParser.cpp
97 ↗(On Diff #184619)

Why not just remove this? Same below.

lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
680 ↗(On Diff #184619)

Remove curlies?

This revision is now accepted and ready to land.Jan 31 2019, 3:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 31 2019, 3:00 PM
aardappel marked 2 inline comments as done.Jan 31 2019, 3:10 PM
aardappel added inline comments.
lib/MC/MCParser/WasmAsmParser.cpp
97 ↗(On Diff #184619)

I thought I'd leave this in at least for review, and potentially also to show "this is what this operation would do", since it is kinda odd that we parse the directive, then don't do anything with it.

I mean, I could remove all the parsing code and replace it with code that skips this directive, but I thought I'd leave it in, should we have a need for it later.

aheejin added inline comments.Jan 31 2019, 3:14 PM
lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
711 ↗(On Diff #184619)

clang-format :) other parts too

aardappel marked an inline comment as done.Jan 31 2019, 3:26 PM
aardappel updated this revision to Diff 184643.Jan 31 2019, 4:12 PM

code review fixes, and simplified end_function check.

dschuff added inline comments.Feb 1 2019, 11:10 AM
lib/MC/MCParser/WasmAsmParser.cpp
97 ↗(On Diff #184619)

Is it really true that we never use the section directive? I guess for functions that makes sense but what about for data sections?

dschuff added inline comments.Feb 1 2019, 11:13 AM
lib/MC/MCParser/WasmAsmParser.cpp
97 ↗(On Diff #184619)

WRT leaving in the commented-out code, the text comment could at least say something like "here is what *would* be here otherwise" so it's clear that the code is there intentionally.

115 ↗(On Diff #184643)

This comment can go now, right?

dschuff accepted this revision.Feb 1 2019, 11:13 AM

otherwise LGTM too

aardappel marked 2 inline comments as done.Feb 4 2019, 9:53 AM
aardappel added inline comments.
lib/MC/MCParser/WasmAsmParser.cpp
97 ↗(On Diff #184619)

We currently don't, as data sections aren't implemented yet. I'll revise this code if/when I implement those. And yes, I'll change the comment.

aardappel updated this revision to Diff 185078.Feb 4 2019, 9:54 AM

code review fixes

This revision was automatically updated to reflect the committed changes.