summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2006-05-02 05:37:32 +0000
committerNate Begeman <natebegeman@mac.com>2006-05-02 05:37:32 +0000
commitb9d4f8324dc6b076b48d1583ea55d7c9c22407ad (patch)
tree660fbbaf1dffadfba25f0240c6043dd370ea03e7 /llvm/lib
parent01364fbba8345f27e4c30fb8021a0a97094821a5 (diff)
downloadbcm5719-llvm-b9d4f8324dc6b076b48d1583ea55d7c9c22407ad.tar.gz
bcm5719-llvm-b9d4f8324dc6b076b48d1583ea55d7c9c22407ad.zip
Extend printBasicBlockLabel a bit so that it can be used to print all
basic block labels, consolidating the code to do so in one place for each target. llvm-svn: 28050
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter.cpp11
-rw-r--r--llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp5
-rw-r--r--llvm/lib/Target/IA64/IA64AsmPrinter.cpp8
-rw-r--r--llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp22
-rw-r--r--llvm/lib/Target/Sparc/SparcAsmPrinter.cpp8
-rwxr-xr-xllvm/lib/Target/X86/X86ATTAsmPrinter.cpp8
-rw-r--r--llvm/lib/Target/X86/X86AsmPrinter.cpp14
-rwxr-xr-xllvm/lib/Target/X86/X86AsmPrinter.h4
-rwxr-xr-xllvm/lib/Target/X86/X86IntelAsmPrinter.cpp8
9 files changed, 51 insertions, 37 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter.cpp
index 1753160e1f0..76a03dce95d 100644
--- a/llvm/lib/CodeGen/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter.cpp
@@ -728,9 +728,14 @@ bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
/// printBasicBlockLabel - This method prints the label for the specified
/// MachineBasicBlock
-void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB) const {
+void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
+ bool printColon,
+ bool printComment) const {
O << PrivateGlobalPrefix << "LBB"
<< Mang->getValueName(MBB->getParent()->getFunction())
- << "_" << MBB->getNumber() << '\t' << CommentString
- << MBB->getBasicBlock()->getName();
+ << "_" << MBB->getNumber();
+ if (printColon)
+ O << ':';
+ if (printComment)
+ O << '\t' << CommentString << MBB->getBasicBlock()->getName();
}
diff --git a/llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp b/llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp
index 5d1f522ca0a..b078b68bd7f 100644
--- a/llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp
+++ b/llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp
@@ -191,9 +191,8 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// Print out code for the function.
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
I != E; ++I) {
- // Print a label for the basic block.
- O << PrivateGlobalPrefix << "LBB" << CurrentFnName << "_" << I->getNumber()
- << ":\t" << CommentString << " " << I->getBasicBlock()->getName() << "\n";
+ printBasicBlockLabel(I, true);
+ O << '\n';
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
// Print the assembly for the instruction.
diff --git a/llvm/lib/Target/IA64/IA64AsmPrinter.cpp b/llvm/lib/Target/IA64/IA64AsmPrinter.cpp
index 359b6441044..7caf57362bf 100644
--- a/llvm/lib/Target/IA64/IA64AsmPrinter.cpp
+++ b/llvm/lib/Target/IA64/IA64AsmPrinter.cpp
@@ -153,10 +153,10 @@ bool IA64AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
I != E; ++I) {
// Print a label for the basic block if there are any predecessors.
- if (I->pred_begin() != I->pred_end())
- O << PrivateGlobalPrefix << "LBB" << CurrentFnName << "_"
- << I->getNumber() << ":\t"
- << CommentString << " " << I->getBasicBlock()->getName() << "\n";
+ if (I->pred_begin() != I->pred_end()) {
+ printBasicBlockLabel(I, true);
+ O << '\n';
+ }
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
// Print the assembly for the instruction.
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 11c0ec008b5..d32b3231fa8 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -233,7 +233,9 @@ namespace {
printOperand(MI, OpNo+1);
}
- virtual void printBasicBlockLabel(const MachineBasicBlock *MBB) const;
+ virtual void printBasicBlockLabel(const MachineBasicBlock *MBB,
+ bool printColon = false,
+ bool printComment = true) const;
virtual bool runOnMachineFunction(MachineFunction &F) = 0;
virtual bool doFinalization(Module &M) = 0;
@@ -505,10 +507,15 @@ void PPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
return;
}
-void PPCAsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB) const {
+void PPCAsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
+ bool printColon,
+ bool printComment) const {
O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << "_"
- << MBB->getNumber() << '\t' << CommentString
- << MBB->getBasicBlock()->getName();
+ << MBB->getNumber();
+ if (printColon)
+ O << ':';
+ if (printComment)
+ O << '\t' << CommentString << MBB->getBasicBlock()->getName();
}
/// runOnMachineFunction - This uses the printMachineInstruction()
@@ -557,11 +564,8 @@ bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
I != E; ++I) {
// Print a label for the basic block.
if (I != MF.begin()) {
- O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << '_'
- << I->getNumber() << ":\t";
- if (!I->getBasicBlock()->getName().empty())
- O << CommentString << " " << I->getBasicBlock()->getName();
- O << "\n";
+ printBasicBlockLabel(I, true);
+ O << '\n';
}
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
diff --git a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
index dc1ab545d76..b4c40f1844a 100644
--- a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
+++ b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
@@ -116,10 +116,10 @@ bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
I != E; ++I) {
// Print a label for the basic block.
- if (I != MF.begin())
- O << ".LBB" << Mang->getValueName(MF.getFunction ())
- << "_" << I->getNumber () << ":\t! "
- << I->getBasicBlock ()->getName () << "\n";
+ if (I != MF.begin()) {
+ printBasicBlockLabel(I, true);
+ O << '\n';
+ }
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
// Print the assembly for the instruction.
diff --git a/llvm/lib/Target/X86/X86ATTAsmPrinter.cpp b/llvm/lib/Target/X86/X86ATTAsmPrinter.cpp
index 38601188ff6..1b10123514d 100755
--- a/llvm/lib/Target/X86/X86ATTAsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86ATTAsmPrinter.cpp
@@ -80,10 +80,10 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
I != E; ++I) {
// Print a label for the basic block.
- if (I->pred_begin() != I->pred_end())
- O << PrivateGlobalPrefix << "BB" << CurrentFnName << "_" << I->getNumber()
- << ":\t" << CommentString << " " << I->getBasicBlock()->getName()
- << "\n";
+ if (I->pred_begin() != I->pred_end()) {
+ printBasicBlockLabel(I, true);
+ O << '\n';
+ }
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
// Print the assembly for the instruction.
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index ee1383e6c2e..2c41663d9d5 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -206,12 +206,16 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
return false; // success
}
-void X86SharedAsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB)
- const {
+void X86SharedAsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
+ bool printColon,
+ bool printComment) const {
O << PrivateGlobalPrefix << "BB"
- << Mang->getValueName(MBB->getParent()->getFunction())
- << "_" << MBB->getNumber() << '\t' << CommentString
- << MBB->getBasicBlock()->getName();
+ << Mang->getValueName(MBB->getParent()->getFunction()) << "_"
+ << MBB->getNumber();
+ if (printColon)
+ O << ':';
+ if (printComment)
+ O << '\t' << CommentString << MBB->getBasicBlock()->getName();
}
/// createX86CodePrinterPass - Returns a pass that prints the X86 assembly code
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.h b/llvm/lib/Target/X86/X86AsmPrinter.h
index fa84c9ec132..2d341d928b3 100755
--- a/llvm/lib/Target/X86/X86AsmPrinter.h
+++ b/llvm/lib/Target/X86/X86AsmPrinter.h
@@ -89,7 +89,9 @@ struct X86SharedAsmPrinter : public AsmPrinter {
MI->getOperand(Op+3).isConstantPoolIndex());
}
- virtual void printBasicBlockLabel(const MachineBasicBlock *MBB) const;
+ virtual void printBasicBlockLabel(const MachineBasicBlock *MBB,
+ bool printColon = false,
+ bool printComment = true) const;
};
} // end namespace llvm
diff --git a/llvm/lib/Target/X86/X86IntelAsmPrinter.cpp b/llvm/lib/Target/X86/X86IntelAsmPrinter.cpp
index 747d576695d..8f12446b61c 100755
--- a/llvm/lib/Target/X86/X86IntelAsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86IntelAsmPrinter.cpp
@@ -72,10 +72,10 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
I != E; ++I) {
// Print a label for the basic block if there are any predecessors.
- if (I->pred_begin() != I->pred_end())
- O << PrivateGlobalPrefix << "BB" << CurrentFnName << "_" << I->getNumber()
- << ":\t"
- << CommentString << " " << I->getBasicBlock()->getName() << "\n";
+ if (I->pred_begin() != I->pred_end()) {
+ printBasicBlockLabel(I, true);
+ O << '\n';
+ }
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
// Print the assembly for the instruction.
OpenPOWER on IntegriCloud