[llvm] [Xtensa] Implement base CallConvention. (PR #83280)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 23 17:04:26 PDT 2024
================
@@ -25,12 +29,193 @@
using namespace llvm;
+static MCSymbolRefExpr::VariantKind
+getModifierVariantKind(XtensaCP::XtensaCPModifier Modifier) {
+ switch (Modifier) {
+ case XtensaCP::no_modifier:
+ return MCSymbolRefExpr::VK_None;
+ case XtensaCP::TPOFF:
+ return MCSymbolRefExpr::VK_TPOFF;
+ }
+ report_fatal_error("Invalid XtensaCPModifier!");
+}
+
void XtensaAsmPrinter::emitInstruction(const MachineInstr *MI) {
MCInst LoweredMI;
lowerToMCInst(MI, LoweredMI);
EmitToStreamer(*OutStreamer, LoweredMI);
}
+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;
+ MCSym = GetExternalSymbolSymbol(StringRef(SymName));
+
+ MCSymbol *LblSym = GetCPISymbol(ACPV->getLabelId());
+ // TODO find a better way to check whether we emit data to .s file
+ if (OutStreamer->hasRawTextSupport()) {
+ SmallString<60> Str;
+ raw_svector_ostream LiteralStr(Str);
+ LiteralStr << "\t.literal " << LblSym->getName() << ", "
+ << MCSym->getName();
+
+ StringRef Modifier = ACPV->getModifierText();
+ LiteralStr << Modifier;
+
+ OutStreamer->emitRawText(StringRef(LiteralStr.str()));
----------------
s-barannikov wrote:
It would be nice to use `XtensaTargetStreamer::emitLiteral` and avoid if/else.
https://github.com/llvm/llvm-project/pull/83280
More information about the llvm-commits
mailing list