This is an archive of the discontinued LLVM Phabricator instance.

[mips] [IAS] Fix parsing of memory offset expressions with parenthesis depth >1.
ClosedPublic

Authored by tomatabacu on May 13 2015, 7:08 AM.

Details

Summary

In an expression such as "(((a+b)+c)+d)", parseParenExpression() would only parse the "a+b)+c", which would result in an error later on in the parser.
This means that we can only parse one level of inner parentheses.

In order to fix this, I added a new function called parseParenExprOfDepth(), which parses a specified number of trailing parenthesis expressions
(except for the outermost parenthesis), and changed MipsAsmParser to use it in parseMemOffset instead of parseParenExpression().

Diff Detail

Event Timeline

tomatabacu updated this revision to Diff 25679.May 13 2015, 7:08 AM
tomatabacu retitled this revision from to [mips] [IAS] Fix parsing of memory offset expressions with parenthesis depth >1..
tomatabacu updated this object.
tomatabacu edited the test plan for this revision. (Show Details)
tomatabacu added reviewers: dsanders, rafael.
tomatabacu added a subscriber: Unknown Object (MLST).
dsanders edited edge metadata.Jun 1 2015, 7:20 AM

I already know why we need this in the short term (to parse %hi,%lo,etc. correctly) but it's not evident from the patch. Could you add some test-cases that depend on the MIPS-specific expression parsing?

tomatabacu updated this revision to Diff 27818.Jun 17 2015, 2:51 AM
tomatabacu edited edge metadata.

Added test case with MIPS-specific expression.

dsanders accepted this revision.Jun 17 2015, 3:30 AM
dsanders edited edge metadata.

LGTM. This seems like a reasonable compromise between the ideal solution (adding the ability to extend the expression parser to support MIPS-specific operators such as '%lo(X)') and getting the most common expressions working.

This revision is now accepted and ready to land.Jun 17 2015, 3:30 AM

Rafael, are the common-code additions ok with you ?

rafael accepted this revision.Jun 24 2015, 6:34 AM
rafael edited edge metadata.

LGTM

tomatabacu closed this revision.Jun 25 2015, 2:52 AM