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

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/PowerPC:

PPCAsmPrinter.cpp updated: 1.117 -> 1.118
---
Log message:

unify the darwin and aix constant pool printers


---
Diffs of the changes:  (+28 -48)

 PPCAsmPrinter.cpp |   76 +++---
 1 files changed, 28 insertions(+), 48 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.117 
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.118
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.117 Mon Nov 21 01:51:23 2005
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp   Mon Nov 21 01:57:37 2005
@@ -62,6 +62,8 @@
   return static_cast(TM);
 }
 
+void printConstantPool(MachineConstantPool *MCP);
+
 unsigned enumRegToMachineReg(unsigned enumReg) {
   switch (enumReg) {
   default: assert(0 && "Unhandled register!"); break;
@@ -197,7 +199,6 @@
   O << (0x80 >> RegNo);
 }
 
-virtual void printConstantPool(MachineConstantPool *MCP) = 0;
 virtual bool runOnMachineFunction(MachineFunction &F) = 0;
 virtual bool doFinalization(Module &M) = 0;
   };
@@ -221,7 +222,6 @@
   return "Darwin PPC Assembly Printer";
 }
 
-void printConstantPool(MachineConstantPool *MCP);
 bool runOnMachineFunction(MachineFunction &F);
 bool doInitialization(Module &M);
 bool doFinalization(Module &M);
@@ -247,7 +247,6 @@
   return "AIX PPC Assembly Printer";
 }
 
-void printConstantPool(MachineConstantPool *MCP);
 bool runOnMachineFunction(MachineFunction &F);
 bool doInitialization(Module &M);
 bool doFinalization(Module &M);
@@ -378,6 +377,32 @@
   return;
 }
 
+/// printConstantPool - Print to the current output stream assembly
+/// representations of the constants in the constant pool MCP. This is
+/// used to print out constants which have been "spilled to memory" by
+/// the code generator.
+///
+void PPCAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
+  const std::vector &CP = MCP->getConstants();
+  const TargetData &TD = TM.getTargetData();
+  
+  if (CP.empty()) return;
+  
+  SwitchSection(".const", 0);
+  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
+// FIXME: force doubles to be naturally aligned.  We should handle this
+// more correctly in the future.
+unsigned Alignment = TD.getTypeAlignmentShift(CP[i]->getType());
+if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3;
+
+EmitAlignment(Alignment);
+O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i
+  << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
+EmitGlobalConstant(CP[i]);
+  }
+}
+
+
 /// runOnMachineFunction - This uses the printMachineInstruction()
 /// method to print assembly for each instruction.
 ///
@@ -420,30 +445,6 @@
   return false;
 }
 
-/// printConstantPool - Print to the current output stream assembly
-/// representations of the constants in the constant pool MCP. This is
-/// used to print out constants which have been "spilled to memory" by
-/// the code generator.
-///
-void DarwinAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
-  const std::vector &CP = MCP->getConstants();
-  const TargetData &TD = TM.getTargetData();
-
-  if (CP.empty()) return;
-
-  SwitchSection(".const", 0);
-  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
-// FIXME: force doubles to be naturally aligned.  We should handle this
-// more correctly in the future.
-if (CP[i]->getType() == Type::DoubleTy)
-  EmitAlignment(3);
-else
-  EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
-O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i
-  << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
-EmitGlobalConstant(CP[i]);
-  }
-}
 
 bool DarwinAsmPrinter::doInitialization(Module &M) {
   if (TM.getSubtarget().isGigaProcessor())
@@ -632,27 +633,6 @@
   return false;
 }
 
-/// printConstantPool - Print to the current output stream assembly
-/// representations of the constants in the constant pool MCP. This is
-/// used to print out constants which have been "spilled to memory" by
-/// the code generator.
-///
-void AIXAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
-  const std::vector &CP = MCP->getConstants();
-  const TargetData &TD = TM.getTargetData();
-
-  if (CP.empty()) return;
-
-  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
-SwitchSection(".const", 0);
-O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType())
-  << "\n";
-O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i
-  << ":\t\t\t\t\t;" << *CP[i] << '\n';
-EmitGlobalConstant(CP[i]);
-  }
-}
-
 bool AIXAsmPrinter::doInitialization(Module &M) {
   SwitchSection("", 0);
   const TargetData &TD = TM.getTargetData();



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/PowerPC:

PPCAsmPrinter.cpp updated: 1.118 -> 1.119
---
Log message:

Use CommentString where possible, fix a bug where aix mode wouldn't assemble
due to basic blocks being misnamed.


---
Diffs of the changes:  (+4 -4)

 PPCAsmPrinter.cpp |8 
 1 files changed, 4 insertions(+), 4 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.118 
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.119
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.118 Mon Nov 21 01:57:37 2005
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp   Mon Nov 21 02:02:41 2005
@@ -590,7 +590,7 @@
 /// method to print assembly for each instruction.
 ///
 bool AIXAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
-  CurrentFnName = MF.getFunction()->getName();
+  SetupMachineFunction(MF);
 
   // Print out constants referenced by the function
   printConstantPool(MF.getConstantPool());
@@ -610,8 +610,8 @@
   for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
I != E; ++I) {
 // Print a label for the basic block.
-O << PrivateGlobalPrefix << "BB" << CurrentFnName << '_' << I->getNumber()
-  << ":\t# " << I->getBasicBlock()->getName() << '\n';
+O << PrivateGlobalPrefix << "BB" << FunctionNumber << '_' << I->getNumber()
+  << ":\t" << CommentString << I->getBasicBlock()->getName() << '\n';
 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
   II != E; ++II) {
   // Print the assembly for the instruction.
@@ -697,7 +697,7 @@
   O << "\t.comm " << Name << "," << TD.getTypeSize(I->getType())
 << "," << Log2_32((unsigned)TD.getTypeAlignment(I->getType()));
 }
-O << "\t\t# ";
+O << "\t\t" << CommentString << " ";
 WriteAsOperand(O, I, false, true, &M);
 O << "\n";
   }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h

2005-11-21 Thread Chris Lattner


Changes in directory llvm/include/llvm/CodeGen:

AsmPrinter.h updated: 1.18 -> 1.19
---
Log message:

Make the AsmPrinter keep track of the notion of a function number.


---
Diffs of the changes:  (+19 -2)

 AsmPrinter.h |   21 +++--
 1 files changed, 19 insertions(+), 2 deletions(-)


Index: llvm/include/llvm/CodeGen/AsmPrinter.h
diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.18 
llvm/include/llvm/CodeGen/AsmPrinter.h:1.19
--- llvm/include/llvm/CodeGen/AsmPrinter.h:1.18 Mon Nov 21 01:51:06 2005
+++ llvm/include/llvm/CodeGen/AsmPrinter.h  Mon Nov 21 02:12:47 2005
@@ -27,6 +27,14 @@
 /// CurrentSection - The current section we are emitting to.  This is
 /// controlled and used by the SwitchSection method.
 std::string CurrentSection;
+
+/// FunctionNumber - This provides a unique ID for each function emitted in
+/// this translation unit.  It is autoincremented by SetupMachineFunction,
+/// and can be accessed with getFunctionNumber() and 
+/// IncrementFunctionNumber().
+///
+unsigned FunctionNumber;
+
   protected:
 /// Output stream on which we're printing assembly code.
 ///
@@ -112,7 +120,7 @@
 bool AlignmentIsInBytes;  // Defaults to true
 
 AsmPrinter(std::ostream &o, TargetMachine &tm)
-  : O(o), TM(tm),
+  : FunctionNumber(0), O(o), TM(tm),
 CommentString("#"),
 GlobalPrefix(""),
 PrivateGlobalPrefix("."),
@@ -140,7 +148,16 @@
 /// current section is, but does not emit a .section directive.
 ///
 void SwitchSection(const char *NewSection, const GlobalValue *GV);
-  
+
+/// getFunctionNumber - Return a unique ID for the current function.
+///
+unsigned getFunctionNumber() const { return FunctionNumber; }
+
+/// IncrementFunctionNumber - Increase Function Number.  AsmPrinters should
+/// not normally call this, as the counter is automatically bumped by
+/// SetupMachineFunction.
+void IncrementFunctionNumber() { FunctionNumber++; }
+
 /// doInitialization - Set up the AsmPrinter when we are working on a new
 /// module.  If your pass overrides this, it must make sure to explicitly
 /// call this implementation.



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.27 -> 1.28
---
Log message:

increment the function number in SetupMachineFunction


---
Diffs of the changes:  (+1 -0)

 AsmPrinter.cpp |1 +
 1 files changed, 1 insertion(+)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.27 
llvm/lib/CodeGen/AsmPrinter.cpp:1.28
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.27Mon Nov 21 01:51:36 2005
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Nov 21 02:13:27 2005
@@ -51,6 +51,7 @@
 void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
   // What's my mangled name?
   CurrentFnName = Mang->getValueName(MF.getFunction());
+  IncrementFunctionNumber();
 }
 
 // EmitAlignment - Emit an alignment directive to the specified power of two.



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/PowerPC:

PPCAsmPrinter.cpp updated: 1.119 -> 1.120
---
Log message:

Use the FunctionNumber provided by the AsmPrinter class


---
Diffs of the changes:  (+15 -19)

 PPCAsmPrinter.cpp |   34 +++---
 1 files changed, 15 insertions(+), 19 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.119 
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.120
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.119 Mon Nov 21 02:02:41 2005
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp   Mon Nov 21 02:14:07 2005
@@ -44,15 +44,11 @@
   Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
 
   class PPCAsmPrinter : public AsmPrinter {
-  public:
+public:
 std::set FnStubs, GVStubs, LinkOnceStubs;
 
 PPCAsmPrinter(std::ostream &O, TargetMachine &TM)
-  : AsmPrinter(O, TM), FunctionNumber(0) {}
-
-/// Unique incrementer for label values for referencing Global values.
-///
-unsigned FunctionNumber;
+  : AsmPrinter(O, TM) {}
 
 virtual const char *getPassName() const {
   return "PowerPC Assembly Printer";
@@ -163,8 +159,8 @@
 void printPICLabel(const MachineInstr *MI, unsigned OpNo,
MVT::ValueType VT) {
   // FIXME: should probably be converted to cout.width and cout.fill
-  O << "\"L" << FunctionNumber << "$pb\"\n";
-  O << "\"L" << FunctionNumber << "$pb\":";
+  O << "\"L" << getFunctionNumber() << "$pb\"\n";
+  O << "\"L" << getFunctionNumber() << "$pb\":";
 }
 void printSymbolHi(const MachineInstr *MI, unsigned OpNo,
MVT::ValueType VT) {
@@ -174,7 +170,7 @@
 O << "ha16(";
 printOp(MI->getOperand(OpNo));
 if (PICEnabled)
-  O << "-\"L" << FunctionNumber << "$pb\")";
+  O << "-\"L" << getFunctionNumber() << "$pb\")";
 else
   O << ')';
   }
@@ -187,7 +183,7 @@
 O << "lo16(";
 printOp(MI->getOperand(OpNo));
 if (PICEnabled)
-  O << "-\"L" << FunctionNumber << "$pb\")";
+  O << "-\"L" << getFunctionNumber() << "$pb\")";
 else
   O << ')';
   }
@@ -301,13 +297,13 @@
 
   case MachineOperand::MO_MachineBasicBlock: {
 MachineBasicBlock *MBBOp = MO.getMachineBasicBlock();
-O << PrivateGlobalPrefix << "BB" << FunctionNumber << "_"
+O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << "_"
   << MBBOp->getNumber() << "\t; " << MBBOp->getBasicBlock()->getName();
 return;
   }
 
   case MachineOperand::MO_ConstantPoolIndex:
-O << PrivateGlobalPrefix << "CPI" << FunctionNumber
+O << PrivateGlobalPrefix << "CPI" << getFunctionNumber()
   << '_' << MO.getConstantPoolIndex();
 return;
 
@@ -396,7 +392,7 @@
 if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3;
 
 EmitAlignment(Alignment);
-O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i
+O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i
   << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
 EmitGlobalConstant(CP[i]);
   }
@@ -426,7 +422,7 @@
I != E; ++I) {
 // Print a label for the basic block.
 if (I != MF.begin()) {
-  O << PrivateGlobalPrefix << "BB" << FunctionNumber << '_'
+  O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << '_'
 << I->getNumber() << ":\t";
   if (!I->getBasicBlock()->getName().empty())
 O << CommentString << " " << I->getBasicBlock()->getName();
@@ -439,7 +435,6 @@
   printMachineInstruction(II);
 }
   }
-  ++FunctionNumber;
 
   // We didn't modify anything.
   return false;
@@ -610,7 +605,8 @@
   for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
I != E; ++I) {
 // Print a label for the basic block.
-O << PrivateGlobalPrefix << "BB" << FunctionNumber << '_' << I->getNumber()
+O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << '_'
+  << I->getNumber()
   << ":\t" << CommentString << I->getBasicBlock()->getName() << '\n';
 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
   II != E; ++II) {
@@ -619,7 +615,6 @@
   printMachineInstruction(II);
 }
   }
-  ++FunctionNumber;
 
   O << "LT.." << CurrentFnName << ":\n"
 << "\t.long 0\n"
@@ -669,14 +664,15 @@
 if (GV->isExternal() && GV->use_begin() == GV->use_end())
   continue;
 
+IncrementFunctionNumber();
 std::string Name = GV->getName();
-std::string Label = "LC.." + utostr(FunctionNumber++);
+std::string Label = "LC.." + utostr(getFunctionNumber());
 GVToLabelMap[GV] = Label;
 O << Label << ":\n"
   << "\t.tc " << Name << "[TC]," << Name;
 if (GV->isExternal()) O << "[RW]";
 O << '\n';
-  }
+   }
 
   AsmPrinter::doInitialization(M);
   return false; // success



___

[llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h

2005-11-21 Thread Chris Lattner


Changes in directory llvm/include/llvm/CodeGen:

AsmPrinter.h updated: 1.19 -> 1.20
---
Log message:

add two more config directives, add method for printing constant pool


---
Diffs of the changes:  (+20 -1)

 AsmPrinter.h |   21 -
 1 files changed, 20 insertions(+), 1 deletion(-)


Index: llvm/include/llvm/CodeGen/AsmPrinter.h
diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.19 
llvm/include/llvm/CodeGen/AsmPrinter.h:1.20
--- llvm/include/llvm/CodeGen/AsmPrinter.h:1.19 Mon Nov 21 02:12:47 2005
+++ llvm/include/llvm/CodeGen/AsmPrinter.h  Mon Nov 21 02:24:11 2005
@@ -85,6 +85,8 @@
 const char *FunctionAddrPrefix;   // Defaults to ""
 const char *FunctionAddrSuffix;   // Defaults to ""
 
+//===--- Data Emission Directives 
-===//
+
 /// ZeroDirective - this should be set to the directive used to get some
 /// number of zero bytes emitted to the current section.  Common cases are
 /// "\t.zero\t" and "\t.space\t".  If this is set to null, the
@@ -108,6 +110,8 @@
 const char *Data32bitsDirective;  // Defaults to "\t.long\t"
 const char *Data64bitsDirective;  // Defaults to "\t.quad\t"
 
+//===--- Alignment Information 
===//
+
 /// AlignDirective - The directive used to emit round up to an alignment
 /// boundary.
 ///
@@ -118,6 +122,17 @@
 /// Otherwise, it emits ".align log2(N)", e.g. 3 to align to an 8 byte
 /// boundary.
 bool AlignmentIsInBytes;  // Defaults to true
+
+//===--- Section Switching Directives 
-===//
+
+/// SwitchToSectionDirective - This is the directive used when we want to
+/// emit a global to an arbitrary section.  The section name is emited 
after
+/// this.
+const char *SwitchToSectionDirective;  // Defaults to "\t.section\t"
+
+/// ConstantPoolSection - This is the section that we SwitchToSection right
+/// before emitting the constant pool for a function.
+const char *ConstantPoolSection; // Defaults to "\t.section .rodata\n"
 
 AsmPrinter(std::ostream &o, TargetMachine &tm)
   : FunctionNumber(0), O(o), TM(tm),
@@ -136,7 +151,9 @@
 Data32bitsDirective("\t.long\t"),
 Data64bitsDirective("\t.quad\t"),
 AlignDirective("\t.align\t"),
-AlignmentIsInBytes(true) {
+AlignmentIsInBytes(true),
+SwitchToSectionDirective("\t.section\t"),
+ConstantPoolSection("\t.section .rodata\n") {
 }
 
 /// SwitchSection - Switch to the specified section of the executable if we
@@ -170,6 +187,8 @@
 /// SetupMachineFunction - This should be called when a new MachineFunction
 /// is being processed from runOnMachineFunction.
 void SetupMachineFunction(MachineFunction &MF);
+
+void EmitConstantPool(MachineConstantPool *MCP);
 
 /// EmitAlignment - Emit an alignment directive to the specified power of
 /// two boundary.  For example, if you pass in 3 here, you will get an 8



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.28 -> 1.29
---
Log message:

Allow target to customize directive used to switch to arbitrary section in 
SwitchSection,
add generic constant pool emitter


---
Diffs of the changes:  (+28 -1)

 AsmPrinter.cpp |   29 -
 1 files changed, 28 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.28 
llvm/lib/CodeGen/AsmPrinter.cpp:1.29
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.28Mon Nov 21 02:13:27 2005
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Nov 21 02:25:09 2005
@@ -14,6 +14,7 @@
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/Constants.h"
 #include "llvm/Module.h"
+#include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/Support/Mangler.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Target/TargetMachine.h"
@@ -26,7 +27,7 @@
   std::string NS;
   
   if (GV && GV->hasSection())
-NS = ".section " + GV->getSection();
+NS = SwitchToSectionDirective + GV->getSection();
   else
 NS = NewSection;
   
@@ -54,6 +55,32 @@
   IncrementFunctionNumber();
 }
 
+/// EmitConstantPool - Print to the current output stream assembly
+/// representations of the constants in the constant pool MCP. This is
+/// used to print out constants which have been "spilled to memory" by
+/// the code generator.
+///
+void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
+  const std::vector &CP = MCP->getConstants();
+  if (CP.empty()) return;
+  const TargetData &TD = TM.getTargetData();
+  
+  SwitchSection(ConstantPoolSection, 0);
+  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
+// FIXME: force doubles to be naturally aligned.  We should handle this
+// more correctly in the future.
+unsigned Alignment = TD.getTypeAlignmentShift(CP[i]->getType());
+if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3;
+
+EmitAlignment(Alignment);
+O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i
+  << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
+EmitGlobalConstant(CP[i]);
+  }
+}
+
+
+
 // EmitAlignment - Emit an alignment directive to the specified power of two.
 void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const {
   if (GV && GV->getAlignment())



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/PowerPC:

PPCAsmPrinter.cpp updated: 1.120 -> 1.121
---
Log message:

Use generic constant pool emission code in the AsmPrinter class.


---
Diffs of the changes:  (+4 -30)

 PPCAsmPrinter.cpp |   34 --
 1 files changed, 4 insertions(+), 30 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.120 
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.121
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.120 Mon Nov 21 02:14:07 2005
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp   Mon Nov 21 02:26:15 2005
@@ -25,7 +25,6 @@
 #include "llvm/Module.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/CodeGen/AsmPrinter.h"
-#include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/CodeGen/ValueTypes.h"
@@ -58,8 +57,6 @@
   return static_cast(TM);
 }
 
-void printConstantPool(MachineConstantPool *MCP);
-
 unsigned enumRegToMachineReg(unsigned enumReg) {
   switch (enumReg) {
   default: assert(0 && "Unhandled register!"); break;
@@ -212,6 +209,7 @@
   ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
   Data64bitsDirective = 0;   // we can't emit a 64-bit unit
   AlignmentIsInBytes = false;// Alignment is by power of 2.
+  ConstantPoolSection = "\t.const\t";
 }
 
 virtual const char *getPassName() const {
@@ -237,6 +235,7 @@
   ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
   Data64bitsDirective = 0;   // we can't emit a 64-bit unit
   AlignmentIsInBytes = false;// Alignment is by power of 2.
+  ConstantPoolSection = "\t.const\t";
 }
 
 virtual const char *getPassName() const {
@@ -373,31 +372,6 @@
   return;
 }
 
-/// printConstantPool - Print to the current output stream assembly
-/// representations of the constants in the constant pool MCP. This is
-/// used to print out constants which have been "spilled to memory" by
-/// the code generator.
-///
-void PPCAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
-  const std::vector &CP = MCP->getConstants();
-  const TargetData &TD = TM.getTargetData();
-  
-  if (CP.empty()) return;
-  
-  SwitchSection(".const", 0);
-  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
-// FIXME: force doubles to be naturally aligned.  We should handle this
-// more correctly in the future.
-unsigned Alignment = TD.getTypeAlignmentShift(CP[i]->getType());
-if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3;
-
-EmitAlignment(Alignment);
-O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i
-  << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
-EmitGlobalConstant(CP[i]);
-  }
-}
-
 
 /// runOnMachineFunction - This uses the printMachineInstruction()
 /// method to print assembly for each instruction.
@@ -407,7 +381,7 @@
   O << "\n\n";
 
   // Print out constants referenced by the function
-  printConstantPool(MF.getConstantPool());
+  EmitConstantPool(MF.getConstantPool());
 
   // Print out labels for the function.
   const Function *F = MF.getFunction();
@@ -588,7 +562,7 @@
   SetupMachineFunction(MF);
 
   // Print out constants referenced by the function
-  printConstantPool(MF.getConstantPool());
+  EmitConstantPool(MF.getConstantPool());
 
   // Print out header for the function.
   O << "\t.csect .text[PR]\n"



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/Alpha:

AlphaAsmPrinter.cpp updated: 1.25 -> 1.26
---
Log message:

Switch to using the generic constant pool emitter impl, use shorter
CPI names


---
Diffs of the changes:  (+2 -25)

 AlphaAsmPrinter.cpp |   27 ++-
 1 files changed, 2 insertions(+), 25 deletions(-)


Index: llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp
diff -u llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.25 
llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.26
--- llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp:1.25  Mon Nov 21 01:51:23 2005
+++ llvm/lib/Target/Alpha/AlphaAsmPrinter.cpp   Mon Nov 21 02:29:17 2005
@@ -18,7 +18,6 @@
 #include "llvm/Module.h"
 #include "llvm/Type.h"
 #include "llvm/Assembly/Writer.h"
-#include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/ValueTypes.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/Target/TargetMachine.h"
@@ -55,7 +54,6 @@
 }
 bool printInstruction(const MachineInstr *MI);
 void printOp(const MachineOperand &MO, bool IsCallOp = false);
-void printConstantPool(MachineConstantPool *MCP);
 void printOperand(const MachineInstr *MI, int opNum, MVT::ValueType VT);
 void printBaseOffsetPair (const MachineInstr *MI, int i, bool 
brackets=true);
 void printMachineInstruction(const MachineInstr *MI);
@@ -128,7 +126,7 @@
   }
 
   case MachineOperand::MO_ConstantPoolIndex:
-O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_"
+O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_"
   << MO.getConstantPoolIndex();
 return;
 
@@ -173,7 +171,7 @@
   O << "\n\n";
 
   // Print out constants referenced by the function
-  printConstantPool(MF.getConstantPool());
+  EmitConstantPool(MF.getConstantPool());
 
   // Print out labels for the function.
   SwitchSection("\t.section .text", MF.getFunction());
@@ -204,27 +202,6 @@
   return false;
 }
 
-
-/// printConstantPool - Print to the current output stream assembly
-/// representations of the constants in the constant pool MCP. This is
-/// used to print out constants which have been "spilled to memory" by
-/// the code generator.
-///
-void AlphaAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
-  const std::vector &CP = MCP->getConstants();
-  const TargetData &TD = TM.getTargetData();
-
-  if (CP.empty()) return;
-
-  SwitchSection("\t.section .rodata", 0);
-  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
-EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
-O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i 
-  << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n";
-EmitGlobalConstant(CP[i]);
-  }
-}
-
 bool AlphaAsmPrinter::doInitialization(Module &M)
 {
   AsmPrinter::doInitialization(M);



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86AsmPrinter.cpp X86AsmPrinter.h X86IntelAsmPrinter.cpp

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/X86:

X86ATTAsmPrinter.cpp updated: 1.12 -> 1.13
X86AsmPrinter.cpp updated: 1.150 -> 1.151
X86AsmPrinter.h updated: 1.4 -> 1.5
X86IntelAsmPrinter.cpp updated: 1.8 -> 1.9
---
Log message:

Switch to using the shared constant pool printer, along with using shorter
CPI ids


---
Diffs of the changes:  (+5 -31)

 X86ATTAsmPrinter.cpp   |4 ++--
 X86AsmPrinter.cpp  |   27 +--
 X86AsmPrinter.h|1 -
 X86IntelAsmPrinter.cpp |4 ++--
 4 files changed, 5 insertions(+), 31 deletions(-)


Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.12 
llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.13
--- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.12   Mon Nov 21 01:51:23 2005
+++ llvm/lib/Target/X86/X86ATTAsmPrinter.cppMon Nov 21 02:32:23 2005
@@ -29,7 +29,7 @@
   O << "\n\n";
 
   // Print out constants referenced by the function
-  printConstantPool(MF.getConstantPool());
+  EmitConstantPool(MF.getConstantPool());
 
   // Print out labels for the function.
   SwitchSection("\t.text\n", MF.getFunction());
@@ -176,7 +176,7 @@
 O << "]";
 return;
   } else if (BaseReg.isConstantPoolIndex()) {
-O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_"
+O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_"
   << BaseReg.getConstantPoolIndex();
 if (DispSpec.getImmedValue())
   O << "+" << DispSpec.getImmedValue();


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.150 
llvm/lib/Target/X86/X86AsmPrinter.cpp:1.151
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.150 Mon Nov 21 01:51:23 2005
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp   Mon Nov 21 02:32:23 2005
@@ -68,37 +68,12 @@
 Data64bitsDirective = 0;   // we can't emit a 64-bit unit
 ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
 PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
+ConstantPoolSection = "\t.const\n";
   }
 
   return AsmPrinter::doInitialization(M);
 }
 
-/// printConstantPool - Print to the current output stream assembly
-/// representations of the constants in the constant pool MCP. This is
-/// used to print out constants which have been "spilled to memory" by
-/// the code generator.
-///
-void X86SharedAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
-  const std::vector &CP = MCP->getConstants();
-  const TargetData &TD = TM.getTargetData();
-
-  if (CP.empty()) return;
-
-  SwitchSection(forDarwin ? "\t.const\n" : "\t.section .rodata\n", 0);
-  
-  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
-// FIXME: force doubles to be naturally aligned.  We should handle this
-// more correctly in the future.
-if (CP[i]->getType() == Type::DoubleTy)
-  EmitAlignment(3);
-else
-  EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
-O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i
-  << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n";
-EmitGlobalConstant(CP[i]);
-  }
-}
-
 bool X86SharedAsmPrinter::doFinalization(Module &M) {
   const TargetData &TD = TM.getTargetData();
 


Index: llvm/lib/Target/X86/X86AsmPrinter.h
diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.4 
llvm/lib/Target/X86/X86AsmPrinter.h:1.5
--- llvm/lib/Target/X86/X86AsmPrinter.h:1.4 Mon Nov 21 01:11:11 2005
+++ llvm/lib/Target/X86/X86AsmPrinter.h Mon Nov 21 02:32:23 2005
@@ -32,7 +32,6 @@
 : AsmPrinter(O, TM), forCygwin(false), forDarwin(false) { }
 
   bool doInitialization(Module &M);
-  void printConstantPool(MachineConstantPool *MCP);
   bool doFinalization(Module &M);
 
   bool forCygwin;


Index: llvm/lib/Target/X86/X86IntelAsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.8 
llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.9
--- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.8  Mon Nov 21 01:51:23 2005
+++ llvm/lib/Target/X86/X86IntelAsmPrinter.cpp  Mon Nov 21 02:32:23 2005
@@ -29,7 +29,7 @@
   O << "\n\n";
 
   // Print out constants referenced by the function
-  printConstantPool(MF.getConstantPool());
+  EmitConstantPool(MF.getConstantPool());
 
   // Print out labels for the function.
   SwitchSection("\t.text\n", MF.getFunction());
@@ -143,7 +143,7 @@
 O << "]";
 return;
   } else if (BaseReg.isConstantPoolIndex()) {
-O << "[" << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_"
+O << "[" << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_"
   << BaseReg.getConstantPoolIndex();
 
 if (IndexReg.getReg()) {



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/X86/X86AsmPrinter.cpp

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/X86:

X86AsmPrinter.cpp updated: 1.151 -> 1.152
---
Log message:

prune #include


---
Diffs of the changes:  (+0 -1)

 X86AsmPrinter.cpp |1 -
 1 files changed, 1 deletion(-)


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.151 
llvm/lib/Target/X86/X86AsmPrinter.cpp:1.152
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.151 Mon Nov 21 02:32:23 2005
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp   Mon Nov 21 02:33:17 2005
@@ -20,7 +20,6 @@
 #include "llvm/Module.h"
 #include "llvm/Type.h"
 #include "llvm/Assembly/Writer.h"
-#include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/Support/Mangler.h"
 #include "llvm/Support/CommandLine.h"
 using namespace llvm;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/IA64:

IA64AsmPrinter.cpp updated: 1.18 -> 1.19
---
Log message:

Start using shared asmprinter Constant Pool emitter, use shorter cpi names.


---
Diffs of the changes:  (+5 -26)

 IA64AsmPrinter.cpp |   31 +--
 1 files changed, 5 insertions(+), 26 deletions(-)


Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp
diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.18 
llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.19
--- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.18Mon Nov 21 01:51:23 2005
+++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Mon Nov 21 02:38:26 2005
@@ -22,7 +22,6 @@
 #include "llvm/Type.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/CodeGen/AsmPrinter.h"
-#include "llvm/CodeGen/MachineConstantPool.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/ValueTypes.h"
 #include "llvm/Target/TargetMachine.h"
@@ -41,32 +40,10 @@
 IA64SharedAsmPrinter(std::ostream &O, TargetMachine &TM)
   : AsmPrinter(O, TM) { }
 
-void printConstantPool(MachineConstantPool *MCP);
 bool doFinalization(Module &M);
   };
 }
 
-/// printConstantPool - Print to the current output stream assembly
-/// representations of the constants in the constant pool MCP. This is
-/// used to print out constants which have been "spilled to memory" by
-/// the code generator.
-///
-void IA64SharedAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
-  const std::vector &CP = MCP->getConstants();
-  const TargetData &TD = TM.getTargetData();
-
-  if (CP.empty()) return;
-
-  // FIXME: would be nice to have rodata (no 'w') when appropriate?
-  SwitchSection("\n\t.section .data, \"aw\", \"progbits\"\n", 0);
-  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
-EmitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
-O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i
-  << ":\t\t\t\t\t" << CommentString << *CP[i] << "\n";
-EmitGlobalConstant(CP[i]);
-  }
-}
-
 bool IA64SharedAsmPrinter::doFinalization(Module &M) {
   const TargetData &TD = TM.getTargetData();
 
@@ -169,7 +146,9 @@
   GlobalVarAddrSuffix="";
   FunctionAddrPrefix="@fptr(";
   FunctionAddrSuffix=")";
-
+  
+  // FIXME: would be nice to have rodata (no 'w') when appropriate?
+  ConstantPoolSection = "\n\t.section .data, \"aw\", \"progbits\"\n";
 }
 
 virtual const char *getPassName() const {
@@ -264,7 +243,7 @@
   O << "\n\n";
 
   // Print out constants referenced by the function
-  printConstantPool(MF.getConstantPool());
+  EmitConstantPool(MF.getConstantPool());
 
   // Print out labels for the function.
   SwitchSection("\n\t.section .text, \"ax\", \"progbits\"\n", 
MF.getFunction());
@@ -328,7 +307,7 @@
 return;
 
   case MachineOperand::MO_ConstantPoolIndex: {
-O << "@gprel(" << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_"
+O << "@gprel(" << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << 
"_"
   << MO.getConstantPoolIndex() << ")";
 return;
   }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/IA64/IA64AsmPrinter.cpp

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/IA64:

IA64AsmPrinter.cpp updated: 1.19 -> 1.20
---
Log message:

Eliminate unneeded intermediate class.  Move doFinalizeMethod to bottom of 
file.


---
Diffs of the changes:  (+88 -99)

 IA64AsmPrinter.cpp |  187 -
 1 files changed, 88 insertions(+), 99 deletions(-)


Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp
diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.19 
llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.20
--- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.19Mon Nov 21 02:38:26 2005
+++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Mon Nov 21 02:40:17 2005
@@ -33,107 +33,10 @@
 namespace {
   Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
 
-  struct IA64SharedAsmPrinter : public AsmPrinter {
-
+  struct IA64AsmPrinter : public AsmPrinter {
 std::set ExternalFunctionNames, ExternalObjectNames;
 
-IA64SharedAsmPrinter(std::ostream &O, TargetMachine &TM)
-  : AsmPrinter(O, TM) { }
-
-bool doFinalization(Module &M);
-  };
-}
-
-bool IA64SharedAsmPrinter::doFinalization(Module &M) {
-  const TargetData &TD = TM.getTargetData();
-
-  // Print out module-level global variables here.
-  for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
-   I != E; ++I)
-if (I->hasInitializer()) {   // External global require no code
-  O << "\n\n";
-  std::string name = Mang->getValueName(I);
-  Constant *C = I->getInitializer();
-  unsigned Size = TD.getTypeSize(C->getType());
-  unsigned Align = TD.getTypeAlignmentShift(C->getType());
-
-  if (C->isNullValue() &&
-  (I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
-   I->hasWeakLinkage() /* FIXME: Verify correct */)) {
-SwitchSection(".data", I);
-if (I->hasInternalLinkage()) {
-  O << "\t.lcomm " << name << "," << TD.getTypeSize(C->getType())
-<< "," << (1 << Align);
-  O << "\t\t// ";
-} else {
-  O << "\t.common " << name << "," << TD.getTypeSize(C->getType())
-<< "," << (1 << Align);
-  O << "\t\t// ";
-}
-WriteAsOperand(O, I, true, true, &M);
-O << "\n";
-  } else {
-switch (I->getLinkage()) {
-case GlobalValue::LinkOnceLinkage:
-case GlobalValue::WeakLinkage:   // FIXME: Verify correct for weak.
-  // Nonnull linkonce -> weak
-  O << "\t.weak " << name << "\n";
-  O << "\t.section\t.llvm.linkonce.d." << name
-<< ", \"aw\", \"progbits\"\n";
-  SwitchSection("", I);
-  break;
-case GlobalValue::AppendingLinkage:
-  // FIXME: appending linkage variables should go into a section of
-  // their name or something.  For now, just emit them as external.
-case GlobalValue::ExternalLinkage:
-  // If external or appending, declare as a global symbol
-  O << "\t.global " << name << "\n";
-  // FALL THROUGH
-case GlobalValue::InternalLinkage:
-  SwitchSection(C->isNullValue() ? ".bss" : ".data", I);
-  break;
-case GlobalValue::GhostLinkage:
-  std::cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n";
-  abort();
-}
-
-EmitAlignment(Align);
-O << "\t.type " << name << ",@object\n";
-O << "\t.size " << name << "," << Size << "\n";
-O << name << ":\t\t\t\t// ";
-WriteAsOperand(O, I, true, true, &M);
-O << " = ";
-WriteAsOperand(O, C, false, false, &M);
-O << "\n";
-EmitGlobalConstant(C);
-  }
-}
-
-  // we print out ".global X \n .type X, @function" for each external function
-  O << "\n\n// br.call targets referenced (and not defined) above: \n";
-  for (std::set::iterator i = ExternalFunctionNames.begin(),
-   e = ExternalFunctionNames.end(); i!=e; ++i) {
-O << "\t.global " << *i << "\n\t.type " << *i << ", @function\n";
-  }
-  O << "\n\n";
-
-  // we print out ".global X \n .type X, @object" for each external object
-  O << "\n\n// (external) symbols referenced (and not defined) above: \n";
-  for (std::set::iterator i = ExternalObjectNames.begin(),
-   e = ExternalObjectNames.end(); i!=e; ++i) {
-O << "\t.global " << *i << "\n\t.type " << *i << ", @object\n";
-  }
-  O << "\n\n";
-
-  AsmPrinter::doFinalization(M);
-  return false; // success
-}
-
-namespace {
-  struct IA64AsmPrinter : public IA64SharedAsmPrinter {
-IA64AsmPrinter(std::ostream &O, TargetMachine &TM)
-  : IA64SharedAsmPrinter(O, TM) {
-
+IA64AsmPrinter(std::ostream &O, TargetMachine &TM) : AsmPrinter(O, TM) {
   CommentString = "//";
   Data8bitsDirective = "\tdata1\t"; // FIXME: check that we are
   Data16bitsDirective = "\tdata2.ua\t"; // disabling auto-alignment
@@ -227,6 +130,7 @@
 void printOp(const MachineOperand &MO, bool isBRCALLinsn= false);
 bool runOnMachin

[llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp

2005-11-21 Thread Duraid Madina


Changes in directory llvm/lib/CodeGen:

RegAllocLinearScan.cpp updated: 1.115 -> 1.116
---
Log message:

I think I know what you meant here, but just to be safe I'll let you
do it. :)

<_sabre_> excuses excuses



---
Diffs of the changes:  (+1 -1)

 RegAllocLinearScan.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp
diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.115 
llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.116
--- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.115   Mon Nov 21 01:06:27 2005
+++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Mon Nov 21 08:09:40 2005
@@ -547,7 +547,7 @@
   minReg = reg;
 }
   }
-  assert(minReg && "Didn't find any reg!");
+// FIXME:  assert(minReg && "Didn't find any reg!");
   DEBUG(std::cerr << "\t\tregister with min weight: "
 << mri_->getName(minReg) << " (" << minWeight << ")\n");
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp

2005-11-21 Thread Duraid Madina


Changes in directory llvm/lib/Target/IA64:

IA64ISelDAGToDAG.cpp updated: 1.10 -> 1.11
---
Log message:

add support for div/rem to the dag->dag isel. yay.



---
Diffs of the changes:  (+180 -0)

 IA64ISelDAGToDAG.cpp |  180 +++
 1 files changed, 180 insertions(+)


Index: llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp
diff -u llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.10 
llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.11
--- llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.10  Sun Nov  6 21:11:03 2005
+++ llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp   Mon Nov 21 08:14:54 2005
@@ -93,6 +93,7 @@
 #include "IA64GenDAGISel.inc"
 
 private:
+SDOperand SelectDIV(SDOperand Op);
 SDOperand SelectCALL(SDOperand Op);
   };
 }
@@ -153,6 +154,179 @@
   ScheduleAndEmitDAG(DAG);
 }
 
+SDOperand IA64DAGToDAGISel::SelectDIV(SDOperand Op) {
+  SDNode *N = Op.Val;
+  SDOperand Chain = Select(N->getOperand(0));
+
+  SDOperand Tmp1 = Select(N->getOperand(0));
+  SDOperand Tmp2 = Select(N->getOperand(1));
+
+  bool isFP=false;
+
+  if(MVT::isFloatingPoint(Tmp1.getValueType()))
+isFP=true;
+
+  bool isModulus=false; // is it a division or a modulus?
+  bool isSigned=false;
+
+  switch(N->getOpcode()) {
+case ISD::FDIV:
+case ISD::SDIV:  isModulus=false; isSigned=true;  break;
+case ISD::UDIV:  isModulus=false; isSigned=false; break;
+case ISD::FREM:
+case ISD::SREM:  isModulus=true;  isSigned=true;  break;
+case ISD::UREM:  isModulus=true;  isSigned=false; break;
+  }
+
+  // TODO: check for integer divides by powers of 2 (or other simple patterns?)
+
+SDOperand TmpPR, TmpPR2;
+SDOperand TmpF1, TmpF2, TmpF3, TmpF4, TmpF5, TmpF6, TmpF7, TmpF8;
+SDOperand TmpF9, TmpF10,TmpF11,TmpF12,TmpF13,TmpF14,TmpF15;
+SDOperand Result;
+
+// OK, emit some code:
+
+if(!isFP) {
+  // first, load the inputs into FP regs.
+  TmpF1 = CurDAG->getTargetNode(IA64::SETFSIG, MVT::f64, Tmp1);
+  Chain = TmpF1.getValue(1);
+  TmpF2 = CurDAG->getTargetNode(IA64::SETFSIG, MVT::f64, Tmp2);
+  Chain = TmpF2.getValue(1);
+  
+  // next, convert the inputs to FP
+  if(isSigned) {
+TmpF3 = CurDAG->getTargetNode(IA64::FCVTXF, MVT::f64, TmpF1);
+Chain = TmpF3.getValue(1);
+TmpF4 = CurDAG->getTargetNode(IA64::FCVTXF, MVT::f64, TmpF2);
+Chain = TmpF4.getValue(1);
+  } else {
+TmpF3 = CurDAG->getTargetNode(IA64::FCVTXUFS1, MVT::f64, TmpF1);
+Chain = TmpF3.getValue(1);
+TmpF4 = CurDAG->getTargetNode(IA64::FCVTXUFS1, MVT::f64, TmpF2);
+Chain = TmpF4.getValue(1);
+  }
+
+} else { // this is an FP divide/remainder, so we 'leak' some temp
+ // regs and assign TmpF3=Tmp1, TmpF4=Tmp2
+  TmpF3=Tmp1;
+  TmpF4=Tmp2;
+}
+
+// we start by computing an approximate reciprocal (good to 9 bits?)
+// note, this instruction writes _both_ TmpF5 (answer) and TmpPR 
(predicate)
+TmpF5 = CurDAG->getTargetNode(IA64::FRCPAS1, MVT::f64, MVT::i1,
+ TmpF3, TmpF4);
+TmpPR = TmpF5.getValue(1);
+Chain = TmpF5.getValue(2);
+
+if(!isModulus) { // if this is a divide, we worry about div-by-zero
+SDOperand bogusPR = CurDAG->getTargetNode(IA64::CMPEQ, MVT::i1, 
+  CurDAG->getRegister(IA64::r0, MVT::i64),
+  CurDAG->getRegister(IA64::r0, MVT::i64));
+Chain = bogusPR.getValue(1);
+TmpPR2 = CurDAG->getTargetNode(IA64::TPCMPNE, MVT::i1, bogusPR,
+  CurDAG->getRegister(IA64::r0, MVT::i64),
+  CurDAG->getRegister(IA64::r0, MVT::i64), TmpPR); 
+Chain = TmpPR2.getValue(1);
+}
+
+SDOperand F0 = CurDAG->getRegister(IA64::F0, MVT::f64);
+SDOperand F1 = CurDAG->getRegister(IA64::F1, MVT::f64);
+
+// now we apply newton's method, thrice! (FIXME: this is ~72 bits of
+// precision, don't need this much for f32/i32)
+TmpF6 = CurDAG->getTargetNode(IA64::CFNMAS1, MVT::f64,
+  TmpF4, TmpF5, F1, TmpPR);
+Chain = TmpF6.getValue(1);
+TmpF7 = CurDAG->getTargetNode(IA64::CFMAS1, MVT::f64,
+  TmpF3, TmpF5, F0, TmpPR);
+Chain = TmpF7.getValue(1);
+TmpF8 = CurDAG->getTargetNode(IA64::CFMAS1, MVT::f64,
+  TmpF6, TmpF6, F0, TmpPR);
+Chain = TmpF8.getValue(1);
+TmpF9 = CurDAG->getTargetNode(IA64::CFMAS1, MVT::f64,
+  TmpF6, TmpF7, TmpF7, TmpPR);
+Chain = TmpF9.getValue(1);
+TmpF10 = CurDAG->getTargetNode(IA64::CFMAS1, MVT::f64,
+  TmpF6, TmpF5, TmpF5, TmpPR);
+Chain = TmpF10.getValue(1);
+TmpF11 = CurDAG->getTargetNode(IA64::CFMAS1, MVT::f64,
+  TmpF8, TmpF9, TmpF9, TmpPR);
+Chain = TmpF11.getValue(1);
+TmpF12 = CurDAG->getTargetNode(IA64::CFMAS1, MVT::f64,
+  TmpF8, TmpF10, TmpF10, TmpPR);
+Chain = TmpF12.getValue(1);
+TmpF13 = CurDAG->getTargetNode(IA64::CFNMAS1, MVT::f64,
+  TmpF4, TmpF11, TmpF3, TmpPR);
+Chain = TmpF13.getValue(1);
+
+   // FIXME

Re: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp

2005-11-21 Thread Chris Lattner


I think I know what you meant here, but just to be safe I'll let you
do it. :)


Can you send me a testcase that this assert breaks?

Thanks,

-Chris


---
Diffs of the changes:  (+1 -1)

RegAllocLinearScan.cpp |2 +-
1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp
diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.115 
llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.116
--- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.115   Mon Nov 21 01:06:27 2005
+++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Mon Nov 21 08:09:40 2005
@@ -547,7 +547,7 @@
  minReg = reg;
}
  }
-  assert(minReg && "Didn't find any reg!");
+// FIXME:  assert(minReg && "Didn't find any reg!");
  DEBUG(std::cerr << "\t\tregister with min weight: "
<< mri_->getName(minReg) << " (" << minWeight << ")\n");




___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



-Chris

--
http://nondot.org/sabre/
http://llvm.org/

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/X86/X86AsmPrinter.cpp

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/X86:

X86AsmPrinter.cpp updated: 1.152 -> 1.153
---
Log message:

simplify and genericize this code


---
Diffs of the changes:  (+69 -55)

 X86AsmPrinter.cpp |  124 ++
 1 files changed, 69 insertions(+), 55 deletions(-)


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.152 
llvm/lib/Target/X86/X86AsmPrinter.cpp:1.153
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.152 Mon Nov 21 02:33:17 2005
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp   Mon Nov 21 13:50:31 2005
@@ -40,8 +40,9 @@
 
 /// doInitialization
 bool X86SharedAsmPrinter::doInitialization(Module& M) {
-  bool leadingUnderscore = false;
   forCygwin = false;
+  forDarwin = false;
+  bool forWin32 = false;
   const std::string& TT = M.getTargetTriple();
   if (TT.length() > 5) {
 forCygwin = TT.find("cygwin") != std::string::npos ||
@@ -53,23 +54,26 @@
 #elif defined(__APPLE__)
 forDarwin = true;
 #elif defined(_WIN32)
-leadingUnderscore = true;
-#else
-leadingUnderscore = false;
+forWin32 = true;
 #endif
   }
 
-  if (leadingUnderscore || forCygwin || forDarwin)
-GlobalPrefix = "_";
-
   if (forDarwin) {
 AlignmentIsInBytes = false;
+GlobalPrefix = "_";
 Data64bitsDirective = 0;   // we can't emit a 64-bit unit
 ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
 PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
 ConstantPoolSection = "\t.const\n";
-  }
-
+LCOMMDirective = "\t.lcomm\t";
+COMMDirectiveTakesAlignment = false;
+  } else if (forCygwin) {
+GlobalPrefix = "_";
+COMMDirectiveTakesAlignment = false;
+  } else if (forWin32) {
+GlobalPrefix = "_";
+  }  
+  
   return AsmPrinter::doInitialization(M);
 }
 
@@ -86,55 +90,65 @@
   unsigned Size = TD.getTypeSize(C->getType());
   unsigned Align = TD.getTypeAlignmentShift(C->getType());
 
-  if (C->isNullValue() &&
-  (I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
-   I->hasWeakLinkage() /* FIXME: Verify correct */)) {
-SwitchSection(".data", I);
-if (!forCygwin && !forDarwin && I->hasInternalLinkage())
-  O << "\t.local " << name << "\n";
-if (forDarwin && I->hasInternalLinkage())
-  O << "\t.lcomm " << name << "," << Size << "," << Align;
-else
-  O << "\t.comm " << name << "," << Size;
-if (!forCygwin && !forDarwin)
-  O << "," << (1 << Align);
-O << "\t\t# ";
-WriteAsOperand(O, I, true, true, &M);
-O << "\n";
-  } else {
-switch (I->getLinkage()) {
-default: assert(0 && "Unknown linkage type!");
-case GlobalValue::LinkOnceLinkage:
-case GlobalValue::WeakLinkage:   // FIXME: Verify correct for weak.
-  // Nonnull linkonce -> weak
-  O << "\t.weak " << name << "\n";
-  O << "\t.section\t.llvm.linkonce.d." << name << 
",\"aw\",@progbits\n";
-  SwitchSection("", I);
-  break;
-case GlobalValue::AppendingLinkage:
-  // FIXME: appending linkage variables should go into a section of
-  // their name or something.  For now, just emit them as external.
-case GlobalValue::ExternalLinkage:
-  // If external or appending, declare as a global symbol
-  O << "\t.globl " << name << "\n";
-  // FALL THROUGH
-case GlobalValue::InternalLinkage:
-  SwitchSection(C->isNullValue() ? ".bss" : ".data", I);
-  break;
+  switch (I->getLinkage()) {
+  default: assert(0 && "Unknown linkage type!");
+  case GlobalValue::LinkOnceLinkage:
+  case GlobalValue::WeakLinkage:   // FIXME: Verify correct for weak.
+if (C->isNullValue()) {
+  O << COMMDirective << name << "," << Size;
+  if (COMMDirectiveTakesAlignment)
+O << "," << (1 << Align);
+  O << "\t\t# ";
+  WriteAsOperand(O, I, true, true, &M);
+  O << "\n";
+  continue;
 }
-
-EmitAlignment(Align);
-if (!forCygwin && !forDarwin) {
-  O << "\t.type " << name << ",@object\n";
-  O << "\t.size " << name << "," << Size << "\n";
+
+// Nonnull linkonce -> weak
+O << "\t.weak " << name << "\n";
+O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n";
+SwitchSection("", I);
+break;
+  case GlobalValue::InternalLinkage:
+if (C->isNullValue()) {
+  if (LCOMMDirective) {
+O << LCOMMDirective << name << "," << Size << "," << Align;
+continue;
+  } else {
+SwitchSection(".bss", I);
+O << "\t.local " << name << "\n";
+O << COMMDirective << name << "," << Size;
+if (COMMDirectiveTakesAlignment)
+  O << "," << (1 << Align);
+O << "\t\t# ";
+WriteAsOperand(O, I,

[llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h

2005-11-21 Thread Chris Lattner


Changes in directory llvm/include/llvm/CodeGen:

AsmPrinter.h updated: 1.20 -> 1.21
---
Log message:

Add some more directives


---
Diffs of the changes:  (+18 -1)

 AsmPrinter.h |   19 ++-
 1 files changed, 18 insertions(+), 1 deletion(-)


Index: llvm/include/llvm/CodeGen/AsmPrinter.h
diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.20 
llvm/include/llvm/CodeGen/AsmPrinter.h:1.21
--- llvm/include/llvm/CodeGen/AsmPrinter.h:1.20 Mon Nov 21 02:24:11 2005
+++ llvm/include/llvm/CodeGen/AsmPrinter.h  Mon Nov 21 13:51:51 2005
@@ -134,6 +134,20 @@
 /// before emitting the constant pool for a function.
 const char *ConstantPoolSection; // Defaults to "\t.section .rodata\n"
 
+//===--- Global Variable Emission Directives 
--===//
+
+/// LCOMMDirective - This is the name of a directive (if supported) that 
can
+/// be used to efficiently declare a local (internal) block of zero
+/// initialized data in the .bss/.data section.  The syntax expected is:
+/// SYMBOLNAME LENGTHINBYTES, ALIGNMENT
+const char *LCOMMDirective;  // Defaults to null.
+
+const char *COMMDirective;   // Defaults to "\t.comm\t".
+
+/// COMMDirectiveTakesAlignment - True if COMMDirective take a third
+/// argument that specifies the alignment of the declaration.
+bool COMMDirectiveTakesAlignment;// Defaults to true.
+
 AsmPrinter(std::ostream &o, TargetMachine &tm)
   : FunctionNumber(0), O(o), TM(tm),
 CommentString("#"),
@@ -153,7 +167,10 @@
 AlignDirective("\t.align\t"),
 AlignmentIsInBytes(true),
 SwitchToSectionDirective("\t.section\t"),
-ConstantPoolSection("\t.section .rodata\n") {
+ConstantPoolSection("\t.section .rodata\n"),
+LCOMMDirective(0),
+COMMDirective("\t.comm\t"),
+COMMDirectiveTakesAlignment(true) {
 }
 
 /// SwitchSection - Switch to the specified section of the executable if we



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86AsmPrinter.cpp X86AsmPrinter.h X86IntelAsmPrinter.cpp

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/X86:

X86ATTAsmPrinter.cpp updated: 1.13 -> 1.14
X86AsmPrinter.cpp updated: 1.153 -> 1.154
X86AsmPrinter.h updated: 1.5 -> 1.6
X86IntelAsmPrinter.cpp updated: 1.9 -> 1.10
---
Log message:

Add a forELF flag, allowing the removal of forCygwin and simplification of
conditionals.


---
Diffs of the changes:  (+12 -7)

 X86ATTAsmPrinter.cpp   |2 +-
 X86AsmPrinter.cpp  |   11 ---
 X86AsmPrinter.h|4 ++--
 X86IntelAsmPrinter.cpp |2 +-
 4 files changed, 12 insertions(+), 7 deletions(-)


Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.13 
llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.14
--- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.13   Mon Nov 21 02:32:23 2005
+++ llvm/lib/Target/X86/X86ATTAsmPrinter.cppMon Nov 21 16:19:48 2005
@@ -35,7 +35,7 @@
   SwitchSection("\t.text\n", MF.getFunction());
   EmitAlignment(4); // FIXME: This should be parameterized somewhere.
   O << "\t.globl\t" << CurrentFnName << "\n";
-  if (!forCygwin && !forDarwin)
+  if (forELF)
 O << "\t.type\t" << CurrentFnName << ", @function\n";
   O << CurrentFnName << ":\n";
 


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.153 
llvm/lib/Target/X86/X86AsmPrinter.cpp:1.154
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.153 Mon Nov 21 13:50:31 2005
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp   Mon Nov 21 16:19:48 2005
@@ -39,15 +39,18 @@
 cl::init(att));
 
 /// doInitialization
-bool X86SharedAsmPrinter::doInitialization(Module& M) {
-  forCygwin = false;
+bool X86SharedAsmPrinter::doInitialization(Module &M) {
+  bool forCygwin = false;
   forDarwin = false;
+  forELF= false;
   bool forWin32 = false;
   const std::string& TT = M.getTargetTriple();
   if (TT.length() > 5) {
 forCygwin = TT.find("cygwin") != std::string::npos ||
 TT.find("mingw")  != std::string::npos;
 forDarwin = TT.find("darwin") != std::string::npos;
+if (!forDarwin && !forCygwin)
+  forELF = true;
   } else if (TT.empty()) {
 #if defined(__CYGWIN__) || defined(__MINGW32__)
 forCygwin = true;
@@ -55,6 +58,8 @@
 forDarwin = true;
 #elif defined(_WIN32)
 forWin32 = true;
+#else
+forELF = true;
 #endif
   }
 
@@ -139,7 +144,7 @@
   }
 
   EmitAlignment(Align);
-  if (!forCygwin && !forDarwin) {
+  if (forELF) {
 O << "\t.type " << name << ",@object\n";
 O << "\t.size " << name << "," << Size << "\n";
   }


Index: llvm/lib/Target/X86/X86AsmPrinter.h
diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.5 
llvm/lib/Target/X86/X86AsmPrinter.h:1.6
--- llvm/lib/Target/X86/X86AsmPrinter.h:1.5 Mon Nov 21 02:32:23 2005
+++ llvm/lib/Target/X86/X86AsmPrinter.h Mon Nov 21 16:19:48 2005
@@ -29,12 +29,12 @@
 
 struct X86SharedAsmPrinter : public AsmPrinter {
   X86SharedAsmPrinter(std::ostream &O, TargetMachine &TM)
-: AsmPrinter(O, TM), forCygwin(false), forDarwin(false) { }
+: AsmPrinter(O, TM), forELF(false), forDarwin(false) { }
 
   bool doInitialization(Module &M);
   bool doFinalization(Module &M);
 
-  bool forCygwin;
+  bool forELF;
   bool forDarwin;
 
   // Necessary for Darwin to print out the apprioriate types of linker stubs


Index: llvm/lib/Target/X86/X86IntelAsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.9 
llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.10
--- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.9  Mon Nov 21 02:32:23 2005
+++ llvm/lib/Target/X86/X86IntelAsmPrinter.cpp  Mon Nov 21 16:19:48 2005
@@ -35,7 +35,7 @@
   SwitchSection("\t.text\n", MF.getFunction());
   EmitAlignment(4);
   O << "\t.globl\t" << CurrentFnName << "\n";
-  if (!forCygwin && !forDarwin)
+  if (forELF)
 O << "\t.type\t" << CurrentFnName << ", @function\n";
   O << CurrentFnName << ":\n";
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm-www/pubs/2005-11-SAFECodeTR.pdf

2005-11-21 Thread Dinakar Dhurjati


Changes in directory llvm-www/pubs:

2005-11-SAFECodeTR.pdf updated: 1.4 -> 1.5
---
Log message:

safecode techreport fixes


---
Diffs of the changes:  (+0 -0)

 2005-11-SAFECodeTR.pdf |0 
 1 files changed


Index: llvm-www/pubs/2005-11-SAFECodeTR.pdf



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/X86/X86Subtarget.cpp X86Subtarget.h

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/X86:

X86Subtarget.cpp updated: 1.6 -> 1.7
X86Subtarget.h updated: 1.5 -> 1.6
---
Log message:

Make the X86 subtarget compute the basic target type: ELF, Cygwin, Darwin, 
or native Win32


---
Diffs of the changes:  (+24 -15)

 X86Subtarget.cpp |   35 ---
 X86Subtarget.h   |4 
 2 files changed, 24 insertions(+), 15 deletions(-)


Index: llvm/lib/Target/X86/X86Subtarget.cpp
diff -u llvm/lib/Target/X86/X86Subtarget.cpp:1.6 
llvm/lib/Target/X86/X86Subtarget.cpp:1.7
--- llvm/lib/Target/X86/X86Subtarget.cpp:1.6Thu Sep  1 16:38:21 2005
+++ llvm/lib/Target/X86/X86Subtarget.cppMon Nov 21 16:31:58 2005
@@ -21,37 +21,42 @@
 asmLeadingUnderscore(false), asmAlignmentIsInBytes(false),
 asmPrintDotLocalConstants(false), asmPrintDotLCommConstants(false),
 asmPrintConstantAlignment(false) {
-  // Declare a boolean for each major platform.
-  bool forCygwin = false;
-  bool forDarwin = false;
-  bool forWindows = false;
-
+  
+  // Default to ELF unless otherwise specified.
+  TargetType = isELF;
+  
   // Set the boolean corresponding to the current target triple, or the default
   // if one cannot be determined, to true.
   const std::string& TT = M.getTargetTriple();
   if (TT.length() > 5) {
-forCygwin = TT.find("cygwin") != std::string::npos ||
-TT.find("mingw")  != std::string::npos;
-forDarwin = TT.find("darwin") != std::string::npos;
-forWindows = TT.find("win32") != std::string::npos;
+if (TT.find("cygwin") != std::string::npos ||
+TT.find("mingw")  != std::string::npos)
+  TargetType = isCygwin;
+else if (TT.find("darwin") != std::string::npos)
+  TargetType = isDarwin;
+else if (TT.find("win32") != std::string::npos)
+  TargetType = isWindows;
   } else if (TT.empty()) {
 #if defined(__CYGWIN__) || defined(__MINGW32__)
-forCygwin = true;
+TargetType = isCygwin;
 #elif defined(__APPLE__)
-forDarwin = true;
+TargetType = isDarwin;
 #elif defined(_WIN32)
-forWindows = true;
+TargetType = isWindows;
 #endif
   }
 
-  if (forCygwin) {
+  switch (TargetType) {
+  case isCygwin:
 asmLeadingUnderscore = true;
-  } else if (forDarwin) {
+break;
+  case isDarwin:
 stackAlignment = 16;
 indirectExternAndWeakGlobals = true;
 asmDarwinLinkerStubs = true;
 asmLeadingUnderscore = true;
 asmPrintDotLCommConstants = true;
-  } else if (forWindows) {
+break;
+  default: break;
   }
 }


Index: llvm/lib/Target/X86/X86Subtarget.h
diff -u llvm/lib/Target/X86/X86Subtarget.h:1.5 
llvm/lib/Target/X86/X86Subtarget.h:1.6
--- llvm/lib/Target/X86/X86Subtarget.h:1.5  Thu Sep  1 16:38:21 2005
+++ llvm/lib/Target/X86/X86Subtarget.h  Mon Nov 21 16:31:58 2005
@@ -38,6 +38,10 @@
   bool asmPrintDotLCommConstants;
   bool asmPrintConstantAlignment;
 public:
+  enum {
+isELF, isCygwin, isDarwin, isWindows
+  } TargetType;
+
   /// This constructor initializes the data members to match that
   /// of the specified module.
   ///



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm-www/pubs/2005-11-SAFECodeTR.pdf

2005-11-21 Thread Dinakar Dhurjati


Changes in directory llvm-www/pubs:

2005-11-SAFECodeTR.pdf updated: 1.5 -> 1.6
---
Log message:

safecode techreport fixes


---
Diffs of the changes:  (+0 -0)

 2005-11-SAFECodeTR.pdf |0 
 1 files changed


Index: llvm-www/pubs/2005-11-SAFECodeTR.pdf



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86AsmPrinter.cpp X86AsmPrinter.h

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/X86:

X86ATTAsmPrinter.cpp updated: 1.14 -> 1.15
X86AsmPrinter.cpp updated: 1.154 -> 1.155
X86AsmPrinter.h updated: 1.6 -> 1.7
---
Log message:

Use subtarget information computed by X86Subtarget instead of rolling our own.


---
Diffs of the changes:  (+22 -29)

 X86ATTAsmPrinter.cpp |2 +-
 X86AsmPrinter.cpp|   47 ---
 X86AsmPrinter.h  |2 +-
 3 files changed, 22 insertions(+), 29 deletions(-)


Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.14 
llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.15
--- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.14   Mon Nov 21 16:19:48 2005
+++ llvm/lib/Target/X86/X86ATTAsmPrinter.cppMon Nov 21 16:39:40 2005
@@ -54,7 +54,7 @@
   printMachineInstruction(II);
 }
   }
-  if (!forDarwin)
+  if (forELF)
 O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n";
 
   // We didn't modify anything.


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.154 
llvm/lib/Target/X86/X86AsmPrinter.cpp:1.155
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.154 Mon Nov 21 16:19:48 2005
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp   Mon Nov 21 16:39:40 2005
@@ -16,6 +16,7 @@
 
 #include "X86ATTAsmPrinter.h"
 #include "X86IntelAsmPrinter.h"
+#include "X86Subtarget.h"
 #include "X86.h"
 #include "llvm/Module.h"
 #include "llvm/Type.h"
@@ -40,30 +41,16 @@
 
 /// doInitialization
 bool X86SharedAsmPrinter::doInitialization(Module &M) {
-  bool forCygwin = false;
+  const X86Subtarget *Subtarget = &TM.getSubtarget();
+  
+  forELF = false;
   forDarwin = false;
-  forELF= false;
-  bool forWin32 = false;
-  const std::string& TT = M.getTargetTriple();
-  if (TT.length() > 5) {
-forCygwin = TT.find("cygwin") != std::string::npos ||
-TT.find("mingw")  != std::string::npos;
-forDarwin = TT.find("darwin") != std::string::npos;
-if (!forDarwin && !forCygwin)
-  forELF = true;
-  } else if (TT.empty()) {
-#if defined(__CYGWIN__) || defined(__MINGW32__)
-forCygwin = true;
-#elif defined(__APPLE__)
-forDarwin = true;
-#elif defined(_WIN32)
-forWin32 = true;
-#else
+  
+  switch (Subtarget->TargetType) {
+  case X86Subtarget::isELF:
 forELF = true;
-#endif
-  }
-
-  if (forDarwin) {
+break;
+  case X86Subtarget::isDarwin:
 AlignmentIsInBytes = false;
 GlobalPrefix = "_";
 Data64bitsDirective = 0;   // we can't emit a 64-bit unit
@@ -72,12 +59,17 @@
 ConstantPoolSection = "\t.const\n";
 LCOMMDirective = "\t.lcomm\t";
 COMMDirectiveTakesAlignment = false;
-  } else if (forCygwin) {
+forDarwin = true;
+break;
+  case X86Subtarget::isCygwin:
 GlobalPrefix = "_";
 COMMDirectiveTakesAlignment = false;
-  } else if (forWin32) {
+break;
+  case X86Subtarget::isWindows:
 GlobalPrefix = "_";
-  }  
+break;
+  default: break;
+  }
   
   return AsmPrinter::doInitialization(M);
 }
@@ -87,7 +79,7 @@
 
   // Print out module-level global variables here.
   for (Module::const_global_iterator I = M.global_begin(),
- E = M.global_end(); I != E; ++I)
+   E = M.global_end(); I != E; ++I) {
 if (I->hasInitializer()) {   // External global require no code
   O << "\n\n";
   std::string name = Mang->getValueName(I);
@@ -155,7 +147,8 @@
   O << "\n";
   EmitGlobalConstant(C);
 }
-
+  }
+  
   if (forDarwin) {
 SwitchSection("", 0);
 // Output stubs for external global variables


Index: llvm/lib/Target/X86/X86AsmPrinter.h
diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.6 
llvm/lib/Target/X86/X86AsmPrinter.h:1.7
--- llvm/lib/Target/X86/X86AsmPrinter.h:1.6 Mon Nov 21 16:19:48 2005
+++ llvm/lib/Target/X86/X86AsmPrinter.h Mon Nov 21 16:39:40 2005
@@ -35,7 +35,7 @@
   bool doFinalization(Module &M);
 
   bool forELF;
-  bool forDarwin;
+  bool forDarwin;  // FIXME: eliminate.
 
   // Necessary for Darwin to print out the apprioriate types of linker stubs
   std::set FnStubs, GVStubs, LinkOnceStubs;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/X86/X86Subtarget.cpp X86Subtarget.h

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/X86:

X86Subtarget.cpp updated: 1.7 -> 1.8
X86Subtarget.h updated: 1.6 -> 1.7
---
Log message:

Simplify the subtarget info, allow the asmwriter to do some target sensing
based on TargetType.


---
Diffs of the changes:  (+2 -22)

 X86Subtarget.cpp |   17 ++---
 X86Subtarget.h   |7 ---
 2 files changed, 2 insertions(+), 22 deletions(-)


Index: llvm/lib/Target/X86/X86Subtarget.cpp
diff -u llvm/lib/Target/X86/X86Subtarget.cpp:1.7 
llvm/lib/Target/X86/X86Subtarget.cpp:1.8
--- llvm/lib/Target/X86/X86Subtarget.cpp:1.7Mon Nov 21 16:31:58 2005
+++ llvm/lib/Target/X86/X86Subtarget.cppMon Nov 21 16:43:58 2005
@@ -16,11 +16,7 @@
 using namespace llvm;
 
 X86Subtarget::X86Subtarget(const Module &M, const std::string &FS)
-  : TargetSubtarget(), stackAlignment(8),
-indirectExternAndWeakGlobals(false), asmDarwinLinkerStubs(false),
-asmLeadingUnderscore(false), asmAlignmentIsInBytes(false),
-asmPrintDotLocalConstants(false), asmPrintDotLCommConstants(false),
-asmPrintConstantAlignment(false) {
+  : stackAlignment(8), indirectExternAndWeakGlobals(false) {
   
   // Default to ELF unless otherwise specified.
   TargetType = isELF;
@@ -46,17 +42,8 @@
 #endif
   }
 
-  switch (TargetType) {
-  case isCygwin:
-asmLeadingUnderscore = true;
-break;
-  case isDarwin:
+  if (TargetType == isDarwin) {
 stackAlignment = 16;
 indirectExternAndWeakGlobals = true;
-asmDarwinLinkerStubs = true;
-asmLeadingUnderscore = true;
-asmPrintDotLCommConstants = true;
-break;
-  default: break;
   }
 }


Index: llvm/lib/Target/X86/X86Subtarget.h
diff -u llvm/lib/Target/X86/X86Subtarget.h:1.6 
llvm/lib/Target/X86/X86Subtarget.h:1.7
--- llvm/lib/Target/X86/X86Subtarget.h:1.6  Mon Nov 21 16:31:58 2005
+++ llvm/lib/Target/X86/X86Subtarget.h  Mon Nov 21 16:43:58 2005
@@ -30,13 +30,6 @@
   /// Used by instruction selector
   bool indirectExternAndWeakGlobals;
 
-  /// Used by the asm printer
-  bool asmDarwinLinkerStubs;
-  bool asmLeadingUnderscore;
-  bool asmAlignmentIsInBytes;
-  bool asmPrintDotLocalConstants;
-  bool asmPrintDotLCommConstants;
-  bool asmPrintConstantAlignment;
 public:
   enum {
 isELF, isCygwin, isDarwin, isWindows



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/X86/X86AsmPrinter.cpp

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/X86:

X86AsmPrinter.cpp updated: 1.155 -> 1.156
---
Log message:

Remove a level of indentation by using a continue.


---
Diffs of the changes:  (+56 -56)

 X86AsmPrinter.cpp |  112 +++---
 1 files changed, 56 insertions(+), 56 deletions(-)


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.155 
llvm/lib/Target/X86/X86AsmPrinter.cpp:1.156
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.155 Mon Nov 21 16:39:40 2005
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp   Mon Nov 21 16:48:18 2005
@@ -80,18 +80,41 @@
   // Print out module-level global variables here.
   for (Module::const_global_iterator I = M.global_begin(),
E = M.global_end(); I != E; ++I) {
-if (I->hasInitializer()) {   // External global require no code
-  O << "\n\n";
-  std::string name = Mang->getValueName(I);
-  Constant *C = I->getInitializer();
-  unsigned Size = TD.getTypeSize(C->getType());
-  unsigned Align = TD.getTypeAlignmentShift(C->getType());
-
-  switch (I->getLinkage()) {
-  default: assert(0 && "Unknown linkage type!");
-  case GlobalValue::LinkOnceLinkage:
-  case GlobalValue::WeakLinkage:   // FIXME: Verify correct for weak.
-if (C->isNullValue()) {
+if (!I->hasInitializer()) continue;   // External global require no code
+
+O << "\n\n";
+std::string name = Mang->getValueName(I);
+Constant *C = I->getInitializer();
+unsigned Size = TD.getTypeSize(C->getType());
+unsigned Align = TD.getTypeAlignmentShift(C->getType());
+
+switch (I->getLinkage()) {
+default: assert(0 && "Unknown linkage type!");
+case GlobalValue::LinkOnceLinkage:
+case GlobalValue::WeakLinkage:   // FIXME: Verify correct for weak.
+  if (C->isNullValue()) {
+O << COMMDirective << name << "," << Size;
+if (COMMDirectiveTakesAlignment)
+  O << "," << (1 << Align);
+O << "\t\t# ";
+WriteAsOperand(O, I, true, true, &M);
+O << "\n";
+continue;
+  }
+  
+  // Nonnull linkonce -> weak
+  O << "\t.weak " << name << "\n";
+  O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n";
+  SwitchSection("", I);
+  break;
+case GlobalValue::InternalLinkage:
+  if (C->isNullValue()) {
+if (LCOMMDirective) {
+  O << LCOMMDirective << name << "," << Size << "," << Align;
+  continue;
+} else {
+  SwitchSection(".bss", I);
+  O << "\t.local " << name << "\n";
   O << COMMDirective << name << "," << Size;
   if (COMMDirectiveTakesAlignment)
 O << "," << (1 << Align);
@@ -100,53 +123,30 @@
   O << "\n";
   continue;
 }
-
-// Nonnull linkonce -> weak
-O << "\t.weak " << name << "\n";
-O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n";
-SwitchSection("", I);
-break;
-  case GlobalValue::InternalLinkage:
-if (C->isNullValue()) {
-  if (LCOMMDirective) {
-O << LCOMMDirective << name << "," << Size << "," << Align;
-continue;
-  } else {
-SwitchSection(".bss", I);
-O << "\t.local " << name << "\n";
-O << COMMDirective << name << "," << Size;
-if (COMMDirectiveTakesAlignment)
-  O << "," << (1 << Align);
-O << "\t\t# ";
-WriteAsOperand(O, I, true, true, &M);
-O << "\n";
-continue;
-  }
-}
-SwitchSection(C->isNullValue() ? ".bss" : ".data", I);
-break;
-  case GlobalValue::AppendingLinkage:
-// FIXME: appending linkage variables should go into a section of
-// their name or something.  For now, just emit them as external.
-  case GlobalValue::ExternalLinkage:
-SwitchSection(C->isNullValue() ? ".bss" : ".data", I);
-// If external or appending, declare as a global symbol
-O << "\t.globl " << name << "\n";
-break;
   }
+  SwitchSection(".data", I);
+  break;
+case GlobalValue::AppendingLinkage:
+  // FIXME: appending linkage variables should go into a section of
+  // their name or something.  For now, just emit them as external.
+case GlobalValue::ExternalLinkage:
+  SwitchSection(C->isNullValue() ? ".bss" : ".data", I);
+  // If external or appending, declare as a global symbol
+  O << "\t.globl " << name << "\n";
+  break;
+}
 
-  EmitAlignment(Align);
-  if (forELF) {
-O << "\t.type " << name << ",@object\n";
-O << "\t.size " << name << "," << Size << "\n";
-  }
-  O << name << ":\t\t\t\t# ";
-  WriteAsOperand(O, I, true, true, &M);
-  O << " = ";
-  WriteAsOperand(O, C, false, false, &M);
-  O << "\n";
-  EmitGlobalConstant(C);
+EmitAlignment(A

[llvm-commits] CVS: llvm/include/llvm/CodeGen/AsmPrinter.h

2005-11-21 Thread Chris Lattner


Changes in directory llvm/include/llvm/CodeGen:

AsmPrinter.h updated: 1.21 -> 1.22
---
Log message:

Add a new flag


---
Diffs of the changes:  (+6 -1)

 AsmPrinter.h |7 ++-
 1 files changed, 6 insertions(+), 1 deletion(-)


Index: llvm/include/llvm/CodeGen/AsmPrinter.h
diff -u llvm/include/llvm/CodeGen/AsmPrinter.h:1.21 
llvm/include/llvm/CodeGen/AsmPrinter.h:1.22
--- llvm/include/llvm/CodeGen/AsmPrinter.h:1.21 Mon Nov 21 13:51:51 2005
+++ llvm/include/llvm/CodeGen/AsmPrinter.h  Mon Nov 21 17:06:08 2005
@@ -147,6 +147,10 @@
 /// COMMDirectiveTakesAlignment - True if COMMDirective take a third
 /// argument that specifies the alignment of the declaration.
 bool COMMDirectiveTakesAlignment;// Defaults to true.
+
+/// HasDotTypeDotSizeDirective - True if the target has .type and .size
+/// directives, this is true for most ELF targets.
+bool HasDotTypeDotSizeDirective; // Defaults to true.
 
 AsmPrinter(std::ostream &o, TargetMachine &tm)
   : FunctionNumber(0), O(o), TM(tm),
@@ -170,7 +174,8 @@
 ConstantPoolSection("\t.section .rodata\n"),
 LCOMMDirective(0),
 COMMDirective("\t.comm\t"),
-COMMDirectiveTakesAlignment(true) {
+COMMDirectiveTakesAlignment(true),
+HasDotTypeDotSizeDirective(true) {
 }
 
 /// SwitchSection - Switch to the specified section of the executable if we



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp X86AsmPrinter.cpp X86AsmPrinter.h X86IntelAsmPrinter.cpp

2005-11-21 Thread Chris Lattner


Changes in directory llvm/lib/Target/X86:

X86ATTAsmPrinter.cpp updated: 1.15 -> 1.16
X86AsmPrinter.cpp updated: 1.156 -> 1.157
X86AsmPrinter.h updated: 1.7 -> 1.8
X86IntelAsmPrinter.cpp updated: 1.10 -> 1.11
---
Log message:

Use HasDotTypeDotSizeDirective instead of forELF


---
Diffs of the changes:  (+10 -18)

 X86ATTAsmPrinter.cpp   |4 ++--
 X86AsmPrinter.cpp  |   19 ++-
 X86AsmPrinter.h|3 +--
 X86IntelAsmPrinter.cpp |2 +-
 4 files changed, 10 insertions(+), 18 deletions(-)


Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.15 
llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.16
--- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.15   Mon Nov 21 16:39:40 2005
+++ llvm/lib/Target/X86/X86ATTAsmPrinter.cppMon Nov 21 17:06:54 2005
@@ -35,7 +35,7 @@
   SwitchSection("\t.text\n", MF.getFunction());
   EmitAlignment(4); // FIXME: This should be parameterized somewhere.
   O << "\t.globl\t" << CurrentFnName << "\n";
-  if (forELF)
+  if (HasDotTypeDotSizeDirective)
 O << "\t.type\t" << CurrentFnName << ", @function\n";
   O << CurrentFnName << ":\n";
 
@@ -54,7 +54,7 @@
   printMachineInstruction(II);
 }
   }
-  if (forELF)
+  if (HasDotTypeDotSizeDirective)
 O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n";
 
   // We didn't modify anything.


Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.156 
llvm/lib/Target/X86/X86AsmPrinter.cpp:1.157
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.156 Mon Nov 21 16:48:18 2005
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp   Mon Nov 21 17:06:54 2005
@@ -43,13 +43,9 @@
 bool X86SharedAsmPrinter::doInitialization(Module &M) {
   const X86Subtarget *Subtarget = &TM.getSubtarget();
   
-  forELF = false;
   forDarwin = false;
   
   switch (Subtarget->TargetType) {
-  case X86Subtarget::isELF:
-forELF = true;
-break;
   case X86Subtarget::isDarwin:
 AlignmentIsInBytes = false;
 GlobalPrefix = "_";
@@ -59,14 +55,17 @@
 ConstantPoolSection = "\t.const\n";
 LCOMMDirective = "\t.lcomm\t";
 COMMDirectiveTakesAlignment = false;
+HasDotTypeDotSizeDirective = false;
 forDarwin = true;
 break;
   case X86Subtarget::isCygwin:
 GlobalPrefix = "_";
 COMMDirectiveTakesAlignment = false;
+HasDotTypeDotSizeDirective = false;
 break;
   case X86Subtarget::isWindows:
 GlobalPrefix = "_";
+HasDotTypeDotSizeDirective = false;
 break;
   default: break;
   }
@@ -96,9 +95,7 @@
 O << COMMDirective << name << "," << Size;
 if (COMMDirectiveTakesAlignment)
   O << "," << (1 << Align);
-O << "\t\t# ";
-WriteAsOperand(O, I, true, true, &M);
-O << "\n";
+O << "\t\t" << CommentString << " " << I->getName() << "\n";
 continue;
   }
   
@@ -137,15 +134,11 @@
 }
 
 EmitAlignment(Align);
-if (forELF) {
+if (HasDotTypeDotSizeDirective) {
   O << "\t.type " << name << ",@object\n";
   O << "\t.size " << name << "," << Size << "\n";
 }
-O << name << ":\t\t\t\t# ";
-WriteAsOperand(O, I, true, true, &M);
-O << " = ";
-WriteAsOperand(O, C, false, false, &M);
-O << "\n";
+O << name << ":\t\t\t" << CommentString << ' ' << I->getName() << '\n';
 EmitGlobalConstant(C);
   }
   


Index: llvm/lib/Target/X86/X86AsmPrinter.h
diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.7 
llvm/lib/Target/X86/X86AsmPrinter.h:1.8
--- llvm/lib/Target/X86/X86AsmPrinter.h:1.7 Mon Nov 21 16:39:40 2005
+++ llvm/lib/Target/X86/X86AsmPrinter.h Mon Nov 21 17:06:54 2005
@@ -29,12 +29,11 @@
 
 struct X86SharedAsmPrinter : public AsmPrinter {
   X86SharedAsmPrinter(std::ostream &O, TargetMachine &TM)
-: AsmPrinter(O, TM), forELF(false), forDarwin(false) { }
+: AsmPrinter(O, TM), forDarwin(false) { }
 
   bool doInitialization(Module &M);
   bool doFinalization(Module &M);
 
-  bool forELF;
   bool forDarwin;  // FIXME: eliminate.
 
   // Necessary for Darwin to print out the apprioriate types of linker stubs


Index: llvm/lib/Target/X86/X86IntelAsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.10 
llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.11
--- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.10 Mon Nov 21 16:19:48 2005
+++ llvm/lib/Target/X86/X86IntelAsmPrinter.cpp  Mon Nov 21 17:06:54 2005
@@ -35,7 +35,7 @@
   SwitchSection("\t.text\n", MF.getFunction());
   EmitAlignment(4);
   O << "\t.globl\t" << CurrentFnName << "\n";
-  if (forELF)
+  if (HasDotTypeDotSizeDirective)
 O << "\t.type\t" << CurrentFnName << ", @function\n";
   O << CurrentFnName << ":\n";
 



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Target/TargetLowering.cpp

2005-11-21 Thread Nate Begeman


Changes in directory llvm/lib/Target:

TargetLowering.cpp updated: 1.13 -> 1.14
---
Log message:

Rather than attempting to legalize 1 x float, make sure the SD ISel never
generates it.  Make MVT::Vector expand-only, and remove the code in
Legalize that attempts to legalize it.

The plan for supporting N x Type is to continually epxand it in ExpandOp
until it gets down to 2 x Type, where it will be scalarized into a pair of
scalars.


---
Diffs of the changes:  (+5 -1)

 TargetLowering.cpp |6 +-
 1 files changed, 5 insertions(+), 1 deletion(-)


Index: llvm/lib/Target/TargetLowering.cpp
diff -u llvm/lib/Target/TargetLowering.cpp:1.13 
llvm/lib/Target/TargetLowering.cpp:1.14
--- llvm/lib/Target/TargetLowering.cpp:1.13 Thu Oct 20 19:02:42 2005
+++ llvm/lib/Target/TargetLowering.cpp  Mon Nov 21 19:29:36 2005
@@ -64,7 +64,7 @@
 assert(VT < PromoteTo && "Must promote to a larger type!");
 TransformToType[VT] = PromoteTo;
   } else if (Action == TargetLowering::Expand) {
-assert(MVT::isInteger(VT) && VT > MVT::i8 &&
+assert((VT == MVT::Vector || MVT::isInteger(VT)) && VT > MVT::i8 &&
"Cannot expand this type: target must support SOME integer reg!");
 // Expand to the next smaller integer type!
 TransformToType[VT] = (MVT::ValueType)(VT-1);
@@ -113,6 +113,10 @@
TransformToType, ValueTypeActions);
   else
 TransformToType[MVT::f32] = MVT::f32;
+  
+  // Set MVT::Vector to always be Expanded
+  SetValueTypeAction(MVT::Vector, Expand, *this, TransformToType, 
+ ValueTypeActions);
 
   assert(isTypeLegal(MVT::f64) && "Target does not support FP?");
   TransformToType[MVT::f64] = MVT::f64;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp SelectionDAGISel.cpp

2005-11-21 Thread Nate Begeman


Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.213 -> 1.214
SelectionDAGISel.cpp updated: 1.103 -> 1.104
---
Log message:

Rather than attempting to legalize 1 x float, make sure the SD ISel never
generates it.  Make MVT::Vector expand-only, and remove the code in
Legalize that attempts to legalize it.

The plan for supporting N x Type is to continually epxand it in ExpandOp
until it gets down to 2 x Type, where it will be scalarized into a pair of
scalars.


---
Diffs of the changes:  (+24 -48)

 LegalizeDAG.cpp  |   42 --
 SelectionDAGISel.cpp |   30 --
 2 files changed, 24 insertions(+), 48 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.213 
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.214
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.213 Sun Nov 20 16:56:56 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp   Mon Nov 21 19:29:36 2005
@@ -925,26 +925,6 @@
 AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1));
 return Result.getValue(Op.ResNo);
 
-  case ISD::VLOAD:
-Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
-Tmp2 = LegalizeOp(Node->getOperand(1));  // Legalize the pointer.
- 
-// If we just have one element, scalarize the result.  Otherwise, check to
-// see if we support this operation on this type at this width.  If not,
-// split the vector in half and try again.
-if (1 == cast(Node->getOperand(2))->getValue()) {
-  MVT::ValueType SVT = cast(Node->getOperand(3))->getVT();
-  Result = LegalizeOp(DAG.getLoad(SVT, Tmp1, Tmp2, Node->getOperand(4)));
-} else {
-  assert(0 && "Expand case for vectors unimplemented");
-}
-
-// Since loads produce two values, make sure to remember that we legalized
-// both of them.
-AddLegalizedOperand(SDOperand(Node, 0), Result);
-AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1));
-return Result.getValue(Op.ResNo);
-
   case ISD::EXTLOAD:
   case ISD::SEXTLOAD:
   case ISD::ZEXTLOAD: {
@@ -1685,28 +1665,6 @@
   Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), 
Tmp1,Tmp2);
 break;
 
-// Vector binary operators
-  case ISD::VADD:
-  case ISD::VSUB:
-  case ISD::VMUL: {
-Tmp1 = Node->getOperand(0); // Element Count
-Tmp2 = Node->getOperand(1); // Element Type
-
-// If we just have one element, scalarize the result.  Otherwise, check to
-// see if we support this operation on this type at this width.  If not,
-// split the vector in half and try again.
-if (1 == cast(Tmp1)->getValue()) {
-  MVT::ValueType SVT = cast(Tmp2)->getVT();
-  
-  Result = DAG.getNode(getScalarizedOpcode(Node->getOpcode(), SVT), SVT,
-   LegalizeOp(Node->getOperand(2)),
-   LegalizeOp(Node->getOperand(3)));
-} else {
-  assert(0 && "Expand case for vectors unimplemented");
-}
-break;
-  }
-
   case ISD::BUILD_PAIR: {
 MVT::ValueType PairTy = Node->getValueType(0);
 // TODO: handle the case where the Lo and Hi operands are not of legal type


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.103 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.104
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.103Sat Nov 19 
12:40:42 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp  Mon Nov 21 19:29:36 2005
@@ -517,9 +517,19 @@
 setValue(&I, DAG.getNode(FPOp, Op1.getValueType(), Op1, Op2));
   } else {
 const PackedType *PTy = cast(Ty);
-SDOperand Num = DAG.getConstant(PTy->getNumElements(), MVT::i32);
-SDOperand Typ = DAG.getValueType(TLI.getValueType(PTy->getElementType()));
-setValue(&I, DAG.getNode(VecOp, Op1.getValueType(), Num, Typ, Op1, Op2));
+unsigned NumElements = PTy->getNumElements();
+MVT::ValueType PVT = TLI.getValueType(PTy->getElementType());
+
+// Immediately scalarize packed types containing only one element, so that
+// the Legalize pass does not have to deal with them.
+if (NumElements == 1) {
+  unsigned Opc = MVT::isFloatingPoint(PVT) ? FPOp : IntOp;
+  setValue(&I, DAG.getNode(Opc, PVT, Op1, Op2));
+} else {
+  SDOperand Num = DAG.getConstant(NumElements, MVT::i32);
+  SDOperand Typ = DAG.getValueType(PVT);
+  setValue(&I, DAG.getNode(VecOp, Op1.getValueType(), Num, Typ, Op1, Op2));
+}
   }
 }
 
@@ -726,9 +736,17 @@
   
   if (Type::PackedTyID == Ty->getTypeID()) {
 const PackedType *PTy = cast(Ty);
-L = DAG.getVecLoad(PTy->getNumElements(), 
-   TLI.getValueType(PTy->getElementType()), Root, Ptr, 
-   DAG.getSrcValue(I.getOperand(0)));
+unsigned NumElements = PTy->getNumElements();
+MVT::ValueType PVT = TLI.getValueType(PTy-

[llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaCodeEmitter.cpp AlphaISelDAGToDAG.cpp AlphaISelPattern.cpp AlphaInstrFormats.td AlphaInstrInfo.td

2005-11-21 Thread Andrew Lenharth


Changes in directory llvm/lib/Target/Alpha:

AlphaCodeEmitter.cpp updated: 1.7 -> 1.8
AlphaISelDAGToDAG.cpp updated: 1.5 -> 1.6
AlphaISelPattern.cpp updated: 1.185 -> 1.186
AlphaInstrFormats.td updated: 1.13 -> 1.14
AlphaInstrInfo.td updated: 1.72 -> 1.73
---
Log message:

massive DAGISel patch.  lots and lots more stuff compiles now

---
Diffs of the changes:  (+207 -52)

 AlphaCodeEmitter.cpp  |4 -
 AlphaISelDAGToDAG.cpp |  151 +++---
 AlphaISelPattern.cpp  |   12 +++
 AlphaInstrFormats.td  |4 -
 AlphaInstrInfo.td |   88 +++--
 5 files changed, 207 insertions(+), 52 deletions(-)


Index: llvm/lib/Target/Alpha/AlphaCodeEmitter.cpp
diff -u llvm/lib/Target/Alpha/AlphaCodeEmitter.cpp:1.7 
llvm/lib/Target/Alpha/AlphaCodeEmitter.cpp:1.8
--- llvm/lib/Target/Alpha/AlphaCodeEmitter.cpp:1.7  Wed Nov 16 15:15:53 2005
+++ llvm/lib/Target/Alpha/AlphaCodeEmitter.cpp  Mon Nov 21 22:20:06 2005
@@ -117,7 +117,9 @@
 case Alpha::ALTENT:
 case Alpha::PCLABEL:
 case Alpha::MEMLABEL:
-case Alpha::IDEF:
+case Alpha::IDEF_I:
+case Alpha::IDEF_F32:
+case Alpha::IDEF_F64:
   break; //skip these
 }
   }


Index: llvm/lib/Target/Alpha/AlphaISelDAGToDAG.cpp
diff -u llvm/lib/Target/Alpha/AlphaISelDAGToDAG.cpp:1.5 
llvm/lib/Target/Alpha/AlphaISelDAGToDAG.cpp:1.6
--- llvm/lib/Target/Alpha/AlphaISelDAGToDAG.cpp:1.5 Wed Oct 26 13:44:46 2005
+++ llvm/lib/Target/Alpha/AlphaISelDAGToDAG.cpp Mon Nov 21 22:20:06 2005
@@ -38,6 +38,10 @@
   class AlphaDAGToDAGISel : public SelectionDAGISel {
 AlphaTargetLowering AlphaLowering;
 
+static const int IMM_LOW  = -32768;
+static const int IMM_HIGH = 32767;
+static const int IMM_MULT = 65536;
+
   public:
 AlphaDAGToDAGISel(TargetMachine &TM)
   : SelectionDAGISel(AlphaLowering), AlphaLowering(TM) {}
@@ -108,13 +112,42 @@
   case ISD::TAILCALL:
   case ISD::CALL: return SelectCALL(Op);
 
-  case ISD::DYNAMIC_STACKALLOC:
-assert(0 && "You want these too?");
+  case ISD::DYNAMIC_STACKALLOC: {
+if (!isa(N->getOperand(2)) ||
+cast(N->getOperand(2))->getValue() != 0) {
+  std::cerr << "Cannot allocate stack object with greater alignment than"
+<< " the stack alignment yet!";
+  abort();
+}
 
+SDOperand Chain = Select(N->getOperand(0));
+SDOperand Amt   = Select(N->getOperand(1));
+SDOperand Reg = CurDAG->getRegister(Alpha::R30, MVT::i64);
+SDOperand Val = CurDAG->getCopyFromReg(Chain, Alpha::R30, MVT::i64);
+Chain = Val.getValue(1);
+
+// Subtract the amount (guaranteed to be a multiple of the stack alignment)
+// from the stack pointer, giving us the result pointer.
+SDOperand Result = CurDAG->getTargetNode(Alpha::SUBQ, MVT::i64, Val, Amt);
+
+// Copy this result back into R30.
+Chain = CurDAG->getNode(ISD::CopyToReg, MVT::Other, Chain, Reg, Result);
+
+// Copy this result back out of R30 to make sure we're not using the stack
+// space without decrementing the stack pointer.
+Result = CurDAG->getCopyFromReg(Chain, Alpha::R30, MVT::i64);
+  
+// Finally, replace the DYNAMIC_STACKALLOC with the copyfromreg.
+CodeGenMap[Op.getValue(0)] = Result;
+CodeGenMap[Op.getValue(1)] = Result.getValue(1);
+return SDOperand(Result.Val, Op.ResNo);
+  }
   case ISD::BRCOND: {
 SDOperand Chain = Select(N->getOperand(0));
 SDOperand CC = Select(N->getOperand(1));
-CurDAG->SelectNodeTo(N, Alpha::BNE, MVT::Other,  CC, Chain);
+MachineBasicBlock *Dest =
+  cast(N->getOperand(2))->getBasicBlock();
+CurDAG->SelectNodeTo(N, Alpha::BNE, MVT::Other, CC, 
CurDAG->getBasicBlock(Dest), Chain);
 return SDOperand(N, 0);
   }
   case ISD::LOAD:
@@ -148,6 +181,33 @@
  getI64Imm(0), Address, Chain);
 return SDOperand(N, Op.ResNo);
   }
+  case ISD::STORE:
+  case ISD::TRUNCSTORE: {
+SDOperand Chain = Select(N->getOperand(0));
+SDOperand Value = Select(N->getOperand(1));
+SDOperand Address = Select(N->getOperand(2));
+
+unsigned Opc = Alpha::WTF;
+
+if (N->getOpcode() == ISD::STORE) {
+  switch (N->getOperand(1).getValueType()) {
+  case MVT::i64: Opc = Alpha::STQ; break;
+  case MVT::f64: Opc = Alpha::STT; break;
+  case MVT::f32: Opc = Alpha::STS; break;
+  default: assert(0 && "Bad store!");
+  };
+} else { //TRUNCSTORE
+  switch (cast(N->getOperand(4))->getVT()) {
+  case MVT::i32: Opc = Alpha::STL; break;
+  case MVT::i16: Opc = Alpha::STW; break;
+  case MVT::i8: Opc = Alpha::STB; break;
+  default: assert(0 && "Bad truncstore!");
+  };
+}
+CurDAG->SelectNodeTo(N, Opc, MVT::Other, Value, getI64Imm(0), Address, 
+ Chain);
+return SDOperand(N, 0);
+  }
 
   case ISD::BR: {
 CurDAG->SelectNodeTo(N, Alpha::BR_DAG, MVT::Other, N->getOperand(1),
@@ -155,32 +215,19 @@
 return SDOperand(N, 0);
   }