summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-10-30 01:27:03 +0000
committerDan Gohman <gohman@apple.com>2009-10-30 01:27:03 +0000
commit6c9388011b8a4b6985e0d17dbfe12ffd4aa405fa (patch)
treeee4402944c4ed14c2b873133d97b40cc0299b2f1 /llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
parent430046321bc6272a808f3e158f11dcabd268c653 (diff)
downloadbcm5719-llvm-6c9388011b8a4b6985e0d17dbfe12ffd4aa405fa.tar.gz
bcm5719-llvm-6c9388011b8a4b6985e0d17dbfe12ffd4aa405fa.zip
Initial target-independent CodeGen support for BlockAddresses.
llvm-svn: 85556
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 8bc5ef91cdf..257b963f9b4 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1613,6 +1613,22 @@ bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
return true;
}
+MCSymbol *AsmPrinter::GetBlockAddressSymbol(const BlockAddress *BA) const {
+ return GetBlockAddressSymbol(BA->getFunction(), BA->getBasicBlock());
+}
+
+MCSymbol *AsmPrinter::GetBlockAddressSymbol(const Function *F,
+ const BasicBlock *BB) const {
+ assert(BB->hasName() &&
+ "Address of anonymous basic block not supported yet!");
+
+ std::string Mangled =
+ Mang->getMangledName(F, Mang->makeNameProper(BB->getName()).c_str(),
+ /*ForcePrivate=*/true);
+
+ return OutContext.GetOrCreateSymbol(StringRef(Mangled));
+}
+
MCSymbol *AsmPrinter::GetMBBSymbol(unsigned MBBID) const {
SmallString<60> Name;
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "BB"
@@ -1629,6 +1645,17 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const {
if (unsigned Align = MBB->getAlignment())
EmitAlignment(Log2_32(Align));
+ if (MBB->hasAddressTaken()) {
+ GetBlockAddressSymbol(MBB->getBasicBlock()->getParent(),
+ MBB->getBasicBlock())->print(O, MAI);
+ O << ':';
+ if (VerboseAsm) {
+ O.PadToColumn(MAI->getCommentColumn());
+ O << MAI->getCommentString() << " Address Taken";
+ }
+ O << '\n';
+ }
+
if (MBB->pred_empty() || MBB->isOnlyReachableByFallthrough()) {
if (VerboseAsm)
O << MAI->getCommentString() << " BB#" << MBB->getNumber() << ':';
OpenPOWER on IntegriCloud