This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fixed AsmParser not allowing instructions with / and :
ClosedPublic

Authored by aardappel on Sep 24 2018, 3:44 PM.

Details

Summary

The AsmParser Lexer regards these as seperate token.
Here we expand the instruction name with them if they are
adjacent (no whitespace).

Tested: the basic-assembly.s test case has one case with a / in it.
The case with a : needs to be enabled once the corresponding
instruction is available, but has been tested to work in the debugger.

Diff Detail

Event Timeline

aardappel created this revision.Sep 24 2018, 3:44 PM
tlively added inline comments.Sep 24 2018, 4:51 PM
test/MC/WebAssembly/basic-assembly.s
48

What happens if an instruction name is used as a label? Is the colon correctly identified as delimiting a label and not as part of the instruction? Is that even allowed?

dschuff added inline comments.Sep 24 2018, 5:00 PM
test/MC/WebAssembly/basic-assembly.s
47

We already have support for i32.trunc_s:sat/f32 (non-vector) and friends behind the FeatureNontrappingFPToInt CPU feature. So we should be able to add that to this test already.

Turns out i32.trunc_s:sat/f32 is parsed as a label i32.trunc_s: followed by an instruction sat/f32.

The label parsing happens in the target agnostic code.

A simple solution would be to require whitespace after :, but only for the wasm target? Or a bit hairier, add a method that asks the target, is this a valid label? (so we can check against a list of instructions) ?

Best would of course be to not have : in names in the first place.

I don't think it's too late to remove colons from all instruction names, so lets try to push in that direction. It's good that this works out cleanly enough for slashes, though.

Do we want to merge this mean-while to gain / support?

Is it possible to fix target-independent parsing code to recognize colons in names?

This comment was removed by dschuff.

I think it makes the most sense to try to remove colons from instruction names in the spec. Only a few shipped instructions have them. Slashes is probably harder, there are a lot more of those and they are all from the original MVP and not from nontrappingFP. So we can probably just remove colon support from this CL and land it.

@dschuff ok, will do.
@aheejin that is possible, but would affect other targets, unless we have some WebAssembly conditional code in there. Probably nice to solve in entirely on the WebAssembly side.

aardappel updated this revision to Diff 167766.Oct 1 2018, 10:20 AM

Addressed review comments, now only fixing / in names.

This revision was not accepted when it landed; it landed in state Needs Review.Oct 1 2018, 10:22 AM
This revision was automatically updated to reflect the committed changes.