This is an archive of the discontinued LLVM Phabricator instance.

[ARM][MC] Cleanup ARM Target Assembly Parser
ClosedPublic

Authored by niravd on Oct 31 2016, 8:45 AM.

Details

Summary

Correctly parse end-of-statement tokens and handle preprocessor
end-of-line comments in ARM assembly processor.

Diff Detail

Repository
rL LLVM

Event Timeline

niravd updated this revision to Diff 76417.Oct 31 2016, 8:45 AM
niravd retitled this revision from to [ARM][MC] Cleanup ARM Target Assembly Parser.
niravd added reviewers: rnk, majnemer.
niravd updated this object.
niravd added a subscriber: llvm-commits.
rnk accepted this revision.Oct 31 2016, 9:04 AM
rnk edited edge metadata.

Nice, lgtm

This revision is now accepted and ready to land.Oct 31 2016, 9:04 AM
rengolin added inline comments.Oct 31 2016, 10:19 AM
lib/Target/ARM/AsmParser/ARMAsmParser.cpp
9233 ↗(On Diff #76417)

This looks like a string switch case.

9280 ↗(On Diff #76417)

Why no return here, too?

rengolin requested changes to this revision.Oct 31 2016, 10:20 AM
rengolin added a reviewer: rengolin.

Changes in this code can break many unrelated (and often untested) things. Let me add a few people that have worked in this area to have a look.

This revision now requires changes to proceed.Oct 31 2016, 10:20 AM
rengolin added inline comments.
lib/Target/ARM/AsmParser/ARMAsmParser.cpp
9306 ↗(On Diff #76417)

Why are we ignoring the return of all the parsing functions?

niravd added inline comments.Oct 31 2016, 11:04 AM
lib/Target/ARM/AsmParser/ARMAsmParser.cpp
9280 ↗(On Diff #76417)

parseDirectiveAlign needed to fail over to the generic align directive parser in AsmParser if it's special case was not encountered, but that violates the pattern here necessitating the return.

9306 ↗(On Diff #76417)

ParseDirective returns false if the Target Parser is relevant and true if we skip it. This is contrary to the return true on error convention of the parser otherwise. As a result a number of directive parse functions violate the convention which is mostly okay because the results are mostly masked, e.g., we parse two statements in a single pass. I've just isolated the non-standard convention to this case function allowing the other parsing functions to be shorter and clearer.

I plan on going through all of the parsers to fix the end-of-line parsing consistency and pushing all of the non-standardness into the various ParseDirective defs as well. Once they I'll do a once time change to make ParseDirective return true on error and just introspect on the Parser state to see if the target specific parser handled the result or not and the special case for parseDirectiveAlign to fall through will be obviated.

peter.smith edited edge metadata.Nov 1 2016, 9:08 AM

To the best of my knowledge, it is a long patch, this looks ok. I couldn't see anything that is changing outside of an existing error condition so this shouldn't affect valid existing code.

rengolin accepted this revision.Nov 1 2016, 7:35 PM
rengolin edited edge metadata.

ok, lgtm, too.

This revision is now accepted and ready to land.Nov 1 2016, 7:35 PM
rnk added a comment.Nov 2 2016, 8:44 AM

Also, the giant directive parsing test case gives me confidence that changing the error return convention didn't break anything.

This revision was automatically updated to reflect the committed changes.