[llvm] [Xtensa] Lower GlobalAddress/BlockAddress/JumpTable (PR #95256)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 17 23:16:50 PDT 2024
================
@@ -42,26 +43,48 @@ getModifierVariantKind(XtensaCP::XtensaCPModifier Modifier) {
}
void XtensaAsmPrinter::emitInstruction(const MachineInstr *MI) {
- MCInst LoweredMI;
- lowerToMCInst(MI, LoweredMI);
- EmitToStreamer(*OutStreamer, LoweredMI);
+ unsigned Opc = MI->getOpcode();
+
+ switch (Opc) {
+ case Xtensa::BR_JT:
+ EmitToStreamer(
+ *OutStreamer,
+ MCInstBuilder(Xtensa::JX).addReg(MI->getOperand(0).getReg()));
+ return;
+ default:
+ MCInst LoweredMI;
+ lowerToMCInst(MI, LoweredMI);
+ EmitToStreamer(*OutStreamer, LoweredMI);
+ return;
+ }
}
void XtensaAsmPrinter::emitMachineConstantPoolValue(
MachineConstantPoolValue *MCPV) {
XtensaConstantPoolValue *ACPV = static_cast<XtensaConstantPoolValue *>(MCPV);
MCSymbol *MCSym;
- assert(ACPV->isExtSymbol() && "unrecognized constant pool value");
-
- XtensaConstantPoolSymbol *XtensaSym = cast<XtensaConstantPoolSymbol>(ACPV);
- const char *Sym = XtensaSym->getSymbol();
- std::string SymName(Sym);
-
- if (XtensaSym->isPrivateLinkage())
- SymName = ".L" + SymName;
+ if (ACPV->isBlockAddress()) {
+ const BlockAddress *BA =
+ cast<XtensaConstantPoolConstant>(ACPV)->getBlockAddress();
+ MCSym = GetBlockAddressSymbol(BA);
+ } else if (ACPV->isJumpTable()) {
+ unsigned Idx = cast<XtensaConstantPoolJumpTable>(ACPV)->getIndex();
+ MCSym = this->GetJTISymbol(Idx, false);
+ } else {
+ assert(ACPV->isExtSymbol() && "unrecognized constant pool value");
+ XtensaConstantPoolSymbol *XtensaSym = cast<XtensaConstantPoolSymbol>(ACPV);
+ const char *SymName = XtensaSym->getSymbol();
+
+ if (XtensaSym->isPrivateLinkage()) {
+ const DataLayout &DL = getDataLayout();
+ MCSym = OutContext.getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
+ SymName);
----------------
arsenm wrote:
I think something further down is supposed to append the prefix for you but I'm no MC expert
https://github.com/llvm/llvm-project/pull/95256
More information about the llvm-commits
mailing list