[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC.h PPCAsmPrinter.cpp PPCTargetMachine.cpp

Jim Laskey jlaskey at apple.com
Wed Sep 6 11:35:04 PDT 2006



Changes in directory llvm/lib/Target/PowerPC:

PPC.h updated: 1.32 -> 1.33
PPCAsmPrinter.cpp updated: 1.192 -> 1.193
PPCTargetMachine.cpp updated: 1.103 -> 1.104
---
Log message:

Separate target specific asm properties from the asm printers.


---
Diffs of the changes:  (+43 -47)

 PPC.h                |    3 +
 PPCAsmPrinter.cpp    |   85 ++++++++++++++++++++++++---------------------------
 PPCTargetMachine.cpp |    2 -
 3 files changed, 43 insertions(+), 47 deletions(-)


Index: llvm/lib/Target/PowerPC/PPC.h
diff -u llvm/lib/Target/PowerPC/PPC.h:1.32 llvm/lib/Target/PowerPC/PPC.h:1.33
--- llvm/lib/Target/PowerPC/PPC.h:1.32	Sun Sep  3 23:14:57 2006
+++ llvm/lib/Target/PowerPC/PPC.h	Wed Sep  6 13:34:40 2006
@@ -26,7 +26,8 @@
 
 FunctionPass *createPPCBranchSelectionPass();
 FunctionPass *createPPCISelDag(PPCTargetMachine &TM);
-FunctionPass *createDarwinAsmPrinter(std::ostream &OS, PPCTargetMachine &TM);
+FunctionPass *createDarwinCodePrinterPass(std::ostream &OS,
+                                          PPCTargetMachine &TM);
 FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM,
                                        MachineCodeEmitter &MCE);
 void addPPCMachOObjectWriterPass(FunctionPassManager &FPM, std::ostream &o, 


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.192 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.193
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.192	Sun Aug 27 07:54:01 2006
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp	Wed Sep  6 13:34:40 2006
@@ -34,6 +34,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Target/MRegisterInfo.h"
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Target/TargetOptions.h"
@@ -46,12 +47,11 @@
 namespace {
   Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
 
-  class VISIBILITY_HIDDEN PPCAsmPrinter : public AsmPrinter {
-  public:
+  struct VISIBILITY_HIDDEN PPCAsmPrinter : public AsmPrinter {
     std::set<std::string> FnStubs, GVStubs;
     
-    PPCAsmPrinter(std::ostream &O, TargetMachine &TM)
-      : AsmPrinter(O, TM) {}
+    PPCAsmPrinter(std::ostream &O, TargetMachine &TM, TargetAsmInfo *T)
+      : AsmPrinter(O, TM, T) {}
 
     virtual const char *getPassName() const {
       return "PowerPC Assembly Printer";
@@ -151,7 +151,7 @@
           }
         }
         if (MO.getType() == MachineOperand::MO_ExternalSymbol) {
-          std::string Name(GlobalPrefix); Name += MO.getSymbolName();
+          std::string Name(TAI->getGlobalPrefix()); Name += MO.getSymbolName();
           FnStubs.insert(Name);
           O << "L" << Name << "$stub";
           return;
@@ -239,14 +239,28 @@
     
   };
 
-  /// DarwinDwarfWriter - Dwarf debug info writer customized for Darwin/Mac OS X
-  ///
-  struct VISIBILITY_HIDDEN DarwinDwarfWriter : public DwarfWriter {
-    // Ctor.
-    DarwinDwarfWriter(std::ostream &o, AsmPrinter *ap)
-    : DwarfWriter(o, ap)
-    {
-      needsSet = true;
+  struct VISIBILITY_HIDDEN DarwinTargetAsmInfo : public TargetAsmInfo {
+    DarwinTargetAsmInfo(PPCTargetMachine &TM) {
+      bool isPPC64 = TM.getSubtargetImpl()->isPPC64();
+
+      CommentString = ";";
+      GlobalPrefix = "_";
+      PrivateGlobalPrefix = "L";
+      ZeroDirective = "\t.space\t";
+      SetDirective = "\t.set";
+      Data64bitsDirective = isPPC64 ? ".quad\t" : 0;  
+      AlignmentIsInBytes = false;
+      ConstantPoolSection = "\t.const\t";
+      JumpTableDataSection = ".const";
+      JumpTableTextSection = "\t.text";
+      LCOMMDirective = "\t.lcomm\t";
+      StaticCtorsSection = ".mod_init_func";
+      StaticDtorsSection = ".mod_term_func";
+      InlineAsmStart = "# InlineAsm Start";
+      InlineAsmEnd = "# InlineAsm End";
+      
+      NeedsSet = true;
+      AddressSize = isPPC64 ? 8 : 4;
       DwarfAbbrevSection = ".section __DWARF,__debug_abbrev";
       DwarfInfoSection = ".section __DWARF,__debug_info";
       DwarfLineSection = ".section __DWARF,__debug_line";
@@ -258,8 +272,6 @@
       DwarfARangesSection = ".section __DWARF,__debug_aranges";
       DwarfRangesSection = ".section __DWARF,__debug_ranges";
       DwarfMacInfoSection = ".section __DWARF,__debug_macinfo";
-      TextSection = ".text";
-      DataSection = ".data";
     }
   };
 
@@ -267,29 +279,11 @@
   /// X
   struct VISIBILITY_HIDDEN DarwinAsmPrinter : public PPCAsmPrinter {
   
-    DarwinDwarfWriter DW;
+    DwarfWriter DW;
 
-    DarwinAsmPrinter(std::ostream &O, PPCTargetMachine &TM)
-      : PPCAsmPrinter(O, TM), DW(O, this) {
+    DarwinAsmPrinter(std::ostream &O, PPCTargetMachine &TM, TargetAsmInfo *T)
+      : PPCAsmPrinter(O, TM, T), DW(O, this, T) {
       bool isPPC64 = TM.getSubtargetImpl()->isPPC64();
-      CommentString = ";";
-      GlobalPrefix = "_";
-      PrivateGlobalPrefix = "L";     // Marker for constant pool idxs
-      ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
-      SetDirective = "\t.set";
-      if (isPPC64)
-        Data64bitsDirective = ".quad\t";       // we can't emit a 64-bit unit
-      else
-        Data64bitsDirective = 0;       // we can't emit a 64-bit unit
-      AlignmentIsInBytes = false;    // Alignment is by power of 2.
-      ConstantPoolSection = "\t.const\t";
-      JumpTableDataSection = ".const";
-      JumpTableTextSection = "\t.text";
-      LCOMMDirective = "\t.lcomm\t";
-      StaticCtorsSection = ".mod_init_func";
-      StaticDtorsSection = ".mod_term_func";
-      InlineAsmStart = "# InlineAsm Start";
-      InlineAsmEnd = "# InlineAsm End";
     }
 
     virtual const char *getPassName() const {
@@ -309,13 +303,14 @@
   };
 } // end of anonymous namespace
 
-/// createDarwinAsmPrinterPass - Returns a pass that prints the PPC assembly
+/// createDarwinCodePrinterPass - Returns a pass that prints the PPC assembly
 /// code for a MachineFunction to the given output stream, in a format that the
 /// Darwin assembler can deal with.
 ///
-FunctionPass *llvm::createDarwinAsmPrinter(std::ostream &o,
-                                           PPCTargetMachine &tm) {
-  return new DarwinAsmPrinter(o, tm);
+FunctionPass *llvm::createDarwinCodePrinterPass(std::ostream &o,
+                                                PPCTargetMachine &tm) {
+  TargetAsmInfo *TAI = new DarwinTargetAsmInfo(tm);
+  return new DarwinAsmPrinter(o, tm, TAI);
 }
 
 // Include the auto-generated portion of the assembly writer
@@ -332,23 +327,23 @@
     printBasicBlockLabel(MO.getMachineBasicBlock());
     return;
   case MachineOperand::MO_JumpTableIndex:
-    O << PrivateGlobalPrefix << "JTI" << getFunctionNumber()
+    O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
       << '_' << MO.getJumpTableIndex();
     // FIXME: PIC relocation model
     return;
   case MachineOperand::MO_ConstantPoolIndex:
-    O << PrivateGlobalPrefix << "CPI" << getFunctionNumber()
+    O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
       << '_' << MO.getConstantPoolIndex();
     return;
   case MachineOperand::MO_ExternalSymbol:
     // Computing the address of an external symbol, not calling it.
     if (TM.getRelocationModel() != Reloc::Static) {
-      std::string Name(GlobalPrefix); Name += MO.getSymbolName();
+      std::string Name(TAI->getGlobalPrefix()); Name += MO.getSymbolName();
       GVStubs.insert(Name);
       O << "L" << Name << "$non_lazy_ptr";
       return;
     }
-    O << GlobalPrefix << MO.getSymbolName();
+    O << TAI->getGlobalPrefix() << MO.getSymbolName();
     return;
   case MachineOperand::MO_GlobalAddress: {
     // Computing the address of a global symbol, not calling it.
@@ -561,7 +556,7 @@
           << Size << ", " << Align;
       } else if (I->hasInternalLinkage()) {
         SwitchToDataSection("\t.data", I);
-        O << LCOMMDirective << name << "," << Size << "," << Align;
+        O << TAI->getLCOMMDirective() << name << "," << Size << "," << Align;
       } else {
         SwitchToDataSection("\t.data", I);
         O << ".comm " << name << "," << Size;


Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
diff -u llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.103 llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.104
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.103	Sun Sep  3 23:14:57 2006
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp	Wed Sep  6 13:34:40 2006
@@ -117,7 +117,7 @@
 
 bool PPCTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast, 
                                           std::ostream &Out) {
-  PM.add(createDarwinAsmPrinter(Out, *this));
+  PM.add(createDarwinCodePrinterPass(Out, *this));
   return false;
 }
 






More information about the llvm-commits mailing list