From 0e6e8cb590e59d31008f0c9467f586caeeac8ecd Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 21 Jul 2009 16:44:47 +0000 Subject: [PATCH] some simple whitespace cleanup, avoid copying vectors for no reason as much, etc. llvm-svn: 76578 --- llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp | 55 ++++++++++++++----------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp b/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp index ca654a3..084038d 100644 --- a/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp +++ b/llvm/lib/Target/PIC16/PIC16AsmPrinter.cpp @@ -64,7 +64,7 @@ bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) { SectionFlags::Code); // Start the Code Section. O << "\n"; - SwitchToSection (fCodeSection); + SwitchToSection(fCodeSection); // Emit the frame address of the function at the beginning of code. O << "\tretlw low(" << PAN::getFrameLabel(CurrentFnName) << ")\n"; @@ -190,7 +190,7 @@ void PIC16AsmPrinter::printLibcallDecls(void) { /// One task that we do here is to sectionize all global variables. /// The MemSelOptimizer pass depends on the sectionizing. /// -bool PIC16AsmPrinter::doInitialization (Module &M) { +bool PIC16AsmPrinter::doInitialization(Module &M) { bool Result = AsmPrinter::doInitialization(M); // FIXME:: This is temporary solution to generate the include file. @@ -218,7 +218,7 @@ bool PIC16AsmPrinter::doInitialization (Module &M) { /// global declarations for function defined in this module and which are /// available to other modules. /// -void PIC16AsmPrinter::EmitFunctionDecls (Module &M) { +void PIC16AsmPrinter::EmitFunctionDecls(Module &M) { // Emit declarations for external functions. O <<"\n"<getCommentString() << "Function Declarations - BEGIN." <<"\n"; for (Module::iterator I = M.begin(), E = M.end(); I != E; I++) { @@ -230,7 +230,7 @@ void PIC16AsmPrinter::EmitFunctionDecls (Module &M) { if (Name.find("llvm.") != std::string::npos) continue; - if (! (I->isDeclaration() || I->hasExternalLinkage())) + if (!I->isDeclaration() && !I->hasExternalLinkage()) continue; const char *directive = I->isDeclaration() ? TAI->getExternDirective() : @@ -245,10 +245,9 @@ void PIC16AsmPrinter::EmitFunctionDecls (Module &M) { } // Emit variables imported from other Modules. -void PIC16AsmPrinter::EmitUndefinedVars (Module &M) -{ +void PIC16AsmPrinter::EmitUndefinedVars(Module &M) { std::vector Items = PTAI->ExternalVarDecls->Items; - if (! Items.size()) return; + if (!Items.size()) return; O << "\n" << TAI->getCommentString() << "Imported Variables - BEGIN" << "\n"; for (unsigned j = 0; j < Items.size(); j++) { @@ -258,10 +257,9 @@ void PIC16AsmPrinter::EmitUndefinedVars (Module &M) } // Emit variables defined in this module and are available to other modules. -void PIC16AsmPrinter::EmitDefinedVars (Module &M) -{ +void PIC16AsmPrinter::EmitDefinedVars(Module &M) { std::vector Items = PTAI->ExternalVarDefs->Items; - if (! Items.size()) return; + if (!Items.size()) return; O << "\n" << TAI->getCommentString() << "Exported Variables - BEGIN" << "\n"; for (unsigned j = 0; j < Items.size(); j++) { @@ -271,13 +269,12 @@ void PIC16AsmPrinter::EmitDefinedVars (Module &M) } // Emit initialized data placed in ROM. -void PIC16AsmPrinter::EmitRomData (Module &M) -{ +void PIC16AsmPrinter::EmitRomData(Module &M) { // Print ROM Data section. - std::vector ROSections = PTAI->ROSections; + const std::vector &ROSections = PTAI->ROSections; for (unsigned i = 0; i < ROSections.size(); i++) { - std::vector Items = ROSections[i]->Items; - if (! Items.size()) continue; + const std::vector &Items = ROSections[i]->Items; + if (!Items.size()) continue; O << "\n"; SwitchToSection(PTAI->ROSections[i]->S_); for (unsigned j = 0; j < Items.size(); j++) { @@ -339,14 +336,14 @@ void PIC16AsmPrinter::EmitFunctionFrame(MachineFunction &MF) { // Emit temporary space int TempSize = PTLI->GetTmpSize(); - if (TempSize > 0 ) - O << PAN::getTempdataLabel(CurrentFnName) << " RES " << TempSize <<"\n"; + if (TempSize > 0) + O << PAN::getTempdataLabel(CurrentFnName) << " RES " << TempSize << '\n'; } -void PIC16AsmPrinter::EmitIData (Module &M) { +void PIC16AsmPrinter::EmitIData(Module &M) { // Print all IDATA sections. - std::vector IDATASections = PTAI->IDATASections; + const std::vector &IDATASections = PTAI->IDATASections; for (unsigned i = 0; i < IDATASections.size(); i++) { O << "\n"; if (IDATASections[i]->S_->getName().find("llvm.") != std::string::npos) @@ -363,11 +360,11 @@ void PIC16AsmPrinter::EmitIData (Module &M) { } } -void PIC16AsmPrinter::EmitUData (Module &M) { +void PIC16AsmPrinter::EmitUData(Module &M) { const TargetData *TD = TM.getTargetData(); // Print all BSS sections. - std::vector BSSSections = PTAI->BSSSections; + const std::vector &BSSSections = PTAI->BSSSections; for (unsigned i = 0; i < BSSSections.size(); i++) { O << "\n"; SwitchToSection(BSSSections[i]->S_); @@ -378,28 +375,25 @@ void PIC16AsmPrinter::EmitUData (Module &M) { const Type *Ty = C->getType(); unsigned Size = TD->getTypeAllocSize(Ty); - O << Name << " " <<"RES"<< " " << Size ; - O << "\n"; + O << Name << " RES " << Size << "\n"; } } } -void PIC16AsmPrinter::EmitAutos (std::string FunctName) -{ +void PIC16AsmPrinter::EmitAutos(std::string FunctName) { // Section names for all globals are already set. - const TargetData *TD = TM.getTargetData(); // Now print Autos section for this function. std::string SectionName = PAN::getAutosSectionName(FunctName); - std::vector AutosSections = PTAI->AutosSections; + const std::vector &AutosSections = PTAI->AutosSections; for (unsigned i = 0; i < AutosSections.size(); i++) { O << "\n"; if (AutosSections[i]->S_->getName() == SectionName) { // Set the printing status to true AutosSections[i]->setPrintedStatus(true); SwitchToSection(AutosSections[i]->S_); - std::vector Items = AutosSections[i]->Items; + const std::vector &Items = AutosSections[i]->Items; for (unsigned j = 0; j < Items.size(); j++) { std::string VarName = Mang->getMangledName(Items[j]); Constant *C = Items[j]->getInitializer(); @@ -415,8 +409,7 @@ void PIC16AsmPrinter::EmitAutos (std::string FunctName) // Print autos that were not printed during the code printing of functions. // As the functions might themselves would have got deleted by the optimizer. -void PIC16AsmPrinter::EmitRemainingAutos() -{ +void PIC16AsmPrinter::EmitRemainingAutos() { const TargetData *TD = TM.getTargetData(); // Now print Autos section for this function. @@ -432,7 +425,7 @@ void PIC16AsmPrinter::EmitRemainingAutos() O << "\n"; SwitchToSection(AutosSections[i]->S_); - std::vector Items = AutosSections[i]->Items; + const std::vector &Items = AutosSections[i]->Items; for (unsigned j = 0; j < Items.size(); j++) { std::string VarName = Mang->getMangledName(Items[j]); Constant *C = Items[j]->getInitializer(); -- 2.7.4