mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-30 16:17:05 +00:00 
			
		
		
		
	Avoid creating expensive comment string if it's not going to be printed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52992 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -93,6 +93,10 @@ namespace llvm { | |||||||
|   /// RealignStack - This flag indicates, whether stack should be automatically |   /// RealignStack - This flag indicates, whether stack should be automatically | ||||||
|   /// realigned, if needed. |   /// realigned, if needed. | ||||||
|   extern bool RealignStack; |   extern bool RealignStack; | ||||||
|  |  | ||||||
|  |   /// VerboseAsm - When this flag is set, the asm printer prints additional | ||||||
|  |   /// comments to asm directives. | ||||||
|  |   extern bool VerboseAsm; | ||||||
| } // End llvm namespace | } // End llvm namespace | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -21,7 +21,6 @@ | |||||||
| #include "llvm/CodeGen/MachineConstantPool.h" | #include "llvm/CodeGen/MachineConstantPool.h" | ||||||
| #include "llvm/CodeGen/MachineJumpTableInfo.h" | #include "llvm/CodeGen/MachineJumpTableInfo.h" | ||||||
| #include "llvm/CodeGen/MachineModuleInfo.h" | #include "llvm/CodeGen/MachineModuleInfo.h" | ||||||
| #include "llvm/Support/CommandLine.h" |  | ||||||
| #include "llvm/Support/Mangler.h" | #include "llvm/Support/Mangler.h" | ||||||
| #include "llvm/Support/MathExtras.h" | #include "llvm/Support/MathExtras.h" | ||||||
| #include "llvm/Support/Streams.h" | #include "llvm/Support/Streams.h" | ||||||
| @@ -29,14 +28,12 @@ | |||||||
| #include "llvm/Target/TargetData.h" | #include "llvm/Target/TargetData.h" | ||||||
| #include "llvm/Target/TargetLowering.h" | #include "llvm/Target/TargetLowering.h" | ||||||
| #include "llvm/Target/TargetMachine.h" | #include "llvm/Target/TargetMachine.h" | ||||||
|  | #include "llvm/Target/TargetOptions.h" | ||||||
| #include "llvm/Target/TargetRegisterInfo.h" | #include "llvm/Target/TargetRegisterInfo.h" | ||||||
| #include "llvm/ADT/SmallPtrSet.h" | #include "llvm/ADT/SmallPtrSet.h" | ||||||
| #include <cerrno> | #include <cerrno> | ||||||
| using namespace llvm; | using namespace llvm; | ||||||
|  |  | ||||||
| static cl::opt<bool> |  | ||||||
| AsmVerbose("asm-verbose", cl::Hidden, cl::desc("Add comments to directives.")); |  | ||||||
|  |  | ||||||
| char AsmPrinter::ID = 0; | char AsmPrinter::ID = 0; | ||||||
| AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm, | AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm, | ||||||
|                        const TargetAsmInfo *T) |                        const TargetAsmInfo *T) | ||||||
| @@ -553,7 +550,7 @@ void AsmPrinter::EOL() const { | |||||||
| } | } | ||||||
|  |  | ||||||
| void AsmPrinter::EOL(const std::string &Comment) const { | void AsmPrinter::EOL(const std::string &Comment) const { | ||||||
|   if (AsmVerbose && !Comment.empty()) { |   if (VerboseAsm && !Comment.empty()) { | ||||||
|     O << '\t' |     O << '\t' | ||||||
|       << TAI->getCommentString() |       << TAI->getCommentString() | ||||||
|       << ' ' |       << ' ' | ||||||
| @@ -563,7 +560,7 @@ void AsmPrinter::EOL(const std::string &Comment) const { | |||||||
| } | } | ||||||
|  |  | ||||||
| void AsmPrinter::EOL(const char* Comment) const { | void AsmPrinter::EOL(const char* Comment) const { | ||||||
|   if (AsmVerbose && *Comment) { |   if (VerboseAsm && *Comment) { | ||||||
|     O << '\t' |     O << '\t' | ||||||
|       << TAI->getCommentString() |       << TAI->getCommentString() | ||||||
|       << ' ' |       << ' ' | ||||||
|   | |||||||
| @@ -2076,11 +2076,15 @@ private: | |||||||
|  |  | ||||||
|     // Emit the code (index) for the abbreviation. |     // Emit the code (index) for the abbreviation. | ||||||
|     Asm->EmitULEB128Bytes(AbbrevNumber); |     Asm->EmitULEB128Bytes(AbbrevNumber); | ||||||
|  |  | ||||||
|  |     if (VerboseAsm) | ||||||
|       Asm->EOL(std::string("Abbrev [" + |       Asm->EOL(std::string("Abbrev [" + | ||||||
|                            utostr(AbbrevNumber) + |                            utostr(AbbrevNumber) + | ||||||
|                            "] 0x" + utohexstr(Die->getOffset()) + |                            "] 0x" + utohexstr(Die->getOffset()) + | ||||||
|                            ":0x" + utohexstr(Die->getSize()) + " " + |                            ":0x" + utohexstr(Die->getSize()) + " " + | ||||||
|                            TagString(Abbrev->getTag()))); |                            TagString(Abbrev->getTag()))); | ||||||
|  |     else | ||||||
|  |       Asm->EOL(); | ||||||
|      |      | ||||||
|     SmallVector<DIEValue*, 32> &Values = Die->getValues(); |     SmallVector<DIEValue*, 32> &Values = Die->getValues(); | ||||||
|     const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData(); |     const SmallVector<DIEAbbrevData, 8> &AbbrevData = Abbrev->getData(); | ||||||
| @@ -2297,8 +2301,7 @@ private: | |||||||
|     Asm->EmitInt8(1); Asm->EOL("DW_LNS_fixed_advance_pc arg count"); |     Asm->EmitInt8(1); Asm->EOL("DW_LNS_fixed_advance_pc arg count"); | ||||||
|  |  | ||||||
|     const UniqueVector<std::string> &Directories = MMI->getDirectories(); |     const UniqueVector<std::string> &Directories = MMI->getDirectories(); | ||||||
|     const UniqueVector<SourceFileInfo> |     const UniqueVector<SourceFileInfo> &SourceFiles = MMI->getSourceFiles(); | ||||||
|       &SourceFiles = MMI->getSourceFiles(); |  | ||||||
|  |  | ||||||
|     // Emit directories. |     // Emit directories. | ||||||
|     for (unsigned DirectoryID = 1, NDID = Directories.size(); |     for (unsigned DirectoryID = 1, NDID = Directories.size(); | ||||||
| @@ -2329,7 +2332,10 @@ private: | |||||||
|       // Isolate current sections line info. |       // Isolate current sections line info. | ||||||
|       const std::vector<SourceLineInfo> &LineInfos = SectionSourceLines[j]; |       const std::vector<SourceLineInfo> &LineInfos = SectionSourceLines[j]; | ||||||
|  |  | ||||||
|  |       if (VerboseAsm) | ||||||
|         Asm->EOL(std::string("Section ") + SectionMap[j + 1]); |         Asm->EOL(std::string("Section ") + SectionMap[j + 1]); | ||||||
|  |       else | ||||||
|  |         Asm->EOL(); | ||||||
|  |  | ||||||
|       // Dwarf assumes we start with first line of first source file. |       // Dwarf assumes we start with first line of first source file. | ||||||
|       unsigned Source = 1; |       unsigned Source = 1; | ||||||
| @@ -2344,10 +2350,13 @@ private: | |||||||
|         unsigned SourceID = LineInfo.getSourceID(); |         unsigned SourceID = LineInfo.getSourceID(); | ||||||
|         const SourceFileInfo &SourceFile = SourceFiles[SourceID]; |         const SourceFileInfo &SourceFile = SourceFiles[SourceID]; | ||||||
|         unsigned DirectoryID = SourceFile.getDirectoryID(); |         unsigned DirectoryID = SourceFile.getDirectoryID(); | ||||||
|  |         if (VerboseAsm) | ||||||
|           Asm->EOL(Directories[DirectoryID] |           Asm->EOL(Directories[DirectoryID] | ||||||
|                    + SourceFile.getName() |                    + SourceFile.getName() | ||||||
|                    + ":" |                    + ":" | ||||||
|                    + utostr_32(LineInfo.getLine())); |                    + utostr_32(LineInfo.getLine())); | ||||||
|  |         else | ||||||
|  |           Asm->EOL(); | ||||||
|  |  | ||||||
|         // Define the line address. |         // Define the line address. | ||||||
|         Asm->EmitInt8(0); Asm->EOL("Extended Op"); |         Asm->EmitInt8(0); Asm->EOL("Extended Op"); | ||||||
|   | |||||||
| @@ -36,8 +36,9 @@ namespace llvm { | |||||||
|   CodeModel::Model CMModel; |   CodeModel::Model CMModel; | ||||||
|   bool PerformTailCallOpt; |   bool PerformTailCallOpt; | ||||||
|   bool OptimizeForSize; |   bool OptimizeForSize; | ||||||
|   bool RealignStack; |  | ||||||
|   unsigned StackAlignment; |   unsigned StackAlignment; | ||||||
|  |   bool RealignStack; | ||||||
|  |   bool VerboseAsm; | ||||||
| } | } | ||||||
|  |  | ||||||
| static cl::opt<bool, true> PrintCode("print-machineinstrs", | static cl::opt<bool, true> PrintCode("print-machineinstrs", | ||||||
| @@ -138,17 +139,23 @@ EnableOptimizeForSize("optimize-size", | |||||||
|                       cl::location(OptimizeForSize), |                       cl::location(OptimizeForSize), | ||||||
|                       cl::init(false)); |                       cl::init(false)); | ||||||
|  |  | ||||||
|  | static cl::opt<unsigned, true> | ||||||
|  | OverrideStackAlignment("stack-alignment", | ||||||
|  |                        cl::desc("Override default stack alignment"), | ||||||
|  |                        cl::location(StackAlignment), | ||||||
|  |                        cl::init(0)); | ||||||
|  |  | ||||||
| static cl::opt<bool, true> | static cl::opt<bool, true> | ||||||
| EnableRealignStack("realign-stack", | EnableRealignStack("realign-stack", | ||||||
|                    cl::desc("Realign stack if needed"), |                    cl::desc("Realign stack if needed"), | ||||||
|                    cl::location(RealignStack), |                    cl::location(RealignStack), | ||||||
|                    cl::init(true)); |                    cl::init(true)); | ||||||
|  |  | ||||||
| static cl::opt<unsigned, true> | static cl::opt<bool, true> | ||||||
| OverrideStackAlignment("stack-alignment", | AsmVerbose("asm-verbose", cl::desc("Add comments to directives."), | ||||||
|                        cl::desc("Override default stack alignment"), |            cl::location(VerboseAsm), | ||||||
|                        cl::location(StackAlignment), |            cl::init(false)); | ||||||
|                        cl::init(0)); |  | ||||||
|  |  | ||||||
| //--------------------------------------------------------------------------- | //--------------------------------------------------------------------------- | ||||||
| // TargetMachine Class | // TargetMachine Class | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user