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

2007-06-04 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.164 - 1.165
---
Log message:

Global ctors / dtors alignment shouldn't be hard-coded at 4. e.g. It could be 8 
for 64-bit targets.

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

 AsmPrinter.cpp |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.164 
llvm/lib/CodeGen/AsmPrinter.cpp:1.165
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.164   Thu May 31 13:57:45 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Jun  4 15:39:18 2007
@@ -327,16 +327,18 @@
 return true;
   }
 
+  const TargetData *TD = TM.getTargetData();
+  unsigned Align = Log2_32(TD-getPointerPrefAlignment());
   if (GV-getName() == llvm.global_ctors  GV-use_empty()) {
 SwitchToDataSection(TAI-getStaticCtorsSection());
-EmitAlignment(2, 0);
+EmitAlignment(Align, 0);
 EmitXXStructorList(GV-getInitializer());
 return true;
   } 
   
   if (GV-getName() == llvm.global_dtors  GV-use_empty()) {
 SwitchToDataSection(TAI-getStaticDtorsSection());
-EmitAlignment(2, 0);
+EmitAlignment(Align, 0);
 EmitXXStructorList(GV-getInitializer());
 return true;
   }



___
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

2007-05-31 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.163 - 1.164
---
Log message:

Fix the asmprinter so that a globalvalue can specify an explicit alignment
smaller than the preferred alignment, but so that the target can actually
specify a minimum alignment if needed.  This fixes some objc protocol 
failures Devang tracked down.


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

 AsmPrinter.cpp |   23 ++-
 1 files changed, 18 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.163 
llvm/lib/CodeGen/AsmPrinter.cpp:1.164
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.163   Wed May  2 20:11:53 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu May 31 13:57:45 2007
@@ -605,12 +605,25 @@
 
 
//===--===//
 
-// EmitAlignment - Emit an alignment directive to the specified power of two.
-// Use the maximum of the specified alignment and the alignment from the
-// specified GlobalValue (if any).
-void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const {
+// 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
+// byte alignment.  If a global value is specified, and if that global has
+// an explicit alignment requested, it will unconditionally override the
+// alignment request.  However, if ForcedAlignBits is specified, this value
+// has final say: the ultimate alignment will be the max of ForcedAlignBits
+// and the alignment computed with NumBits and the global.
+//
+// The algorithm is:
+// Align = NumBits;
+// if (GV  GV-hasalignment) Align = GV-getalignment();
+// Align = std::max(Align, ForcedAlignBits);
+//
+void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV,
+   unsigned ForcedAlignBits) const {
   if (GV  GV-getAlignment())
-NumBits = std::max(NumBits, Log2_32(GV-getAlignment()));
+NumBits = Log2_32(GV-getAlignment());
+  NumBits = std::max(NumBits, ForcedAlignBits);
+  
   if (NumBits == 0) return;   // No need to emit alignment.
   if (TAI-getAlignmentIsInBytes()) NumBits = 1  NumBits;
   O  TAI-getAlignDirective()  NumBits  \n;



___
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 BranchFolding.cpp ELFWriter.cpp ELFWriter.h LiveIntervalAnalysis.cpp LiveVariables.cpp MachOWriter.cpp MachOWriter.h MachineFunction.cpp MachineModu

2007-05-02 Thread Devang Patel


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.161 - 1.162
BranchFolding.cpp updated: 1.47 - 1.48
ELFWriter.cpp updated: 1.39 - 1.40
ELFWriter.h updated: 1.2 - 1.3
LiveIntervalAnalysis.cpp updated: 1.241 - 1.242
LiveVariables.cpp updated: 1.80 - 1.81
MachOWriter.cpp updated: 1.33 - 1.34
MachOWriter.h updated: 1.4 - 1.5
MachineFunction.cpp updated: 1.112 - 1.113
MachineModuleInfo.cpp updated: 1.7 - 1.8
PHIElimination.cpp updated: 1.58 - 1.59
PrologEpilogInserter.cpp updated: 1.85 - 1.86
RegAllocLinearScan.cpp updated: 1.146 - 1.147
RegAllocLocal.cpp updated: 1.103 - 1.104
RegAllocSimple.cpp updated: 1.84 - 1.85
TwoAddressInstructionPass.cpp updated: 1.48 - 1.49
UnreachableBlockElim.cpp updated: 1.10 - 1.11
---
Log message:

Use 'static const char' instead of 'static const int'.
Due to darwin gcc bug, one version of darwin linker coalesces 
static const int, which defauts PassID based pass identification.


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

 AsmPrinter.cpp|2 +-
 BranchFolding.cpp |4 ++--
 ELFWriter.cpp |2 +-
 ELFWriter.h   |2 +-
 LiveIntervalAnalysis.cpp  |2 +-
 LiveVariables.cpp |2 +-
 MachOWriter.cpp   |2 +-
 MachOWriter.h |2 +-
 MachineFunction.cpp   |8 
 MachineModuleInfo.cpp |6 +++---
 PHIElimination.cpp|4 ++--
 PrologEpilogInserter.cpp  |4 ++--
 RegAllocLinearScan.cpp|4 ++--
 RegAllocLocal.cpp |4 ++--
 RegAllocSimple.cpp|4 ++--
 TwoAddressInstructionPass.cpp |4 ++--
 UnreachableBlockElim.cpp  |4 ++--
 17 files changed, 30 insertions(+), 30 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.161 
llvm/lib/CodeGen/AsmPrinter.cpp:1.162
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.161   Tue May  1 16:15:46 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed May  2 16:39:18 2007
@@ -32,7 +32,7 @@
 static cl::optbool
 AsmVerbose(asm-verbose, cl::Hidden, cl::desc(Add comments to directives.));
 
-const int AsmPrinter::ID = 0;
+const char AsmPrinter::ID = 0;
 AsmPrinter::AsmPrinter(std::ostream o, TargetMachine tm,
const TargetAsmInfo *T)
   : MachineFunctionPass((intptr_t)ID), FunctionNumber(0), O(o), TM(tm), TAI(T)


Index: llvm/lib/CodeGen/BranchFolding.cpp
diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.47 
llvm/lib/CodeGen/BranchFolding.cpp:1.48
--- llvm/lib/CodeGen/BranchFolding.cpp:1.47 Tue May  1 16:15:46 2007
+++ llvm/lib/CodeGen/BranchFolding.cpp  Wed May  2 16:39:18 2007
@@ -39,7 +39,7 @@
 
 namespace {
   struct BranchFolder : public MachineFunctionPass {
-static const int ID;
+static const char ID;
 BranchFolder() : MachineFunctionPass((intptr_t)ID) {}
 
 virtual bool runOnMachineFunction(MachineFunction MF);
@@ -67,7 +67,7 @@
 MachineBasicBlock *TBB, MachineBasicBlock *FBB,
 const std::vectorMachineOperand Cond);
   };
-  const int BranchFolder::ID = 0;
+  const char BranchFolder::ID = 0;
 }
 
 FunctionPass *llvm::createBranchFoldingPass() { return new BranchFolder(); }


Index: llvm/lib/CodeGen/ELFWriter.cpp
diff -u llvm/lib/CodeGen/ELFWriter.cpp:1.39 llvm/lib/CodeGen/ELFWriter.cpp:1.40
--- llvm/lib/CodeGen/ELFWriter.cpp:1.39 Tue May  1 16:15:46 2007
+++ llvm/lib/CodeGen/ELFWriter.cpp  Wed May  2 16:39:18 2007
@@ -47,7 +47,7 @@
 #include list
 using namespace llvm;
 
-const int ELFWriter::ID = 0;
+const char ELFWriter::ID = 0;
 /// AddELFWriter - Concrete function to add the ELF writer to the function pass
 /// manager.
 MachineCodeEmitter *llvm::AddELFWriter(FunctionPassManager FPM,


Index: llvm/lib/CodeGen/ELFWriter.h
diff -u llvm/lib/CodeGen/ELFWriter.h:1.2 llvm/lib/CodeGen/ELFWriter.h:1.3
--- llvm/lib/CodeGen/ELFWriter.h:1.2Tue May  1 16:15:46 2007
+++ llvm/lib/CodeGen/ELFWriter.hWed May  2 16:39:18 2007
@@ -30,7 +30,7 @@
   class ELFWriter : public MachineFunctionPass {
 friend class ELFCodeEmitter;
   public:
-static const int ID;
+static const char ID;
 
 MachineCodeEmitter getMachineCodeEmitter() const {
   return *(MachineCodeEmitter*)MCE;


Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.241 
llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.242
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.241 Wed May  2 15:37:47 2007
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp   Wed May  2 16:39:18 2007
@@ -44,7 +44,7 @@
 STATISTIC(numFolded   , Number of loads/stores folded into instructions);
 STATISTIC(numAborts   , Number of times interval joining aborted);
 
-const int LiveIntervals::ID = 0;
+const char LiveIntervals::ID = 0;
 namespace {
   RegisterPassLiveIntervals X(liveintervals, Live Interval Analysis);
 


Index: llvm/lib/CodeGen/LiveVariables.cpp
diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.80 

[llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp BranchFolding.cpp ELFWriter.cpp ELFWriter.h LiveIntervalAnalysis.cpp LiveVariables.cpp MachOWriter.cpp MachOWriter.h MachineFunction.cpp MachineModu

2007-05-02 Thread Devang Patel


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.162 - 1.163
BranchFolding.cpp updated: 1.48 - 1.49
ELFWriter.cpp updated: 1.40 - 1.41
ELFWriter.h updated: 1.3 - 1.4
LiveIntervalAnalysis.cpp updated: 1.242 - 1.243
LiveVariables.cpp updated: 1.81 - 1.82
MachOWriter.cpp updated: 1.34 - 1.35
MachOWriter.h updated: 1.5 - 1.6
MachineFunction.cpp updated: 1.113 - 1.114
MachineModuleInfo.cpp updated: 1.8 - 1.9
PHIElimination.cpp updated: 1.59 - 1.60
PrologEpilogInserter.cpp updated: 1.86 - 1.87
RegAllocLinearScan.cpp updated: 1.147 - 1.148
RegAllocLocal.cpp updated: 1.104 - 1.105
RegAllocSimple.cpp updated: 1.85 - 1.86
TwoAddressInstructionPass.cpp updated: 1.49 - 1.50
UnreachableBlockElim.cpp updated: 1.11 - 1.12
---
Log message:

Drop 'const'


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

 AsmPrinter.cpp|2 +-
 BranchFolding.cpp |4 ++--
 ELFWriter.cpp |2 +-
 ELFWriter.h   |2 +-
 LiveIntervalAnalysis.cpp  |2 +-
 LiveVariables.cpp |2 +-
 MachOWriter.cpp   |2 +-
 MachOWriter.h |2 +-
 MachineFunction.cpp   |8 
 MachineModuleInfo.cpp |6 +++---
 PHIElimination.cpp|4 ++--
 PrologEpilogInserter.cpp  |4 ++--
 RegAllocLinearScan.cpp|4 ++--
 RegAllocLocal.cpp |4 ++--
 RegAllocSimple.cpp|4 ++--
 TwoAddressInstructionPass.cpp |4 ++--
 UnreachableBlockElim.cpp  |4 ++--
 17 files changed, 30 insertions(+), 30 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.162 
llvm/lib/CodeGen/AsmPrinter.cpp:1.163
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.162   Wed May  2 16:39:18 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed May  2 20:11:53 2007
@@ -32,7 +32,7 @@
 static cl::optbool
 AsmVerbose(asm-verbose, cl::Hidden, cl::desc(Add comments to directives.));
 
-const char AsmPrinter::ID = 0;
+char AsmPrinter::ID = 0;
 AsmPrinter::AsmPrinter(std::ostream o, TargetMachine tm,
const TargetAsmInfo *T)
   : MachineFunctionPass((intptr_t)ID), FunctionNumber(0), O(o), TM(tm), TAI(T)


Index: llvm/lib/CodeGen/BranchFolding.cpp
diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.48 
llvm/lib/CodeGen/BranchFolding.cpp:1.49
--- llvm/lib/CodeGen/BranchFolding.cpp:1.48 Wed May  2 16:39:18 2007
+++ llvm/lib/CodeGen/BranchFolding.cpp  Wed May  2 20:11:53 2007
@@ -39,7 +39,7 @@
 
 namespace {
   struct BranchFolder : public MachineFunctionPass {
-static const char ID;
+static char ID;
 BranchFolder() : MachineFunctionPass((intptr_t)ID) {}
 
 virtual bool runOnMachineFunction(MachineFunction MF);
@@ -67,7 +67,7 @@
 MachineBasicBlock *TBB, MachineBasicBlock *FBB,
 const std::vectorMachineOperand Cond);
   };
-  const char BranchFolder::ID = 0;
+  char BranchFolder::ID = 0;
 }
 
 FunctionPass *llvm::createBranchFoldingPass() { return new BranchFolder(); }


Index: llvm/lib/CodeGen/ELFWriter.cpp
diff -u llvm/lib/CodeGen/ELFWriter.cpp:1.40 llvm/lib/CodeGen/ELFWriter.cpp:1.41
--- llvm/lib/CodeGen/ELFWriter.cpp:1.40 Wed May  2 16:39:18 2007
+++ llvm/lib/CodeGen/ELFWriter.cpp  Wed May  2 20:11:53 2007
@@ -47,7 +47,7 @@
 #include list
 using namespace llvm;
 
-const char ELFWriter::ID = 0;
+char ELFWriter::ID = 0;
 /// AddELFWriter - Concrete function to add the ELF writer to the function pass
 /// manager.
 MachineCodeEmitter *llvm::AddELFWriter(FunctionPassManager FPM,


Index: llvm/lib/CodeGen/ELFWriter.h
diff -u llvm/lib/CodeGen/ELFWriter.h:1.3 llvm/lib/CodeGen/ELFWriter.h:1.4
--- llvm/lib/CodeGen/ELFWriter.h:1.3Wed May  2 16:39:18 2007
+++ llvm/lib/CodeGen/ELFWriter.hWed May  2 20:11:53 2007
@@ -30,7 +30,7 @@
   class ELFWriter : public MachineFunctionPass {
 friend class ELFCodeEmitter;
   public:
-static const char ID;
+static char ID;
 
 MachineCodeEmitter getMachineCodeEmitter() const {
   return *(MachineCodeEmitter*)MCE;


Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.242 
llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.243
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.242 Wed May  2 16:39:18 2007
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp   Wed May  2 20:11:53 2007
@@ -44,7 +44,7 @@
 STATISTIC(numFolded   , Number of loads/stores folded into instructions);
 STATISTIC(numAborts   , Number of times interval joining aborted);
 
-const char LiveIntervals::ID = 0;
+char LiveIntervals::ID = 0;
 namespace {
   RegisterPassLiveIntervals X(liveintervals, Live Interval Analysis);
 


Index: llvm/lib/CodeGen/LiveVariables.cpp
diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.81 
llvm/lib/CodeGen/LiveVariables.cpp:1.82
--- llvm/lib/CodeGen/LiveVariables.cpp:1.81 Wed May  2 16:39:18 2007
+++ llvm/lib/CodeGen/LiveVariables.cpp  Wed May  2 20:11:53 2007
@@ -37,7 +37,7 @@
 #include 

[llvm-commits] CVS: llvm/lib/CodeGen/AsmPrinter.cpp BranchFolding.cpp ELFWriter.cpp ELFWriter.h LiveIntervalAnalysis.cpp LiveVariables.cpp MachOWriter.cpp MachOWriter.h MachineFunction.cpp MachineModu

2007-05-01 Thread Devang Patel


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.160 - 1.161
BranchFolding.cpp updated: 1.46 - 1.47
ELFWriter.cpp updated: 1.38 - 1.39
ELFWriter.h updated: 1.1 - 1.2
LiveIntervalAnalysis.cpp updated: 1.239 - 1.240
LiveVariables.cpp updated: 1.79 - 1.80
MachOWriter.cpp updated: 1.32 - 1.33
MachOWriter.h updated: 1.3 - 1.4
MachineFunction.cpp updated: 1.111 - 1.112
MachineModuleInfo.cpp updated: 1.5 - 1.6
PHIElimination.cpp updated: 1.57 - 1.58
PrologEpilogInserter.cpp updated: 1.84 - 1.85
RegAllocLinearScan.cpp updated: 1.145 - 1.146
RegAllocLocal.cpp updated: 1.102 - 1.103
RegAllocSimple.cpp updated: 1.83 - 1.84
TwoAddressInstructionPass.cpp updated: 1.47 - 1.48
UnreachableBlockElim.cpp updated: 1.9 - 1.10
---
Log message:

Do not use typeinfo to identify pass in pass manager.


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

 AsmPrinter.cpp|3 ++-
 BranchFolding.cpp |4 
 ELFWriter.cpp |4 +++-
 ELFWriter.h   |2 ++
 LiveIntervalAnalysis.cpp  |1 +
 LiveVariables.cpp |1 +
 MachOWriter.cpp   |4 +++-
 MachOWriter.h |1 +
 MachineFunction.cpp   |   11 +--
 MachineModuleInfo.cpp |9 -
 PHIElimination.cpp|4 
 PrologEpilogInserter.cpp  |4 
 RegAllocLinearScan.cpp|4 
 RegAllocLocal.cpp |5 +
 RegAllocSimple.cpp|6 +-
 TwoAddressInstructionPass.cpp |4 
 UnreachableBlockElim.cpp  |4 
 17 files changed, 64 insertions(+), 7 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.160 
llvm/lib/CodeGen/AsmPrinter.cpp:1.161
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.160   Mon Apr 30 12:00:18 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue May  1 16:15:46 2007
@@ -32,9 +32,10 @@
 static cl::optbool
 AsmVerbose(asm-verbose, cl::Hidden, cl::desc(Add comments to directives.));
 
+const int AsmPrinter::ID = 0;
 AsmPrinter::AsmPrinter(std::ostream o, TargetMachine tm,
const TargetAsmInfo *T)
-: FunctionNumber(0), O(o), TM(tm), TAI(T)
+  : MachineFunctionPass((intptr_t)ID), FunctionNumber(0), O(o), TM(tm), TAI(T)
 {}
 
 std::string AsmPrinter::getSectionForFunction(const Function F) const {


Index: llvm/lib/CodeGen/BranchFolding.cpp
diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.46 
llvm/lib/CodeGen/BranchFolding.cpp:1.47
--- llvm/lib/CodeGen/BranchFolding.cpp:1.46 Mon Apr 30 18:35:00 2007
+++ llvm/lib/CodeGen/BranchFolding.cpp  Tue May  1 16:15:46 2007
@@ -39,6 +39,9 @@
 
 namespace {
   struct BranchFolder : public MachineFunctionPass {
+static const int ID;
+BranchFolder() : MachineFunctionPass((intptr_t)ID) {}
+
 virtual bool runOnMachineFunction(MachineFunction MF);
 virtual const char *getPassName() const { return Control Flow Optimizer; 
}
 const TargetInstrInfo *TII;
@@ -64,6 +67,7 @@
 MachineBasicBlock *TBB, MachineBasicBlock *FBB,
 const std::vectorMachineOperand Cond);
   };
+  const int BranchFolder::ID = 0;
 }
 
 FunctionPass *llvm::createBranchFoldingPass() { return new BranchFolder(); }


Index: llvm/lib/CodeGen/ELFWriter.cpp
diff -u llvm/lib/CodeGen/ELFWriter.cpp:1.38 llvm/lib/CodeGen/ELFWriter.cpp:1.39
--- llvm/lib/CodeGen/ELFWriter.cpp:1.38 Tue Feb 13 23:52:17 2007
+++ llvm/lib/CodeGen/ELFWriter.cpp  Tue May  1 16:15:46 2007
@@ -47,6 +47,7 @@
 #include list
 using namespace llvm;
 
+const int ELFWriter::ID = 0;
 /// AddELFWriter - Concrete function to add the ELF writer to the function pass
 /// manager.
 MachineCodeEmitter *llvm::AddELFWriter(FunctionPassManager FPM,
@@ -176,7 +177,8 @@
 //  ELFWriter Implementation
 
//===--===//
 
-ELFWriter::ELFWriter(std::ostream o, TargetMachine tm) : O(o), TM(tm) {
+ELFWriter::ELFWriter(std::ostream o, TargetMachine tm) 
+  : MachineFunctionPass((intptr_t)ID), O(o), TM(tm) {
   e_flags = 0;// e_flags defaults to 0, no flags.
 
   is64Bit = TM.getTargetData()-getPointerSizeInBits() == 64;


Index: llvm/lib/CodeGen/ELFWriter.h
diff -u llvm/lib/CodeGen/ELFWriter.h:1.1 llvm/lib/CodeGen/ELFWriter.h:1.2
--- llvm/lib/CodeGen/ELFWriter.h:1.1Wed Feb  7 19:30:50 2007
+++ llvm/lib/CodeGen/ELFWriter.hTue May  1 16:15:46 2007
@@ -30,6 +30,8 @@
   class ELFWriter : public MachineFunctionPass {
 friend class ELFCodeEmitter;
   public:
+static const int ID;
+
 MachineCodeEmitter getMachineCodeEmitter() const {
   return *(MachineCodeEmitter*)MCE;
 }


Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.239 
llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.240
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.239 Thu Apr 26 13:59:33 2007
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp   Tue May  1 

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

2007-04-30 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.159 - 1.160
---
Log message:

Clean up multi-line asam string printing.  Instead of printing:

# InlineAsm Start
subfc r3,r5,r4
subfze r4,r3
# InlineAsm End

print:

# InlineAsm Start
subfc r3,r5,r4
subfze r4,r3
# InlineAsm End



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

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


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.159 
llvm/lib/CodeGen/AsmPrinter.cpp:1.160
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.159   Sun Apr 29 13:02:48 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Apr 30 12:00:18 2007
@@ -954,7 +954,7 @@
 }
 case '\n':
   ++LastEmitted;   // Consume newline character.
-  O  \n\t; // Indent code with newline.
+  O  \n;   // Indent code with newline.
   break;
 case '$': {
   ++LastEmitted;   // Consume '$' character.



___
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

2007-04-29 Thread Anton Korobeynikov


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.158 - 1.159
---
Log message:

Implement review feedback


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

 AsmPrinter.cpp |   15 +++
 1 files changed, 3 insertions(+), 12 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.158 
llvm/lib/CodeGen/AsmPrinter.cpp:1.159
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.158   Sat Apr 28 08:44:59 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sun Apr 29 13:02:48 2007
@@ -129,22 +129,13 @@
 O  \n;
 for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end();
  I!=E; ++I) {
-  const Constant *Aliasee = dyn_cast_or_nullConstant(I-getAliasee());
-  assert(Aliasee  Aliasee cannot be null);
-
   std::string Name = Mang-getValueName(I);
   std::string Target;
   
-  if (const GlobalValue *GV = dyn_castGlobalValue(Aliasee))
+  if (const GlobalValue *GV = I-getAliasedGlobal())
 Target = Mang-getValueName(GV);
-  else {
-const ConstantExpr *CE = 0;
-if ((CE = dyn_castConstantExpr(Aliasee)) 
-(CE-getOpcode() == Instruction::BitCast))
-  Target = Mang-getValueName(CE-getOperand(0));
-else
-  assert(0  Unsupported aliasee);
-  }
+  else
+assert(0  Unsupported aliasee);
   
   if (I-hasExternalLinkage())
 O  \t.globl\t  Name  \n;



___
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

2007-04-28 Thread Anton Korobeynikov


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.157 - 1.158
---
Log message:

Implement review feedback. Aliasees can be either GlobalValue's or 
bitcasts of them.


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

 AsmPrinter.cpp |   23 +--
 1 files changed, 17 insertions(+), 6 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.157 
llvm/lib/CodeGen/AsmPrinter.cpp:1.158
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.157   Wed Apr 25 09:27:10 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sat Apr 28 08:44:59 2007
@@ -123,18 +123,29 @@
   }
 
   if (TAI-getSetDirective()) {
-if (M.alias_size())
+if (!M.alias_empty())
   SwitchToTextSection(TAI-getTextSection());
 
 O  \n;
 for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end();
  I!=E; ++I) {
-  const GlobalValue *Aliasee = I-getAliasee();
-  assert(Aliasee  Aliasee cannot be null!);
-  std::string Target   = Mang-getValueName(Aliasee);
-  std::string Name = Mang-getValueName(I);
+  const Constant *Aliasee = dyn_cast_or_nullConstant(I-getAliasee());
+  assert(Aliasee  Aliasee cannot be null);
 
-  // Aliases with external weak linkage was emitted already
+  std::string Name = Mang-getValueName(I);
+  std::string Target;
+  
+  if (const GlobalValue *GV = dyn_castGlobalValue(Aliasee))
+Target = Mang-getValueName(GV);
+  else {
+const ConstantExpr *CE = 0;
+if ((CE = dyn_castConstantExpr(Aliasee)) 
+(CE-getOpcode() == Instruction::BitCast))
+  Target = Mang-getValueName(CE-getOperand(0));
+else
+  assert(0  Unsupported aliasee);
+  }
+  
   if (I-hasExternalLinkage())
 O  \t.globl\t  Name  \n;
   else if (I-hasWeakLinkage())



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


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

2007-04-28 Thread Chris Lattner
 Index: llvm/lib/CodeGen/AsmPrinter.cpp
 diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.157 llvm/lib/CodeGen/ 
 AsmPrinter.cpp:1.158
 --- llvm/lib/CodeGen/AsmPrinter.cpp:1.157 Wed Apr 25 09:27:10 2007
 +++ llvm/lib/CodeGen/AsmPrinter.cpp   Sat Apr 28 08:44:59 2007
 @@ -123,18 +123,29 @@
  for (Module::const_alias_iterator I = M.alias_begin(), E =  
 M.alias_end();
   I!=E; ++I) {
 -  const GlobalValue *Aliasee = I-getAliasee();
 -  assert(Aliasee  Aliasee cannot be null!);
 -  std::string Target   = Mang-getValueName(Aliasee);
 -  std::string Name = Mang-getValueName(I);
 +  const Constant *Aliasee = dyn_cast_or_nullConstant(I- 
 getAliasee());
 +  assert(Aliasee  Aliasee cannot be null);

Just use castConstant()

It will assert that the pointer is non-null and is a constant.


 -  // Aliases with external weak linkage was emitted already
 +  std::string Name = Mang-getValueName(I);
 +  std::string Target;
 +
 +  if (const GlobalValue *GV = dyn_castGlobalValue(Aliasee))
 +Target = Mang-getValueName(GV);
 +  else {
 +const ConstantExpr *CE = 0;
 +if ((CE = dyn_castConstantExpr(Aliasee)) 
 +(CE-getOpcode() == Instruction::BitCast))
 +  Target = Mang-getValueName(CE-getOperand(0));
 +else
 +  assert(0  Unsupported aliasee);

This seems like a common operation: I'd suggest introducing an (out- 
of-line) method to GlobalAlias:
  GlobalValue *GlobalAlias::getAliaseeGlobal() const

That does this.  At that point, you'd have:

   if (const GlobalValue *GV = I-getAliaseeGlobal())
 ..
   else
 assert();

-Chris


 +  }
 +
if (I-hasExternalLinkage())
  O  \t.globl\t  Name  \n;
else if (I-hasWeakLinkage())



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

___
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

2007-04-25 Thread Anton Korobeynikov


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.156 - 1.157
---
Log message:

Implement aliases. This fixes PR1017: http://llvm.org/PR1017  and it's 
dependent bugs. CFE part 
will follow.


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

 AsmPrinter.cpp |   26 +-
 1 files changed, 25 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.156 
llvm/lib/CodeGen/AsmPrinter.cpp:1.157
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.156   Mon Apr 23 18:33:31 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Apr 25 09:27:10 2007
@@ -111,7 +111,7 @@
 
 bool AsmPrinter::doFinalization(Module M) {
   if (TAI-getWeakRefDirective()) {
-if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
+if (!ExtWeakSymbols.empty())
   SwitchToDataSection();
 
 for (std::setconst GlobalValue*::iterator i = ExtWeakSymbols.begin(),
@@ -122,6 +122,30 @@
 }
   }
 
+  if (TAI-getSetDirective()) {
+if (M.alias_size())
+  SwitchToTextSection(TAI-getTextSection());
+
+O  \n;
+for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end();
+ I!=E; ++I) {
+  const GlobalValue *Aliasee = I-getAliasee();
+  assert(Aliasee  Aliasee cannot be null!);
+  std::string Target   = Mang-getValueName(Aliasee);
+  std::string Name = Mang-getValueName(I);
+
+  // Aliases with external weak linkage was emitted already
+  if (I-hasExternalLinkage())
+O  \t.globl\t  Name  \n;
+  else if (I-hasWeakLinkage())
+O  TAI-getWeakRefDirective()  Name  \n;
+  else if (!I-hasInternalLinkage())
+assert(0  Invalid alias linkage);
+  
+  O  TAI-getSetDirective()  Name  ,   Target  \n;
+}
+  }
+
   delete Mang; Mang = 0;
   return false;
 }



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


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

2007-04-25 Thread Chris Lattner
 +  if (TAI-getSetDirective()) {
 +if (M.alias_size())
 +  SwitchToTextSection(TAI-getTextSection());

M.alias_size is linear time (okay okay, in the number of aliases, but  
still...).  Please use !M.alias_empty()

-Chris


___
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

2007-04-23 Thread Dale Johannesen


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.154 - 1.155
---
Log message:

make EmitAlignment work the way Chris says it should


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

 AsmPrinter.cpp |4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.154 
llvm/lib/CodeGen/AsmPrinter.cpp:1.155
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.154   Tue Mar  6 13:25:02 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Apr 23 14:58:54 2007
@@ -579,8 +579,10 @@
 
//===--===//
 
 // EmitAlignment - Emit an alignment directive to the specified power of two.
+// Use the maximum of the specified alignment and the alignment from the
+// specified GlobalValue (if any).
 void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const {
-  if (GV  GV-getAlignment())
+  if (GV  GV-getAlignment()  Log2_32(GV-getAlignment())  NumBits)
 NumBits = Log2_32(GV-getAlignment());
   if (NumBits == 0) return;   // No need to emit alignment.
   if (TAI-getAlignmentIsInBytes()) NumBits = 1  NumBits;



___
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

2007-04-23 Thread Dale Johannesen


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.155 - 1.156
---
Log message:

modify per review commentary


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

 AsmPrinter.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.155 
llvm/lib/CodeGen/AsmPrinter.cpp:1.156
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.155   Mon Apr 23 14:58:54 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Apr 23 18:33:31 2007
@@ -582,8 +582,8 @@
 // Use the maximum of the specified alignment and the alignment from the
 // specified GlobalValue (if any).
 void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const {
-  if (GV  GV-getAlignment()  Log2_32(GV-getAlignment())  NumBits)
-NumBits = Log2_32(GV-getAlignment());
+  if (GV  GV-getAlignment())
+NumBits = std::max(NumBits, Log2_32(GV-getAlignment()));
   if (NumBits == 0) return;   // No need to emit alignment.
   if (TAI-getAlignmentIsInBytes()) NumBits = 1  NumBits;
   O  TAI-getAlignDirective()  NumBits  \n;



___
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

2007-03-06 Thread Anton Korobeynikov


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.153 - 1.154
---
Log message:

Small eye-candy: use asciz directive everywhere, where possible.


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

 AsmPrinter.cpp |   13 ++---
 1 files changed, 10 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.153 
llvm/lib/CodeGen/AsmPrinter.cpp:1.154
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.153   Wed Feb 21 16:48:45 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue Mar  6 13:25:02 2007
@@ -559,13 +559,20 @@
 /// Special characters are emitted properly.
 /// \literal (Eg. '\t') \endliteral
 void AsmPrinter::EmitString(const std::string String) const {
-  O  TAI-getAsciiDirective()
- \;
+  const char* AscizDirective = TAI-getAscizDirective();
+  if (AscizDirective)
+O  AscizDirective;
+  else
+O  TAI-getAsciiDirective();
+  O  \;
   for (unsigned i = 0, N = String.size(); i  N; ++i) {
 unsigned char C = String[i];
 printStringChar(O, C);
   }
-  O  \\0\;
+  if (AscizDirective)
+O  \;
+  else
+O  \\0\;
 }
 
 



___
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

2007-02-21 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.151 - 1.152
---
Log message:

Add support for changes in DwarfWriter.

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

 AsmPrinter.cpp |   12 
 1 files changed, 12 insertions(+)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.151 
llvm/lib/CodeGen/AsmPrinter.cpp:1.152
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.151   Thu Feb 15 19:54:53 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Feb 21 16:47:38 2007
@@ -370,6 +370,14 @@
   return LinkName;
 }
 
+/// EmitExternalGlobal - Emit the external reference to a global variable.
+/// Should be overridden if an indirect reference should be used.
+void AsmPrinter::EmitExternalGlobal(const GlobalVariable *GV) {
+  O  getGlobalLinkName(GV);
+}
+
+
+
 
//===--===//
 /// LEB 128 number encoding.
 
@@ -440,6 +448,9 @@
 
 /// EOL - Print a newline character to asm stream.  If a comment is present
 /// then it will be printed first.  Comments should not contain '\n'.
+void AsmPrinter::EOL() const {
+  O  \n;
+}
 void AsmPrinter::EOL(const std::string Comment) const {
   if (AsmVerbose  !Comment.empty()) {
 O  \t
@@ -569,6 +580,7 @@
   O  TAI-getAlignDirective()  NumBits  \n;
 }
 
+
 /// EmitZeros - Emit a block of zeros.
 ///
 void AsmPrinter::EmitZeros(uint64_t NumZeros) const {



___
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

2007-02-15 Thread Dale Johannesen


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.150 - 1.151
---
Log message:

test commit (blank line)


---
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.150 
llvm/lib/CodeGen/AsmPrinter.cpp:1.151
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.150   Wed Feb 14 20:26:09 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Feb 15 19:54:53 2007
@@ -1144,3 +1144,4 @@
 break;
   }
 }
+



___
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 MachOWriter.cpp

2007-02-14 Thread Reid Spencer


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.149 - 1.150
MachOWriter.cpp updated: 1.27 - 1.28
---
Log message:

For PR1195: http://llvm.org/PR1195 :
Rename PackedType - VectorType, ConstantPacked - ConstantVector, and
PackedTyID - VectorTyID. No functional changes.


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

 AsmPrinter.cpp  |4 ++--
 MachOWriter.cpp |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.149 
llvm/lib/CodeGen/AsmPrinter.cpp:1.150
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.149   Sat Feb 10 14:31:59 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Feb 14 20:26:09 2007
@@ -805,8 +805,8 @@
   }
   return;
 }
-  } else if (const ConstantPacked *CP = dyn_castConstantPacked(CV)) {
-const PackedType *PTy = CP-getType();
+  } else if (const ConstantVector *CP = dyn_castConstantVector(CV)) {
+const VectorType *PTy = CP-getType();
 
 for (unsigned I = 0, E = PTy-getNumElements(); I  E; ++I)
   EmitGlobalConstant(CP-getOperand(I));


Index: llvm/lib/CodeGen/MachOWriter.cpp
diff -u llvm/lib/CodeGen/MachOWriter.cpp:1.27 
llvm/lib/CodeGen/MachOWriter.cpp:1.28
--- llvm/lib/CodeGen/MachOWriter.cpp:1.27   Tue Feb 13 23:52:17 2007
+++ llvm/lib/CodeGen/MachOWriter.cppWed Feb 14 20:26:09 2007
@@ -769,7 +769,7 @@
 
 if (isaUndefValue(PC)) {
   continue;
-} else if (const ConstantPacked *CP = dyn_castConstantPacked(PC)) {
+} else if (const ConstantVector *CP = dyn_castConstantVector(PC)) {
   unsigned ElementSize = TD-getTypeSize(CP-getType()-getElementType());
   for (unsigned i = 0, e = CP-getNumOperands(); i != e; ++i)
 WorkList.push_back(CPair(CP-getOperand(i), PA+i*ElementSize));



___
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 MachOWriter.cpp

2007-02-10 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.146 - 1.147
MachOWriter.cpp updated: 1.24 - 1.25
---
Log message:

Privatize StructLayout::MemberOffsets, adding an accessor


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

 AsmPrinter.cpp  |4 ++--
 MachOWriter.cpp |3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.146 
llvm/lib/CodeGen/AsmPrinter.cpp:1.147
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.146   Mon Feb  5 19:56:31 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sat Feb 10 13:55:17 2007
@@ -739,8 +739,8 @@
   // Check if padding is needed and insert one or more 0s.
   uint64_t fieldSize = TD-getTypeSize(field-getType());
   uint64_t padSize = ((i == e-1? cvsLayout-StructSize
-   : cvsLayout-MemberOffsets[i+1])
-  - cvsLayout-MemberOffsets[i]) - fieldSize;
+   : cvsLayout-getElementOffset(i+1))
+  - cvsLayout-getElementOffset(i)) - fieldSize;
   sizeSoFar += fieldSize + padSize;
 
   // Now print the actual field value


Index: llvm/lib/CodeGen/MachOWriter.cpp
diff -u llvm/lib/CodeGen/MachOWriter.cpp:1.24 
llvm/lib/CodeGen/MachOWriter.cpp:1.25
--- llvm/lib/CodeGen/MachOWriter.cpp:1.24   Wed Feb  7 19:35:27 2007
+++ llvm/lib/CodeGen/MachOWriter.cppSat Feb 10 13:55:17 2007
@@ -878,7 +878,8 @@
   const StructLayout *SL =
 TD-getStructLayout(castStructType(CPS-getType()));
   for (unsigned i = 0, e = CPS-getNumOperands(); i != e; ++i)
-WorkList.push_back(CPair(CPS-getOperand(i), PA+SL-MemberOffsets[i]));
+WorkList.push_back(CPair(CPS-getOperand(i),
+ PA+SL-getElementOffset(i)));
 } else {
   cerr  Bad Type:   *PC-getType()  \n;
   assert(0  Unknown constant type to initialize memory with!);



___
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 MachOWriter.cpp

2007-02-10 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.148 - 1.149
MachOWriter.cpp updated: 1.25 - 1.26
---
Log message:

eliminate temporary vectors.


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

 AsmPrinter.cpp  |5 +++--
 MachOWriter.cpp |4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.148 
llvm/lib/CodeGen/AsmPrinter.cpp:1.149
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.148   Sat Feb 10 13:59:22 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sat Feb 10 14:31:59 2007
@@ -613,8 +613,9 @@
 case Instruction::GetElementPtr: {
   // generate a symbolic expression for the byte address
   const Constant *ptrVal = CE-getOperand(0);
-  std::vectorValue* idxVec(CE-op_begin()+1, CE-op_end());
-  if (int64_t Offset = TD-getIndexedOffset(ptrVal-getType(), idxVec)) {
+  SmallVectorValue*, 8 idxVec(CE-op_begin()+1, CE-op_end());
+  if (int64_t Offset = TD-getIndexedOffset(ptrVal-getType(), idxVec[0],
+idxVec.size())) {
 if (Offset)
   O  (;
 EmitConstantValueOnly(ptrVal);


Index: llvm/lib/CodeGen/MachOWriter.cpp
diff -u llvm/lib/CodeGen/MachOWriter.cpp:1.25 
llvm/lib/CodeGen/MachOWriter.cpp:1.26
--- llvm/lib/CodeGen/MachOWriter.cpp:1.25   Sat Feb 10 13:55:17 2007
+++ llvm/lib/CodeGen/MachOWriter.cppSat Feb 10 14:31:59 2007
@@ -779,9 +779,9 @@
   //
   switch (CE-getOpcode()) {
   case Instruction::GetElementPtr: {
-std::vectorValue* Indexes(CE-op_begin()+1, CE-op_end());
+SmallVectorValue*, 8 Indices(CE-op_begin()+1, CE-op_end());
 ScatteredOffset = TD-getIndexedOffset(CE-getOperand(0)-getType(),
-   Indexes);
+   Indices[0], Indices.size());
 WorkList.push_back(CPair(CE-getOperand(0), PA));
 break;
   }



___
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

2007-02-04 Thread Anton Korobeynikov


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.143 - 1.144
---
Log message:

Fixing silly not-implemented bug in AsmPrinter. This fixes PR1169: 
http://llvm.org/PR1169 .


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

 AsmPrinter.cpp |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.143 
llvm/lib/CodeGen/AsmPrinter.cpp:1.144
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.143   Thu Feb  1 11:46:10 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sun Feb  4 17:27:42 2007
@@ -608,7 +608,8 @@
 }
   } else if (const ConstantExpr *CE = dyn_castConstantExpr(CV)) {
 const TargetData *TD = TM.getTargetData();
-switch(CE-getOpcode()) {
+unsigned Opcode = CE-getOpcode();
+switch (Opcode) {
 case Instruction::GetElementPtr: {
   // generate a symbolic expression for the byte address
   const Constant *ptrVal = CE-getOperand(0);
@@ -666,9 +667,10 @@
   break;
 }
 case Instruction::Add:
+case Instruction::Sub:
   O  (;
   EmitConstantValueOnly(CE-getOperand(0));
-  O  ) + (;
+  O  (Opcode==Instruction::Add ? ) + ( : ) - ();
   EmitConstantValueOnly(CE-getOperand(1));
   O  );
   break;



___
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 DwarfWriter.cpp MachineModuleInfo.cpp

2007-02-01 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.141 - 1.142
DwarfWriter.cpp updated: 1.122 - 1.123
MachineModuleInfo.cpp updated: 1.2 - 1.3
---
Log message:

Support for non-landing pad exception handling.

---
Diffs of the changes:  (+272 -173)

 AsmPrinter.cpp|4 
 DwarfWriter.cpp   |  438 ++
 MachineModuleInfo.cpp |3 
 3 files changed, 272 insertions(+), 173 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.141 
llvm/lib/CodeGen/AsmPrinter.cpp:1.142
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.141   Fri Jan 26 15:22:28 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Feb  1 10:31:34 2007
@@ -1032,8 +1032,8 @@
 /// printLabel - This method prints a local label used by debug and
 /// exception handling tables.
 void AsmPrinter::printLabel(const MachineInstr *MI) const {
-  if (AsmVerbose) O  \n;
-  O  TAI-getPrivateGlobalPrefix()
+  O  \n
+ TAI-getPrivateGlobalPrefix()
  debug_loc
  MI-getOperand(0).getImmedValue()
  :\n;


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.122 
llvm/lib/CodeGen/DwarfWriter.cpp:1.123
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.122  Mon Jan 29 17:40:33 2007
+++ llvm/lib/CodeGen/DwarfWriter.cppThu Feb  1 10:31:34 2007
@@ -824,62 +824,13 @@
   // Accessors.
   //
   AsmPrinter *getAsm() const { return Asm; }
+  MachineModuleInfo *getMMI() const { return MMI; }
   const TargetAsmInfo *getTargetAsmInfo() const { return TAI; }
 
   /// ShouldEmitDwarf - Returns true if Dwarf declarations should be made.
   ///
   bool ShouldEmitDwarf() const { return shouldEmit; }
 
-};
-
-//===--===//
-/// DwarfDebug - Emits Dwarf debug directives. 
-///
-class DwarfDebug : public Dwarf {
-
-private:
-  
//======//
-  // Attributes used to construct specific Dwarf sections.
-  //
-  
-  /// CompileUnits - All the compile units involved in this build.  The index
-  /// of each entry in this vector corresponds to the sources in MMI.
-  std::vectorCompileUnit * CompileUnits;
-  
-  /// AbbreviationsSet - Used to uniquely define abbreviations.
-  ///
-  FoldingSetDIEAbbrev AbbreviationsSet;
-
-  /// Abbreviations - A list of all the unique abbreviations in use.
-  ///
-  std::vectorDIEAbbrev * Abbreviations;
-  
-  /// ValuesSet - Used to uniquely define values.
-  ///
-  FoldingSetDIEValue ValuesSet;
-  
-  /// Values - A list of all the unique values in use.
-  ///
-  std::vectorDIEValue * Values;
-  
-  /// StringPool - A UniqueVector of strings used by indirect references.
-  ///
-  UniqueVectorstd::string StringPool;
-
-  /// UnitMap - Map debug information descriptor to compile unit.
-  ///
-  std::mapDebugInfoDesc *, CompileUnit * DescToUnitMap;
-  
-  /// SectionMap - Provides a unique id per text section.
-  ///
-  UniqueVectorstd::string SectionMap;
-  
-  /// SectionSourceLines - Tracks line numbers per text section.
-  ///
-  std::vectorstd::vectorSourceLineInfo  SectionSourceLines;
-
-
-public:
 
   /// PrintLabelName - Print label name in form used by Dwarf writer.
   ///
@@ -905,24 +856,29 @@
   
   /// EmitReference - Emit a reference to a label.
   ///
-  void EmitReference(DWLabel Label) const {
-EmitReference(Label.Tag, Label.Number);
+  void EmitReference(DWLabel Label, bool IsPCRelative = false) const {
+EmitReference(Label.Tag, Label.Number, IsPCRelative);
   }
-  void EmitReference(const char *Tag, unsigned Number) const {
+  void EmitReference(const char *Tag, unsigned Number,
+ bool IsPCRelative = false) const {
 if (TAI-getAddressSize() == sizeof(int32_t))
   O  TAI-getData32bitsDirective();
 else
   O  TAI-getData64bitsDirective();
   
 PrintLabelName(Tag, Number);
+
+if (IsPCRelative) O  -  TAI-getPCSymbol();
   }
-  void EmitReference(const std::string Name) const {
+  void EmitReference(const std::string Name, bool IsPCRelative = false) const 
{
 if (TAI-getAddressSize() == sizeof(int32_t))
   O  TAI-getData32bitsDirective();
 else
   O  TAI-getData64bitsDirective();
   
 O  Name;
+
+if (IsPCRelative) O  -  TAI-getPCSymbol();
   }
 
   /// EmitDifference - Emit the difference between two labels.  Some
@@ -938,7 +894,7 @@
   const char *TagLo, unsigned NumberLo,
   bool IsSmall = false) const {
 if (TAI-needsSet()) {
-  static unsigned SetCounter = 0;
+  static unsigned SetCounter = 1;
   
   O  \t.set\t;
   PrintLabelName(set, SetCounter);
@@ -968,6 +924,151 @@
 }
   }
   
+  /// EmitFrameMoves - Emit frame instructions to describe the layout of the
+  /// frame.
+  void EmitFrameMoves(const char *BaseLabel, unsigned BaseLabelID,
+   

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

2007-02-01 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.142 - 1.143
DwarfWriter.cpp updated: 1.123 - 1.124
---
Log message:

Emit labels as label_n and not as debug_n

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

 AsmPrinter.cpp  |2 +-
 DwarfWriter.cpp |   16 
 2 files changed, 9 insertions(+), 9 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.142 
llvm/lib/CodeGen/AsmPrinter.cpp:1.143
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.142   Thu Feb  1 10:31:34 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Feb  1 11:46:10 2007
@@ -1034,7 +1034,7 @@
 void AsmPrinter::printLabel(const MachineInstr *MI) const {
   O  \n
  TAI-getPrivateGlobalPrefix()
- debug_loc
+ label_
  MI-getOperand(0).getImmedValue()
  :\n;
 }


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.123 
llvm/lib/CodeGen/DwarfWriter.cpp:1.124
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.123  Thu Feb  1 10:31:34 2007
+++ llvm/lib/CodeGen/DwarfWriter.cppThu Feb  1 11:46:10 2007
@@ -80,7 +80,7 @@
 if (O) print(*O);
   }
   void print(std::ostream O) const {
-O  .debug_  Tag;
+O  .D  Tag;
 if (Number) O  Number;
   }
 #endif
@@ -839,7 +839,7 @@
   }
   void PrintLabelName(const char *Tag, unsigned Number) const {
 O  TAI-getPrivateGlobalPrefix()
-   debug_
+   ((Tag  *Tag) ? debug_ : label_)
Tag;
 if (Number) O  Number;
   }
@@ -932,7 +932,7 @@
 Asm-TM.getFrameInfo()-getStackGrowthDirection() ==
   TargetFrameInfo::StackGrowsUp ?
 TAI-getAddressSize() : -TAI-getAddressSize();
-bool IsLocal = BaseLabel  strcmp(BaseLabel, loc) == 0;
+bool IsLocal = BaseLabel  strcmp(BaseLabel, ) == 0;
 
 for (unsigned i = 0, N = Moves.size(); i  N; ++i) {
   MachineMove Move = Moves[i];
@@ -952,11 +952,11 @@
   if (BaseLabel  LabelID  (BaseLabelID != LabelID || !IsLocal)) {
 Asm-EmitInt8(DW_CFA_advance_loc4);
 Asm-EOL(DW_CFA_advance_loc4);
-EmitDifference(loc, LabelID, BaseLabel, BaseLabelID, true);
+EmitDifference(, LabelID, BaseLabel, BaseLabelID, true);
 Asm-EOL();
 
 BaseLabelID = LabelID;
-BaseLabel = loc;
+BaseLabel = ;
 IsLocal = true;
   }
   
@@ -1850,14 +1850,14 @@
 // Add the scope bounds.
 if (StartID) {
   AddLabel(ScopeDie, DW_AT_low_pc, DW_FORM_addr,
- DWLabel(loc, StartID));
+ DWLabel(, StartID));
 } else {
   AddLabel(ScopeDie, DW_AT_low_pc, DW_FORM_addr,
  DWLabel(func_begin, SubprogramCount));
 }
 if (EndID) {
   AddLabel(ScopeDie, DW_AT_high_pc, DW_FORM_addr,
- DWLabel(loc, EndID));
+ DWLabel(, EndID));
 } else {
   AddLabel(ScopeDie, DW_AT_high_pc, DW_FORM_addr,
  DWLabel(func_end, SubprogramCount));
@@ -2217,7 +2217,7 @@
 Asm-EmitInt8(0); Asm-EOL(Extended Op);
 Asm-EmitInt8(TAI-getAddressSize() + 1); Asm-EOL(Op size);
 Asm-EmitInt8(DW_LNE_set_address); Asm-EOL(DW_LNE_set_address);
-EmitReference(loc,  LabelID); Asm-EOL(Location label);
+EmitReference(,  LabelID); Asm-EOL(Location label);
 
 // If change of source, then switch to the new source.
 if (Source != LineInfo.getSourceID()) {



___
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 BranchFolding.cpp MachineDebugInfo.cpp

2007-01-26 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.139 - 1.140
BranchFolding.cpp updated: 1.39 - 1.40
MachineDebugInfo.cpp updated: 1.70 - 1.71
---
Log message:

Make LABEL a builtin opcode.

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

 AsmPrinter.cpp   |   10 ++
 BranchFolding.cpp|8 ++--
 MachineDebugInfo.cpp |5 +
 3 files changed, 13 insertions(+), 10 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.139 
llvm/lib/CodeGen/AsmPrinter.cpp:1.140
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.139   Thu Jan 25 09:12:02 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Fri Jan 26 08:34:51 2007
@@ -1029,6 +1029,16 @@
   O  \n\t  TAI-getInlineAsmEnd()  \n;
 }
 
+/// printLabel - This method prints a local label used by debug and
+/// exception handling tables.
+void AsmPrinter::printLabel(const MachineInstr *MI) const {
+  if (AsmVerbose) O  \n;
+  O  TAI-getPrivateGlobalPrefix()
+ debug_loc
+ MI-getOperand(0).getImmedValue()
+ :\n;
+}
+
 /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
 /// instruction, using the specified assembler variant.  Targets should
 /// overried this to format as appropriate.


Index: llvm/lib/CodeGen/BranchFolding.cpp
diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.39 
llvm/lib/CodeGen/BranchFolding.cpp:1.40
--- llvm/lib/CodeGen/BranchFolding.cpp:1.39 Tue Dec 19 16:41:21 2006
+++ llvm/lib/CodeGen/BranchFolding.cpp  Fri Jan 26 08:34:51 2007
@@ -74,16 +74,12 @@
   while (!MBB-succ_empty())
 MBB-removeSuccessor(MBB-succ_end()-1);
   
-  // If there is DWARF info to active, check to see if there are any 
DWARF_LABEL
+  // If there is DWARF info to active, check to see if there are any LABEL
   // records in the basic block.  If so, unregister them from MachineDebugInfo.
   if (MDI  !MBB-empty()) {
-unsigned DWARF_LABELOpc = TII-getDWARF_LABELOpcode();
-assert(DWARF_LABELOpc 
-   Target supports dwarf but didn't implement getDWARF_LABELOpcode!);
-
 for (MachineBasicBlock::iterator I = MBB-begin(), E = MBB-end();
  I != E; ++I) {
-  if ((unsigned)I-getOpcode() == DWARF_LABELOpc) {
+  if ((unsigned)I-getOpcode() == TargetInstrInfo::LABEL) {
 // The label ID # is always operand #0, an immediate.
 MDI-InvalidateLabel(I-getOperand(0).getImm());
   }


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.70 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.71
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.70  Wed Jan 24 12:45:13 2007
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Fri Jan 26 08:34:51 2007
@@ -1649,9 +1649,6 @@
   // Get target instruction info.
   const TargetInstrInfo *TII = MF.getTarget().getInstrInfo();
   if (!TII) return false;
-  // Get target version of the debug label opcode.
-  unsigned DWARF_LABELOpc = TII-getDWARF_LABELOpcode();
-  if (!DWARF_LABELOpc) return false;
   
   // Track if change is made.
   bool MadeChange = false;
@@ -1664,7 +1661,7 @@
 // Iterate through instructions.
 for (MachineBasicBlock::iterator I = BB-begin(), E = BB-end(); I != E; ) 
{
   // Is it a debug label.
-  if ((unsigned)I-getOpcode() == DWARF_LABELOpc) {
+  if ((unsigned)I-getOpcode() == TargetInstrInfo::LABEL) {
 // The label ID # is always operand #0, an immediate.
 unsigned NextLabel = I-getOperand(0).getImm();
 



___
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 BranchFolding.cpp DwarfWriter.cpp PrologEpilogInserter.cpp

2007-01-26 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.140 - 1.141
BranchFolding.cpp updated: 1.40 - 1.41
DwarfWriter.cpp updated: 1.116 - 1.117
PrologEpilogInserter.cpp updated: 1.67 - 1.68
---
Log message:

Change the MachineDebugInfo to MachineModuleInfo to better reflect usage
for debugging and exception handling.


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

 AsmPrinter.cpp   |4 +--
 BranchFolding.cpp|   12 -
 DwarfWriter.cpp  |   60 +++
 PrologEpilogInserter.cpp |6 ++--
 4 files changed, 41 insertions(+), 41 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.140 
llvm/lib/CodeGen/AsmPrinter.cpp:1.141
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.140   Fri Jan 26 08:34:51 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Fri Jan 26 15:22:28 2007
@@ -102,8 +102,8 @@
 
   SwitchToDataSection();   // Reset back to no section.
   
-  if (MachineDebugInfo *DebugInfo = getAnalysisToUpdateMachineDebugInfo()) {
-DebugInfo-AnalyzeModule(M);
+  if (MachineModuleInfo *MMI = getAnalysisToUpdateMachineModuleInfo()) {
+MMI-AnalyzeModule(M);
   }
   
   return false;


Index: llvm/lib/CodeGen/BranchFolding.cpp
diff -u llvm/lib/CodeGen/BranchFolding.cpp:1.40 
llvm/lib/CodeGen/BranchFolding.cpp:1.41
--- llvm/lib/CodeGen/BranchFolding.cpp:1.40 Fri Jan 26 08:34:51 2007
+++ llvm/lib/CodeGen/BranchFolding.cpp  Fri Jan 26 15:22:28 2007
@@ -18,7 +18,7 @@
 
 #define DEBUG_TYPE branchfolding
 #include llvm/CodeGen/Passes.h
-#include llvm/CodeGen/MachineDebugInfo.h
+#include llvm/CodeGen/MachineModuleInfo.h
 #include llvm/CodeGen/MachineFunctionPass.h
 #include llvm/CodeGen/MachineJumpTableInfo.h
 #include llvm/Target/TargetInstrInfo.h
@@ -40,7 +40,7 @@
 virtual bool runOnMachineFunction(MachineFunction MF);
 virtual const char *getPassName() const { return Control Flow Optimizer; 
}
 const TargetInstrInfo *TII;
-MachineDebugInfo *MDI;
+MachineModuleInfo *MMI;
 bool MadeChange;
   private:
 // Tail Merging.
@@ -75,13 +75,13 @@
 MBB-removeSuccessor(MBB-succ_end()-1);
   
   // If there is DWARF info to active, check to see if there are any LABEL
-  // records in the basic block.  If so, unregister them from MachineDebugInfo.
-  if (MDI  !MBB-empty()) {
+  // records in the basic block.  If so, unregister them from 
MachineModuleInfo.
+  if (MMI  !MBB-empty()) {
 for (MachineBasicBlock::iterator I = MBB-begin(), E = MBB-end();
  I != E; ++I) {
   if ((unsigned)I-getOpcode() == TargetInstrInfo::LABEL) {
 // The label ID # is always operand #0, an immediate.
-MDI-InvalidateLabel(I-getOperand(0).getImm());
+MMI-InvalidateLabel(I-getOperand(0).getImm());
   }
 }
   }
@@ -94,7 +94,7 @@
   TII = MF.getTarget().getInstrInfo();
   if (!TII) return false;
 
-  MDI = getAnalysisToUpdateMachineDebugInfo();
+  MMI = getAnalysisToUpdateMachineModuleInfo();
   
   bool EverMadeChange = false;
   bool MadeChangeThisIteration = true;


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.116 
llvm/lib/CodeGen/DwarfWriter.cpp:1.117
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.116  Fri Jan 26 08:19:17 2007
+++ llvm/lib/CodeGen/DwarfWriter.cppFri Jan 26 15:22:28 2007
@@ -19,7 +19,7 @@
 #include llvm/Module.h
 #include llvm/Type.h
 #include llvm/CodeGen/AsmPrinter.h
-#include llvm/CodeGen/MachineDebugInfo.h
+#include llvm/CodeGen/MachineModuleInfo.h
 #include llvm/CodeGen/MachineFrameInfo.h
 #include llvm/CodeGen/MachineLocation.h
 #include llvm/Support/Dwarf.h
@@ -786,9 +786,9 @@
   ///
   MachineFunction *MF;
   
-  /// DebugInfo - Collected debug information.
+  /// MMI - Collected machine module information.
   ///
-  MachineDebugInfo *DebugInfo;
+  MachineModuleInfo *MMI;
   
   /// didInitial - Flag to indicate if initial emission has been done.
   ///
@@ -807,7 +807,7 @@
   //
   
   /// CompileUnits - All the compile units involved in this build.  The index
-  /// of each entry in this vector corresponds to the sources in DebugInfo.
+  /// of each entry in this vector corresponds to the sources in MMI.
   std::vectorCompileUnit * CompileUnits;
   
   /// AbbreviationsSet - Used to uniquely define abbreviations.
@@ -1702,8 +1702,8 @@
   // FIXME - Ignore inlined functions for the time being.
   if (!Scope-getParent()) continue;
   
-  unsigned StartID = DebugInfo-MappedLabel(Scope-getStartLabelID());
-  unsigned EndID = DebugInfo-MappedLabel(Scope-getEndLabelID());
+  unsigned StartID = MMI-MappedLabel(Scope-getStartLabelID());
+  unsigned EndID = MMI-MappedLabel(Scope-getEndLabelID());
 
   // Ignore empty scopes.
   if (StartID == EndID  StartID != 0) continue;
@@ -1933,7 +1933,7 @@
   unsigned LabelID = Move.getLabelID();
   
   if (LabelID) {
-LabelID = DebugInfo-MappedLabel(LabelID);
+LabelID = MMI-MappedLabel(LabelID);
   

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

2007-01-25 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.138 - 1.139
DwarfWriter.cpp updated: 1.113 - 1.114
---
Log message:

Migrate print routines to asm to be shared by exception handling.


---
Diffs of the changes:  (+382 -369)

 AsmPrinter.cpp  |  223 ---
 DwarfWriter.cpp |  528 +++-
 2 files changed, 382 insertions(+), 369 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.138 
llvm/lib/CodeGen/AsmPrinter.cpp:1.139
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.138   Mon Jan 22 18:36:17 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Jan 25 09:12:02 2007
@@ -18,6 +18,7 @@
 #include llvm/Module.h
 #include llvm/CodeGen/MachineConstantPool.h
 #include llvm/CodeGen/MachineJumpTableInfo.h
+#include llvm/Support/CommandLine.h
 #include llvm/Support/Mangler.h
 #include llvm/Support/MathExtras.h
 #include llvm/Support/Streams.h
@@ -28,6 +29,9 @@
 #include cerrno
 using namespace llvm;
 
+static cl::optbool
+AsmVerbose(asm-verbose, cl::Hidden, cl::desc(Add comments to directives.));
+
 AsmPrinter::AsmPrinter(std::ostream o, TargetMachine tm,
const TargetAsmInfo *T)
 : FunctionNumber(0), O(o), TM(tm), TAI(T)
@@ -366,6 +370,196 @@
   return LinkName;
 }
 
+//===--===//
+/// LEB 128 number encoding.
+
+/// PrintULEB128 - Print a series of hexidecimal values (separated by commas)
+/// representing an unsigned leb128 value.
+void AsmPrinter::PrintULEB128(unsigned Value) const {
+  do {
+unsigned Byte = Value  0x7f;
+Value = 7;
+if (Value) Byte |= 0x80;
+O  0x  std::hex  Byte  std::dec;
+if (Value) O  , ;
+  } while (Value);
+}
+
+/// SizeULEB128 - Compute the number of bytes required for an unsigned leb128
+/// value.
+unsigned AsmPrinter::SizeULEB128(unsigned Value) {
+  unsigned Size = 0;
+  do {
+Value = 7;
+Size += sizeof(int8_t);
+  } while (Value);
+  return Size;
+}
+
+/// PrintSLEB128 - Print a series of hexidecimal values (separated by commas)
+/// representing a signed leb128 value.
+void AsmPrinter::PrintSLEB128(int Value) const {
+  int Sign = Value  (8 * sizeof(Value) - 1);
+  bool IsMore;
+  
+  do {
+unsigned Byte = Value  0x7f;
+Value = 7;
+IsMore = Value != Sign || ((Byte ^ Sign)  0x40) != 0;
+if (IsMore) Byte |= 0x80;
+O  0x  std::hex  Byte  std::dec;
+if (IsMore) O  , ;
+  } while (IsMore);
+}
+
+/// SizeSLEB128 - Compute the number of bytes required for a signed leb128
+/// value.
+unsigned AsmPrinter::SizeSLEB128(int Value) {
+  unsigned Size = 0;
+  int Sign = Value  (8 * sizeof(Value) - 1);
+  bool IsMore;
+  
+  do {
+unsigned Byte = Value  0x7f;
+Value = 7;
+IsMore = Value != Sign || ((Byte ^ Sign)  0x40) != 0;
+Size += sizeof(int8_t);
+  } while (IsMore);
+  return Size;
+}
+
+//======//
+// Emission and print routines
+//
+
+/// PrintHex - Print a value as a hexidecimal value.
+///
+void AsmPrinter::PrintHex(int Value) const { 
+  O  0x  std::hex  Value  std::dec;
+}
+
+/// EOL - Print a newline character to asm stream.  If a comment is present
+/// then it will be printed first.  Comments should not contain '\n'.
+void AsmPrinter::EOL(const std::string Comment) const {
+  if (AsmVerbose  !Comment.empty()) {
+O  \t
+   TAI-getCommentString()
+
+   Comment;
+  }
+  O  \n;
+}
+
+/// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
+/// unsigned leb128 value.
+void AsmPrinter::EmitULEB128Bytes(unsigned Value) const {
+  if (TAI-hasLEB128()) {
+O  \t.uleb128\t
+   Value;
+  } else {
+O  TAI-getData8bitsDirective();
+PrintULEB128(Value);
+  }
+}
+
+/// EmitSLEB128Bytes - print an assembler byte data directive to compose a
+/// signed leb128 value.
+void AsmPrinter::EmitSLEB128Bytes(int Value) const {
+  if (TAI-hasLEB128()) {
+O  \t.sleb128\t
+   Value;
+  } else {
+O  TAI-getData8bitsDirective();
+PrintSLEB128(Value);
+  }
+}
+
+/// EmitInt8 - Emit a byte directive and value.
+///
+void AsmPrinter::EmitInt8(int Value) const {
+  O  TAI-getData8bitsDirective();
+  PrintHex(Value  0xFF);
+}
+
+/// EmitInt16 - Emit a short directive and value.
+///
+void AsmPrinter::EmitInt16(int Value) const {
+  O  TAI-getData16bitsDirective();
+  PrintHex(Value  0x);
+}
+
+/// EmitInt32 - Emit a long directive and value.
+///
+void AsmPrinter::EmitInt32(int Value) const {
+  O  TAI-getData32bitsDirective();
+  PrintHex(Value);
+}
+
+/// EmitInt64 - Emit a long long directive and value.
+///
+void AsmPrinter::EmitInt64(uint64_t Value) const {
+  if (TAI-getData64bitsDirective()) {
+O  TAI-getData64bitsDirective();
+PrintHex(Value);
+  } else {
+if (TM.getTargetData()-isBigEndian()) {
+  EmitInt32(unsigned(Value  32)); O  \n;
+  EmitInt32(unsigned(Value));
+} 

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

2007-01-22 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.137 - 1.138
---
Log message:

Fix a bunch of inline asm failures


---
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.137 
llvm/lib/CodeGen/AsmPrinter.cpp:1.138
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.137   Wed Jan 17 19:12:56 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Jan 22 18:36:17 2007
@@ -779,6 +779,7 @@
   
   const char *IDStart = LastEmitted;
   char *IDEnd;
+  errno = 0;
   long Val = strtol(IDStart, IDEnd, 10); // We only accept numbers for 
IDs.
   if (!isdigit(*IDStart) || (Val == 0  errno == EINVAL)) {
 cerr  Bad $ operand number in inline asm string: ' 



___
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

2007-01-17 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.136 - 1.137
---
Log message:

add new JumpTableSpecialLabelPrefix hook to asmprinter for jumptable emission.


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

 AsmPrinter.cpp |   10 +-
 1 files changed, 9 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.136 
llvm/lib/CodeGen/AsmPrinter.cpp:1.137
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.136   Mon Jan 15 21:42:04 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Jan 17 19:12:56 2007
@@ -244,6 +244,13 @@
 if (EmittedSets.insert(JTBBs[ii]).second)
   printSetLabel(i, JTBBs[ii]);
 
+// On some targets (e.g. darwin) we want to emit two consequtive labels
+// before each jump table.  The first label is never referenced, but tells
+// the assembler and linker the extents of the jump table object.  The
+// second label is actually referenced by the code.
+if (const char *JTLabelPrefix = TAI-getJumpTableSpecialLabelPrefix())
+  O  JTLabelPrefix  JTI  getFunctionNumber()  '_'  i  :\n;
+
 O  TAI-getPrivateGlobalPrefix()  JTI  getFunctionNumber() 
'_'  i  :\n;
 
@@ -259,7 +266,8 @@
'_'  i  _set_  JTBBs[ii]-getNumber();
   } else if (IsPic) {
 printBasicBlockLabel(JTBBs[ii], false, false);
-//If the arch uses custom Jump Table directives, don't calc relative 
to JT
+// If the arch uses custom Jump Table directives, don't calc relative 
to
+// JT
 if (!HadJTEntryDirective) 
   O  '-'  TAI-getPrivateGlobalPrefix()  JTI
  getFunctionNumber()  '_'  i;



___
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

2007-01-15 Thread Bill Wendling


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.135 - 1.136
---
Log message:

Fix for PR1095: http://llvm.org/PR1095 :
LLVM would miscompile ASM dialects when compiling for PPC. Added dialects for
the X86 and PPC backends. It defaults to 0, the first variant of a compound
inline asm expression.



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

 AsmPrinter.cpp |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.135 
llvm/lib/CodeGen/AsmPrinter.cpp:1.136
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.135   Sun Jan 14 20:27:26 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Jan 15 21:42:04 2007
@@ -698,9 +698,9 @@
   
   O  TAI-getInlineAsmStart()  \n\t;
 
-  // The variant of the current asmprinter: FIXME: change.
-  int AsmPrinterVariant = 0;
-  
+  // The variant of the current asmprinter.
+  int AsmPrinterVariant = TAI-getAssemblerDialect();
+
   int CurVariant = -1;// The number of the {.|.|.} region we are 
in.
   const char *LastEmitted = AsmStr; // One past the last character emitted.
   



___
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 IntrinsicLowering.cpp

2007-01-14 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.134 - 1.135
IntrinsicLowering.cpp updated: 1.58 - 1.59
---
Log message:

rename Type::isIntegral to Type::isInteger, eliminating the old Type::isInteger.
rename Type::getIntegralTypeMask to Type::getIntegerTypeMask.

This makes naming much more consistent.  For example, there are now no longer 
any
instances of IntegerType that are not considered isInteger! :)



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

 AsmPrinter.cpp|2 +-
 IntrinsicLowering.cpp |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.134 
llvm/lib/CodeGen/AsmPrinter.cpp:1.135
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.134   Fri Jan 12 12:15:09 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sun Jan 14 20:27:26 2007
@@ -455,7 +455,7 @@
 
   // We can emit the pointer value into this slot if the slot is an
   // integer slot greater or equal to the size of the pointer.
-  if (Ty-isIntegral() 
+  if (Ty-isInteger() 
   TD-getTypeSize(Ty) = TD-getTypeSize(Op-getType()))
 return EmitConstantValueOnly(Op);
   


Index: llvm/lib/CodeGen/IntrinsicLowering.cpp
diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.58 
llvm/lib/CodeGen/IntrinsicLowering.cpp:1.59
--- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.58 Sun Jan 14 20:03:16 2007
+++ llvm/lib/CodeGen/IntrinsicLowering.cpp  Sun Jan 14 20:27:26 2007
@@ -107,7 +107,7 @@
 /// LowerBSWAP - Emit the code to lower bswap of V before the specified
 /// instruction IP.
 static Value *LowerBSWAP(Value *V, Instruction *IP) {
-  assert(V-getType()-isIntegral()  Can't bswap a non-integer type!);
+  assert(V-getType()-isInteger()  Can't bswap a non-integer type!);
 
   unsigned BitSize = V-getType()-getPrimitiveSizeInBits();
   
@@ -193,7 +193,7 @@
 /// LowerCTPOP - Emit the code to lower ctpop of V before the specified
 /// instruction IP.
 static Value *LowerCTPOP(Value *V, Instruction *IP) {
-  assert(V-getType()-isIntegral()  Can't ctpop a non-integer type!);
+  assert(V-getType()-isInteger()  Can't ctpop a non-integer type!);
 
   static const uint64_t MaskValues[6] = {
 0xULL, 0xULL,



___
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

2007-01-12 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.133 - 1.134
---
Log message:

Simplify code


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

 AsmPrinter.cpp |5 +
 1 files changed, 1 insertion(+), 4 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.133 
llvm/lib/CodeGen/AsmPrinter.cpp:1.134
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.133   Fri Jan 12 01:05:13 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Fri Jan 12 12:15:09 2007
@@ -389,10 +389,7 @@
   if (CV-isNullValue() || isaUndefValue(CV))
 O  0;
   else if (const ConstantInt *CI = dyn_castConstantInt(CV)) {
-if (CI-getType() == Type::Int1Ty) {
-  assert(CI-getZExtValue());
-  O  1;
-} else O  CI-getSExtValue();
+O  CI-getZExtValue();
   } else if (const GlobalValue *GV = dyn_castGlobalValue(CV)) {
 // This is a constant address for a global variable or function. Use the
 // name of the variable or function as the address value, possibly



___
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 MachineDebugInfo.cpp

2007-01-11 Thread Zhou Sheng


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.129 - 1.130
MachineDebugInfo.cpp updated: 1.66 - 1.67
---
Log message:

For PR1043: http://llvm.org/PR1043 :
Merge ConstantIntegral and ConstantBool into ConstantInt.
Remove ConstantIntegral and ConstantBool from LLVM.


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

 AsmPrinter.cpp   |   10 +-
 MachineDebugInfo.cpp |6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.129 
llvm/lib/CodeGen/AsmPrinter.cpp:1.130
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.129   Sat Dec 30 23:55:36 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Jan 11 06:24:14 2007
@@ -388,11 +388,11 @@
 void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {
   if (CV-isNullValue() || isaUndefValue(CV))
 O  0;
-  else if (const ConstantBool *CB = dyn_castConstantBool(CV)) {
-assert(CB-getValue());
-O  1;
-  } else if (const ConstantInt *CI = dyn_castConstantInt(CV)) {
-O  CI-getSExtValue();
+  else if (const ConstantInt *CI = dyn_castConstantInt(CV)) {
+if (CI-getType() == Type::BoolTy) {
+  assert(CI-getBoolValue());
+  O  1;
+} else O  CI-getSExtValue();
   } else if (const GlobalValue *GV = dyn_castGlobalValue(CV)) {
 // This is a constant address for a global variable or function. Use the
 // name of the variable or function as the address value, possibly


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.66 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.67
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.66  Wed Jan  3 07:46:20 2007
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Thu Jan 11 06:24:14 2007
@@ -211,7 +211,7 @@
   }
   virtual void Apply(bool Field) {
 Constant *C = CI-getOperand(I++);
-Field = castConstantBool(C)-getValue();
+Field = castConstantInt(C)-getBoolValue();
   }
   virtual void Apply(std::string Field) {
 Constant *C = CI-getOperand(I++);
@@ -276,7 +276,7 @@
 Elements.push_back(ConstantInt::get(Type::Int64Ty, uint64_t(Field)));
   }
   virtual void Apply(bool Field) {
-Elements.push_back(ConstantBool::get(Field));
+Elements.push_back(ConstantInt::get(Field));
   }
   virtual void Apply(std::string Field) {
   Elements.push_back(SR.getString(Field));
@@ -426,7 +426,7 @@
   }
   virtual void Apply(bool Field) {
 Constant *C = CI-getOperand(I++);
-IsValid = IsValid  isaConstantBool(C);
+IsValid = IsValid  isaConstantInt(C)  C-getType() == Type::BoolTy;
   }
   virtual void Apply(std::string Field) {
 Constant *C = CI-getOperand(I++);



___
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 MachOWriter.cpp MachineDebugInfo.cpp

2007-01-11 Thread Reid Spencer


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.130 - 1.131
MachOWriter.cpp updated: 1.10 - 1.11
MachineDebugInfo.cpp updated: 1.67 - 1.68
---
Log message:

Rename BoolTy as Int1Ty. Patch by Sheng Zhou.


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

 AsmPrinter.cpp   |4 ++--
 MachOWriter.cpp  |2 +-
 MachineDebugInfo.cpp |4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.130 
llvm/lib/CodeGen/AsmPrinter.cpp:1.131
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.130   Thu Jan 11 06:24:14 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Jan 11 12:21:29 2007
@@ -389,7 +389,7 @@
   if (CV-isNullValue() || isaUndefValue(CV))
 O  0;
   else if (const ConstantInt *CI = dyn_castConstantInt(CV)) {
-if (CI-getType() == Type::BoolTy) {
+if (CI-getType() == Type::Int1Ty) {
   assert(CI-getBoolValue());
   O  1;
 } else O  CI-getSExtValue();
@@ -917,7 +917,7 @@
 void AsmPrinter::printDataDirective(const Type *type) {
   const TargetData *TD = TM.getTargetData();
   switch (type-getTypeID()) {
-  case Type::BoolTyID:
+  case Type::Int1TyID:
   case Type::Int8TyID:
 O  TAI-getData8bitsDirective();
 break;


Index: llvm/lib/CodeGen/MachOWriter.cpp
diff -u llvm/lib/CodeGen/MachOWriter.cpp:1.10 
llvm/lib/CodeGen/MachOWriter.cpp:1.11
--- llvm/lib/CodeGen/MachOWriter.cpp:1.10   Sat Dec 30 23:55:36 2006
+++ llvm/lib/CodeGen/MachOWriter.cppThu Jan 11 12:21:29 2007
@@ -729,7 +729,7 @@
   uint64_t val;
   
   switch (PC-getType()-getTypeID()) {
-  case Type::BoolTyID:
+  case Type::Int1TyID:
   case Type::Int8TyID:
 ptr[0] = castConstantInt(PC)-getZExtValue();
 break;


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.67 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.68
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.67  Thu Jan 11 06:24:14 2007
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Thu Jan 11 12:21:29 2007
@@ -363,7 +363,7 @@
 Fields.push_back(Type::Int64Ty);
   }
   virtual void Apply(bool Field) {
-Fields.push_back(Type::BoolTy);
+Fields.push_back(Type::Int1Ty);
   }
   virtual void Apply(std::string Field) {
 Fields.push_back(SR.getStrPtrType());
@@ -426,7 +426,7 @@
   }
   virtual void Apply(bool Field) {
 Constant *C = CI-getOperand(I++);
-IsValid = IsValid  isaConstantInt(C)  C-getType() == Type::BoolTy;
+IsValid = IsValid  isaConstantInt(C)  C-getType() == Type::Int1Ty;
   }
   virtual void Apply(std::string Field) {
 Constant *C = CI-getOperand(I++);



___
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 MachineDebugInfo.cpp

2007-01-11 Thread Reid Spencer


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.131 - 1.132
MachineDebugInfo.cpp updated: 1.68 - 1.69
---
Log message:

Implement review feedback for the ConstantBool-ConstantInt merge. Chris
recommended that getBoolValue be replaced with getZExtValue and that
get(bool) be replaced by get(const Type*, uint64_t). This implements
those changes.


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

 AsmPrinter.cpp   |2 +-
 MachineDebugInfo.cpp |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.131 
llvm/lib/CodeGen/AsmPrinter.cpp:1.132
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.131   Thu Jan 11 12:21:29 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Jan 11 22:24:45 2007
@@ -390,7 +390,7 @@
 O  0;
   else if (const ConstantInt *CI = dyn_castConstantInt(CV)) {
 if (CI-getType() == Type::Int1Ty) {
-  assert(CI-getBoolValue());
+  assert(CI-getZExtValue());
   O  1;
 } else O  CI-getSExtValue();
   } else if (const GlobalValue *GV = dyn_castGlobalValue(CV)) {


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.68 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.69
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.68  Thu Jan 11 12:21:29 2007
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Thu Jan 11 22:24:45 2007
@@ -211,7 +211,7 @@
   }
   virtual void Apply(bool Field) {
 Constant *C = CI-getOperand(I++);
-Field = castConstantInt(C)-getBoolValue();
+Field = castConstantInt(C)-getZExtValue();
   }
   virtual void Apply(std::string Field) {
 Constant *C = CI-getOperand(I++);
@@ -276,7 +276,7 @@
 Elements.push_back(ConstantInt::get(Type::Int64Ty, uint64_t(Field)));
   }
   virtual void Apply(bool Field) {
-Elements.push_back(ConstantInt::get(Field));
+Elements.push_back(ConstantInt::get(Type::Int1Ty, Field));
   }
   virtual void Apply(std::string Field) {
   Elements.push_back(SR.getString(Field));



___
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 MachOWriter.cpp

2007-01-11 Thread Reid Spencer


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.132 - 1.133
MachOWriter.cpp updated: 1.11 - 1.12
---
Log message:

For PR1064: http://llvm.org/PR1064 :
Implement the arbitrary bit-width integer feature. The feature allows
integers of any bitwidth (up to 64) to be defined instead of just 1, 8, 
16, 32, and 64 bit integers.  

This change does several things:
1. Introduces a new Derived Type, IntegerType, to represent the number of
   bits in an integer. The Type classes SubclassData field is used to
   store the number of bits. This allows 2^23 bits in an integer type. 
2. Removes the five integer Type::TypeID values for the 1, 8, 16, 32 and
   64-bit integers. These are replaced with just IntegerType which is not
   a primitive any more. 
3. Adjust the rest of LLVM to account for this change.

Note that while this incremental change lays the foundation for arbitrary
bit-width integers, LLVM has not yet been converted to actually deal with 
them in any significant way. Most optimization passes, for example, will 
still only deal with the byte-width integer types.  Future increments
will rectify this situation.



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

 AsmPrinter.cpp  |   33 ++-
 MachOWriter.cpp |   68 
 2 files changed, 56 insertions(+), 45 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.132 
llvm/lib/CodeGen/AsmPrinter.cpp:1.133
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.132   Thu Jan 11 22:24:45 2007
+++ llvm/lib/CodeGen/AsmPrinter.cpp Fri Jan 12 01:05:13 2007
@@ -459,7 +459,7 @@
   // We can emit the pointer value into this slot if the slot is an
   // integer slot greater or equal to the size of the pointer.
   if (Ty-isIntegral() 
-  Ty-getPrimitiveSize() = TD-getTypeSize(Op-getType()))
+  TD-getTypeSize(Ty) = TD-getTypeSize(Op-getType()))
 return EmitConstantValueOnly(Op);
   
   assert(0  FIXME: Don't yet support this kind of constant cast expr);
@@ -917,28 +917,29 @@
 void AsmPrinter::printDataDirective(const Type *type) {
   const TargetData *TD = TM.getTargetData();
   switch (type-getTypeID()) {
-  case Type::Int1TyID:
-  case Type::Int8TyID:
-O  TAI-getData8bitsDirective();
-break;
-  case Type::Int16TyID: 
-O  TAI-getData16bitsDirective();
+  case Type::IntegerTyID: {
+unsigned BitWidth = castIntegerType(type)-getBitWidth();
+if (BitWidth = 8)
+  O  TAI-getData8bitsDirective();
+else if (BitWidth = 16)
+  O  TAI-getData16bitsDirective();
+else if (BitWidth = 32)
+  O  TAI-getData32bitsDirective();
+else if (BitWidth = 64) {
+  assert(TAI-getData64bitsDirective() 
+ Target cannot handle 64-bit constant exprs!);
+  O  TAI-getData64bitsDirective();
+}
 break;
+  }
   case Type::PointerTyID:
 if (TD-getPointerSize() == 8) {
   assert(TAI-getData64bitsDirective() 
  Target cannot handle 64-bit pointer exprs!);
   O  TAI-getData64bitsDirective();
-  break;
+} else {
+  O  TAI-getData32bitsDirective();
 }
-//Fall through for pointer size == int size
-  case Type::Int32TyID: 
-O  TAI-getData32bitsDirective();
-break;
-  case Type::Int64TyID:
-assert(TAI-getData64bitsDirective() 
-   Target cannot handle 64-bit constant exprs!);
-O  TAI-getData64bitsDirective();
 break;
   case Type::FloatTyID: case Type::DoubleTyID:
 assert (0  Should have already output floating point constant.);


Index: llvm/lib/CodeGen/MachOWriter.cpp
diff -u llvm/lib/CodeGen/MachOWriter.cpp:1.11 
llvm/lib/CodeGen/MachOWriter.cpp:1.12
--- llvm/lib/CodeGen/MachOWriter.cpp:1.11   Thu Jan 11 12:21:29 2007
+++ llvm/lib/CodeGen/MachOWriter.cppFri Jan 12 01:05:13 2007
@@ -708,8 +708,7 @@
 if (isaUndefValue(PC)) {
   continue;
 } else if (const ConstantPacked *CP = dyn_castConstantPacked(PC)) {
-  unsigned ElementSize = 
-CP-getType()-getElementType()-getPrimitiveSize();
+  unsigned ElementSize = TD-getTypeSize(CP-getType()-getElementType());
   for (unsigned i = 0, e = CP-getNumOperands(); i != e; ++i)
 WorkList.push_back(CPair(CP-getOperand(i), PA+i*ElementSize));
 } else if (const ConstantExpr *CE = dyn_castConstantExpr(PC)) {
@@ -726,27 +725,42 @@
   }
 } else if (PC-getType()-isFirstClassType()) {
   unsigned char *ptr = (unsigned char *)PA;
-  uint64_t val;
-  
   switch (PC-getType()-getTypeID()) {
-  case Type::Int1TyID:
-  case Type::Int8TyID:
-ptr[0] = castConstantInt(PC)-getZExtValue();
-break;
-  case Type::Int16TyID:
-val = castConstantInt(PC)-getZExtValue();
-if (TD-isBigEndian())
-  val = ByteSwap_16(val);
-ptr[0] = val;
-ptr[1] = val  8;
-break;
-  case Type::Int32TyID:
-  case Type::FloatTyID:
-if 

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

2006-12-30 Thread Reid Spencer


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.128 - 1.129
IntrinsicLowering.cpp updated: 1.54 - 1.55
MachOWriter.cpp updated: 1.9 - 1.10
MachineDebugInfo.cpp updated: 1.64 - 1.65
---
Log message:

For PR950: http://llvm.org/PR950 :
Three changes:
1. Convert signed integer types to signless versions.
2. Implement the @sext and @zext parameter attributes. Previously the
   type of an function parameter was used to determine whether it should
   be sign extended or zero extended before the call. This information is
   now communicated via the function type's parameter attributes. 
3. The interface to LowerCallTo had to be changed in order to accommodate
   the parameter attribute information. Although it would have been
   convenient to pass in the FunctionType itself, there isn't always one
   present in the caller. Consequently, a signedness indication for the
   result type and for each parameter was provided for in the interface
   to this method. All implementations were changed to make the adjustment
   necessary.


---
Diffs of the changes:  (+50 -54)

 AsmPrinter.cpp|   10 
 IntrinsicLowering.cpp |   60 +-
 MachOWriter.cpp   |   12 +++---
 MachineDebugInfo.cpp  |   22 +-
 4 files changed, 50 insertions(+), 54 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.128 
llvm/lib/CodeGen/AsmPrinter.cpp:1.129
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.128   Thu Dec 21 13:04:23 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sat Dec 30 23:55:36 2006
@@ -607,7 +607,7 @@
  \t  TAI-getCommentString()   float   Val  \n;
   return;
 }
-  } else if (CV-getType() == Type::ULongTy || CV-getType() == Type::LongTy) {
+  } else if (CV-getType() == Type::Int64Ty) {
 if (const ConstantInt *CI = dyn_castConstantInt(CV)) {
   uint64_t Val = CI-getZExtValue();
 
@@ -918,10 +918,10 @@
   const TargetData *TD = TM.getTargetData();
   switch (type-getTypeID()) {
   case Type::BoolTyID:
-  case Type::UByteTyID: case Type::SByteTyID:
+  case Type::Int8TyID:
 O  TAI-getData8bitsDirective();
 break;
-  case Type::UShortTyID: case Type::ShortTyID:
+  case Type::Int16TyID: 
 O  TAI-getData16bitsDirective();
 break;
   case Type::PointerTyID:
@@ -932,10 +932,10 @@
   break;
 }
 //Fall through for pointer size == int size
-  case Type::UIntTyID: case Type::IntTyID:
+  case Type::Int32TyID: 
 O  TAI-getData32bitsDirective();
 break;
-  case Type::ULongTyID: case Type::LongTyID:
+  case Type::Int64TyID:
 assert(TAI-getData64bitsDirective() 
Target cannot handle 64-bit constant exprs!);
 O  TAI-getData64bitsDirective();


Index: llvm/lib/CodeGen/IntrinsicLowering.cpp
diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.54 
llvm/lib/CodeGen/IntrinsicLowering.cpp:1.55
--- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.54 Sat Dec 23 00:05:40 2006
+++ llvm/lib/CodeGen/IntrinsicLowering.cpp  Sat Dec 30 23:55:36 2006
@@ -95,7 +95,7 @@
   default: break;
   case Intrinsic::setjmp:
 EnsureFunctionExists(M, setjmp, I-arg_begin(), I-arg_end(),
- Type::IntTy);
+ Type::Int32Ty);
 break;
   case Intrinsic::longjmp:
 EnsureFunctionExists(M, longjmp, I-arg_begin(), I-arg_end(),
@@ -117,9 +117,9 @@
 break;
   case Intrinsic::memset_i32:
   case Intrinsic::memset_i64:
-M.getOrInsertFunction(memset, PointerType::get(Type::SByteTy),
-  PointerType::get(Type::SByteTy),
-  Type::IntTy, (--(--I-arg_end()))-getType(),
+M.getOrInsertFunction(memset, PointerType::get(Type::Int8Ty),
+  PointerType::get(Type::Int8Ty),
+  Type::Int32Ty, (--(--I-arg_end()))-getType(),
   (Type *)0);
 break;
   case Intrinsic::isunordered_f32:
@@ -150,26 +150,26 @@
   default: assert(0  Unhandled type size of value to byteswap!);
   case 16: {
 Value *Tmp1 = new ShiftInst(Instruction::Shl, V,
-
ConstantInt::get(Type::UByteTy,8),bswap.2,IP);
+ConstantInt::get(Type::Int8Ty,8),bswap.2,IP);
 Value *Tmp2 = new ShiftInst(Instruction::LShr, V,
-
ConstantInt::get(Type::UByteTy,8),bswap.1,IP);
+ConstantInt::get(Type::Int8Ty,8),bswap.1,IP);
 V = BinaryOperator::createOr(Tmp1, Tmp2, bswap.i16, IP);
 break;
   }
   case 32: {
 Value *Tmp4 = new ShiftInst(Instruction::Shl, V,
-  ConstantInt::get(Type::UByteTy,24),bswap.4, 
IP);
+  ConstantInt::get(Type::Int8Ty,24),bswap.4, IP);
 Value *Tmp3 = new ShiftInst(Instruction::Shl, V,
-  

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

2006-12-21 Thread Reid Spencer


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.127 - 1.128
---
Log message:

Just print integer constants as signed values. The actual signedness 
doesn't matter as it is determined in the way the constant is used.


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

 AsmPrinter.cpp |8 +---
 1 files changed, 1 insertion(+), 7 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.127 
llvm/lib/CodeGen/AsmPrinter.cpp:1.128
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.127   Tue Dec 19 15:04:20 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Dec 21 13:04:23 2006
@@ -392,13 +392,7 @@
 assert(CB-getValue());
 O  1;
   } else if (const ConstantInt *CI = dyn_castConstantInt(CV)) {
-if (CI-getType()-isSigned()) {
-  if (((CI-getSExtValue()  32)  32) == CI-getSExtValue())
-O  CI-getSExtValue();
-  else
-O  (uint64_t)CI-getSExtValue();
-} else 
-  O  CI-getZExtValue();
+O  CI-getSExtValue();
   } else if (const GlobalValue *GV = dyn_castGlobalValue(CV)) {
 // This is a constant address for a global variable or function. Use the
 // name of the variable or function as the address value, possibly



___
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

2006-12-19 Thread Anton Korobeynikov


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.126 - 1.127
---
Log message:

Fix for PR1059: http://llvm.org/PR1059 : http://llvm.org/PR1059: 
http://llvm.org/PR1059 


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

 AsmPrinter.cpp |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.126 
llvm/lib/CodeGen/AsmPrinter.cpp:1.127
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.126   Sun Dec 17 21:37:18 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue Dec 19 15:04:20 2006
@@ -214,14 +214,17 @@
   // Pick the directive to use to print the jump table entries, and switch to 
   // the appropriate section.
   TargetLowering *LoweringInfo = TM.getTargetLowering();
-  
-  if (IsPic  !(LoweringInfo  LoweringInfo-usesGlobalOffsetTable())) {
+
+  const char* JumpTableDataSection = TAI-getJumpTableDataSection();  
+  if ((IsPic  !(LoweringInfo  LoweringInfo-usesGlobalOffsetTable())) ||
+ !JumpTableDataSection) {
 // In PIC mode, we need to emit the jump table to the same section as the
 // function body itself, otherwise the label differences won't make sense.
+// We should also do if the section name is NULL.
 const Function *F = MF.getFunction();
 SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
   } else {
-SwitchToDataSection(TAI-getJumpTableDataSection());
+SwitchToDataSection(JumpTableDataSection);
   }
   
   EmitAlignment(Log2_32(MJTI-getAlignment()));



___
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

2006-12-17 Thread Rafael Espindola


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.125 - 1.126
---
Log message:

move ExtWeakSymbols to AsmPrinter


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

 AsmPrinter.cpp |   12 
 1 files changed, 12 insertions(+)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.125 
llvm/lib/CodeGen/AsmPrinter.cpp:1.126
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.125   Thu Dec 14 13:17:33 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sun Dec 17 21:37:18 2006
@@ -106,6 +106,18 @@
 }
 
 bool AsmPrinter::doFinalization(Module M) {
+  if (TAI-getWeakRefDirective()) {
+if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
+  SwitchToDataSection();
+
+for (std::setconst GlobalValue*::iterator i = ExtWeakSymbols.begin(),
+ e = ExtWeakSymbols.end(); i != e; ++i) {
+  const GlobalValue *GV = *i;
+  std::string Name = Mang-getValueName(GV);
+  O  TAI-getWeakRefDirective()  Name  \n;
+}
+  }
+
   delete Mang; Mang = 0;
   return false;
 }



___
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

2006-12-11 Thread Reid Spencer


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.121 - 1.122
---
Log message:

Tidy up a bit.


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

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


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.121 
llvm/lib/CodeGen/AsmPrinter.cpp:1.122
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.121   Mon Dec 11 19:17:40 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Dec 11 19:32:02 2006
@@ -450,7 +450,7 @@
 if (opcode == Instruction::IntToPtr)
   Op = ConstantExpr::getIntegerCast(Op, IntPtrTy, false /*ZExt*/);
 else 
-  Op = ConstantExpr::getCast(Instruction::PtrToInt, Op, IntPtrTy);
+  Op = ConstantExpr::getPtrToInt(Op, IntPtrTy);
 return EmitConstantValueOnly(Op);
   }
   



___
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

2006-12-11 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.122 - 1.123
---
Log message:

the operand of a bitcast is always the right size, just emit it in place.


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

 AsmPrinter.cpp |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.122 
llvm/lib/CodeGen/AsmPrinter.cpp:1.123
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.122   Mon Dec 11 19:32:02 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Dec 11 23:14:13 2006
@@ -434,9 +434,11 @@
 case Instruction::FPToSI:
   assert(0  FIXME: Don't yet support this kind of constant cast expr);
   break;
+case Instruction::BitCast:
+  return EmitConstantValueOnly(CE-getOperand(0));
+
 case Instruction::IntToPtr:
-case Instruction::PtrToInt:
-case Instruction::BitCast: {
+case Instruction::PtrToInt:{
   // Support only foldable casts to/from pointers that can be eliminated by
   // changing the pointer to the appropriately sized integer type.
   Constant *Op = CE-getOperand(0);



___
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

2006-12-11 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.123 - 1.124
---
Log message:

split up inttoptr from ptrtoint handling, the cases aren't similar at all.


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

 AsmPrinter.cpp |   37 +++--
 1 files changed, 15 insertions(+), 22 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.123 
llvm/lib/CodeGen/AsmPrinter.cpp:1.124
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.123   Mon Dec 11 23:14:13 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Dec 11 23:18:19 2006
@@ -437,33 +437,26 @@
 case Instruction::BitCast:
   return EmitConstantValueOnly(CE-getOperand(0));
 
-case Instruction::IntToPtr:
-case Instruction::PtrToInt:{
+case Instruction::IntToPtr: {
+  // Handle casts to pointers by changing them into casts to the 
appropriate
+  // integer type.  This promotes constant folding and simplifies this 
code.
+  Constant *Op = CE-getOperand(0);
+  Op = ConstantExpr::getIntegerCast(Op, TD-getIntPtrType(), 
false/*ZExt*/);
+  return EmitConstantValueOnly(Op);
+}
+  
+  
+case Instruction::PtrToInt: {
   // Support only foldable casts to/from pointers that can be eliminated by
   // changing the pointer to the appropriately sized integer type.
   Constant *Op = CE-getOperand(0);
-  const Type *OpTy = Op-getType(), *Ty = CE-getType();
+  const Type *Ty = CE-getType();
 
-  // Handle casts to pointers by changing them into casts to the 
appropriate
-  // integer type.  This promotes constant folding and simplifies this 
code.
-  if (isaPointerType(Ty)) {
-const Type *IntPtrTy = TD-getIntPtrType();
-Instruction::CastOps opcode = Instruction::CastOps(CE-getOpcode());
-if (opcode == Instruction::IntToPtr)
-  Op = ConstantExpr::getIntegerCast(Op, IntPtrTy, false /*ZExt*/);
-else 
-  Op = ConstantExpr::getPtrToInt(Op, IntPtrTy);
+  // We can emit the pointer value into this slot if the slot is an
+  // integer slot greater or equal to the size of the pointer.
+  if (Ty-isIntegral() 
+  Ty-getPrimitiveSize() = TD-getTypeSize(Op-getType()))
 return EmitConstantValueOnly(Op);
-  }
-  
-  // We know the dest type is not a pointer.  Is the src value a pointer or
-  // integral?
-  if (isaPointerType(OpTy) || OpTy-isIntegral()) {
-// We can emit the pointer value into this slot if the slot is an
-// integer slot greater or equal to the size of the pointer.
-if (Ty-isIntegral()  TD-getTypeSize(Ty) = TD-getTypeSize(OpTy))
-  return EmitConstantValueOnly(Op);
-  }
   
   assert(0  FIXME: Don't yet support this kind of constant cast expr);
   EmitConstantValueOnly(Op);



___
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 DwarfWriter.cpp ELFWriter.cpp LiveInterval.cpp LiveIntervalAnalysis.cpp

2006-11-28 Thread Bill Wendling


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.118 - 1.119
DwarfWriter.cpp updated: 1.101 - 1.102
ELFWriter.cpp updated: 1.28 - 1.29
LiveInterval.cpp updated: 1.38 - 1.39
LiveIntervalAnalysis.cpp updated: 1.197 - 1.198
---
Log message:

Converted to using llvm streams instead of iostreams


---
Diffs of the changes:  (+101 -87)

 AsmPrinter.cpp   |   25 
 DwarfWriter.cpp  |   20 +-
 ELFWriter.cpp|5 +
 LiveInterval.cpp |2 
 LiveIntervalAnalysis.cpp |  136 +++
 5 files changed, 101 insertions(+), 87 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.118 
llvm/lib/CodeGen/AsmPrinter.cpp:1.119
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.118   Sun Nov 26 19:05:09 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue Nov 28 18:39:47 2006
@@ -20,11 +20,12 @@
 #include llvm/CodeGen/MachineJumpTableInfo.h
 #include llvm/Support/Mangler.h
 #include llvm/Support/MathExtras.h
+#include llvm/Support/Streams.h
 #include llvm/Target/TargetAsmInfo.h
 #include llvm/Target/TargetData.h
 #include llvm/Target/TargetLowering.h
 #include llvm/Target/TargetMachine.h
-#include iostream
+#include ostream
 #include cerrno
 using namespace llvm;
 
@@ -667,7 +668,7 @@
 if (LastMI != MI) { ++Counter; LastMI = MI; }
 O  Counter;
   } else {
-std::cerr  Unknown special formatter '  Code
+llvm_cerr  Unknown special formatter '  Code
' for machine instr:   *MI;
 exit(1);
   }
@@ -736,8 +737,8 @@
   case '(': // $( - same as GCC's { character.
 ++LastEmitted;  // Consume '(' character.
 if (CurVariant != -1) {
-  std::cerr  Nested variants found in inline asm string: '
-   AsmStr  '\n;
+  llvm_cerr  Nested variants found in inline asm string: '
+ AsmStr  '\n;
   exit(1);
 }
 CurVariant = 0; // We're in the first variant now.
@@ -745,8 +746,8 @@
   case '|':
 ++LastEmitted;  // consume '|' character.
 if (CurVariant == -1) {
-  std::cerr  Found '|' character outside of variant in inline asm 
-   string: '  AsmStr  '\n;
+  llvm_cerr  Found '|' character outside of variant in inline asm 
+ string: '  AsmStr  '\n;
   exit(1);
 }
 ++CurVariant;   // We're in the next variant.
@@ -754,7 +755,7 @@
   case ')': // $) - same as GCC's } char.
 ++LastEmitted;  // consume ')' character.
 if (CurVariant == -1) {
-  std::cerr  Found '}' character outside of variant in inline asm 
+  llvm_cerr  Found '}' character outside of variant in inline asm 
  string: '  AsmStr  '\n;
   exit(1);
 }
@@ -773,7 +774,7 @@
   char *IDEnd;
   long Val = strtol(IDStart, IDEnd, 10); // We only accept numbers for 
IDs.
   if (!isdigit(*IDStart) || (Val == 0  errno == EINVAL)) {
-std::cerr  Bad $ operand number in inline asm string: ' 
+llvm_cerr  Bad $ operand number in inline asm string: ' 
AsmStr  '\n;
 exit(1);
   }
@@ -787,7 +788,7 @@
 if (*LastEmitted == ':') {
   ++LastEmitted;// Consume ':' character.
   if (*LastEmitted == 0) {
-std::cerr  Bad ${:} expression in inline asm string: ' 
+llvm_cerr  Bad ${:} expression in inline asm string: ' 
AsmStr  '\n;
 exit(1);
   }
@@ -797,7 +798,7 @@
 }
 
 if (*LastEmitted != '}') {
-  std::cerr  Bad ${} expression in inline asm string: ' 
+  llvm_cerr  Bad ${} expression in inline asm string: ' 
  AsmStr  '\n;
   exit(1);
 }
@@ -805,7 +806,7 @@
   }
   
   if ((unsigned)Val = NumOperands-1) {
-std::cerr  Invalid $ operand number in inline asm string: ' 
+llvm_cerr  Invalid $ operand number in inline asm string: ' 
AsmStr  '\n;
 exit(1);
   }
@@ -840,7 +841,7 @@
   }
 }
 if (Error) {
-  std::cerr  Invalid operand found in inline asm: '
+  llvm_cerr  Invalid operand found in inline asm: '
  AsmStr  '\n;
   MI-dump();
   exit(1);


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.101 
llvm/lib/CodeGen/DwarfWriter.cpp:1.102
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.101  Thu Nov  9 10:32:26 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppTue Nov 28 18:39:47 2006
@@ -32,7 +32,7 @@
 #include llvm/Target/TargetMachine.h
 #include llvm/Target/TargetFrameInfo.h
 
-#include iostream
+#include ostream
 #include string
 
 using namespace llvm;
@@ -139,6 +139,9 @@
   }
   
 #ifndef NDEBUG
+  void print(llvm_ostream O) const {
+if (O.stream()) print(*O.stream());
+  }
   void 

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

2006-11-26 Thread Reid Spencer


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.117 - 1.118
IntrinsicLowering.cpp updated: 1.46 - 1.47
MachineDebugInfo.cpp updated: 1.59 - 1.60
---
Log message:

For PR950: http://llvm.org/PR950 :
The long awaited CAST patch. This introduces 12 new instructions into LLVM
to replace the cast instruction. Corresponding changes throughout LLVM are
provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the
exception of 175.vpr which fails only on a slight floating point output
difference.


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

 AsmPrinter.cpp|   15 +++
 IntrinsicLowering.cpp |  100 +++---
 MachineDebugInfo.cpp  |4 +-
 3 files changed, 95 insertions(+), 24 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.117 
llvm/lib/CodeGen/AsmPrinter.cpp:1.118
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.117   Mon Nov 20 14:29:06 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sun Nov 26 19:05:09 2006
@@ -423,7 +423,20 @@
   }
   break;
 }
-case Instruction::Cast: {
+case Instruction::Trunc:
+case Instruction::ZExt:
+case Instruction::SExt:
+case Instruction::FPTrunc:
+case Instruction::FPExt:
+case Instruction::UIToFP:
+case Instruction::SIToFP:
+case Instruction::FPToUI:
+case Instruction::FPToSI:
+  assert(0  FIXME: Don't yet support this kind of constant cast expr);
+  break;
+case Instruction::IntToPtr:
+case Instruction::PtrToInt:
+case Instruction::BitCast: {
   // Support only foldable casts to/from pointers that can be eliminated by
   // changing the pointer to the appropriately sized integer type.
   Constant *Op = CE-getOperand(0);


Index: llvm/lib/CodeGen/IntrinsicLowering.cpp
diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.46 
llvm/lib/CodeGen/IntrinsicLowering.cpp:1.47
--- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.46 Wed Nov 15 12:00:10 2006
+++ llvm/lib/CodeGen/IntrinsicLowering.cpp  Sun Nov 26 19:05:09 2006
@@ -40,6 +40,7 @@
 template class ArgIt
 static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI,
  ArgIt ArgBegin, ArgIt ArgEnd,
+ const unsigned *castOpcodes,
  const Type *RetTy, Function *FCache) {
   if (!FCache) {
 // If we haven't already looked up this function, check to see if the
@@ -63,7 +64,12 @@
++I, ++ArgNo) {
 Value *Arg = *I;
 if (Arg-getType() != FT-getParamType(ArgNo))
-  Arg = new CastInst(Arg, FT-getParamType(ArgNo), Arg-getName(), CI);
+  if (castOpcodes[ArgNo])
+Arg = CastInst::create(Instruction::CastOps(castOpcodes[ArgNo]),
+  Arg, FT-getParamType(ArgNo), Arg-getName(), CI);
+  else
+Arg = CastInst::createInferredCast(Arg, FT-getParamType(ArgNo), 
+   Arg-getName(), CI);
 Operands.push_back(Arg);
   }
   // Pass nulls into any additional arguments...
@@ -76,7 +82,7 @@
   if (!CI-use_empty()) {
 Value *V = NewCI;
 if (CI-getType() != NewCI-getType())
-  V = new CastInst(NewCI, CI-getType(), Name, CI);
+  V = CastInst::createInferredCast(NewCI, CI-getType(), Name, CI);
 CI-replaceAllUsesWith(V);
   }
   return NewCI;
@@ -283,8 +289,9 @@
 // convert the call to an explicit setjmp or longjmp call.
   case Intrinsic::setjmp: {
 static Function *SetjmpFCache = 0;
+static const unsigned castOpcodes[] = { Instruction::BitCast };
 Value *V = ReplaceCallWith(setjmp, CI, CI-op_begin()+1, CI-op_end(),
-   Type::IntTy, SetjmpFCache);
+   castOpcodes, Type::IntTy, SetjmpFCache);
 if (CI-getType() != Type::VoidTy)
   CI-replaceAllUsesWith(V);
 break;
@@ -296,16 +303,20 @@
 
   case Intrinsic::longjmp: {
 static Function *LongjmpFCache = 0;
+static const unsigned castOpcodes[] = 
+  { Instruction::BitCast, 0 };
 ReplaceCallWith(longjmp, CI, CI-op_begin()+1, CI-op_end(),
-Type::VoidTy, LongjmpFCache);
+castOpcodes, Type::VoidTy, LongjmpFCache);
 break;
   }
 
   case Intrinsic::siglongjmp: {
 // Insert the call to abort
 static Function *AbortFCache = 0;
-ReplaceCallWith(abort, CI, CI-op_end(), CI-op_end(), Type::VoidTy,
-AbortFCache);
+static const unsigned castOpcodes[] =
+  { Instruction::BitCast, 0 };
+ReplaceCallWith(abort, CI, CI-op_end(), CI-op_end(), 
+castOpcodes, Type::VoidTy, AbortFCache);
 break;
   }
   case Intrinsic::ctpop_i8:
@@ -383,31 +394,76 @@
   case Intrinsic::dbg_declare:
 break;// Simply strip out debugging intrinsics
 
-  case Intrinsic::memcpy_i32:
-  case Intrinsic::memcpy_i64: {
+  case Intrinsic::memcpy_i32: {
 // The memcpy intrinsic take an extra alignment argument that the memcpy
 // libc function 

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

2006-11-01 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.115 - 1.116
---
Log message:

Add a printSetLabel that takes two id's.

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

 AsmPrinter.cpp |   13 +
 1 files changed, 13 insertions(+)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.115 
llvm/lib/CodeGen/AsmPrinter.cpp:1.116
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.115   Tue Oct 31 02:31:23 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Nov  1 03:23:08 2006
@@ -875,6 +875,19 @@
  '_'  uid  '\n';
 }
 
+void AsmPrinter::printSetLabel(unsigned uid, unsigned uid2,
+   const MachineBasicBlock *MBB) const {
+  if (!TAI-getSetDirective())
+return;
+  
+  O  TAI-getSetDirective()  ' '  TAI-getPrivateGlobalPrefix()
+ getFunctionNumber()  '_'  uid  '_'  uid2
+ _set_  MBB-getNumber()  ',';
+  printBasicBlockLabel(MBB, false, false);
+  O  '-'  TAI-getPrivateGlobalPrefix()  JTI  getFunctionNumber() 
+ '_'  uid  '_'  uid2  '\n';
+}
+
 /// printDataDirective - This method prints the asm directive for the
 /// specified type.
 void AsmPrinter::printDataDirective(const Type *type) {



___
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

2006-10-28 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.113 - 1.114
---
Log message:

don't print dead jump tables


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

 AsmPrinter.cpp |3 +++
 1 files changed, 3 insertions(+)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.113 
llvm/lib/CodeGen/AsmPrinter.cpp:1.114
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.113   Tue Oct 24 15:32:14 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sat Oct 28 13:10:06 2006
@@ -221,6 +221,9 @@
   
   for (unsigned i = 0, e = JT.size(); i != e; ++i) {
 const std::vectorMachineBasicBlock* JTBBs = JT[i].MBBs;
+
+// If this jump table was deleted, ignore it. 
+if (JTBBs.empty()) continue;
 
 // For PIC codegen, if possible we want to use the SetDirective to reduce
 // the number of relocations the assembler will generate for the jump 
table.



___
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

2006-10-24 Thread Devang Patel


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.112 - 1.113
---
Log message:

Move getPreferredAlignmentLog from AsmPrinter to TargetData


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

 AsmPrinter.cpp |   23 ---
 1 files changed, 23 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.112 
llvm/lib/CodeGen/AsmPrinter.cpp:1.113
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.112   Fri Oct 20 02:07:24 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue Oct 24 15:32:14 2006
@@ -326,29 +326,6 @@
 }
 }
 
-/// getPreferredAlignmentLog - Return the preferred alignment of the
-/// specified global, returned in log form.  This includes an explicitly
-/// requested alignment (if the global has one).
-unsigned AsmPrinter::getPreferredAlignmentLog(const GlobalVariable *GV) const {
-  const Type *ElemType = GV-getType()-getElementType();
-  unsigned Alignment = TM.getTargetData()-getTypeAlignmentShift(ElemType);
-  if (GV-getAlignment()  (1U  Alignment))
-Alignment = Log2_32(GV-getAlignment());
-  
-  if (GV-hasInitializer()) {
-// Always round up alignment of global doubles to 8 bytes.
-if (GV-getType()-getElementType() == Type::DoubleTy  Alignment  3)
-  Alignment = 3;
-if (Alignment  4) {
-  // If the global is not external, see if it is large.  If so, give it a
-  // larger alignment.
-  if (TM.getTargetData()-getTypeSize(ElemType)  128)
-Alignment = 4;// 16-byte alignment.
-}
-  }
-  return Alignment;
-}
-
 /// getGlobalLinkName - Returns the asm/link name of of the specified
 /// global variable.  Should be overridden by each target asm printer to
 /// generate the appropriate value.



___
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 IntrinsicLowering.cpp MachineDebugInfo.cpp

2006-10-20 Thread Reid Spencer


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.111 - 1.112
IntrinsicLowering.cpp updated: 1.43 - 1.44
MachineDebugInfo.cpp updated: 1.50 - 1.51
---
Log message:

For PR950: http://llvm.org/PR950 :
This patch implements the first increment for the Signless Types feature.
All changes pertain to removing the ConstantSInt and ConstantUInt classes
in favor of just using ConstantInt.


---
Diffs of the changes:  (+45 -42)

 AsmPrinter.cpp|   23 ---
 IntrinsicLowering.cpp |   35 ++-
 MachineDebugInfo.cpp  |   29 +++--
 3 files changed, 45 insertions(+), 42 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.111 
llvm/lib/CodeGen/AsmPrinter.cpp:1.112
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.111   Tue Oct 17 12:17:24 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Fri Oct 20 02:07:24 2006
@@ -393,14 +393,15 @@
   else if (const ConstantBool *CB = dyn_castConstantBool(CV)) {
 assert(CB-getValue());
 O  1;
-  } else if (const ConstantSInt *CI = dyn_castConstantSInt(CV))
-if (((CI-getValue()  32)  32) == CI-getValue())
-  O  CI-getValue();
-else
-  O  (uint64_t)CI-getValue();
-  else if (const ConstantUInt *CI = dyn_castConstantUInt(CV))
-O  CI-getValue();
-  else if (const GlobalValue *GV = dyn_castGlobalValue(CV)) {
+  } else if (const ConstantInt *CI = dyn_castConstantInt(CV)) {
+if (CI-getType()-isSigned()) {
+  if (((CI-getSExtValue()  32)  32) == CI-getSExtValue())
+O  CI-getSExtValue();
+  else
+O  (uint64_t)CI-getSExtValue();
+} else 
+  O  CI-getZExtValue();
+  } else if (const GlobalValue *GV = dyn_castGlobalValue(CV)) {
 // This is a constant address for a global variable or function. Use the
 // name of the variable or function as the address value, possibly
 // decorating it with GlobalVarAddrPrefix/Suffix or
@@ -492,7 +493,7 @@
   O  \;
   for (unsigned i = 0; i != LastElt; ++i) {
 unsigned char C =
-(unsigned char)castConstantInt(CVA-getOperand(i))-getRawValue();
+(unsigned char)castConstantInt(CVA-getOperand(i))-getZExtValue();
 
 if (C == '') {
   O  \\\;
@@ -524,7 +525,7 @@
 void AsmPrinter::EmitString(const ConstantArray *CVA) const {
   unsigned NumElts = CVA-getNumOperands();
   if (TAI-getAscizDirective()  NumElts  
-  castConstantInt(CVA-getOperand(NumElts-1))-getRawValue() == 0) {
+  castConstantInt(CVA-getOperand(NumElts-1))-getZExtValue() == 0) {
 O  TAI-getAscizDirective();
 printAsCString(O, CVA, NumElts-1);
   } else {
@@ -604,7 +605,7 @@
 }
   } else if (CV-getType() == Type::ULongTy || CV-getType() == Type::LongTy) {
 if (const ConstantInt *CI = dyn_castConstantInt(CV)) {
-  uint64_t Val = CI-getRawValue();
+  uint64_t Val = CI-getZExtValue();
 
   if (TAI-getData64bitsDirective())
 O  TAI-getData64bitsDirective()  Val  \n;


Index: llvm/lib/CodeGen/IntrinsicLowering.cpp
diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.43 
llvm/lib/CodeGen/IntrinsicLowering.cpp:1.44
--- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.43 Thu Mar 23 12:06:46 2006
+++ llvm/lib/CodeGen/IntrinsicLowering.cpp  Fri Oct 20 02:07:24 2006
@@ -166,10 +166,10 @@
 Value *Tmp1 = new ShiftInst(Instruction::Shr, V,
   ConstantInt::get(Type::UByteTy,24),bswap.1, 
IP);
 Tmp3 = BinaryOperator::createAnd(Tmp3, 
- ConstantUInt::get(Type::UIntTy, 0xFF),
+ ConstantInt::get(Type::UIntTy, 0xFF),
  bswap.and3, IP);
 Tmp2 = BinaryOperator::createAnd(Tmp2, 
- ConstantUInt::get(Type::UIntTy, 0xFF00),
+ ConstantInt::get(Type::UIntTy, 0xFF00),
  bswap.and2, IP);
 Tmp4 = BinaryOperator::createOr(Tmp4, Tmp3, bswap.or1, IP);
 Tmp2 = BinaryOperator::createOr(Tmp2, Tmp1, bswap.or2, IP);
@@ -194,23 +194,24 @@
 Value *Tmp1 = new ShiftInst(Instruction::Shr, V,
   ConstantInt::get(Type::UByteTy,56),bswap.1, 
IP);
 Tmp7 = BinaryOperator::createAnd(Tmp7,
-  ConstantUInt::get(Type::ULongTy, 
0xFFULL),
-  bswap.and7, IP);
+ ConstantInt::get(Type::ULongTy, 
+   0xFFULL),
+ bswap.and7, IP);
 Tmp6 = BinaryOperator::createAnd(Tmp6,
-ConstantUInt::get(Type::ULongTy, 
0xFF00ULL),
-bswap.and6, IP);
+ ConstantInt::get(Type::ULongTy, 
0xFF00ULL),
+ bswap.and6, IP);
 Tmp5 = BinaryOperator::createAnd(Tmp5,
-  ConstantUInt::get(Type::ULongTy, 

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

2006-10-10 Thread Andrew Lenharth


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.108 - 1.109
---
Log message:

Jimptables working again on alpha.

As a bonus, use the GOT node instead of the AlphaISD::GOT for internal stuff.



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

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


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.108 
llvm/lib/CodeGen/AsmPrinter.cpp:1.109
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.108   Fri Oct  6 17:50:56 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue Oct 10 23:29:42 2006
@@ -204,7 +204,7 @@
 TargetLowering *LoweringInfo = TM.getTargetLowering();
 if (LoweringInfo  LoweringInfo-usesGlobalOffsetTable()) {
   SwitchToDataSection(TAI-getJumpTableDataSection(), 0);
-  if (TD-getPointerSize() == 8)
+  if (TD-getPointerSize() == 8  !JTEntryDirective)
 JTEntryDirective = TAI-getData64bitsDirective();
 } else {  
   // In PIC mode, we need to emit the jump table to the same section as the



___
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

2006-10-06 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.107 - 1.108
---
Log message:

If a target uses a GOT, put it in the jt data section, not the text 
section.  This will fix alpha when Andrew implements 
AlphaTargetMachine::getTargetLowering().


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

 AsmPrinter.cpp |   16 
 1 files changed, 12 insertions(+), 4 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.107 
llvm/lib/CodeGen/AsmPrinter.cpp:1.108
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.107   Thu Oct  5 16:40:14 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Fri Oct  6 17:50:56 2006
@@ -22,6 +22,7 @@
 #include llvm/Support/MathExtras.h
 #include llvm/Target/TargetAsmInfo.h
 #include llvm/Target/TargetData.h
+#include llvm/Target/TargetLowering.h
 #include llvm/Target/TargetMachine.h
 #include iostream
 #include cerrno
@@ -200,10 +201,17 @@
   // Pick the directive to use to print the jump table entries, and switch to 
   // the appropriate section.
   if (TM.getRelocationModel() == Reloc::PIC_) {
-// In PIC mode, we need to emit the jump table to the same section as the
-// function body itself, otherwise the label differences won't make sense.
-const Function *F = MF.getFunction();
-SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
+TargetLowering *LoweringInfo = TM.getTargetLowering();
+if (LoweringInfo  LoweringInfo-usesGlobalOffsetTable()) {
+  SwitchToDataSection(TAI-getJumpTableDataSection(), 0);
+  if (TD-getPointerSize() == 8)
+JTEntryDirective = TAI-getData64bitsDirective();
+} else {  
+  // In PIC mode, we need to emit the jump table to the same section as the
+  // function body itself, otherwise the label differences won't make 
sense.
+  const Function *F = MF.getFunction();
+  SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
+}
   } else {
 SwitchToDataSection(TAI-getJumpTableDataSection(), 0);
 if (TD-getPointerSize() == 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

2006-10-05 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.106 - 1.107
---
Log message:

Don't crash if an MBB doesn't have an LLVM BB


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

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


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.106 
llvm/lib/CodeGen/AsmPrinter.cpp:1.107
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.106   Wed Oct  4 22:13:28 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Oct  5 16:40:14 2006
@@ -857,7 +857,7 @@
  MBB-getNumber();
   if (printColon)
 O  ':';
-  if (printComment)
+  if (printComment  MBB-getBasicBlock())
 O  '\t'  TAI-getCommentString()  MBB-getBasicBlock()-getName();
 }
 



___
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

2006-10-04 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.103 - 1.104
---
Log message:

move getSectionForFunction to AsmPrinter


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

 AsmPrinter.cpp |4 
 1 files changed, 4 insertions(+)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.103 
llvm/lib/CodeGen/AsmPrinter.cpp:1.104
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.103   Tue Oct  3 18:27:09 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Oct  4 21:42:47 2006
@@ -32,6 +32,10 @@
 : FunctionNumber(0), O(o), TM(tm), TAI(T)
 {}
 
+std::string AsmPrinter::getSectionForFunction(const Function F) const {
+  return TAI-getTextSection();
+}
+
 
 /// SwitchToTextSection - Switch to the specified text section of the 
executable
 /// if we are not already in it!



___
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

2006-10-04 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.104 - 1.105
---
Log message:

Pass the MachineFunction into EmitJumpTableInfo.


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

 AsmPrinter.cpp |3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.104 
llvm/lib/CodeGen/AsmPrinter.cpp:1.105
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.104   Wed Oct  4 21:42:47 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Oct  4 22:00:37 2006
@@ -183,7 +183,8 @@
 /// EmitJumpTableInfo - Print assembly representations of the jump tables used
 /// by the current function to the current output stream.  
 ///
-void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI) {
+void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI,
+   MachineFunction MF) {
   const std::vectorMachineJumpTableEntry JT = MJTI-getJumpTables();
   if (JT.empty()) return;
   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/CodeGen/AsmPrinter.cpp

2006-10-04 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.105 - 1.106
---
Log message:

Emit pic jumptables to the same section that the function is emitted to,
allowing label differences to work.  This fixes CodeGen/X86/pic_jumptable.ll


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

 AsmPrinter.cpp |5 -
 1 files changed, 4 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.105 
llvm/lib/CodeGen/AsmPrinter.cpp:1.106
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.105   Wed Oct  4 22:00:37 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Oct  4 22:13:28 2006
@@ -200,7 +200,10 @@
   // Pick the directive to use to print the jump table entries, and switch to 
   // the appropriate section.
   if (TM.getRelocationModel() == Reloc::PIC_) {
-SwitchToTextSection(TAI-getJumpTableTextSection(), 0);
+// In PIC mode, we need to emit the jump table to the same section as the
+// function body itself, otherwise the label differences won't make sense.
+const Function *F = MF.getFunction();
+SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
   } else {
 SwitchToDataSection(TAI-getJumpTableDataSection(), 0);
 if (TD-getPointerSize() == 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

2006-10-03 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.102 - 1.103
---
Log message:

Use $( $| $) to represent alternatives in asm blocks instead of {|}.  This
is needed to support targets where {|} aren't special symbols.


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

 AsmPrinter.cpp |   62 +++--
 1 files changed, 34 insertions(+), 28 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.102 
llvm/lib/CodeGen/AsmPrinter.cpp:1.103
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.102   Thu Sep 28 18:17:41 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue Oct  3 18:27:09 2006
@@ -694,12 +694,45 @@
   break;
 case '$': {
   ++LastEmitted;   // Consume '$' character.
-  if (*LastEmitted == '$') { // $$ - $
+  bool Done = true;
+
+  // Handle escapes.
+  switch (*LastEmitted) {
+  default: Done = false; break;
+  case '$': // $$ - $
 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
   O  '$';
 ++LastEmitted;  // Consume second '$' character.
 break;
+  case '(': // $( - same as GCC's { character.
+++LastEmitted;  // Consume '(' character.
+if (CurVariant != -1) {
+  std::cerr  Nested variants found in inline asm string: '
+   AsmStr  '\n;
+  exit(1);
+}
+CurVariant = 0; // We're in the first variant now.
+break;
+  case '|':
+++LastEmitted;  // consume '|' character.
+if (CurVariant == -1) {
+  std::cerr  Found '|' character outside of variant in inline asm 
+   string: '  AsmStr  '\n;
+  exit(1);
+}
+++CurVariant;   // We're in the next variant.
+break;
+  case ')': // $) - same as GCC's } char.
+++LastEmitted;  // consume ')' character.
+if (CurVariant == -1) {
+  std::cerr  Found '}' character outside of variant in inline asm 
+ string: '  AsmStr  '\n;
+  exit(1);
+}
+CurVariant = -1;
+break;
   }
+  if (Done) break;
   
   bool HasCurlyBraces = false;
   if (*LastEmitted == '{') { // ${variable}
@@ -786,33 +819,6 @@
   }
   break;
 }
-case '{':
-  ++LastEmitted;  // Consume '{' character.
-  if (CurVariant != -1) {
-std::cerr  Nested variants found in inline asm string: '
-   AsmStr  '\n;
-exit(1);
-  }
-  CurVariant = 0; // We're in the first variant now.
-  break;
-case '|':
-  ++LastEmitted;  // consume '|' character.
-  if (CurVariant == -1) {
-std::cerr  Found '|' character outside of variant in inline asm 
-   string: '  AsmStr  '\n;
-exit(1);
-  }
-  ++CurVariant;   // We're in the next variant.
-  break;
-case '}':
-  ++LastEmitted;  // consume '}' character.
-  if (CurVariant == -1) {
-std::cerr  Found '}' character outside of variant in inline asm 
-   string: '  AsmStr  '\n;
-exit(1);
-  }
-  CurVariant = -1;
-  break;
 }
   }
   O  \n\t  TAI-getInlineAsmEnd()  \n;



___
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

2006-09-26 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.99 - 1.100
---
Log message:

Add support for ${:comment}, which expands to the current target's comment
character, and ${:uid} which expands to a unique ID for the MachineInstr. 
More can be added if/when they are needed.



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

 AsmPrinter.cpp |   24 
 1 files changed, 24 insertions(+)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.99 
llvm/lib/CodeGen/AsmPrinter.cpp:1.100
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.99Mon Sep 25 22:38:18 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue Sep 26 18:59:50 2006
@@ -619,6 +619,30 @@
   abort();
 }
 
+/// PrintSpecial - Print information related to the specified machine instr
+/// that is independent of the operand, and may be independent of the instr
+/// itself.  This can be useful for portably encoding the comment character
+/// or other bits of target-specific knowledge into the asmstrings.  The
+/// syntax used is ${:comment}.  Targets can override this to add support
+/// for their own strange codes.
+void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) {
+  if (!strcmp(Code, comment)) {
+O  TAI-getCommentString();
+  } else if (!strcmp(Code, uid)) {
+// Assign a unique ID to this machine instruction.
+static const MachineInstr *LastMI = 0;
+static unsigned Counter = 0U-1;
+// If this is a new machine instruction, bump the counter.
+if (LastMI != MI) { ++Counter; LastMI = MI; }
+O  Counter;
+  } else {
+std::cerr  Unknown special formatter '  Code
+   ' for machine instr:   *MI;
+exit(1);
+  }
+}
+
+
 /// printInlineAsm - This method formats and prints the specified machine
 /// instruction that is an inline asm.
 void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {



___
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

2006-09-26 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.100 - 1.101
---
Log message:

Add support for ${:private} which prints L on darwin.


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

 AsmPrinter.cpp |4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.100 
llvm/lib/CodeGen/AsmPrinter.cpp:1.101
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.100   Tue Sep 26 18:59:50 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue Sep 26 19:06:07 2006
@@ -626,7 +626,9 @@
 /// syntax used is ${:comment}.  Targets can override this to add support
 /// for their own strange codes.
 void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) {
-  if (!strcmp(Code, comment)) {
+  if (!strcmp(Code, private)) {
+O  TAI-getPrivateGlobalPrefix();
+  } else if (!strcmp(Code, comment)) {
 O  TAI-getCommentString();
   } else if (!strcmp(Code, uid)) {
 // Assign a unique ID to this machine instruction.



___
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

2006-09-24 Thread Andrew Lenharth


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.97 - 1.98
---
Log message:

Add support for other relocation bases to jump tables, as well as custom asm 
directives

---
Diffs of the changes:  (+8 -3)

 AsmPrinter.cpp |   11 ---
 1 files changed, 8 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.97 
llvm/lib/CodeGen/AsmPrinter.cpp:1.98
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.97Mon Sep 18 13:00:18 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sun Sep 24 14:44:59 2006
@@ -187,7 +187,10 @@
   // JTEntryDirective is a string to print sizeof(ptr) for non-PIC jump tables,
   // and 32 bits for PIC since PIC jump table entries are differences, not
   // pointers to blocks.
-  const char *JTEntryDirective = TAI-getData32bitsDirective();
+  // Use the architecture specific relocation directive, if it is set
+  const char *JTEntryDirective = TAI-getJumpTableDirective();
+  if (!JTEntryDirective)
+JTEntryDirective = TAI-getData32bitsDirective();
   
   // Pick the directive to use to print the jump table entries, and switch to 
   // the appropriate section.
@@ -227,8 +230,10 @@
'_'  i  _set_  JTBBs[ii]-getNumber();
   } else if (TM.getRelocationModel() == Reloc::PIC_) {
 printBasicBlockLabel(JTBBs[ii], false, false);
-O  '-'  TAI-getPrivateGlobalPrefix()  JTI
-   getFunctionNumber()  '_'  i;
+   //If the arch uses custom Jump Table directives, don't calc relative to 
JT
+   if (!TAI-getJumpTableDirective()) 
+ O  '-'  TAI-getPrivateGlobalPrefix()  JTI
+getFunctionNumber()  '_'  i;
   } else {
 printBasicBlockLabel(JTBBs[ii], false, false);
   }



___
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

2006-09-18 Thread Andrew Lenharth


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.95 - 1.96
---
Log message:

absolute addresses must match pointer size

---
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.95 
llvm/lib/CodeGen/AsmPrinter.cpp:1.96
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.95Thu Sep 14 02:35:00 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Sep 18 12:59:35 2006
@@ -714,6 +714,7 @@
 
 if (OpNo = MI-getNumOperands()) {
   Error = true;
+ std::cerr  Too many operands\n;
 } else {
   unsigned OpFlags = MI-getOperand(OpNo).getImmedValue();
   ++OpNo;  // Skip over the ID number.



___
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

2006-09-18 Thread Andrew Lenharth


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.96 - 1.97
---
Log message:

oops

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

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


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.96 
llvm/lib/CodeGen/AsmPrinter.cpp:1.97
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.96Mon Sep 18 12:59:35 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Sep 18 13:00:18 2006
@@ -714,7 +714,6 @@
 
 if (OpNo = MI-getNumOperands()) {
   Error = true;
- std::cerr  Too many operands\n;
 } else {
   unsigned OpFlags = MI-getOperand(OpNo).getImmedValue();
   ++OpNo;  // Skip over the ID number.



___
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

2006-09-14 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.94 - 1.95
---
Log message:

Use MachineConstantPoolEntry getOffset() and getType() accessors.

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

 AsmPrinter.cpp |   20 +++-
 1 files changed, 7 insertions(+), 13 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.94 
llvm/lib/CodeGen/AsmPrinter.cpp:1.95
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.94Tue Sep 12 16:00:35 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Sep 14 02:35:00 2006
@@ -129,8 +129,7 @@
   std::vectorstd::pairMachineConstantPoolEntry,unsigned  TargetCPs;
   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
 MachineConstantPoolEntry CPE = CP[i];
-const Type *Ty = CPE.isMachineConstantPoolEntry()
-  ? CPE.Val.MachineCPVal-getType() : CPE.Val.ConstVal-getType();
+const Type *Ty = CPE.getType();
 if (TAI-getFourByteConstantSection() 
 TM.getTargetData()-getTypeSize(Ty) == 4)
   FourByteCPs.push_back(std::make_pair(CPE, i));
@@ -161,23 +160,18 @@
   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
 O  TAI-getPrivateGlobalPrefix()  CPI  getFunctionNumber()  '_'
CP[i].second  :\t\t\t\t\t  TAI-getCommentString()   ;
-if (CP[i].first.isMachineConstantPoolEntry()) {
-  WriteTypeSymbolic(O, CP[i].first.Val.MachineCPVal-getType(), 0)  '\n';
-  printDataDirective(CP[i].first.Val.MachineCPVal-getType());
+WriteTypeSymbolic(O, CP[i].first.getType(), 0)  '\n';
+if (CP[i].first.isMachineConstantPoolEntry())
   EmitMachineConstantPoolValue(CP[i].first.Val.MachineCPVal);
-} else {
-  WriteTypeSymbolic(O, CP[i].first.Val.ConstVal-getType(), 0)  '\n';
+ else
   EmitGlobalConstant(CP[i].first.Val.ConstVal);
-}
 if (i != e-1) {
-  const Type *Ty = CP[i].first.isMachineConstantPoolEntry()
-? CP[i].first.Val.MachineCPVal-getType()
-: CP[i].first.Val.ConstVal-getType();
+  const Type *Ty = CP[i].first.getType();
   unsigned EntSize =
 TM.getTargetData()-getTypeSize(Ty);
-  unsigned ValEnd = CP[i].first.Offset + EntSize;
+  unsigned ValEnd = CP[i].first.getOffset() + EntSize;
   // Emit inter-object padding for alignment.
-  EmitZeros(CP[i+1].first.Offset-ValEnd);
+  EmitZeros(CP[i+1].first.getOffset()-ValEnd);
 }
   }
 }



___
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 MachineFunction.cpp

2006-09-12 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.93 - 1.94
MachineFunction.cpp updated: 1.97 - 1.98
---
Log message:

Added support for machine specific constantpool values. These are useful for
representing expressions that can only be resolved at link time, etc.


---
Diffs of the changes:  (+95 -38)

 AsmPrinter.cpp  |   93 
 MachineFunction.cpp |   40 --
 2 files changed, 95 insertions(+), 38 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.93 
llvm/lib/CodeGen/AsmPrinter.cpp:1.94
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.93Thu Sep  7 17:06:40 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue Sep 12 16:00:35 2006
@@ -126,10 +126,11 @@
   std::vectorstd::pairMachineConstantPoolEntry,unsigned  EightByteCPs;
   std::vectorstd::pairMachineConstantPoolEntry,unsigned  SixteenByteCPs;
   std::vectorstd::pairMachineConstantPoolEntry,unsigned  OtherCPs;
+  std::vectorstd::pairMachineConstantPoolEntry,unsigned  TargetCPs;
   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
 MachineConstantPoolEntry CPE = CP[i];
-const Constant *CV = CPE.Val;
-const Type *Ty = CV-getType();
+const Type *Ty = CPE.isMachineConstantPoolEntry()
+  ? CPE.Val.MachineCPVal-getType() : CPE.Val.ConstVal-getType();
 if (TAI-getFourByteConstantSection() 
 TM.getTargetData()-getTypeSize(Ty) == 4)
   FourByteCPs.push_back(std::make_pair(CPE, i));
@@ -160,11 +161,20 @@
   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
 O  TAI-getPrivateGlobalPrefix()  CPI  getFunctionNumber()  '_'
CP[i].second  :\t\t\t\t\t  TAI-getCommentString()   ;
-WriteTypeSymbolic(O, CP[i].first.Val-getType(), 0)  '\n';
-EmitGlobalConstant(CP[i].first.Val);
+if (CP[i].first.isMachineConstantPoolEntry()) {
+  WriteTypeSymbolic(O, CP[i].first.Val.MachineCPVal-getType(), 0)  '\n';
+  printDataDirective(CP[i].first.Val.MachineCPVal-getType());
+  EmitMachineConstantPoolValue(CP[i].first.Val.MachineCPVal);
+} else {
+  WriteTypeSymbolic(O, CP[i].first.Val.ConstVal-getType(), 0)  '\n';
+  EmitGlobalConstant(CP[i].first.Val.ConstVal);
+}
 if (i != e-1) {
+  const Type *Ty = CP[i].first.isMachineConstantPoolEntry()
+? CP[i].first.Val.MachineCPVal-getType()
+: CP[i].first.Val.ConstVal-getType();
   unsigned EntSize =
-TM.getTargetData()-getTypeSize(CP[i].first.Val-getType());
+TM.getTargetData()-getTypeSize(Ty);
   unsigned ValEnd = CP[i].first.Offset + EntSize;
   // Emit inter-object padding for alignment.
   EmitZeros(CP[i+1].first.Offset-ValEnd);
@@ -580,40 +590,17 @@
   }
 
   const Type *type = CV-getType();
-  switch (type-getTypeID()) {
-  case Type::BoolTyID:
-  case Type::UByteTyID: case Type::SByteTyID:
-O  TAI-getData8bitsDirective();
-break;
-  case Type::UShortTyID: case Type::ShortTyID:
-O  TAI-getData16bitsDirective();
-break;
-  case Type::PointerTyID:
-if (TD-getPointerSize() == 8) {
-  assert(TAI-getData64bitsDirective() 
- Target cannot handle 64-bit pointer exprs!);
-  O  TAI-getData64bitsDirective();
-  break;
-}
-//Fall through for pointer size == int size
-  case Type::UIntTyID: case Type::IntTyID:
-O  TAI-getData32bitsDirective();
-break;
-  case Type::ULongTyID: case Type::LongTyID:
-assert(TAI-getData64bitsDirective() 
-   Target cannot handle 64-bit constant exprs!);
-O  TAI-getData64bitsDirective();
-break;
-  case Type::FloatTyID: case Type::DoubleTyID:
-assert (0  Should have already output floating point constant.);
-  default:
-assert (0  Can't handle printing this type of thing);
-break;
-  }
+  printDataDirective(type);
   EmitConstantValueOnly(CV);
   O  \n;
 }
 
+void
+AsmPrinter::EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
+  // Target doesn't support this yet!
+  abort();
+}
+
 /// printInlineAsm - This method formats and prints the specified machine
 /// instruction that is an inline asm.
 void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
@@ -829,3 +816,39 @@
   O  '-'  TAI-getPrivateGlobalPrefix()  JTI  getFunctionNumber() 
  '_'  uid  '\n';
 }
+
+/// printDataDirective - This method prints the asm directive for the
+/// specified type.
+void AsmPrinter::printDataDirective(const Type *type) {
+  const TargetData *TD = TM.getTargetData();
+  switch (type-getTypeID()) {
+  case Type::BoolTyID:
+  case Type::UByteTyID: case Type::SByteTyID:
+O  TAI-getData8bitsDirective();
+break;
+  case Type::UShortTyID: case Type::ShortTyID:
+O  TAI-getData16bitsDirective();
+break;
+  case Type::PointerTyID:
+if (TD-getPointerSize() == 8) {
+  assert(TAI-getData64bitsDirective() 
+ Target cannot handle 64-bit pointer exprs!);
+  O  TAI-getData64bitsDirective();
+  break;
+}
+//Fall 

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

2006-09-07 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.91 - 1.92
---
Log message:

Fix pasto that was breaking x86 tests.

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

 AsmPrinter.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.91 
llvm/lib/CodeGen/AsmPrinter.cpp:1.92
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.91Wed Sep  6 13:34:40 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Sep  7 13:50:20 2006
@@ -132,10 +132,10 @@
 if (TAI-getFourByteConstantSection() 
 TM.getTargetData()-getTypeSize(Ty) == 4)
   FourByteCPs.push_back(std::make_pair(CPE, i));
-else if (TAI-getSectionEndDirectiveSuffix() 
+else if (TAI-getEightByteConstantSection() 
  TM.getTargetData()-getTypeSize(Ty) == 8)
   EightByteCPs.push_back(std::make_pair(CPE, i));
-else if (TAI-getSectionEndDirectiveSuffix() 
+else if (TAI-getSixteenByteConstantSection() 
  TM.getTargetData()-getTypeSize(Ty) == 16)
   SixteenByteCPs.push_back(std::make_pair(CPE, i));
 else



___
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 DwarfWriter.cpp

2006-09-07 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.92 - 1.93
DwarfWriter.cpp updated: 1.74 - 1.75
---
Log message:

Make target asm info a property of the target machine.


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

 AsmPrinter.cpp  |3 ++-
 DwarfWriter.cpp |   35 ++-
 2 files changed, 20 insertions(+), 18 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.92 
llvm/lib/CodeGen/AsmPrinter.cpp:1.93
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.92Thu Sep  7 13:50:20 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Sep  7 17:06:40 2006
@@ -27,7 +27,8 @@
 #include cerrno
 using namespace llvm;
 
-AsmPrinter::AsmPrinter(std::ostream o, TargetMachine tm, TargetAsmInfo *T)
+AsmPrinter::AsmPrinter(std::ostream o, TargetMachine tm,
+   const TargetAsmInfo *T)
 : FunctionNumber(0), O(o), TM(tm), TAI(T)
 {}
 


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.74 
llvm/lib/CodeGen/DwarfWriter.cpp:1.75
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.74   Wed Sep  6 13:34:40 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppThu Sep  7 17:06:40 2006
@@ -574,24 +574,24 @@
 }
 
 #ifndef NDEBUG
-  void DIEAbbrev::print(std::ostream O) {
-O  Abbreviation @
-   std::hex  (intptr_t)this  std::dec
+void DIEAbbrev::print(std::ostream O) {
+  O  Abbreviation @
+ std::hex  (intptr_t)this  std::dec
+   
+ TagString(Tag)
+  
+ ChildrenString(ChildrenFlag)
+ \n;
+  
+  for (unsigned i = 0, N = Data.size(); i  N; ++i) {
+O
+   AttributeString(Data[i].getAttribute())
  
-   TagString(Tag)
-
-   ChildrenString(ChildrenFlag)
+   FormEncodingString(Data[i].getForm())
\n;
-
-for (unsigned i = 0, N = Data.size(); i  N; ++i) {
-  O
- AttributeString(Data[i].getAttribute())
-   
- FormEncodingString(Data[i].getForm())
- \n;
-}
   }
-  void DIEAbbrev::dump() { print(std::cerr); }
+}
+void DIEAbbrev::dump() { print(std::cerr); }
 #endif
 
 
//===--===//
@@ -1160,7 +1160,7 @@
 /// is an option (needsSet) to use an intermediary 'set' expression.
 void DwarfWriter::EmitDifference(const char *TagHi, unsigned NumberHi,
  const char *TagLo, unsigned NumberLo) const {
-  if (TAI-getNeedsSet()) {
+  if (TAI-needsSet()) {
 static unsigned SetCounter = 0;
 
 O  \t.set\t;
@@ -2467,7 +2467,8 @@
 // Main entry points.
 //
   
-DwarfWriter::DwarfWriter(std::ostream OS, AsmPrinter *A, TargetAsmInfo *T)
+DwarfWriter::DwarfWriter(std::ostream OS, AsmPrinter *A,
+  const TargetAsmInfo *T)
 : O(OS)
 , Asm(A)
 , TAI(T)



___
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 DwarfWriter.cpp

2006-09-06 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.90 - 1.91
DwarfWriter.cpp updated: 1.73 - 1.74
---
Log message:

Separate target specific asm properties from the asm printers.


---
Diffs of the changes:  (+169 -212)

 AsmPrinter.cpp  |  237 
 DwarfWriter.cpp |  144 +++---
 2 files changed, 169 insertions(+), 212 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.90 
llvm/lib/CodeGen/AsmPrinter.cpp:1.91
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.90Tue Sep  5 15:02:51 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Sep  6 13:34:40 2006
@@ -20,51 +20,16 @@
 #include llvm/CodeGen/MachineJumpTableInfo.h
 #include llvm/Support/Mangler.h
 #include llvm/Support/MathExtras.h
+#include llvm/Target/TargetAsmInfo.h
 #include llvm/Target/TargetData.h
 #include llvm/Target/TargetMachine.h
 #include iostream
 #include cerrno
 using namespace llvm;
 
-AsmPrinter::AsmPrinter(std::ostream o, TargetMachine tm)
-: FunctionNumber(0), O(o), TM(tm),
-  CommentString(#),
-  GlobalPrefix(),
-  PrivateGlobalPrefix(.),
-  GlobalVarAddrPrefix(),
-  GlobalVarAddrSuffix(),
-  FunctionAddrPrefix(),
-  FunctionAddrSuffix(),
-  InlineAsmStart(#APP),
-  InlineAsmEnd(#NO_APP),
-  ZeroDirective(\t.zero\t),
-  ZeroDirectiveSuffix(0),
-  AsciiDirective(\t.ascii\t),
-  AscizDirective(\t.asciz\t),
-  Data8bitsDirective(\t.byte\t),
-  Data16bitsDirective(\t.short\t),
-  Data32bitsDirective(\t.long\t),
-  Data64bitsDirective(\t.quad\t),
-  AlignDirective(\t.align\t),
-  AlignmentIsInBytes(true),
-  SwitchToSectionDirective(\t.section\t),
-  TextSectionStartSuffix(),
-  DataSectionStartSuffix(),
-  SectionEndDirectiveSuffix(0),
-  ConstantPoolSection(\t.section .rodata\n),
-  JumpTableDataSection(\t.section .rodata\n),
-  JumpTableTextSection(\t.text\n),
-  StaticCtorsSection(\t.section .ctors,\aw\,@progbits),
-  StaticDtorsSection(\t.section .dtors,\aw\,@progbits),
-  FourByteConstantSection(0),
-  EightByteConstantSection(0),
-  SixteenByteConstantSection(0),
-  SetDirective(0),
-  LCOMMDirective(0),
-  COMMDirective(\t.comm\t),
-  COMMDirectiveTakesAlignment(true),
-  HasDotTypeDotSizeDirective(true) {
-}
+AsmPrinter::AsmPrinter(std::ostream o, TargetMachine tm, TargetAsmInfo *T)
+: FunctionNumber(0), O(o), TM(tm), TAI(T)
+{}
 
 
 /// SwitchToTextSection - Switch to the specified text section of the 
executable
@@ -74,7 +39,7 @@
  const GlobalValue *GV) {
   std::string NS;
   if (GV  GV-hasSection())
-NS = SwitchToSectionDirective + GV-getSection();
+NS = TAI-getSwitchToSectionDirective() + GV-getSection();
   else
 NS = NewSection;
   
@@ -82,13 +47,13 @@
   if (CurrentSection == NS) return;
 
   // Close the current section, if applicable.
-  if (SectionEndDirectiveSuffix  !CurrentSection.empty())
-O  CurrentSection  SectionEndDirectiveSuffix  \n;
+  if (TAI-getSectionEndDirectiveSuffix()  !CurrentSection.empty())
+O  CurrentSection  TAI-getSectionEndDirectiveSuffix()  \n;
 
   CurrentSection = NS;
 
   if (!CurrentSection.empty())
-O  CurrentSection  TextSectionStartSuffix  '\n';
+O  CurrentSection  TAI-getTextSectionStartSuffix()  '\n';
 }
 
 /// SwitchToDataSection - Switch to the specified data section of the 
executable
@@ -98,7 +63,7 @@
  const GlobalValue *GV) {
   std::string NS;
   if (GV  GV-hasSection())
-NS = SwitchToSectionDirective + GV-getSection();
+NS = TAI-getSwitchToSectionDirective() + GV-getSection();
   else
 NS = NewSection;
   
@@ -106,23 +71,24 @@
   if (CurrentSection == NS) return;
 
   // Close the current section, if applicable.
-  if (SectionEndDirectiveSuffix  !CurrentSection.empty())
-O  CurrentSection  SectionEndDirectiveSuffix  \n;
+  if (TAI-getSectionEndDirectiveSuffix()  !CurrentSection.empty())
+O  CurrentSection  TAI-getSectionEndDirectiveSuffix()  \n;
 
   CurrentSection = NS;
   
   if (!CurrentSection.empty())
-O  CurrentSection  DataSectionStartSuffix  '\n';
+O  CurrentSection  TAI-getDataSectionStartSuffix()  '\n';
 }
 
 
 bool AsmPrinter::doInitialization(Module M) {
-  Mang = new Mangler(M, GlobalPrefix);
+  Mang = new Mangler(M, TAI-getGlobalPrefix());
   
   if (!M.getModuleInlineAsm().empty())
-O  CommentString   Start of file scope inline assembly\n
+O  TAI-getCommentString()   Start of file scope inline assembly\n
M.getModuleInlineAsm()
-   \n  CommentString   End of file scope inline assembly\n;
+   \n  TAI-getCommentString()
+End of file scope inline assembly\n;
 
   SwitchToDataSection(, 0);   // Reset back to no section.
   
@@ -163,13 +129,13 @@
 MachineConstantPoolEntry CPE = CP[i];
 const Constant *CV = CPE.Val;
 const Type *Ty = CV-getType();
-if (FourByteConstantSection 
+if (TAI-getFourByteConstantSection() 
 TM.getTargetData()-getTypeSize(Ty) == 

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

2006-08-12 Thread Nate Begeman


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.88 - 1.89
---
Log message:

Emit .set directives for jump table entries when possible, which reduces
the number of relocations in object files, shrinkifying them.


---
Diffs of the changes:  (+39 -3)

 AsmPrinter.cpp |   42 +++---
 1 files changed, 39 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.88 
llvm/lib/CodeGen/AsmPrinter.cpp:1.89
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.88Fri Jul 28 20:57:19 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sat Aug 12 16:29:52 2006
@@ -59,6 +59,7 @@
   FourByteConstantSection(0),
   EightByteConstantSection(0),
   SixteenByteConstantSection(0),
+  SetDirective(0),
   LCOMMDirective(0),
   COMMDirective(\t.comm\t),
   COMMDirectiveTakesAlignment(true),
@@ -228,15 +229,36 @@
   EmitAlignment(Log2_32(TD-getPointerAlignment()));
   
   for (unsigned i = 0, e = JT.size(); i != e; ++i) {
+const std::vectorMachineBasicBlock* JTBBs = JT[i].MBBs;
+
+// For PIC codegen, if possible we want to use the SetDirective to reduce
+// the number of relocations the assembler will generate for the jump 
table.
+// Set directives are all printed before the jump table itself.
+std::setMachineBasicBlock* EmittedSets;
+if (SetDirective  TM.getRelocationModel() == Reloc::PIC_)
+  for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii)
+if (EmittedSets.insert(JTBBs[ii]).second)
+  printSetLabel(i, JTBBs[ii]);
+
 O  PrivateGlobalPrefix  JTI  getFunctionNumber()  '_'  i 
:\n;
-const std::vectorMachineBasicBlock* JTBBs = JT[i].MBBs;
+
 for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
   O  JTEntryDirective  ' ';
-  printBasicBlockLabel(JTBBs[ii], false, false);
-  if (TM.getRelocationModel() == Reloc::PIC_) {
+  // If we have emitted set directives for the jump table entries, print 
+  // them rather than the entries themselves.  If we're emitting PIC, then
+  // emit the table entries as differences between two text section labels.
+  // If we're emitting non-PIC code, then emit the entries as direct
+  // references to the target basic blocks.
+  if (!EmittedSets.empty()) {
+O  PrivateGlobalPrefix  getFunctionNumber()  '_'  i  _set_
+   JTBBs[ii]-getNumber();
+  } else if (TM.getRelocationModel() == Reloc::PIC_) {
+printBasicBlockLabel(JTBBs[ii], false, false);
 O  '-'  PrivateGlobalPrefix  JTI  getFunctionNumber() 
'_'  i;
+  } else {
+printBasicBlockLabel(JTBBs[ii], false, false);
   }
   O  '\n';
 }
@@ -818,3 +840,17 @@
   if (printComment)
 O  '\t'  CommentString  MBB-getBasicBlock()-getName();
 }
+
+/// printSetLabel - This method prints a set label for the specified
+/// MachineBasicBlock
+void AsmPrinter::printSetLabel(unsigned uid, 
+   const MachineBasicBlock *MBB) const {
+  if (!SetDirective)
+return;
+  
+  O  SetDirective  ' '  PrivateGlobalPrefix  getFunctionNumber() 
+ '_'  uid  _set_  MBB-getNumber()  ',';
+  printBasicBlockLabel(MBB, false, false);
+  O  '-'  PrivateGlobalPrefix  JTI  getFunctionNumber() 
+ '_'  uid  '\n';
+}



___
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

2006-07-28 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.87 - 1.88
---
Log message:

Instead of blindly looking past constantexpr casts, actually constant
fold them.  This correctly truncates constants that are too large for the
destination slot and makes the code easier to understand.  This fixes PR853: 
http://llvm.org/PR853 
and Regression/CodeGen/X86/2006-07-28-AsmPrint-Long-As-Pointer.ll


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

 AsmPrinter.cpp |   34 --
 1 files changed, 20 insertions(+), 14 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.87 
llvm/lib/CodeGen/AsmPrinter.cpp:1.88
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.87Thu Jul 27 19:17:20 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Fri Jul 28 20:57:19 2006
@@ -385,23 +385,29 @@
   break;
 }
 case Instruction::Cast: {
-  // Support only non-converting or widening casts for now, that is, ones
-  // that do not involve a change in value.  This assertion is really 
gross,
-  // and may not even be a complete check.
+  // Support only foldable casts to/from pointers that can be eliminated by
+  // changing the pointer to the appropriately sized integer type.
   Constant *Op = CE-getOperand(0);
   const Type *OpTy = Op-getType(), *Ty = CE-getType();
 
-  // Remember, kids, pointers can be losslessly converted back and forth
-  // into 32-bit or wider integers, regardless of signedness. :-P
-  assert(((isaPointerType(OpTy)
-(Ty == Type::LongTy || Ty == Type::ULongTy
-   || Ty == Type::IntTy || Ty == Type::UIntTy))
-  || (isaPointerType(Ty)
-   (OpTy == Type::LongTy || OpTy == Type::ULongTy
-  || OpTy == Type::IntTy || OpTy == Type::UIntTy))
-  || (((TD-getTypeSize(Ty) = TD-getTypeSize(OpTy))
-OpTy-isLosslesslyConvertibleTo(Ty
-  FIXME: Don't yet support this kind of constant cast expr);
+  // Handle casts to pointers by changing them into casts to the 
appropriate
+  // integer type.  This promotes constant folding and simplifies this 
code.
+  if (isaPointerType(Ty)) {
+const Type *IntPtrTy = TD-getIntPtrType();
+Op = ConstantExpr::getCast(Op, IntPtrTy);
+return EmitConstantValueOnly(Op);
+  }
+  
+  // We know the dest type is not a pointer.  Is the src value a pointer or
+  // integral?
+  if (isaPointerType(OpTy) || OpTy-isIntegral()) {
+// We can emit the pointer value into this slot if the slot is an
+// integer slot greater or equal to the size of the pointer.
+if (Ty-isIntegral()  TD-getTypeSize(Ty) = TD-getTypeSize(OpTy))
+  return EmitConstantValueOnly(Op);
+  }
+  
+  assert(0  FIXME: Don't yet support this kind of constant cast expr);
   EmitConstantValueOnly(Op);
   break;
 }



___
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

2006-07-27 Thread Nate Begeman


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.85 - 1.86
---
Log message:

Code cleanups, per review


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

 AsmPrinter.cpp |   10 +++---
 1 files changed, 7 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.85 
llvm/lib/CodeGen/AsmPrinter.cpp:1.86
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.85Wed Jul 26 20:13:04 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Jul 27 11:46:58 2006
@@ -210,7 +210,11 @@
   const std::vectorMachineJumpTableEntry JT = MJTI-getJumpTables();
   if (JT.empty()) return;
   const TargetData *TD = TM.getTargetData();
-  const char *PtrDataDirective = Data32bitsDirective;
+  
+  // JTEntryDirective is a string to print sizeof(ptr) for non-PIC jump tables,
+  // and 32 bits for PIC since PIC jump table entries are differences, not
+  // pointers to blocks.
+  const char *JTEntryDirective = Data32bitsDirective;
   
   // Pick the directive to use to print the jump table entries, and switch to 
   // the appropriate section.
@@ -219,7 +223,7 @@
   } else {
 SwitchToDataSection(JumpTableDataSection, 0);
 if (TD-getPointerSize() == 8)
-  PtrDataDirective = Data64bitsDirective;
+  JTEntryDirective = Data64bitsDirective;
   }
   EmitAlignment(Log2_32(TD-getPointerAlignment()));
   
@@ -228,7 +232,7 @@
:\n;
 const std::vectorMachineBasicBlock* JTBBs = JT[i].MBBs;
 for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
-  O  PtrDataDirective  ' ';
+  O  JTEntryDirective  ' ';
   printBasicBlockLabel(JTBBs[ii], false, false);
   if (TM.getRelocationModel() == Reloc::PIC_) {
 O  '-'  PrivateGlobalPrefix  JTI  getFunctionNumber() 



___
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

2006-07-26 Thread Nate Begeman


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.84 - 1.85
---
Log message:

Support jump tables when in PIC relocation model


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

 AsmPrinter.cpp |   34 ++
 1 files changed, 18 insertions(+), 16 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.84 
llvm/lib/CodeGen/AsmPrinter.cpp:1.85
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.84Fri Jul 14 20:34:12 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Jul 26 20:13:04 2006
@@ -52,7 +52,8 @@
   DataSectionStartSuffix(),
   SectionEndDirectiveSuffix(0),
   ConstantPoolSection(\t.section .rodata\n),
-  JumpTableSection(\t.section .rodata\n),
+  JumpTableDataSection(\t.section .rodata\n),
+  JumpTableTextSection(\t.text\n),
   StaticCtorsSection(\t.section .ctors,\aw\,@progbits),
   StaticDtorsSection(\t.section .dtors,\aw\,@progbits),
   FourByteConstantSection(0),
@@ -89,7 +90,7 @@
 O  CurrentSection  TextSectionStartSuffix  '\n';
 }
 
-/// SwitchToTextSection - Switch to the specified text section of the 
executable
+/// SwitchToDataSection - Switch to the specified data section of the 
executable
 /// if we are not already in it!
 ///
 void AsmPrinter::SwitchToDataSection(const char *NewSection,
@@ -209,29 +210,30 @@
   const std::vectorMachineJumpTableEntry JT = MJTI-getJumpTables();
   if (JT.empty()) return;
   const TargetData *TD = TM.getTargetData();
+  const char *PtrDataDirective = Data32bitsDirective;
   
-  // FIXME: someday we need to handle PIC jump tables
-  assert((TM.getRelocationModel() == Reloc::Static ||
-  TM.getRelocationModel() == Reloc::DynamicNoPIC) 
- Unhandled relocation model emitting jump table information!);
-  
-  SwitchToDataSection(JumpTableSection, 0);
+  // Pick the directive to use to print the jump table entries, and switch to 
+  // the appropriate section.
+  if (TM.getRelocationModel() == Reloc::PIC_) {
+SwitchToTextSection(JumpTableTextSection, 0);
+  } else {
+SwitchToDataSection(JumpTableDataSection, 0);
+if (TD-getPointerSize() == 8)
+  PtrDataDirective = Data64bitsDirective;
+  }
   EmitAlignment(Log2_32(TD-getPointerAlignment()));
   
-  // Pick the directive to use based on the pointer size. FIXME: when we 
support
-  // PIC jumptables, this should always use the 32-bit directive for label
-  // differences. 
-  const char *PtrDataDirective = Data32bitsDirective;
-  if (TD-getPointerSize() == 8)
-PtrDataDirective = Data64bitsDirective;
-
   for (unsigned i = 0, e = JT.size(); i != e; ++i) {
 O  PrivateGlobalPrefix  JTI  getFunctionNumber()  '_'  i 
:\n;
 const std::vectorMachineBasicBlock* JTBBs = JT[i].MBBs;
 for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
   O  PtrDataDirective  ' ';
-  printBasicBlockLabel(JTBBs[ii]);
+  printBasicBlockLabel(JTBBs[ii], false, false);
+  if (TM.getRelocationModel() == Reloc::PIC_) {
+O  '-'  PrivateGlobalPrefix  JTI  getFunctionNumber() 
+   '_'  i;
+  }
   O  '\n';
 }
   }



___
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

2006-06-28 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.82 - 1.83
---
Log message:

Add support to print 4-, 8-, and 16- byte constant literals in special
sections. e.g. On Darwin that would be .literal4 and .literal8.


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

 AsmPrinter.cpp |   58 +++--
 1 files changed, 48 insertions(+), 10 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.82 
llvm/lib/CodeGen/AsmPrinter.cpp:1.83
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.82Thu Jun 15 14:37:14 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Jun 28 19:26:09 2006
@@ -55,6 +55,9 @@
   JumpTableSection(\t.section .rodata\n),
   StaticCtorsSection(\t.section .ctors,\aw\,@progbits),
   StaticDtorsSection(\t.section .dtors,\aw\,@progbits),
+  FourByteConstantSection(0),
+  EightByteConstantSection(0),
+  SixteenByteConstantSection(0),
   LCOMMDirective(0),
   COMMDirective(\t.comm\t),
   COMMDirectiveTakesAlignment(true),
@@ -147,19 +150,54 @@
 void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
   const std::vectorMachineConstantPoolEntry CP = MCP-getConstants();
   if (CP.empty()) return;
-  
-  SwitchToDataSection(ConstantPoolSection, 0);
-  EmitAlignment(MCP-getConstantPoolAlignment());
+
+  // Some targets require 4-, 8-, and 16- byte constant literals to be placed
+  // in special sections.
+  std::vectorstd::pairMachineConstantPoolEntry,unsigned  FourByteCPs;
+  std::vectorstd::pairMachineConstantPoolEntry,unsigned  EightByteCPs;
+  std::vectorstd::pairMachineConstantPoolEntry,unsigned  SixteenByteCPs;
+  std::vectorstd::pairMachineConstantPoolEntry,unsigned  OtherCPs;
+  for (unsigned i = 0, e = CP.size(); i != e; ++i) {
+MachineConstantPoolEntry CPE = CP[i];
+const Constant *CV = CPE.Val;
+const Type *Ty = CV-getType();
+if (FourByteConstantSection 
+TM.getTargetData()-getTypeSize(Ty) == 4)
+  FourByteCPs.push_back(std::make_pair(CPE, i));
+else if (EightByteConstantSection 
+ TM.getTargetData()-getTypeSize(Ty) == 8)
+  EightByteCPs.push_back(std::make_pair(CPE, i));
+else if (SixteenByteConstantSection 
+ TM.getTargetData()-getTypeSize(Ty) == 16)
+  SixteenByteCPs.push_back(std::make_pair(CPE, i));
+else
+  OtherCPs.push_back(std::make_pair(CPE, i));
+  }
+
+  unsigned Alignment = MCP-getConstantPoolAlignment();
+  EmitConstantPool(Alignment, FourByteConstantSection,FourByteCPs);
+  EmitConstantPool(Alignment, EightByteConstantSection,   EightByteCPs);
+  EmitConstantPool(Alignment, SixteenByteConstantSection, SixteenByteCPs);
+  EmitConstantPool(Alignment, ConstantPoolSection,OtherCPs);
+}
+
+void AsmPrinter::EmitConstantPool(unsigned Alignment, const char *Section,
+   std::vectorstd::pairMachineConstantPoolEntry,unsigned  CP) 
{
+  if (CP.empty()) return;
+
+  SwitchToDataSection(Section, 0);
+  EmitAlignment(Alignment);
   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
-O  PrivateGlobalPrefix  CPI  getFunctionNumber()  '_'  i
-   :\t\t\t\t\t  CommentString   ;
-WriteTypeSymbolic(O, CP[i].Val-getType(), 0)  '\n';
-EmitGlobalConstant(CP[i].Val);
+O  PrivateGlobalPrefix  CPI  getFunctionNumber()  '_'
+   CP[i].second  :\t\t\t\t\t  CommentString   ;
+WriteTypeSymbolic(O, CP[i].first.Val-getType(), 0)  '\n';
+EmitGlobalConstant(CP[i].first.Val);
 if (i != e-1) {
-  unsigned EntSize = TM.getTargetData()-getTypeSize(CP[i].Val-getType());
-  unsigned ValEnd = CP[i].Offset + EntSize;
+  unsigned EntSize =
+TM.getTargetData()-getTypeSize(CP[i].first.Val-getType());
+  unsigned ValEnd = CP[i].first.Offset + EntSize;
   // Emit inter-object padding for alignment.
-  EmitZeros(CP[i+1].Offset-ValEnd);
+  EmitZeros(CP[i+1].first.Offset-ValEnd);
 }
   }
 }



___
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

2006-06-15 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.79 - 1.80
---
Log message:

Assert. Rather than silently stop printing.

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

 AsmPrinter.cpp |2 ++
 1 files changed, 2 insertions(+)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.79 
llvm/lib/CodeGen/AsmPrinter.cpp:1.80
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.79Thu Jun  8 13:00:47 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Jun 15 03:10:56 2006
@@ -536,6 +536,8 @@
 break;
   case Type::PointerTyID:
 if (TD-getPointerSize() == 8) {
+  assert(Data64bitsDirective 
+ Target cannot handle 64-bit pointer exprs!);
   O  Data64bitsDirective;
   break;
 }



___
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

2006-06-15 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.80 - 1.81
---
Log message:

Alignment of globals has not been quite right.  Needed to drop the pointer type
to get the alignment of the element type.


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

 AsmPrinter.cpp |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.80 
llvm/lib/CodeGen/AsmPrinter.cpp:1.81
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.80Thu Jun 15 03:10:56 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Jun 15 08:10:58 2006
@@ -244,18 +244,16 @@
 /// specified global, returned in log form.  This includes an explicitly
 /// requested alignment (if the global has one).
 unsigned AsmPrinter::getPreferredAlignmentLog(const GlobalVariable *GV) const {
-  unsigned Alignment = 
TM.getTargetData()-getTypeAlignmentShift(GV-getType());
+  const Type *ElemType = GV-getType()-getElementType();
+  unsigned Alignment = TM.getTargetData()-getTypeAlignmentShift(ElemType);
   if (GV-getAlignment()  (1U  Alignment))
 Alignment = Log2_32(GV-getAlignment());
   
   if (GV-hasInitializer()) {
-// Always round up alignment of global doubles to 8 bytes.
-if (GV-getType()-getElementType() == Type::DoubleTy  Alignment  3)
-  Alignment = 3;
 if (Alignment  4) {
   // If the global is not external, see if it is large.  If so, give it a
   // larger alignment.
-  if (TM.getTargetData()-getTypeSize(GV-getType()-getElementType())  
128)
+  if (TM.getTargetData()-getTypeSize(ElemType)  128)
 Alignment = 4;// 16-byte alignment.
 }
   }



___
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

2006-06-15 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.81 - 1.82
---
Log message:

Was pointed out that structure alignment and type alignment are not the same
thing.  Doubles still need to be special cased.


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

 AsmPrinter.cpp |3 +++
 1 files changed, 3 insertions(+)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.81 
llvm/lib/CodeGen/AsmPrinter.cpp:1.82
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.81Thu Jun 15 08:10:58 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Jun 15 14:37:14 2006
@@ -250,6 +250,9 @@
 Alignment = Log2_32(GV-getAlignment());
   
   if (GV-hasInitializer()) {
+// Always round up alignment of global doubles to 8 bytes.
+if (GV-getType()-getElementType() == Type::DoubleTy  Alignment  3)
+  Alignment = 3;
 if (Alignment  4) {
   // If the global is not external, see if it is large.  If so, give it a
   // larger alignment.



___
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

2006-06-08 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.78 - 1.79
---
Log message:

Fix an assert-on-inline-inline-asm bug.


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

 AsmPrinter.cpp |   30 ++
 1 files changed, 18 insertions(+), 12 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.78 
llvm/lib/CodeGen/AsmPrinter.cpp:1.79
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.78Fri May 12 12:50:35 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Jun  8 13:00:47 2006
@@ -656,24 +656,30 @@
   // operand!
   if (CurVariant == -1 || CurVariant == AsmPrinterVariant) {
 unsigned OpNo = 1;
-
+
+bool Error = false;
+
 // Scan to find the machine operand number for the operand.
 for (; Val; --Val) {
+  if (OpNo = MI-getNumOperands()) break;
   unsigned OpFlags = MI-getOperand(OpNo).getImmedValue();
   OpNo += (OpFlags  3) + 1;
 }
-
-unsigned OpFlags = MI-getOperand(OpNo).getImmedValue();
-++OpNo;  // Skip over the ID number.
-
-bool Error;
-AsmPrinter *AP = const_castAsmPrinter*(this);
-if ((OpFlags  7) == 4 /*ADDR MODE*/) {
-  Error = AP-PrintAsmMemoryOperand(MI, OpNo, AsmPrinterVariant,
-Modifier[0] ? Modifier : 0);
+
+if (OpNo = MI-getNumOperands()) {
+  Error = true;
 } else {
-  Error = AP-PrintAsmOperand(MI, OpNo, AsmPrinterVariant,
-  Modifier[0] ? Modifier : 0);
+  unsigned OpFlags = MI-getOperand(OpNo).getImmedValue();
+  ++OpNo;  // Skip over the ID number.
+
+  AsmPrinter *AP = const_castAsmPrinter*(this);
+  if ((OpFlags  7) == 4 /*ADDR MODE*/) {
+Error = AP-PrintAsmMemoryOperand(MI, OpNo, AsmPrinterVariant,
+  Modifier[0] ? Modifier : 0);
+  } else {
+Error = AP-PrintAsmOperand(MI, OpNo, AsmPrinterVariant,
+Modifier[0] ? Modifier : 0);
+  }
 }
 if (Error) {
   std::cerr  Invalid operand found in inline asm: '



___
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 DwarfWriter.cpp ELFWriter.cpp MachineBasicBlock.cpp MachineFunction.cpp

2006-05-12 Thread Owen Anderson


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.76 - 1.77
DwarfWriter.cpp updated: 1.59 - 1.60
ELFWriter.cpp updated: 1.25 - 1.26
MachineBasicBlock.cpp updated: 1.27 - 1.28
MachineFunction.cpp updated: 1.90 - 1.91
---
Log message:

Refactor a bunch of includes so that TargetMachine.h doesn't have to include
TargetData.h.  This should make recompiles a bit faster with my current
TargetData tinkering.


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

 AsmPrinter.cpp|1 +
 DwarfWriter.cpp   |1 +
 ELFWriter.cpp |1 +
 MachineBasicBlock.cpp |1 +
 MachineFunction.cpp   |1 +
 5 files changed, 5 insertions(+)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.76 
llvm/lib/CodeGen/AsmPrinter.cpp:1.77
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.76Tue May  9 11:41:59 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Fri May 12 01:33:48 2006
@@ -20,6 +20,7 @@
 #include llvm/CodeGen/MachineJumpTableInfo.h
 #include llvm/Support/Mangler.h
 #include llvm/Support/MathExtras.h
+#include llvm/Target/TargetData.h
 #include llvm/Target/TargetMachine.h
 #include iostream
 #include cerrno


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.59 
llvm/lib/CodeGen/DwarfWriter.cpp:1.60
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.59   Mon May  8 23:59:56 2006
+++ llvm/lib/CodeGen/DwarfWriter.cppFri May 12 01:33:48 2006
@@ -24,6 +24,7 @@
 #include llvm/Support/CommandLine.h
 #include llvm/Support/Mangler.h
 #include llvm/Target/MRegisterInfo.h
+#include llvm/Target/TargetData.h
 #include llvm/Target/TargetMachine.h
 #include llvm/Target/TargetFrameInfo.h
 


Index: llvm/lib/CodeGen/ELFWriter.cpp
diff -u llvm/lib/CodeGen/ELFWriter.cpp:1.25 llvm/lib/CodeGen/ELFWriter.cpp:1.26
--- llvm/lib/CodeGen/ELFWriter.cpp:1.25 Wed May  3 12:10:41 2006
+++ llvm/lib/CodeGen/ELFWriter.cpp  Fri May 12 01:33:48 2006
@@ -35,6 +35,7 @@
 #include llvm/Module.h
 #include llvm/CodeGen/MachineCodeEmitter.h
 #include llvm/CodeGen/MachineConstantPool.h
+#include llvm/Target/TargetData.h
 #include llvm/Target/TargetMachine.h
 #include llvm/Support/Mangler.h
 #include iostream


Index: llvm/lib/CodeGen/MachineBasicBlock.cpp
diff -u llvm/lib/CodeGen/MachineBasicBlock.cpp:1.27 
llvm/lib/CodeGen/MachineBasicBlock.cpp:1.28
--- llvm/lib/CodeGen/MachineBasicBlock.cpp:1.27 Thu May  4 13:16:01 2006
+++ llvm/lib/CodeGen/MachineBasicBlock.cpp  Fri May 12 01:33:48 2006
@@ -15,6 +15,7 @@
 #include llvm/BasicBlock.h
 #include llvm/CodeGen/MachineFunction.h
 #include llvm/CodeGen/MachineInstr.h
+#include llvm/Target/TargetData.h
 #include llvm/Target/TargetInstrInfo.h
 #include llvm/Target/TargetMachine.h
 #include llvm/Support/LeakDetector.h


Index: llvm/lib/CodeGen/MachineFunction.cpp
diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.90 
llvm/lib/CodeGen/MachineFunction.cpp:1.91
--- llvm/lib/CodeGen/MachineFunction.cpp:1.90   Tue May  2 20:29:56 2006
+++ llvm/lib/CodeGen/MachineFunction.cppFri May 12 01:33:48 2006
@@ -20,6 +20,7 @@
 #include llvm/CodeGen/MachineConstantPool.h
 #include llvm/CodeGen/MachineJumpTableInfo.h
 #include llvm/CodeGen/Passes.h
+#include llvm/Target/TargetData.h
 #include llvm/Target/TargetMachine.h
 #include llvm/Target/TargetFrameInfo.h
 #include llvm/Function.h



___
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

2006-05-12 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.77 - 1.78
---
Log message:

Remove dead var


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

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


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.77 
llvm/lib/CodeGen/AsmPrinter.cpp:1.78
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.77Fri May 12 01:33:48 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Fri May 12 12:50:35 2006
@@ -147,7 +147,6 @@
 void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
   const std::vectorMachineConstantPoolEntry CP = MCP-getConstants();
   if (CP.empty()) return;
-  const TargetData *TD = TM.getTargetData();
   
   SwitchToDataSection(ConstantPoolSection, 0);
   EmitAlignment(MCP-getConstantPoolAlignment());



___
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 DwarfWriter.cpp

2006-05-08 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.68 - 1.69
DwarfWriter.cpp updated: 1.58 - 1.59
---
Log message:

Split SwitchSection into SwitchTo{Text|Data}Section methods.


---
Diffs of the changes:  (+81 -39)

 AsmPrinter.cpp  |   70 
 DwarfWriter.cpp |   50 
 2 files changed, 81 insertions(+), 39 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.68 
llvm/lib/CodeGen/AsmPrinter.cpp:1.69
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.68Sat May  6 16:27:14 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon May  8 23:59:56 2006
@@ -59,10 +59,11 @@
 }
 
 
-/// SwitchSection - Switch to the specified section of the executable if we
-/// are not already in it!
+/// SwitchToTextSection - Switch to the specified text section of the 
executable
+/// if we are not already in it!
 ///
-void AsmPrinter::SwitchSection(const char *NewSection, const GlobalValue *GV) {
+void AsmPrinter::SwitchToTextSection(const char *NewSection,
+ const GlobalValue *GV) {
   std::string NS;
 
   // Microsoft ML/MASM has a fundamentally different approach to handling
@@ -78,12 +79,8 @@
   return;
 }
 
-bool isData = strcmp(NewSection , .data) == 0;
-
 if (GV  GV-hasSection())
   NS = GV-getSection();
-else if (isData)
-  NS = _data;
 else
   NS = _text;
 
@@ -91,8 +88,7 @@
   if (!CurrentSection.empty())
 O  CurrentSection  \tends\n\n;
   CurrentSection = NS;
-  O  CurrentSection  (isData ? \tsegment 'DATA'\n
- : \tsegment 'CODE'\n);
+  O  CurrentSection  \tsegment 'CODE'\n;
 }
   } else {
 if (GV  GV-hasSection())
@@ -108,6 +104,52 @@
   }
 }
 
+/// SwitchToTextSection - Switch to the specified text section of the 
executable
+/// if we are not already in it!
+///
+void AsmPrinter::SwitchToDataSection(const char *NewSection,
+ const GlobalValue *GV) {
+  std::string NS;
+  
+  // Microsoft ML/MASM has a fundamentally different approach to handling
+  // sections.
+  
+  if (MLSections) {
+if (*NewSection == 0) {
+  // Simply end the current section, if any.
+  if (!CurrentSection.empty()) {
+O  CurrentSection  \tends\n\n;
+CurrentSection.clear();
+  }
+  return;
+}
+
+if (GV  GV-hasSection())
+  NS = GV-getSection();
+else
+  NS = _data;
+
+if (CurrentSection != NS) {
+  if (!CurrentSection.empty())
+O  CurrentSection  \tends\n\n;
+  CurrentSection = NS;
+  O  CurrentSection  \tsegment 'DATA'\n;
+}
+  } else {
+if (GV  GV-hasSection())
+  NS = SwitchToSectionDirective + GV-getSection();
+else
+  NS = std::string(\t)+NewSection;
+
+if (CurrentSection != NS) {
+  CurrentSection = NS;
+  if (!CurrentSection.empty())
+O  CurrentSection  '\n';
+}
+  }
+}
+
+
 bool AsmPrinter::doInitialization(Module M) {
   Mang = new Mangler(M, GlobalPrefix);
   
@@ -116,7 +158,7 @@
M.getModuleInlineAsm()
\n  CommentString   End of file scope inline assembly\n;
 
-  SwitchSection(, 0);   // Reset back to no section.
+  SwitchToDataSection(, 0);   // Reset back to no section.
   
   if (MachineDebugInfo *DebugInfo = getAnalysisToUpdateMachineDebugInfo()) {
 DebugInfo-AnalyzeModule(M);
@@ -146,7 +188,7 @@
   if (CP.empty()) return;
   const TargetData *TD = TM.getTargetData();
   
-  SwitchSection(ConstantPoolSection, 0);
+  SwitchToDataSection(ConstantPoolSection, 0);
   EmitAlignment(MCP-getConstantPoolAlignment());
   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
 O  PrivateGlobalPrefix  CPI  getFunctionNumber()  '_'  i
@@ -175,7 +217,7 @@
   TM.getRelocationModel() == Reloc::DynamicNoPIC) 
  Unhandled relocation model emitting jump table information!);
   
-  SwitchSection(JumpTableSection, 0);
+  SwitchToDataSection(JumpTableSection, 0);
   EmitAlignment(Log2_32(TD-getPointerAlignment()));
   for (unsigned i = 0, e = JT.size(); i != e; ++i) {
 O  PrivateGlobalPrefix  JTI  getFunctionNumber()  '_'  i 
@@ -204,14 +246,14 @@
 return true;  // No need to emit this at all.
 
   if (GV-getName() == llvm.global_ctors  GV-use_empty()) {
-SwitchSection(StaticCtorsSection, 0);
+SwitchToDataSection(StaticCtorsSection, 0);
 EmitAlignment(2, 0);
 EmitXXStructorList(GV-getInitializer());
 return true;
   } 
   
   if (GV-getName() == llvm.global_dtors  GV-use_empty()) {
-SwitchSection(StaticDtorsSection, 0);
+SwitchToDataSection(StaticDtorsSection, 0);
 EmitAlignment(2, 0);
 EmitXXStructorList(GV-getInitializer());
 return true;


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.58 
llvm/lib/CodeGen/DwarfWriter.cpp:1.59
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.58   Tue May  2 

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

2006-05-08 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.69 - 1.70
---
Log message:

The MASM asmprinter has been fixed, these hacks are no longer needed.


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

 AsmPrinter.cpp |   22 ++
 1 files changed, 2 insertions(+), 20 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.69 
llvm/lib/CodeGen/AsmPrinter.cpp:1.70
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.69Mon May  8 23:59:56 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue May  9 00:13:34 2006
@@ -70,19 +70,10 @@
   // sections.
 
   if (MLSections) {
-if (*NewSection == 0) {
-  // Simply end the current section, if any.
-  if (!CurrentSection.empty()) {
-O  CurrentSection  \tends\n\n;
-CurrentSection.clear();
-  }
-  return;
-}
-
 if (GV  GV-hasSection())
   NS = GV-getSection();
 else
-  NS = _text;
+  NS = NewSection;
 
 if (CurrentSection != NS) {
   if (!CurrentSection.empty())
@@ -115,19 +106,10 @@
   // sections.
   
   if (MLSections) {
-if (*NewSection == 0) {
-  // Simply end the current section, if any.
-  if (!CurrentSection.empty()) {
-O  CurrentSection  \tends\n\n;
-CurrentSection.clear();
-  }
-  return;
-}
-
 if (GV  GV-hasSection())
   NS = GV-getSection();
 else
-  NS = _data;
+  NS = NewSection;
 
 if (CurrentSection != NS) {
   if (!CurrentSection.empty())



___
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

2006-05-08 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.70 - 1.71
---
Log message:

Make the masm codepath work like the normal code path.


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

 AsmPrinter.cpp |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.70 
llvm/lib/CodeGen/AsmPrinter.cpp:1.71
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.70Tue May  9 00:13:34 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue May  9 00:15:58 2006
@@ -79,7 +79,8 @@
   if (!CurrentSection.empty())
 O  CurrentSection  \tends\n\n;
   CurrentSection = NS;
-  O  CurrentSection  \tsegment 'CODE'\n;
+  if (!CurrentSection.empty())
+O  CurrentSection  \tsegment 'CODE'\n;
 }
   } else {
 if (GV  GV-hasSection())
@@ -115,7 +116,8 @@
   if (!CurrentSection.empty())
 O  CurrentSection  \tends\n\n;
   CurrentSection = NS;
-  O  CurrentSection  \tsegment 'DATA'\n;
+  if (!CurrentSection.empty())
+O  CurrentSection  \tsegment 'DATA'\n;
 }
   } else {
 if (GV  GV-hasSection())



___
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

2006-05-08 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.72 - 1.73
---
Log message:

Setting SwitchToSectionDirective properly in the MASM backend permits a bunch
of code to be unified.



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

 AsmPrinter.cpp |   37 +++--
 1 files changed, 15 insertions(+), 22 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.72 
llvm/lib/CodeGen/AsmPrinter.cpp:1.73
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.72Tue May  9 00:19:59 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue May  9 00:23:12 2006
@@ -102,34 +102,27 @@
 void AsmPrinter::SwitchToDataSection(const char *NewSection,
  const GlobalValue *GV) {
   std::string NS;
+  if (GV  GV-hasSection())
+NS = SwitchToSectionDirective + GV-getSection();
+  else
+NS = NewSection;
   
+  // If we're already in this section, we're done.
+  if (CurrentSection == NS) return;
+
   // Microsoft ML/MASM has a fundamentally different approach to handling
   // sections.
   
   if (MLSections) {
-if (GV  GV-hasSection())
-  NS = GV-getSection();
-else
-  NS = NewSection;
-
-if (CurrentSection != NS) {
-  if (!CurrentSection.empty())
-O  CurrentSection  \tends\n\n;
-  CurrentSection = NS;
-  if (!CurrentSection.empty())
-O  CurrentSection  \tsegment 'DATA'\n;
-}
+if (!CurrentSection.empty())
+  O  CurrentSection  \tends\n\n;
+CurrentSection = NS;
+if (!CurrentSection.empty())
+  O  CurrentSection  \tsegment 'DATA'\n;
   } else {
-if (GV  GV-hasSection())
-  NS = SwitchToSectionDirective + GV-getSection();
-else
-  NS = NewSection;
-
-if (CurrentSection != NS) {
-  CurrentSection = NS;
-  if (!CurrentSection.empty())
-O  CurrentSection  '\n';
-}
+CurrentSection = NS;
+if (!CurrentSection.empty())
+  O  CurrentSection  '\n';
   }
 }
 



___
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

2006-05-08 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.73 - 1.74
---
Log message:

Oh yeah, there are two of these now, unify both.


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

 AsmPrinter.cpp |   37 +++--
 1 files changed, 15 insertions(+), 22 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.73 
llvm/lib/CodeGen/AsmPrinter.cpp:1.74
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.73Tue May  9 00:23:12 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue May  9 00:24:50 2006
@@ -65,34 +65,27 @@
 void AsmPrinter::SwitchToTextSection(const char *NewSection,
  const GlobalValue *GV) {
   std::string NS;
+  if (GV  GV-hasSection())
+NS = GV-getSection();
+  else
+NS = NewSection;
+  
+  // If we're already in this section, we're done.
+  if (CurrentSection == NS) return;
 
   // Microsoft ML/MASM has a fundamentally different approach to handling
   // sections.
 
   if (MLSections) {
-if (GV  GV-hasSection())
-  NS = GV-getSection();
-else
-  NS = NewSection;
-
-if (CurrentSection != NS) {
-  if (!CurrentSection.empty())
-O  CurrentSection  \tends\n\n;
-  CurrentSection = NS;
-  if (!CurrentSection.empty())
-O  CurrentSection  \tsegment 'CODE'\n;
-}
+if (!CurrentSection.empty())
+  O  CurrentSection  \tends\n\n;
+CurrentSection = NS;
+if (!CurrentSection.empty())
+  O  CurrentSection  \tsegment 'CODE'\n;
   } else {
-if (GV  GV-hasSection())
-  NS = SwitchToSectionDirective + GV-getSection();
-else
-  NS = std::string(\t)+NewSection;
-
-if (CurrentSection != NS) {
-  CurrentSection = NS;
-  if (!CurrentSection.empty())
-O  CurrentSection  '\n';
-}
+CurrentSection = NS;
+if (!CurrentSection.empty())
+  O  CurrentSection  '\n';
   }
 }
 



___
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

2006-05-08 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.71 - 1.72
---
Log message:


Don't prefix section directives with a tab.  Doing so causes blank lines to
be emitted to the .s file.


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

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


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.71 
llvm/lib/CodeGen/AsmPrinter.cpp:1.72
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.71Tue May  9 00:15:58 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue May  9 00:19:59 2006
@@ -123,7 +123,7 @@
 if (GV  GV-hasSection())
   NS = SwitchToSectionDirective + GV-getSection();
 else
-  NS = std::string(\t)+NewSection;
+  NS = NewSection;
 
 if (CurrentSection != NS) {
   CurrentSection = NS;



___
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

2006-05-08 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.74 - 1.75
---
Log message:

Implement MASM sections correctly, without a has masm sections flag and a 
bunch of special case code.


---
Diffs of the changes:  (+17 -27)

 AsmPrinter.cpp |   44 +---
 1 files changed, 17 insertions(+), 27 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.74 
llvm/lib/CodeGen/AsmPrinter.cpp:1.75
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.74Tue May  9 00:24:50 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue May  9 00:33:48 2006
@@ -47,7 +47,9 @@
   AlignDirective(\t.align\t),
   AlignmentIsInBytes(true),
   SwitchToSectionDirective(\t.section\t),
-  MLSections(false),
+  TextSectionStartSuffix(),
+  DataSectionStartSuffix(),
+  SectionEndDirectiveSuffix(0),
   ConstantPoolSection(\t.section .rodata\n),
   JumpTableSection(\t.section .rodata\n),
   StaticCtorsSection(\t.section .ctors,\aw\,@progbits),
@@ -73,20 +75,14 @@
   // If we're already in this section, we're done.
   if (CurrentSection == NS) return;
 
-  // Microsoft ML/MASM has a fundamentally different approach to handling
-  // sections.
+  // Close the current section, if applicable.
+  if (SectionEndDirectiveSuffix  !CurrentSection.empty())
+O  CurrentSection  SectionEndDirectiveSuffix  \n;
 
-  if (MLSections) {
-if (!CurrentSection.empty())
-  O  CurrentSection  \tends\n\n;
-CurrentSection = NS;
-if (!CurrentSection.empty())
-  O  CurrentSection  \tsegment 'CODE'\n;
-  } else {
-CurrentSection = NS;
-if (!CurrentSection.empty())
-  O  CurrentSection  '\n';
-  }
+  CurrentSection = NS;
+
+  if (!CurrentSection.empty())
+O  CurrentSection  TextSectionStartSuffix  '\n';
 }
 
 /// SwitchToTextSection - Switch to the specified text section of the 
executable
@@ -103,20 +99,14 @@
   // If we're already in this section, we're done.
   if (CurrentSection == NS) return;
 
-  // Microsoft ML/MASM has a fundamentally different approach to handling
-  // sections.
+  // Close the current section, if applicable.
+  if (SectionEndDirectiveSuffix  !CurrentSection.empty())
+O  CurrentSection  SectionEndDirectiveSuffix  \n;
+
+  CurrentSection = NS;
   
-  if (MLSections) {
-if (!CurrentSection.empty())
-  O  CurrentSection  \tends\n\n;
-CurrentSection = NS;
-if (!CurrentSection.empty())
-  O  CurrentSection  \tsegment 'DATA'\n;
-  } else {
-CurrentSection = NS;
-if (!CurrentSection.empty())
-  O  CurrentSection  '\n';
-  }
+  if (!CurrentSection.empty())
+O  CurrentSection  DataSectionStartSuffix  '\n';
 }
 
 



___
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

2006-05-06 Thread Jeff Cohen


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.67 - 1.68
---
Log message:

Fix some loose ends in MASM support.

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

 AsmPrinter.cpp |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.67 
llvm/lib/CodeGen/AsmPrinter.cpp:1.68
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.67Fri May  5 16:47:05 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sat May  6 16:27:14 2006
@@ -71,9 +71,9 @@
   if (MLSections) {
 if (*NewSection == 0) {
   // Simply end the current section, if any.
-  if (CurrentSection != ) {
-O  CurrentSection  \tends\n;
-CurrentSection = ;
+  if (!CurrentSection.empty()) {
+O  CurrentSection  \tends\n\n;
+CurrentSection.clear();
   }
   return;
 }
@@ -88,8 +88,8 @@
   NS = _text;
 
 if (CurrentSection != NS) {
-  if (CurrentSection != )
-O  CurrentSection  \tends\n;
+  if (!CurrentSection.empty())
+O  CurrentSection  \tends\n\n;
   CurrentSection = NS;
   O  CurrentSection  (isData ? \tsegment 'DATA'\n
  : \tsegment 'CODE'\n);



___
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

2006-05-05 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.66 - 1.67
---
Log message:

Indent multiline asm strings more nicely


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

 AsmPrinter.cpp |   14 +-
 1 files changed, 9 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.66 
llvm/lib/CodeGen/AsmPrinter.cpp:1.67
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.66Tue May  2 20:29:56 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Fri May  5 16:47:05 2006
@@ -34,8 +34,8 @@
   GlobalVarAddrSuffix(),
   FunctionAddrPrefix(),
   FunctionAddrSuffix(),
-  InlineAsmStart(#APP\n\t),
-  InlineAsmEnd(\t#NO_APP\n),
+  InlineAsmStart(#APP),
+  InlineAsmEnd(#NO_APP),
   ZeroDirective(\t.zero\t),
   ZeroDirectiveSuffix(0),
   AsciiDirective(\t.ascii\t),
@@ -558,7 +558,7 @@
 /// printInlineAsm - This method formats and prints the specified machine
 /// instruction that is an inline asm.
 void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
-  O  InlineAsmStart;
+  O  InlineAsmStart  \n\t;
   unsigned NumOperands = MI-getNumOperands();
   
   // Count the number of register definitions.
@@ -583,13 +583,17 @@
   // Not a special case, emit the string section literally.
   const char *LiteralEnd = LastEmitted+1;
   while (*LiteralEnd  *LiteralEnd != '{'  *LiteralEnd != '|' 
- *LiteralEnd != '}'  *LiteralEnd != '$')
+ *LiteralEnd != '}'  *LiteralEnd != '$'  *LiteralEnd != '\n')
 ++LiteralEnd;
   if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
 O.write(LastEmitted, LiteralEnd-LastEmitted);
   LastEmitted = LiteralEnd;
   break;
 }
+case '\n':
+  ++LastEmitted;   // Consume newline character.
+  O  \n\t; // Indent code with newline.
+  break;
 case '$': {
   ++LastEmitted;   // Consume '$' character.
   if (*LastEmitted == '$') { // $$ - $
@@ -707,7 +711,7 @@
   break;
 }
   }
-  O  \n  InlineAsmEnd;
+  O  \n\t  InlineAsmEnd  \n;
 }
 
 /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM



___
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

2006-05-02 Thread Nate Begeman


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.64 - 1.65
---
Log message:

Print function number instead of name


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

 AsmPrinter.cpp |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.64 
llvm/lib/CodeGen/AsmPrinter.cpp:1.65
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.64Tue May  2 00:37:32 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue May  2 12:36:46 2006
@@ -731,9 +731,8 @@
 void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
   bool printColon,
   bool printComment) const {
-  O  PrivateGlobalPrefix  LBB 
- Mang-getValueName(MBB-getParent()-getFunction())
- _  MBB-getNumber();
+  O  PrivateGlobalPrefix  BB  FunctionNumber  _
+ MBB-getNumber();
   if (printColon)
 O  ':';
   if (printComment)



___
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 DwarfWriter.cpp ELFWriter.cpp MachineFunction.cpp

2006-05-02 Thread Owen Anderson


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.65 - 1.66
DwarfWriter.cpp updated: 1.57 - 1.58
ELFWriter.cpp updated: 1.23 - 1.24
MachineFunction.cpp updated: 1.89 - 1.90
---
Log message:

Refactor TargetMachine, pushing handling of TargetData into the target-specific 
subclasses.  This has one caller-visible change: getTargetData() now returns a 
pointer instead of a reference.

This fixes PR 759: http://llvm.cs.uiuc.edu/PR759 .



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

 AsmPrinter.cpp  |   32 
 DwarfWriter.cpp |4 ++--
 ELFWriter.cpp   |8 
 MachineFunction.cpp |6 +++---
 4 files changed, 25 insertions(+), 25 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.65 
llvm/lib/CodeGen/AsmPrinter.cpp:1.66
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.65Tue May  2 12:36:46 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue May  2 20:29:56 2006
@@ -144,7 +144,7 @@
 void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
   const std::vectorMachineConstantPoolEntry CP = MCP-getConstants();
   if (CP.empty()) return;
-  const TargetData TD = TM.getTargetData();
+  const TargetData *TD = TM.getTargetData();
   
   SwitchSection(ConstantPoolSection, 0);
   EmitAlignment(MCP-getConstantPoolAlignment());
@@ -154,7 +154,7 @@
 WriteTypeSymbolic(O, CP[i].Val-getType(), 0)  '\n';
 EmitGlobalConstant(CP[i].Val);
 if (i != e-1) {
-  unsigned EntSize = TM.getTargetData().getTypeSize(CP[i].Val-getType());
+  unsigned EntSize = TM.getTargetData()-getTypeSize(CP[i].Val-getType());
   unsigned ValEnd = CP[i].Offset + EntSize;
   // Emit inter-object padding for alignment.
   EmitZeros(CP[i+1].Offset-ValEnd);
@@ -168,7 +168,7 @@
 void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI) {
   const std::vectorMachineJumpTableEntry JT = MJTI-getJumpTables();
   if (JT.empty()) return;
-  const TargetData TD = TM.getTargetData();
+  const TargetData *TD = TM.getTargetData();
   
   // FIXME: someday we need to handle PIC jump tables
   assert((TM.getRelocationModel() == Reloc::Static ||
@@ -176,7 +176,7 @@
  Unhandled relocation model emitting jump table information!);
   
   SwitchSection(JumpTableSection, 0);
-  EmitAlignment(Log2_32(TD.getPointerAlignment()));
+  EmitAlignment(Log2_32(TD-getPointerAlignment()));
   for (unsigned i = 0, e = JT.size(); i != e; ++i) {
 O  PrivateGlobalPrefix  JTI  getFunctionNumber()  '_'  i 
:\n;
@@ -242,7 +242,7 @@
 /// specified global, returned in log form.  This includes an explicitly
 /// requested alignment (if the global has one).
 unsigned AsmPrinter::getPreferredAlignmentLog(const GlobalVariable *GV) const {
-  unsigned Alignment = TM.getTargetData().getTypeAlignmentShift(GV-getType());
+  unsigned Alignment = 
TM.getTargetData()-getTypeAlignmentShift(GV-getType());
   if (GV-getAlignment()  (1U  Alignment))
 Alignment = Log2_32(GV-getAlignment());
   
@@ -253,7 +253,7 @@
 if (Alignment  4) {
   // If the global is not external, see if it is large.  If so, give it a
   // larger alignment.
-  if (TM.getTargetData().getTypeSize(GV-getType()-getElementType())  
128)
+  if (TM.getTargetData()-getTypeSize(GV-getType()-getElementType())  
128)
 Alignment = 4;// 16-byte alignment.
 }
   }
@@ -310,13 +310,13 @@
 else
   O  GlobalVarAddrPrefix  Mang-getValueName(GV)  
GlobalVarAddrSuffix;
   } else if (const ConstantExpr *CE = dyn_castConstantExpr(CV)) {
-const TargetData TD = TM.getTargetData();
+const TargetData *TD = TM.getTargetData();
 switch(CE-getOpcode()) {
 case Instruction::GetElementPtr: {
   // generate a symbolic expression for the byte address
   const Constant *ptrVal = CE-getOperand(0);
   std::vectorValue* idxVec(CE-op_begin()+1, CE-op_end());
-  if (int64_t Offset = TD.getIndexedOffset(ptrVal-getType(), idxVec)) {
+  if (int64_t Offset = TD-getIndexedOffset(ptrVal-getType(), idxVec)) {
 if (Offset)
   O  (;
 EmitConstantValueOnly(ptrVal);
@@ -344,7 +344,7 @@
   || (isaPointerType(Ty)
(OpTy == Type::LongTy || OpTy == Type::ULongTy
   || OpTy == Type::IntTy || OpTy == Type::UIntTy))
-  || (((TD.getTypeSize(Ty) = TD.getTypeSize(OpTy))
+  || (((TD-getTypeSize(Ty) = TD-getTypeSize(OpTy))
 OpTy-isLosslesslyConvertibleTo(Ty
   FIXME: Don't yet support this kind of constant cast expr);
   EmitConstantValueOnly(Op);
@@ -426,10 +426,10 @@
 /// EmitGlobalConstant - Print a general LLVM constant to the .s file.
 ///
 void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
-  const TargetData TD = TM.getTargetData();
+  const TargetData *TD = TM.getTargetData();
 
   if (CV-isNullValue() || isaUndefValue(CV)) {
-EmitZeros(TD.getTypeSize(CV-getType()));
+

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

2006-05-01 Thread Jeff Cohen


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.60 - 1.61
---
Log message:

Make Intel syntax mode friendlier to Microsoft ML assembler (still needs more 
work).

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

 AsmPrinter.cpp |   26 --
 1 files changed, 16 insertions(+), 10 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.60 
llvm/lib/CodeGen/AsmPrinter.cpp:1.61
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.60Sun Apr 30 23:11:03 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon May  1 20:16:28 2006
@@ -372,6 +372,21 @@
   O  \;
 }
 
+/// EmitString - Emit a zero-byte-terminated string constant.
+///
+void AsmPrinter::EmitString(const ConstantArray *CVA) const {
+  unsigned NumElts = CVA-getNumOperands();
+  if (AscizDirective  NumElts  
+  castConstantInt(CVA-getOperand(NumElts-1))-getRawValue() == 0) {
+O  AscizDirective;
+printAsCString(O, CVA, NumElts-1);
+  } else {
+O  AsciiDirective;
+printAsCString(O, CVA, NumElts);
+  }
+  O  \n;
+}
+
 /// EmitGlobalConstant - Print a general LLVM constant to the .s file.
 ///
 void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
@@ -382,16 +397,7 @@
 return;
   } else if (const ConstantArray *CVA = dyn_castConstantArray(CV)) {
 if (CVA-isString()) {
-  unsigned NumElts = CVA-getNumOperands();
-  if (AscizDirective  NumElts  
-  castConstantInt(CVA-getOperand(NumElts-1))-getRawValue() == 0) {
-O  AscizDirective;
-printAsCString(O, CVA, NumElts-1);
-  } else {
-O  AsciiDirective;
-printAsCString(O, CVA, NumElts);
-  }
-  O  \n;
+  EmitString(CVA);
 } else { // Not a string.  Print the values in successive locations
   for (unsigned i = 0, e = CVA-getNumOperands(); i != e; ++i)
 EmitGlobalConstant(CVA-getOperand(i));



___
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

2006-05-01 Thread Jeff Cohen


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.61 - 1.62
---
Log message:

De-virtualize EmitZeroes.

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

 AsmPrinter.cpp |   10 +++---
 1 files changed, 7 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.61 
llvm/lib/CodeGen/AsmPrinter.cpp:1.62
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.61Mon May  1 20:16:28 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon May  1 22:46:13 2006
@@ -37,6 +37,7 @@
   InlineAsmStart(#APP\n\t),
   InlineAsmEnd(\t#NO_APP\n),
   ZeroDirective(\t.zero\t),
+  ZeroDirectiveSuffix(0),
   AsciiDirective(\t.ascii\t),
   AscizDirective(\t.asciz\t),
   Data8bitsDirective(\t.byte\t),
@@ -240,9 +241,12 @@
 ///
 void AsmPrinter::EmitZeros(uint64_t NumZeros) const {
   if (NumZeros) {
-if (ZeroDirective)
-  O  ZeroDirective  NumZeros  \n;
-else {
+if (ZeroDirective) {
+  O  ZeroDirective  NumZeros;
+  if (ZeroDirectiveSuffix)
+O  ZeroDirectiveSuffix;
+  O  \n;
+} else {
   for (; NumZeros; --NumZeros)
 O  Data8bitsDirective  0\n;
 }



___
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

2006-05-01 Thread Jeff Cohen


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.62 - 1.63
---
Log message:

De-virtualize SwitchSection.

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

 AsmPrinter.cpp |   52 ++--
 1 files changed, 42 insertions(+), 10 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.62 
llvm/lib/CodeGen/AsmPrinter.cpp:1.63
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.62Mon May  1 22:46:13 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon May  1 22:58:45 2006
@@ -47,6 +47,7 @@
   AlignDirective(\t.align\t),
   AlignmentIsInBytes(true),
   SwitchToSectionDirective(\t.section\t),
+  MLSections(false),
   ConstantPoolSection(\t.section .rodata\n),
   JumpTableSection(\t.section .rodata\n),
   StaticCtorsSection(\t.section .ctors,\aw\,@progbits),
@@ -63,16 +64,47 @@
 ///
 void AsmPrinter::SwitchSection(const char *NewSection, const GlobalValue *GV) {
   std::string NS;
-  
-  if (GV  GV-hasSection())
-NS = SwitchToSectionDirective + GV-getSection();
-  else
-NS = std::string(\t)+NewSection;
-  
-  if (CurrentSection != NS) {
-CurrentSection = NS;
-if (!CurrentSection.empty())
-  O  CurrentSection  '\n';
+
+  // Microsoft ML/MASM has a fundamentally different approach to handling
+  // sections.
+
+  if (MLSections) {
+if (*NewSection == 0) {
+  // Simply end the current section, if any.
+  if (CurrentSection != ) {
+O  CurrentSection  \tends\n;
+CurrentSection = ;
+  }
+  return;
+}
+
+bool isData = strcmp(NewSection , .data) == 0;
+
+if (GV  GV-hasSection())
+  NS = GV-getSection();
+else if (isData)
+  NS = _data;
+else
+  NS = _text;
+
+if (CurrentSection != NS) {
+  if (CurrentSection != )
+O  CurrentSection  \tends\n;
+  CurrentSection = NS;
+  O  CurrentSection  (isData ? \tsegment 'DATA'\n
+ : \tsegment 'CODE'\n);
+}
+  } else {
+if (GV  GV-hasSection())
+  NS = SwitchToSectionDirective + GV-getSection();
+else
+  NS = std::string(\t)+NewSection;
+
+if (CurrentSection != NS) {
+  CurrentSection = NS;
+  if (!CurrentSection.empty())
+O  CurrentSection  '\n';
+}
   }
 }
 



___
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

2006-04-30 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.59 - 1.60
---
Log message:

Format #APP lines a bit nicer


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

 AsmPrinter.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.59 
llvm/lib/CodeGen/AsmPrinter.cpp:1.60
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.59Sat Apr 22 13:53:45 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sun Apr 30 23:11:03 2006
@@ -34,8 +34,8 @@
   GlobalVarAddrSuffix(),
   FunctionAddrPrefix(),
   FunctionAddrSuffix(),
-  InlineAsmStart(#APP\n),
-  InlineAsmEnd(#NO_APP\n),
+  InlineAsmStart(#APP\n\t),
+  InlineAsmEnd(\t#NO_APP\n),
   ZeroDirective(\t.zero\t),
   AsciiDirective(\t.ascii\t),
   AscizDirective(\t.asciz\t),



___
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 ELFWriter.cpp MachineCodeEmitter.cpp MachineFunction.cpp MachineInstr.cpp

2006-04-22 Thread Nate Begeman


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.58 - 1.59
ELFWriter.cpp updated: 1.17 - 1.18
MachineCodeEmitter.cpp updated: 1.25 - 1.26
MachineFunction.cpp updated: 1.87 - 1.88
MachineInstr.cpp updated: 1.110 - 1.111
---
Log message:

JumpTable support!  What this represents is working asm and jit support for
x86 and ppc for 100% dense switch statements when relocations are non-PIC.
This support will be extended and enhanced in the coming days to support
PIC, and less dense forms of jump tables.


---
Diffs of the changes:  (+96 -3)

 AsmPrinter.cpp |   38 ++
 ELFWriter.cpp  |5 -
 MachineCodeEmitter.cpp |   14 --
 MachineFunction.cpp|   36 
 MachineInstr.cpp   |6 ++
 5 files changed, 96 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.58 
llvm/lib/CodeGen/AsmPrinter.cpp:1.59
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.58Tue Mar  7 16:00:35 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sat Apr 22 13:53:45 2006
@@ -17,6 +17,7 @@
 #include llvm/Constants.h
 #include llvm/Module.h
 #include llvm/CodeGen/MachineConstantPool.h
+#include llvm/CodeGen/MachineJumpTableInfo.h
 #include llvm/Support/Mangler.h
 #include llvm/Support/MathExtras.h
 #include llvm/Target/TargetMachine.h
@@ -46,6 +47,7 @@
   AlignmentIsInBytes(true),
   SwitchToSectionDirective(\t.section\t),
   ConstantPoolSection(\t.section .rodata\n),
+  JumpTableSection(\t.section .rodata\n),
   StaticCtorsSection(\t.section .ctors,\aw\,@progbits),
   StaticDtorsSection(\t.section .dtors,\aw\,@progbits),
   LCOMMDirective(0),
@@ -127,6 +129,33 @@
   }
 }
 
+/// EmitJumpTableInfo - Print assembly representations of the jump tables used
+/// by the current function to the current output stream.  
+///
+void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI) {
+  const std::vectorMachineJumpTableEntry JT = MJTI-getJumpTables();
+  if (JT.empty()) return;
+  const TargetData TD = TM.getTargetData();
+  
+  // FIXME: someday we need to handle PIC jump tables
+  assert((TM.getRelocationModel() == Reloc::Static ||
+  TM.getRelocationModel() == Reloc::DynamicNoPIC) 
+ Unhandled relocation model emitting jump table information!);
+  
+  SwitchSection(JumpTableSection, 0);
+  EmitAlignment(Log2_32(TD.getPointerAlignment()));
+  for (unsigned i = 0, e = JT.size(); i != e; ++i) {
+O  PrivateGlobalPrefix  JTI  getFunctionNumber()  '_'  i 
+   :\n;
+const std::vectorMachineBasicBlock* JTBBs = JT[i].MBBs;
+for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
+  O  Data32bitsDirective  ' ';
+  printBasicBlockLabel(JTBBs[ii]);
+  O  '\n';
+}
+  }
+}
+
 /// EmitSpecialLLVMGlobal - Check to see if the specified global is a
 /// special global used by LLVM.  If so, emit it and return true, otherwise
 /// do nothing and return false.
@@ -654,3 +683,12 @@
   // Target doesn't support this yet!
   return true;
 }
+
+/// printBasicBlockLabel - This method prints the label for the specified
+/// MachineBasicBlock
+void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB) const {
+  O  PrivateGlobalPrefix  LBB 
+ Mang-getValueName(MBB-getParent()-getFunction())
+ _  MBB-getNumber()  '\t'  CommentString
+ MBB-getBasicBlock()-getName();
+}


Index: llvm/lib/CodeGen/ELFWriter.cpp
diff -u llvm/lib/CodeGen/ELFWriter.cpp:1.17 llvm/lib/CodeGen/ELFWriter.cpp:1.18
--- llvm/lib/CodeGen/ELFWriter.cpp:1.17 Wed Dec 28 00:29:02 2005
+++ llvm/lib/CodeGen/ELFWriter.cpp  Sat Apr 22 13:53:45 2006
@@ -84,7 +84,10 @@
   assert(0  CP not implementated yet!);
   return 0;
 }
-
+virtual uint64_t getJumpTableEntryAddress(unsigned Index) {
+  assert(0  JT not implementated yet!);
+  return 0;
+}
 virtual unsigned char* allocateGlobal(unsigned size, unsigned alignment) {
   assert(0  Globals not implemented yet!);
   return 0;


Index: llvm/lib/CodeGen/MachineCodeEmitter.cpp
diff -u llvm/lib/CodeGen/MachineCodeEmitter.cpp:1.25 
llvm/lib/CodeGen/MachineCodeEmitter.cpp:1.26
--- llvm/lib/CodeGen/MachineCodeEmitter.cpp:1.25Tue Dec 27 20:44:35 2005
+++ llvm/lib/CodeGen/MachineCodeEmitter.cpp Sat Apr 22 13:53:45 2006
@@ -56,6 +56,7 @@
 { return 0; }
 
 uint64_t getConstantPoolEntryAddress(unsigned Num) { return 0; }
+uint64_t getJumpTableEntryAddress(unsigned Num) { return 0; }
 uint64_t getCurrentPCValue() { return 0; }
 uint64_t getCurrentPCOffset() { return 0; }
   };
@@ -97,7 +98,14 @@
 void emitConstantPool(MachineConstantPool *MCP) {
   MCE.emitConstantPool(MCP);
 }
-
+void initJumpTableInfo(MachineJumpTableInfo *MJTI) {
+  MCE.initJumpTableInfo(MJTI);
+}
+void emitJumpTableInfo(MachineJumpTableInfo *MJTI,
+   std::mapMachineBasicBlock*,uint64_t MBBM) {
+  MCE.emitJumpTableInfo(MJTI, 

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

2006-03-07 Thread Jim Laskey


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.57 - 1.58
MachineDebugInfo.cpp updated: 1.24 - 1.25
---
Log message:

Use llvm.metadata section for debug globals.  Filter out these globals in the
asm printer.


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

 AsmPrinter.cpp   |8 ++--
 MachineDebugInfo.cpp |3 +++
 2 files changed, 9 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.57 
llvm/lib/CodeGen/AsmPrinter.cpp:1.58
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.57Thu Mar  2 20:04:29 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Tue Mar  7 16:00:35 2006
@@ -131,8 +131,12 @@
 /// special global used by LLVM.  If so, emit it and return true, otherwise
 /// do nothing and return false.
 bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
-  assert(GV-hasInitializer()  GV-hasAppendingLinkage() 
- Not a special LLVM global!);
+  // Ignore debug and non-emitted data.
+  if (GV-getSection() == llvm.metadata) return true;
+  
+  if (!GV-hasAppendingLinkage()) return false;
+
+  assert(GV-hasInitializer()  Not a special LLVM global!);
   
   if (GV-getName() == llvm.used)
 return true;  // No need to emit this at all.


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.24 
llvm/lib/CodeGen/MachineDebugInfo.cpp:1.25
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.24  Tue Mar  7 14:53:47 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp   Tue Mar  7 16:00:35 2006
@@ -350,6 +350,7 @@
   GlobalValue::InternalLinkage,
   CA, llvm.dbg.array,
   SR.getModule());
+CAGV-setSection(llvm.metadata);
 Constant *CAE = ConstantExpr::getCast(CAGV, EmptyTy);
 Elements.push_back(CAE);
   }
@@ -1193,6 +1194,7 @@
   GlobalVariable *StrGV = new GlobalVariable(ConstStr-getType(), true,
  GlobalVariable::InternalLinkage,
  ConstStr, str, M);
+  StrGV-setSection(llvm.metadata);
   // Convert to generic string pointer.
   Slot = ConstantExpr::getCast(StrGV, getStrPtrType());
   return Slot;
@@ -1214,6 +1216,7 @@
   // Create the GlobalVariable early to prevent infinite recursion.
   GlobalVariable *GV = new GlobalVariable(Ty, true, DD-getLinkage(),
   NULL, DD-getDescString(), M);
+  GV-setSection(llvm.metadata);
 
   // Insert new GlobalVariable in DescGlobals map.
   Slot = GV;



___
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

2006-03-01 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.55 - 1.56
---
Log message:

Don't print llvm constant in assmebly file. Assembler won't like comments that
span multiple lines.


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

 AsmPrinter.cpp |4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.55 
llvm/lib/CodeGen/AsmPrinter.cpp:1.56
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.55Fri Feb 24 14:21:58 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Mar  1 16:18:09 2006
@@ -11,6 +11,7 @@
 //
 
//===--===//
 
+#include llvm/Assembly/Writer.h
 #include llvm/DerivedTypes.h
 #include llvm/CodeGen/AsmPrinter.h
 #include llvm/Constants.h
@@ -114,7 +115,8 @@
   EmitAlignment(MCP-getConstantPoolAlignment());
   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
 O  PrivateGlobalPrefix  CPI  getFunctionNumber()  '_'  i
-   :\t\t\t\t\t  CommentString  *CP[i].Val  '\n';
+   :\t\t\t\t\t  CommentString   ;
+WriteTypeSymbolic(O, CP[i].Val-getType(), 0)  '\n';
 EmitGlobalConstant(CP[i].Val);
 if (i != e-1) {
   unsigned EntSize = TM.getTargetData().getTypeSize(CP[i].Val-getType());



___
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

2006-02-23 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.52 - 1.53
---
Log message:

Record all of the expanded registers in the DAG and machine instr, fixing
several bugs in inline asm expanded operands.


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

 AsmPrinter.cpp |   17 -
 1 files changed, 12 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.52 
llvm/lib/CodeGen/AsmPrinter.cpp:1.53
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.52Wed Feb  8 22:46:04 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Thu Feb 23 13:21:04 2006
@@ -569,19 +569,26 @@
 exit(1);
   }
   
-  char ExtraCode = 0;  // FIXME:
-  
-  // Okay, we finally have an operand number.  Ask the target to print this
+  // Okay, we finally have a value number.  Ask the target to print this
   // operand!
-  if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
+  if (CurVariant == -1 || CurVariant == AsmPrinterVariant) {
+unsigned OpNo = 1;
+
+// Scan to find the machine operand number for the operand.
+for (; Val; --Val)
+  OpNo += MI-getOperand(OpNo).getImmedValue()+1;
+
+++OpNo;  // Skip over the ID number.
+
 if (const_castAsmPrinter*(this)-
-PrintAsmOperand(MI, Val+1, AsmPrinterVariant,
+PrintAsmOperand(MI, OpNo, AsmPrinterVariant,
 Modifier[0] ? Modifier : 0)) {
   std::cerr  Invalid operand found in inline asm: '
  AsmStr  '\n;
   MI-dump();
   exit(1);
 }
+  }
   break;
 }
 case '{':



___
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 MachineFunction.cpp

2006-02-08 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.50 - 1.51
MachineFunction.cpp updated: 1.84 - 1.85
---
Log message:

rename fields of constant pool entries


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

 AsmPrinter.cpp  |8 
 MachineFunction.cpp |4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.50 
llvm/lib/CodeGen/AsmPrinter.cpp:1.51
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.50Wed Feb  8 20:26:04 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Feb  8 22:22:52 2006
@@ -106,16 +106,16 @@
 /// the code generator.
 ///
 void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
-  const std::vectorstd::pairConstant*, unsigned  CP = MCP-getConstants();
+  const std::vectorMachineConstantPoolEntry 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) {
-EmitAlignment(CP[i].second);
+EmitAlignment(CP[i].Alignment);
 O  PrivateGlobalPrefix  CPI  getFunctionNumber()  '_'  i
-   :\t\t\t\t\t  CommentString  *CP[i].first  '\n';
-EmitGlobalConstant(CP[i].first);
+   :\t\t\t\t\t  CommentString  *CP[i].Val  '\n';
+EmitGlobalConstant(CP[i].Val);
   }
 }
 


Index: llvm/lib/CodeGen/MachineFunction.cpp
diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.84 
llvm/lib/CodeGen/MachineFunction.cpp:1.85
--- llvm/lib/CodeGen/MachineFunction.cpp:1.84   Tue Jan 31 16:21:33 2006
+++ llvm/lib/CodeGen/MachineFunction.cppWed Feb  8 22:22:52 2006
@@ -347,8 +347,8 @@
 
 void MachineConstantPool::print(std::ostream OS) const {
   for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
-OScp #  i   is  *(Value*)Constants[i].first;
-if (Constants[i].second != 0) OS   , align=  Constants[i].second;
+OScp #  i   is  *(Value*)Constants[i].Val;
+OS   , align=  Constants[i].Alignment;
 OS  \n;
   }
 }



___
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 MachineFunction.cpp

2006-02-08 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.51 - 1.52
MachineFunction.cpp updated: 1.85 - 1.86
---
Log message:

Adjust to MachineConstantPool interface change: instead of keeping a 
value/alignment pair for each constant, keep a value/offset pair.


---
Diffs of the changes:  (+37 -3)

 AsmPrinter.cpp  |8 +++-
 MachineFunction.cpp |   32 ++--
 2 files changed, 37 insertions(+), 3 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.51 
llvm/lib/CodeGen/AsmPrinter.cpp:1.52
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.51Wed Feb  8 22:22:52 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Feb  8 22:46:04 2006
@@ -111,11 +111,17 @@
   const TargetData TD = TM.getTargetData();
   
   SwitchSection(ConstantPoolSection, 0);
+  EmitAlignment(MCP-getConstantPoolAlignment());
   for (unsigned i = 0, e = CP.size(); i != e; ++i) {
-EmitAlignment(CP[i].Alignment);
 O  PrivateGlobalPrefix  CPI  getFunctionNumber()  '_'  i
:\t\t\t\t\t  CommentString  *CP[i].Val  '\n';
 EmitGlobalConstant(CP[i].Val);
+if (i != e-1) {
+  unsigned EntSize = TM.getTargetData().getTypeSize(CP[i].Val-getType());
+  unsigned ValEnd = CP[i].Offset + EntSize;
+  // Emit inter-object padding for alignment.
+  EmitZeros(CP[i+1].Offset-ValEnd);
+}
   }
 }
 


Index: llvm/lib/CodeGen/MachineFunction.cpp
diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.85 
llvm/lib/CodeGen/MachineFunction.cpp:1.86
--- llvm/lib/CodeGen/MachineFunction.cpp:1.85   Wed Feb  8 22:22:52 2006
+++ llvm/lib/CodeGen/MachineFunction.cppWed Feb  8 22:46:04 2006
@@ -112,7 +112,7 @@
   SSARegMapping = new SSARegMap();
   MFInfo = 0;
   FrameInfo = new MachineFrameInfo();
-  ConstantPool = new MachineConstantPool();
+  ConstantPool = new MachineConstantPool(TM.getTargetData());
   BasicBlocks.Parent = this;
 }
 
@@ -345,10 +345,38 @@
 //  MachineConstantPool implementation
 
//===--===//
 
+/// getConstantPoolIndex - Create a new entry in the constant pool or return
+/// an existing one.  User must specify an alignment in bytes for the object.
+///
+unsigned MachineConstantPool::getConstantPoolIndex(Constant *C, 
+   unsigned Alignment) {
+  assert(Alignment  Alignment must be specified!);
+  if (Alignment  PoolAlignment) PoolAlignment = Alignment;
+  
+  // Check to see if we already have this constant.
+  //
+  // FIXME, this could be made much more efficient for large constant pools.
+  unsigned AlignMask = (1  Alignment)-1;
+  for (unsigned i = 0, e = Constants.size(); i != e; ++i)
+if (Constants[i].Val == C  (Constants[i].Offset  AlignMask) == 0)
+  return i;
+  
+  unsigned Offset = 0;
+  if (!Constants.empty()) {
+Offset = Constants.back().Offset;
+Offset += TD.getTypeSize(Constants.back().Val-getType());
+Offset = (Offset+AlignMask)~AlignMask;
+  }
+  
+  Constants.push_back(MachineConstantPoolEntry(C, Offset));
+  return Constants.size()-1;
+}
+
+
 void MachineConstantPool::print(std::ostream OS) const {
   for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
 OScp #  i   is  *(Value*)Constants[i].Val;
-OS   , align=  Constants[i].Alignment;
+OS   , offset=  Constants[i].Offset;
 OS  \n;
   }
 }



___
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

2006-02-06 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.47 - 1.48
---
Log message:

Add support for modifier characters to operand printers


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

 AsmPrinter.cpp |   23 +--
 1 files changed, 21 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.47 
llvm/lib/CodeGen/AsmPrinter.cpp:1.48
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.47Sat Feb  4 19:46:49 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Mon Feb  6 16:17:23 2006
@@ -538,7 +538,23 @@
   }
   LastEmitted = IDEnd;
   
+  char Modifier[2] = { 0, 0 };
+  
   if (HasCurlyBraces) {
+// If we have curly braces, check for a modifier character.  This
+// supports syntax like ${0:u}, which correspond to %u0 in GCC asm.
+if (*LastEmitted == ':') {
+  ++LastEmitted;// Consume ':' character.
+  if (*LastEmitted == 0) {
+std::cerr  Bad ${:} expression in inline asm string: ' 
+   AsmStr  '\n;
+exit(1);
+  }
+  
+  Modifier[0] = *LastEmitted;
+  ++LastEmitted;// Consume modifier character.
+}
+
 if (*LastEmitted != '}') {
   std::cerr  Bad ${} expression in inline asm string: ' 
  AsmStr  '\n;
@@ -553,11 +569,14 @@
 exit(1);
   }
   
+  char ExtraCode = 0;  // FIXME:
+  
   // Okay, we finally have an operand number.  Ask the target to print this
   // operand!
   if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
 if (const_castAsmPrinter*(this)-
-PrintAsmOperand(MI, Val+1, AsmPrinterVariant)) {
+PrintAsmOperand(MI, Val+1, AsmPrinterVariant,
+Modifier[0] ? Modifier : 0)) {
   std::cerr  Invalid operand found in inline asm: '
  AsmStr  '\n;
   MI-dump();
@@ -601,7 +620,7 @@
 /// instruction, using the specified assembler variant.  Targets should
 /// overried this to format as appropriate.
 bool AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
- unsigned AsmVariant) {
+ unsigned AsmVariant, const char *ExtraCode) {
   // Target doesn't support this yet!
   return true;
 }



___
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

2006-02-04 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.45 - 1.46
---
Log message:

Implement the AsmPrinter::getPreferredAlignmentLog method.


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

 AsmPrinter.cpp |   16 
 1 files changed, 16 insertions(+)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.45 
llvm/lib/CodeGen/AsmPrinter.cpp:1.46
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.45Wed Feb  1 16:41:11 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sat Feb  4 19:29:18 2006
@@ -171,6 +171,22 @@
 }
 }
 
+/// getPreferredAlignmentLog - Return the preferred alignment of the
+/// specified global, returned in log form.  This includes an explicitly
+/// requested alignment (if the global has one).
+unsigned AsmPrinter::getPreferredAlignmentLog(const GlobalVariable *GV) const {
+  unsigned Alignment = TM.getTargetData().getTypeAlignmentShift(GV-getType());
+  if (GV-getAlignment()  (1U  Alignment))
+Alignment = Log2_32(GV-getAlignment());
+  
+  if (GV-hasInitializer()  Alignment  4) {
+// If the global is not external, see if it is large.  If so, give it a
+// larger alignment.
+if (TM.getTargetData().getTypeSize(GV-getType()-getElementType())  128)
+  Alignment = 4;// 16-byte alignment.
+  }
+  return Alignment;
+}
 
 // EmitAlignment - Emit an alignment directive to the specified power of two.
 void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const {



___
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

2006-02-04 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.46 - 1.47
---
Log message:

make sure that global doubles are aligned to 8 bytes


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

 AsmPrinter.cpp |   15 ++-
 1 files changed, 10 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.46 
llvm/lib/CodeGen/AsmPrinter.cpp:1.47
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.46Sat Feb  4 19:29:18 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Sat Feb  4 19:46:49 2006
@@ -179,11 +179,16 @@
   if (GV-getAlignment()  (1U  Alignment))
 Alignment = Log2_32(GV-getAlignment());
   
-  if (GV-hasInitializer()  Alignment  4) {
-// If the global is not external, see if it is large.  If so, give it a
-// larger alignment.
-if (TM.getTargetData().getTypeSize(GV-getType()-getElementType())  128)
-  Alignment = 4;// 16-byte alignment.
+  if (GV-hasInitializer()) {
+// Always round up alignment of global doubles to 8 bytes.
+if (GV-getType()-getElementType() == Type::DoubleTy  Alignment  3)
+  Alignment = 3;
+if (Alignment  4) {
+  // If the global is not external, see if it is large.  If so, give it a
+  // larger alignment.
+  if (TM.getTargetData().getTypeSize(GV-getType()-getElementType())  
128)
+Alignment = 4;// 16-byte alignment.
+}
   }
   return Alignment;
 }



___
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

2006-02-01 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen:

AsmPrinter.cpp updated: 1.44 - 1.45
---
Log message:

Implement smart printing of inline asm strings, handling variants and 
substituted operands.  For this testcase:

int %test(int %A, int %B) {
  %C = call int asm xyz $0, $1, $2, =r,r,r(int %A, int %B)
  ret int %C
}

we now emit:

_test:
or r2, r3, r3
or r3, r4, r4
xyz r2, r2, r3  ;; look here
or r3, r2, r2
blr

... note the substituted operands. :)



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

 AsmPrinter.cpp |  117 ++---
 1 files changed, 112 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/AsmPrinter.cpp
diff -u llvm/lib/CodeGen/AsmPrinter.cpp:1.44 
llvm/lib/CodeGen/AsmPrinter.cpp:1.45
--- llvm/lib/CodeGen/AsmPrinter.cpp:1.44Tue Jan 31 19:28:23 2006
+++ llvm/lib/CodeGen/AsmPrinter.cpp Wed Feb  1 16:41:11 2006
@@ -20,6 +20,7 @@
 #include llvm/Support/MathExtras.h
 #include llvm/Target/TargetMachine.h
 #include iostream
+#include cerrno
 using namespace llvm;
 
 AsmPrinter::AsmPrinter(std::ostream o, TargetMachine tm)
@@ -468,12 +469,118 @@
 assert(NumDefs != NumOperands-1  No asm string?);
   
   assert(MI-getOperand(NumDefs).isExternalSymbol()  No asm string?);
-  
+
+  // Disassemble the AsmStr, printing out the literal pieces, the operands, 
etc.
   const char *AsmStr = MI-getOperand(NumDefs).getSymbolName();
+
+  // The variant of the current asmprinter: FIXME: change.
+  int AsmPrinterVariant = 0;
   
-  O  AsmStr  \n;
-  
-  // Use a virtual printAsmOperand method, which takes the constraint
-  // string?  Must pass the constraint string to here if needed.
+  int CurVariant = -1;// The number of the {.|.|.} region we are 
in.
+  const char *LastEmitted = AsmStr; // One past the last character emitted.
   
+  while (*LastEmitted) {
+switch (*LastEmitted) {
+default: {
+  // Not a special case, emit the string section literally.
+  const char *LiteralEnd = LastEmitted+1;
+  while (*LiteralEnd  *LiteralEnd != '{'  *LiteralEnd != '|' 
+ *LiteralEnd != '}'  *LiteralEnd != '$')
+++LiteralEnd;
+  if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
+O.write(LastEmitted, LiteralEnd-LastEmitted);
+  LastEmitted = LiteralEnd;
+  break;
+}
+case '$': {
+  ++LastEmitted;   // Consume '$' character.
+  if (*LastEmitted == '$') { // $$ - $
+if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
+  O  '$';
+++LastEmitted;  // Consume second '$' character.
+break;
+  }
+  
+  bool HasCurlyBraces = false;
+  if (*LastEmitted == '{') { // ${variable}
+++LastEmitted;   // Consume '{' character.
+HasCurlyBraces = true;
+  }
+  
+  const char *IDStart = LastEmitted;
+  char *IDEnd;
+  long Val = strtol(IDStart, IDEnd, 10); // We only accept numbers for 
IDs.
+  if (!isdigit(*IDStart) || (Val == 0  errno == EINVAL)) {
+std::cerr  Bad $ operand number in inline asm string: ' 
+   AsmStr  '\n;
+exit(1);
+  }
+  LastEmitted = IDEnd;
+  
+  if (HasCurlyBraces) {
+if (*LastEmitted != '}') {
+  std::cerr  Bad ${} expression in inline asm string: ' 
+ AsmStr  '\n;
+  exit(1);
+}
+++LastEmitted;// Consume '}' character.
+  }
+  
+  if ((unsigned)Val = NumOperands-1) {
+std::cerr  Invalid $ operand number in inline asm string: ' 
+   AsmStr  '\n;
+exit(1);
+  }
+  
+  // Okay, we finally have an operand number.  Ask the target to print this
+  // operand!
+  if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
+if (const_castAsmPrinter*(this)-
+PrintAsmOperand(MI, Val+1, AsmPrinterVariant)) {
+  std::cerr  Invalid operand found in inline asm: '
+ AsmStr  '\n;
+  MI-dump();
+  exit(1);
+}
+  break;
+}
+case '{':
+  ++LastEmitted;  // Consume '{' character.
+  if (CurVariant != -1) {
+std::cerr  Nested variants found in inline asm string: '
+   AsmStr  '\n;
+exit(1);
+  }
+  CurVariant = 0; // We're in the first variant now.
+  break;
+case '|':
+  ++LastEmitted;  // consume '|' character.
+  if (CurVariant == -1) {
+std::cerr  Found '|' character outside of variant in inline asm 
+   string: '  AsmStr  '\n;
+exit(1);
+  }
+  ++CurVariant;   // We're in the next variant.
+  break;
+case '}':
+  ++LastEmitted;  // consume '}' character.
+  if (CurVariant == -1) {
+std::cerr  Found '}' character outside of variant in inline asm 
+   string: '  AsmStr  '\n;
+exit(1);
+  }
+  CurVariant = -1;
+  break;
+   

  1   2   >