Some refactoring to X86AsmParser, mostly regarding the way rewrites are conducted.
Mainly, we try to concentrate all the rewrite effort under one hood, so it'll hopefully be less of a mess and easier to maintain and understand.
naturally, some frontend tests were affected: D36794
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
IntelExpr::isValid looks rather strange because it validates possible multiplication only. But if we have Scale == 1 and don't have either BaseReg or Disp?
I didn't get to this this week, but this code could definitely use some refactoring. :)
first of all, thanks for your comment.
AOK_IntelExpr is a rewrite mechanism, and as such its mandate is to be a dumb (but convenient) conveyor. 'isValid()', under those guidelines, checks some most trivial parts which can be inferred with ease. others parts are assumed to be validated on the path that led to its emission (either pre or post).
Specific to the scenario you've described - if we 'have' Scale == 1 (which is the default case) any other part is 'considered' legal (to the purpose of this rewrite, again - this is simply a conveyor - we expect validation effort to be conducted by the parser). Index/Base/ImmDisp will be emitted if present.
lib/Target/X86/AsmParser/X86AsmParser.cpp | ||
---|---|---|
339–377 ↗ | (On Diff #111880) | Can you clang-format this? |
604 ↗ | (On Diff #111880) | formatting |
606 ↗ | (On Diff #111880) | I think HasSymbol would be a better name for this, and Sym != nullptr is a more readable way to force a boolean conversion. |
1708 ↗ | (On Diff #111880) | I think ParseIntelMemoryOperandSize would be a better name for this. |
1790 ↗ | (On Diff #111880) | Use != instead of <>, it's not commonly used. |
lgtm
lib/Target/X86/AsmParser/X86AsmParser.cpp | ||
---|---|---|
1306 ↗ | (On Diff #112459) | Woohoo, excited to see this go. :) |
lib/Target/X86/AsmParser/X86AsmParser.cpp | ||
---|---|---|
1306 ↗ | (On Diff #112459) | Aye, won't yearn for it either ! |