diff options
author | Misha Brukman <brukman+llvm@gmail.com> | 2004-06-25 15:42:10 +0000 |
---|---|---|
committer | Misha Brukman <brukman+llvm@gmail.com> | 2004-06-25 15:42:10 +0000 |
commit | 2bf183c092138e426c7f66bb072d8e0f7de36648 (patch) | |
tree | d67dd247b2c598c209f350a96f5dcf6fe6c49c11 | |
parent | fa0818711ae6f226cece78c1f79238bb683ef911 (diff) |
* Be consistent about MachineBB labels and references to them in instr stream
* Use MachineBB's built-in numbering system instead of reinventing one
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14408 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/PowerPC/PPC32AsmPrinter.cpp | 28 | ||||
-rw-r--r-- | lib/Target/PowerPC/PPCAsmPrinter.cpp | 28 | ||||
-rw-r--r-- | lib/Target/PowerPC/PowerPCAsmPrinter.cpp | 28 |
3 files changed, 18 insertions, 66 deletions
diff --git a/lib/Target/PowerPC/PPC32AsmPrinter.cpp b/lib/Target/PowerPC/PPC32AsmPrinter.cpp index 8a4e59bf1d..a200ce714e 100644 --- a/lib/Target/PowerPC/PPC32AsmPrinter.cpp +++ b/lib/Target/PowerPC/PPC32AsmPrinter.cpp @@ -55,13 +55,6 @@ namespace { Printer(std::ostream &o, TargetMachine &tm) : O(o), TM(tm) { } - /// We name each basic block in a Function with a unique number, so - /// that we can consistently refer to them later. This is cleared - /// at the beginning of each call to runOnMachineFunction(). - /// - typedef std::map<const Value *, unsigned> ValueMapTy; - ValueMapTy NumberForBB; - /// Cache of mangled name for current function. This is /// recalculated at the beginning of each call to /// runOnMachineFunction(). @@ -297,9 +290,8 @@ void Printer::emitGlobalConstant(const Constant *CV) { } } } else if (CV->getType()->getPrimitiveSize() == 64) { - const ConstantInt *CI = dyn_cast<ConstantInt>(CV); - if(CI) { - union DU { // Abide by C TBAA rules + if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { + union DU { // Abide by C TBAA rules int64_t UVal; struct { uint32_t MSWord; @@ -385,19 +377,11 @@ bool Printer::runOnMachineFunction(MachineFunction &MF) { O << "\t.align 5\n"; O << CurrentFnName << ":\n"; - // Number each basic block so that we can consistently refer to them - // in PC-relative references. - NumberForBB.clear(); - for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); - I != E; ++I) { - NumberForBB[I->getBasicBlock()] = BBNumber++; - } - // 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 << "L" << NumberForBB[I->getBasicBlock()] << ":\t# " + O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t# " << I->getBasicBlock()->getName() << "\n"; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); II != E; ++II) { @@ -434,8 +418,8 @@ void Printer::printOp(const MachineOperand &MO, case MachineOperand::MO_MachineBasicBlock: { MachineBasicBlock *MBBOp = MO.getMachineBasicBlock(); O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction()) - << "_" << MBBOp->getNumber () << "\t# " - << MBBOp->getBasicBlock ()->getName (); + << "_" << MBBOp->getNumber() << "\t# " + << MBBOp->getBasicBlock()->getName(); return; } case MachineOperand::MO_PCRelativeDisp: @@ -525,7 +509,7 @@ void Printer::printMachineInstruction(const MachineInstr *MI) { if (Opcode == PPC32::MovePCtoLR) { O << "mflr r0\n"; O << "bcl 20,31,L" << CurrentFnName << "$pb\n"; - O << "L" << CurrentFnName << "$pb:\n"; + O << "L" << CurrentFnName << "$pb:\n"; return; } diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index 8a4e59bf1d..a200ce714e 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -55,13 +55,6 @@ namespace { Printer(std::ostream &o, TargetMachine &tm) : O(o), TM(tm) { } - /// We name each basic block in a Function with a unique number, so - /// that we can consistently refer to them later. This is cleared - /// at the beginning of each call to runOnMachineFunction(). - /// - typedef std::map<const Value *, unsigned> ValueMapTy; - ValueMapTy NumberForBB; - /// Cache of mangled name for current function. This is /// recalculated at the beginning of each call to /// runOnMachineFunction(). @@ -297,9 +290,8 @@ void Printer::emitGlobalConstant(const Constant *CV) { } } } else if (CV->getType()->getPrimitiveSize() == 64) { - const ConstantInt *CI = dyn_cast<ConstantInt>(CV); - if(CI) { - union DU { // Abide by C TBAA rules + if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { + union DU { // Abide by C TBAA rules int64_t UVal; struct { uint32_t MSWord; @@ -385,19 +377,11 @@ bool Printer::runOnMachineFunction(MachineFunction &MF) { O << "\t.align 5\n"; O << CurrentFnName << ":\n"; - // Number each basic block so that we can consistently refer to them - // in PC-relative references. - NumberForBB.clear(); - for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); - I != E; ++I) { - NumberForBB[I->getBasicBlock()] = BBNumber++; - } - // 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 << "L" << NumberForBB[I->getBasicBlock()] << ":\t# " + O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t# " << I->getBasicBlock()->getName() << "\n"; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); II != E; ++II) { @@ -434,8 +418,8 @@ void Printer::printOp(const MachineOperand &MO, case MachineOperand::MO_MachineBasicBlock: { MachineBasicBlock *MBBOp = MO.getMachineBasicBlock(); O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction()) - << "_" << MBBOp->getNumber () << "\t# " - << MBBOp->getBasicBlock ()->getName (); + << "_" << MBBOp->getNumber() << "\t# " + << MBBOp->getBasicBlock()->getName(); return; } case MachineOperand::MO_PCRelativeDisp: @@ -525,7 +509,7 @@ void Printer::printMachineInstruction(const MachineInstr *MI) { if (Opcode == PPC32::MovePCtoLR) { O << "mflr r0\n"; O << "bcl 20,31,L" << CurrentFnName << "$pb\n"; - O << "L" << CurrentFnName << "$pb:\n"; + O << "L" << CurrentFnName << "$pb:\n"; return; } diff --git a/lib/Target/PowerPC/PowerPCAsmPrinter.cpp b/lib/Target/PowerPC/PowerPCAsmPrinter.cpp index 8a4e59bf1d..a200ce714e 100644 --- a/lib/Target/PowerPC/PowerPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PowerPCAsmPrinter.cpp @@ -55,13 +55,6 @@ namespace { Printer(std::ostream &o, TargetMachine &tm) : O(o), TM(tm) { } - /// We name each basic block in a Function with a unique number, so - /// that we can consistently refer to them later. This is cleared - /// at the beginning of each call to runOnMachineFunction(). - /// - typedef std::map<const Value *, unsigned> ValueMapTy; - ValueMapTy NumberForBB; - /// Cache of mangled name for current function. This is /// recalculated at the beginning of each call to /// runOnMachineFunction(). @@ -297,9 +290,8 @@ void Printer::emitGlobalConstant(const Constant *CV) { } } } else if (CV->getType()->getPrimitiveSize() == 64) { - const ConstantInt *CI = dyn_cast<ConstantInt>(CV); - if(CI) { - union DU { // Abide by C TBAA rules + if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { + union DU { // Abide by C TBAA rules int64_t UVal; struct { uint32_t MSWord; @@ -385,19 +377,11 @@ bool Printer::runOnMachineFunction(MachineFunction &MF) { O << "\t.align 5\n"; O << CurrentFnName << ":\n"; - // Number each basic block so that we can consistently refer to them - // in PC-relative references. - NumberForBB.clear(); - for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); - I != E; ++I) { - NumberForBB[I->getBasicBlock()] = BBNumber++; - } - // 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 << "L" << NumberForBB[I->getBasicBlock()] << ":\t# " + O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t# " << I->getBasicBlock()->getName() << "\n"; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); II != E; ++II) { @@ -434,8 +418,8 @@ void Printer::printOp(const MachineOperand &MO, case MachineOperand::MO_MachineBasicBlock: { MachineBasicBlock *MBBOp = MO.getMachineBasicBlock(); O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction()) - << "_" << MBBOp->getNumber () << "\t# " - << MBBOp->getBasicBlock ()->getName (); + << "_" << MBBOp->getNumber() << "\t# " + << MBBOp->getBasicBlock()->getName(); return; } case MachineOperand::MO_PCRelativeDisp: @@ -525,7 +509,7 @@ void Printer::printMachineInstruction(const MachineInstr *MI) { if (Opcode == PPC32::MovePCtoLR) { O << "mflr r0\n"; O << "bcl 20,31,L" << CurrentFnName << "$pb\n"; - O << "L" << CurrentFnName << "$pb:\n"; + O << "L" << CurrentFnName << "$pb:\n"; return; } |