[llvm-dev] MASM & RIP-relative addressing
Eric Astor via llvm-dev
llvm-dev at lists.llvm.org
Mon Jan 20 18:25:52 PST 2020
Continuing work on llvm-ml (a MASM assembler)... and my latest obstacle is
in enabling MASM's convention that (unless specified) all memory location
references should be RIP-relative. Without it, we emit the wrong
instructions for "call", "jmp", etc., and anything we build fails at the
My best attempt at this so far is a small patch to X86AsmParser.cpp - just
taking any Intel expression with no specified base register and switching
it to use RIP - and this works alright. There's at least one exception: it
breaks the "jcc" instructions, at least "jcc <label>". The issue seems to
be that the "jcc" family exclusively takes a relative offset, never an
absolute reference... so adding a base register causes the operand not to
match. ("jcc" is always RIP-relative anyway.)
I'm not very familiar with the operand-matching logic, and am still pretty
new to LLVM as a whole. Are there more X86 instructions this will interact
badly with? Any thoughts on how this could be handled better?
If this is mostly a valid approach, might there be a way to change the
operand type of "jcc" to accept offset(base) operands, as long as base ==
X86::RIP, then ignore the RIP bit?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev