[PATCH] D127972: [AsmPrinter] Further restrict expressions supported in global initializers
Chris Lattner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 27 13:20:29 PDT 2022
lattner added a comment.
I'm not a competent reviewer for this patch, but it caused me to looked up other uses of `MCBinaryExpr::createDiv`, I see the ARM backend is doing this:
// Otherwise it's an offset from the dispatch instruction. Construct an
// MCExpr for the entry. We want a value of the form:
// (BasicBlockAddr - TBBInstAddr + 4) / 2
//
// For example, a TBB table with entries jumping to basic blocks BB0 and BB1
// would look like:
// LJTI_0_0:
// .byte (LBB0 - (LCPI0_0 + 4)) / 2
// .byte (LBB1 - (LCPI0_0 + 4)) / 2
// where LCPI0_0 is a label defined just before the TBB instruction using
// this table.
MCSymbol *TBInstPC = GetCPISymbol(MI->getOperand(0).getImm());
const MCExpr *Expr = MCBinaryExpr::createAdd(
MCSymbolRefExpr::create(TBInstPC, OutContext),
MCConstantExpr::create(4, OutContext), OutContext);
Expr = MCBinaryExpr::createSub(MBBSymbolExpr, Expr, OutContext);
Expr = MCBinaryExpr::createDiv(Expr, MCConstantExpr::create(2, OutContext),
OutContext);
This is super crazy. MC should support target specific relocations like this. I'm pretty sure this has to have magic pattern matching in the assembler?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127972/new/
https://reviews.llvm.org/D127972
More information about the llvm-commits
mailing list