[llvm] [Xtensa] Lower GlobalAddress/BlockAddress/JumpTable (PR #95256)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 08:25:26 PDT 2024
================
@@ -52,16 +64,25 @@ void XtensaAsmPrinter::emitMachineConstantPoolValue(
XtensaConstantPoolValue *ACPV = static_cast<XtensaConstantPoolValue *>(MCPV);
MCSymbol *MCSym;
- assert(ACPV->isExtSymbol() && "unrecognized constant pool value");
+ 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 *Sym = XtensaSym->getSymbol();
+ std::string SymName(Sym);
- XtensaConstantPoolSymbol *XtensaSym = cast<XtensaConstantPoolSymbol>(ACPV);
- const char *Sym = XtensaSym->getSymbol();
- std::string SymName(Sym);
+ if (XtensaSym->isPrivateLinkage())
+ SymName = ".L" + SymName;
- if (XtensaSym->isPrivateLinkage())
- SymName = ".L" + SymName;
+ MCSym = GetExternalSymbolSymbol(StringRef(SymName));
----------------
arsenm wrote:
GetExternalSymbolSymbol uses Twine so you shouldn't need to build a new std::string here for the prefix. Also avoid hardcoding the prefix. Also, can't you just use getOrCreateSymbol? I think that takes care of the prefix?
https://github.com/llvm/llvm-project/pull/95256
More information about the llvm-commits
mailing list