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–378 | Can you clang-format this? | |
604 | formatting | |
606 | I think HasSymbol would be a better name for this, and Sym != nullptr is a more readable way to force a boolean conversion. | |
1708 | I think ParseIntelMemoryOperandSize would be a better name for this. | |
1790 | Use != instead of <>, it's not commonly used. |
lib/Target/X86/AsmParser/X86AsmParser.cpp | ||
---|---|---|
1306 | Aye, won't yearn for it either ! |
Can you clang-format this?