diff options
| author | Amy Kwan <amy.kwan1@ibm.com> | 2026-01-06 00:40:04 -0500 |
|---|---|---|
| committer | Amy Kwan <amy.kwan1@ibm.com> | 2026-01-06 00:40:04 -0500 |
| commit | c7f24718e30e42c036fc51414ff850dea14d445a (patch) | |
| tree | 4ec8e379c5774ac04faf7b37b1fdc4160418cfed | |
| parent | 7f9a00e59c569110ac2bdaa5f21d26eff9c1de65 (diff) | |
| download | llvm-users/amy-kwan/update-ADA-API.tar.gz llvm-users/amy-kwan/update-ADA-API.tar.bz2 llvm-users/amy-kwan/update-ADA-API.zip | |
[NFC][SystemZ] Update insert() API of the AssociatedDataAreaTable classusers/amy-kwan/update-ADA-API
This patch updates the insert() calls of the AssociatedDataAreaTable class
to return a pair of <const MCSymbol *, uint32_t> instead of just a uint32_t.
This API change of including the MCSymbol is needed in subsequent patches
to come.
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp | 28 | ||||
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZAsmPrinter.h | 9 |
2 files changed, 23 insertions, 14 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp index 444bc578a3fa..b36605ec5437 100644 --- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp +++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp @@ -170,13 +170,14 @@ void SystemZAsmPrinter::emitCallInformation(CallType CT) { .addReg(SystemZMC::GR64Regs[static_cast<unsigned>(CT)])); } -uint32_t SystemZAsmPrinter::AssociatedDataAreaTable::insert(const MCSymbol *Sym, - unsigned SlotKind) { +std::pair<const MCSymbol *, uint32_t> +SystemZAsmPrinter::AssociatedDataAreaTable::insert(const MCSymbol *Sym, + unsigned SlotKind) { auto Key = std::make_pair(Sym, SlotKind); - auto It = Displacements.find(Key); + auto *It = Displacements.find(Key); if (It != Displacements.end()) - return (*It).second; + return std::pair(Sym, (*It).second); // Determine length of descriptor. uint32_t Length; @@ -193,14 +194,15 @@ uint32_t SystemZAsmPrinter::AssociatedDataAreaTable::insert(const MCSymbol *Sym, Displacements[std::make_pair(Sym, SlotKind)] = NextDisplacement; NextDisplacement += Length; - return Displacement; + return std::pair(Sym, Displacement); } -uint32_t +std::pair<const MCSymbol *, uint32_t> SystemZAsmPrinter::AssociatedDataAreaTable::insert(const MachineOperand MO) { MCSymbol *Sym; if (MO.getType() == MachineOperand::MO_GlobalAddress) { const GlobalValue *GV = MO.getGlobal(); + assert(GV->hasName() && "Cannot put unnamed value in ADA"); Sym = MO.getParent()->getMF()->getTarget().getSymbol(GV); assert(Sym && "No symbol"); } else if (MO.getType() == MachineOperand::MO_ExternalSymbol) { @@ -347,7 +349,9 @@ void SystemZAsmPrinter::emitInstruction(const MachineInstr *MI) { case SystemZ::ADA_ENTRY: { const SystemZSubtarget &Subtarget = MF->getSubtarget<SystemZSubtarget>(); const SystemZInstrInfo *TII = Subtarget.getInstrInfo(); - uint32_t Disp = ADATable.insert(MI->getOperand(1)); + const MCSymbol *Sym; + uint32_t Disp; + std::tie(Sym, Disp) = ADATable.insert(MI->getOperand(1)); Register TargetReg = MI->getOperand(0).getReg(); Register ADAReg = MI->getOperand(2).getReg(); @@ -1562,13 +1566,17 @@ void SystemZAsmPrinter::emitPPA1(MCSymbol *FnEndSym) { OutStreamer->AddComment("Flags"); OutStreamer->emitInt32(0); // LSDA field is a WAS offset OutStreamer->AddComment("Personality routine"); - OutStreamer->emitInt64(ADATable.insert( - PersonalityRoutine, SystemZII::MO_ADA_INDIRECT_FUNC_DESC)); + // Store only offset of function descriptor + OutStreamer->emitInt64( + ADATable + .insert(PersonalityRoutine, SystemZII::MO_ADA_INDIRECT_FUNC_DESC) + .second); + // Store only offset of LSDA OutStreamer->AddComment("LSDA location"); MCSymbol *GCCEH = MF->getContext().getOrCreateSymbol( Twine("GCC_except_table") + Twine(MF->getFunctionNumber())); OutStreamer->emitInt64( - ADATable.insert(GCCEH, SystemZII::MO_ADA_DATA_SYMBOL_ADDR)); + ADATable.insert(GCCEH, SystemZII::MO_ADA_DATA_SYMBOL_ADDR).second); } // Emit name length and name optional section (0x01 of flags 4) diff --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h index cb101e472824..0611179ee726 100644 --- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h +++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.h @@ -73,16 +73,17 @@ private: /// @brief Add a function descriptor to the ADA. /// @param MI Pointer to an ADA_ENTRY instruction. - /// @return The displacement of the descriptor into the ADA. - uint32_t insert(const MachineOperand MO); + /// @return The symbol and displacement of the descriptor into the ADA. + std::pair<const MCSymbol *, uint32_t> insert(const MachineOperand MO); /// @brief Get the displacement into associated data area (ADA) for a name. /// If no displacement is already associated with the name, assign one and /// return it. /// @param Sym The symbol for which the displacement should be returned. /// @param SlotKind The ADA type. - /// @return The displacement of the descriptor into the ADA. - uint32_t insert(const MCSymbol *Sym, unsigned SlotKind); + /// @return The symbol and displacement of the descriptor into the ADA. + std::pair<const MCSymbol *, uint32_t> insert(const MCSymbol *Sym, + unsigned SlotKind); /// Get the table of GOFF displacements. This is 'const' since it should /// never be modified by anything except the APIs on this class. |
