[llvm-dev] Adding fix-up information to an instruction created with BuildMI
Tim Northover via llvm-dev
llvm-dev at lists.llvm.org
Wed Apr 20 07:17:36 PDT 2016
On 20 April 2016 at 06:22, Chris.Dewhurst via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> MIB = BuildMI(*thisMBB, MI, DL, TII->get(SP::SETHIi), LabelReg)
> // Need some code here to mark that a Sparc HI22 fix-up is needed on this
There's a second "TargetFlags" argument to addMBB which encodes
information about the type of fixup needed. The rough sequence is:
1. You pass some "VK_*" argument there.
2. This gets attached to an MCExpr MCOperand when the MachineInstr ->
MCInst lowering takes place (SparcMCInstLower.cpp,
3. During MCCodeEmitter this gets converted into a fixup_* style fixup
(getMachineOpValue via a call to getFixupKind) and push_backed onto a
list of Fixups (separate from the instruction now).
4. Finally, this fixup either gets resolved in SparcAsmBackend
(hopefully this, for an MBB) or converted to an R_SPARC_* relocation
in SparcELFObjectWriter.cpp (goodness knows what would happen there,
since an MBB normally gets an assembler-local symbol).
So your main goal is going to be working out which kind of VK_* tag
you really need (see SparcMCExpr.h for the list). It *looks* like that
would be VK_Sparc_HI (& LO for your other inst), but that's just going
by the names -- I actually know basically nothing about Sparc.
More information about the llvm-dev