Teach operand parsing to distinguish between assembler variable assigned to
named registers and those assigned to immediate values.
Details
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 26512 Build 26511: arc lint + arc unit
Event Timeline
Could use some test-cases for the error parsees, not just the successful parses.
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | ||
---|---|---|
1963 | Since this is quite long, it may make sense to put the whole thing into ParseMemOperand -- perhaps renaming 'ParseX86MemOperandOrRegister'. | |
1984 | I think it'd be clearer to create a temporary name e.g. "Expr" to use instead of "Imm" inside this block, for the expression value which is either an imm or register. And only assign to Imm in the "else" of the dyn_cast<X86MCExpr> conditional. | |
1988 | Typo -> "Parse out" | |
2033 | This entire block should be split into a separate "isAtMemOperand" helper function. | |
2036 | I'd write > 0 here, the >= 1 vs the > 1 below confused me for a second. | |
2043 | These lower cases are effectively implementing a "peekIdentifier" operation. It would be good to have a comment to that effect. Or, maybe peekIdentifier should even be split out as a separate function. | |
2074 | Is this guaranteed to be true? | |
2083–2084 | "If we're not at a "(" this is an immediate expression." is confusing, because it sounds like "this" is the upcoming tokens, not those already parsed. Probably can just be removed as redundant witht he first sentence. | |
2103 | No error message if !isa<X86MCExpr>? |
Add error tests and do minor reorganization to parseExpression to existant extra invalid token errors.
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | ||
---|---|---|
2074 | Yes. The previous peekidentifier should return true if it was a register. |
Since this is quite long, it may make sense to put the whole thing into ParseMemOperand -- perhaps renaming 'ParseX86MemOperandOrRegister'.