Re: [llvm-commits] llvm-gcc4: display the LLVM type when printing type trees

2007-02-19 Thread Duncan Sands
> Very cool.  However, it doesn't apply to CVS right.  GET_TYPE_LLVM  
> needs to go through the LTypes vector now, can you plz update the patch?

Here you go.  I put GET_TYPE_LLVM back into tree.h (it was moved into
llvm-types.cpp recently) so that print-tree.c can get at it.  I only
made a C version available, to discourage use outside of llvm-types.cpp.

Ciao,

Duncan.
Index: gcc.llvm.master/gcc/print-tree.c
===
--- gcc.llvm.master.orig/gcc/print-tree.c	2007-02-19 12:19:15.0 +0100
+++ gcc.llvm.master/gcc/print-tree.c	2007-02-19 12:51:11.0 +0100
@@ -603,6 +603,16 @@
 
   lang_hooks.print_type (file, node, indent);
 
+  /* APPLE LOCAL begin LLVM */
+#ifdef ENABLE_LLVM
+  if (GET_TYPE_LLVM (node))
+	{
+	  indent_to (file, indent + 4);
+	  print_llvm_type (file, GET_TYPE_LLVM (node));
+	}
+#endif
+  /* APPLE LOCAL end LLVM */
+
   if (TYPE_POINTER_TO (node) || TREE_CHAIN (node))
 	indent_to (file, indent + 3);
 
Index: gcc.llvm.master/gcc/llvm-backend.cpp
===
--- gcc.llvm.master.orig/gcc/llvm-backend.cpp	2007-02-19 12:37:23.0 +0100
+++ gcc.llvm.master/gcc/llvm-backend.cpp	2007-02-19 12:51:11.0 +0100
@@ -917,4 +917,13 @@
   WriteAsOperand(FS, (Value*)LLVM, true, TheModule);
 }
 
+// print_llvm_type - Print the specified LLVM type symbolically, called by
+// print-tree.c for tree dumps.
+//
+void print_llvm_type(FILE *file, void *LLVM) {
+  oFILEstream FS(file);
+  FS << "LLVM: ";
+  WriteTypeSymbolic(FS, (const Type*)LLVM, TheModule);
+}
+
 /* APPLE LOCAL end LLVM (ENTIRE FILE!)  */
Index: gcc.llvm.master/gcc/llvm.h
===
--- gcc.llvm.master.orig/gcc/llvm.h	2007-02-19 12:50:55.0 +0100
+++ gcc.llvm.master/gcc/llvm.h	2007-02-19 12:51:11.0 +0100
@@ -80,6 +80,11 @@
  */
 void print_llvm(FILE *file, void *LLVM);
 
+/* print_llvm_type - Print the specified LLVM type symbolically, called by
+ * print-tree.c for tree dumps.
+ */
+void print_llvm_type(FILE *file, void *LLVM);
+
 /* Init pch writing. */
 void llvm_pch_write_init(void);
 
Index: gcc.llvm.master/gcc/tree.h
===
--- gcc.llvm.master.orig/gcc/tree.h	2007-02-19 12:37:23.0 +0100
+++ gcc.llvm.master/gcc/tree.h	2007-02-19 14:20:41.0 +0100
@@ -2095,6 +2095,14 @@
 /* The DECL_LLVM for NODE, if it is set, or NULL, if it is not set.  */
 #define DECL_LLVM_IF_SET(NODE) \
   (DECL_LLVM_SET_P (NODE) ? DECL_LLVM (NODE) : NULL)
+
+#ifndef __cplusplus
+/* C version, for debugging */
+extern void *llvm_get_type(unsigned);
+#define GET_TYPE_LLVM(NODE) \
+  (void *)llvm_get_type( TYPE_CHECK (NODE)->type.symtab.llvm)
+#endif
+
 #endif
 /* APPLE LOCAL end LLVM */
 
Index: gcc.llvm.master/gcc/llvm-types.cpp
===
--- gcc.llvm.master.orig/gcc/llvm-types.cpp	2007-02-19 13:02:58.0 +0100
+++ gcc.llvm.master/gcc/llvm-types.cpp	2007-02-19 15:16:46.0 +0100
@@ -64,8 +64,7 @@
 static LTypesMapTy LTypesMap;
 
 // GET_TYPE_LLVM/SET_TYPE_LLVM - Associate an LLVM type with each TREE type.
-// These are lazily computed by ConvertType, accessors available only to C++
-// code.
+// These are lazily computed by ConvertType.
 
 #define SET_TYPE_SYMTAB_LLVM(NODE, index) (TYPE_CHECK (NODE)->type.symtab.llvm = index)
 
@@ -92,7 +91,7 @@
 // Get LLVM Type for the GCC tree node based on LTypes vector index.
 // When GCC tree node is initialized, it has 0 as the index value. This is
 // why all recorded indexes are offset by 1. 
-static inline const Type *llvm_get_type(unsigned Index) {
+extern "C" inline const Type *llvm_get_type(unsigned Index) {
 
   if (Index == 0)
 return NULL;
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/docs/DeveloperPolicy.html

2007-02-19 Thread Reid Spencer


Changes in directory llvm/docs:

DeveloperPolicy.html updated: 1.32 -> 1.33
---
Log message:

Some minor tweaks and grammar cleanup.


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

 DeveloperPolicy.html |   28 ++--
 1 files changed, 14 insertions(+), 14 deletions(-)


Index: llvm/docs/DeveloperPolicy.html
diff -u llvm/docs/DeveloperPolicy.html:1.32 llvm/docs/DeveloperPolicy.html:1.33
--- llvm/docs/DeveloperPolicy.html:1.32 Mon Feb 19 00:57:46 2007
+++ llvm/docs/DeveloperPolicy.html  Mon Feb 19 11:38:38 2007
@@ -62,10 +62,11 @@
 

 
   This section contains policies that pertain to frequent LLVM
-  developers.  We always welcome random patches from
-  people who do not routinely contribute to LLVM, but expect more from frequent
-  contributors to keep the system as efficient as possible for everyone.
-  Frequent LLVM contributors are expected to meet the following obligations in
+  developers.  We always welcome one-off patches from
+  people who do not routinely contribute to LLVM, but we expect more from 
+  frequent contributors to keep the system as efficient as possible for 
+  everyone.
+  Frequent LLVM contributors are expected to meet the following requirements in
   order for LLVM to maintain a high standard of quality.
 
 
@@ -133,15 +134,15 @@
 reviewed after commit.
 The developer responsible for a code change is also responsible for
 making all necessary review-related changes.
-Code review can be an iterative process, which goes until the patch
+Code review can be an iterative process, which continues until the 
patch
 is ready to be committed.
   
   
   Developers should participate in code reviews as both reviewers and 
-a reviewees. If someone is kind enough to review your code, you should
+reviewees. If someone is kind enough to review your code, you should
 return the favor for someone else.  Note that anyone is welcome to review
-and give feedback on a patch,
-but only people with CVS write access can approve it.
+and give feedback on a patch, but only people with CVS write access can 
+approve it.
 
 
 
@@ -383,8 +384,8 @@
 

 
 
-  This section addresses the issues of copyright and license for the LLVM
-  project.
+  This section addresses the issues of copyright, license and patents for 
+  the LLVM project.
   Currently, the University of Illinois is the LLVM copyright holder and the 
   terms of its license to LLVM users and developers is the 
   http://www.opensource.org/licenses/UoI-NCSA.php";>University of 
@@ -392,10 +393,9 @@
 
 
   NOTE: This section deals with legal matters but does not provide
-  official legal advice.  We are not lawyers, please seek legal counsel from an
+  legal advice.  We are not lawyers, please seek legal counsel from an
   attorney.
 
-
 
 
 
@@ -446,7 +446,7 @@
   software (notably, llvm-gcc which is based on the GCC GPL source base).
   This means that anything "linked" into to llvm-gcc must itself be compatible
   with the GPL, and must be releasable under the terms of the GPL.  This 
implies
-  that you any code linked into llvm-gcc and distributed to others may be
+  that any code linked into llvm-gcc and distributed to others may be
   subject to
   the viral aspects of the GPL.  This is not a problem for the main LLVM
   distribution (which is already licensed under a more liberal license), but 
may
@@ -499,7 +499,7 @@
   Written by the 
   mailto:[EMAIL PROTECTED]">LLVM Oversight Group
   http://llvm.org";>The LLVM Compiler Infrastructure
-  Last modified: $Date: 2007/02/19 06:57:46 $
+  Last modified: $Date: 2007/02/19 17:38:38 $
 
 
 



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


[llvm-commits] CVS: llvm/docs/DeveloperPolicy.html

2007-02-19 Thread Bill Wendling


Changes in directory llvm/docs:

DeveloperPolicy.html updated: 1.33 -> 1.34
---
Log message:

Corrected typo.


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

 DeveloperPolicy.html |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/docs/DeveloperPolicy.html
diff -u llvm/docs/DeveloperPolicy.html:1.33 llvm/docs/DeveloperPolicy.html:1.34
--- llvm/docs/DeveloperPolicy.html:1.33 Mon Feb 19 11:38:38 2007
+++ llvm/docs/DeveloperPolicy.html  Mon Feb 19 12:32:40 2007
@@ -444,7 +444,7 @@
   
   Note that the LLVM Project does distribute some code that includes GPL
   software (notably, llvm-gcc which is based on the GCC GPL source base).
-  This means that anything "linked" into to llvm-gcc must itself be compatible
+  This means that anything "linked" into llvm-gcc must itself be compatible
   with the GPL, and must be releasable under the terms of the GPL.  This 
implies
   that any code linked into llvm-gcc and distributed to others may be
   subject to
@@ -499,7 +499,7 @@
   Written by the 
   mailto:[EMAIL PROTECTED]">LLVM Oversight Group
   http://llvm.org";>The LLVM Compiler Infrastructure
-  Last modified: $Date: 2007/02/19 17:38:38 $
+  Last modified: $Date: 2007/02/19 18:32:40 $
 
 
 



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


[llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp

2007-02-19 Thread Reid Spencer


Changes in directory llvm/lib/VMCore:

Instruction.cpp updated: 1.67 -> 1.68
---
Log message:

Add a FIXME for unwritten code.


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

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


Index: llvm/lib/VMCore/Instruction.cpp
diff -u llvm/lib/VMCore/Instruction.cpp:1.67 
llvm/lib/VMCore/Instruction.cpp:1.68
--- llvm/lib/VMCore/Instruction.cpp:1.67Thu Feb 15 20:25:55 2007
+++ llvm/lib/VMCore/Instruction.cpp Mon Feb 19 13:00:29 2007
@@ -239,6 +239,8 @@
   case Instruction::Call:
 if (const IntrinsicInst *II = dyn_cast(this)) {
   // If the intrinsic doesn't write memory, it is safe.
+  // FIXME: this is obviously supposed to determine which  intrinsics 
+  // don't write to memory, but hasn't been implemented yet.
 }
 return true;
   case Instruction::Load:



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


[llvm-commits] CVS: llvm/include/llvm/Constants.h

2007-02-19 Thread Evan Cheng


Changes in directory llvm/include/llvm:

Constants.h updated: 1.126 -> 1.127
---
Log message:

Temporarily reverting the patch. It's breaking llvm-gcc build.

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

 Constants.h |   14 ++
 1 files changed, 14 insertions(+)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.126 llvm/include/llvm/Constants.h:1.127
--- llvm/include/llvm/Constants.h:1.126 Mon Feb 19 01:44:24 2007
+++ llvm/include/llvm/Constants.h   Mon Feb 19 13:22:52 2007
@@ -550,6 +550,10 @@
   ///
   static Constant *getSizeOf(const Type *Ty);
 
+  /// getPtrPtrFromArrayPtr constant expr - given a pointer to a constant 
array,
+  /// return a pointer to a pointer of the array element type.
+  static Constant *getPtrPtrFromArrayPtr(Constant *C);
+
   /// ConstantExpr::get - Return a binary or shift operator constant 
expression,
   /// folding if possible.
   ///
@@ -589,6 +593,16 @@
   static Constant *getGetElementPtr(Constant *C,
 Value* const *IdxList, unsigned NumIdx);
   
+  // FIXME: Remove these.
+  static Constant *getGetElementPtr(Constant *C,
+const std::vector &IdxList) {
+return getGetElementPtr(C, &IdxList[0], IdxList.size());
+  }
+  static Constant *getGetElementPtr(Constant *C,
+const std::vector &IdxList) {
+return getGetElementPtr(C, &IdxList[0], IdxList.size());
+  }
+  
   static Constant *getExtractElement(Constant *Vec, Constant *Idx);
   static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant 
*Idx);
   static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant 
*Mask);



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


[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

2007-02-19 Thread Evan Cheng


Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.212 -> 1.213
---
Log message:

Temporarily reverting the patch. It's breaking llvm-gcc build.

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

 Constants.cpp |   35 ---
 1 files changed, 20 insertions(+), 15 deletions(-)


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.212 llvm/lib/VMCore/Constants.cpp:1.213
--- llvm/lib/VMCore/Constants.cpp:1.212 Mon Feb 19 01:44:24 2007
+++ llvm/lib/VMCore/Constants.cpp   Mon Feb 19 13:23:41 2007
@@ -22,7 +22,6 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MathExtras.h"
-#include "llvm/ADT/SmallVector.h"
 #include 
 #include 
 using namespace llvm;
@@ -483,14 +482,13 @@
 Op2 = (OpNo == 2) ? Op : getOperand(2);
 return ConstantExpr::getShuffleVector(Op0, Op1, Op2);
   case Instruction::GetElementPtr: {
-SmallVector Ops;
-Ops.resize(getNumOperands());
+std::vector Ops;
 for (unsigned i = 1, e = getNumOperands(); i != e; ++i)
-  Ops[i] = getOperand(i);
+  Ops.push_back(getOperand(i));
 if (OpNo == 0)
-  return ConstantExpr::getGetElementPtr(Op, &Ops[0], Ops.size());
+  return ConstantExpr::getGetElementPtr(Op, Ops);
 Ops[OpNo-1] = Op;
-return ConstantExpr::getGetElementPtr(getOperand(0), &Ops[0], Ops.size());
+return ConstantExpr::getGetElementPtr(getOperand(0), Ops);
   }
   default:
 assert(getNumOperands() == 2 && "Must be binary operator?");
@@ -537,8 +535,10 @@
 return ConstantExpr::getExtractElement(Ops[0], Ops[1]);
   case Instruction::ShuffleVector:
 return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]);
-  case Instruction::GetElementPtr:
-return ConstantExpr::getGetElementPtr(Ops[0], &Ops[1], Ops.size()-1);
+  case Instruction::GetElementPtr: {
+std::vector ActualOps(Ops.begin()+1, Ops.end());
+return ConstantExpr::getGetElementPtr(Ops[0], ActualOps);
+  }
   case Instruction::ICmp:
   case Instruction::FCmp:
 return ConstantExpr::getCompare(getPredicate(), Ops[0], Ops[1]);
@@ -1578,10 +1578,16 @@
 
 Constant *ConstantExpr::getSizeOf(const Type *Ty) {
   // sizeof is implemented as: (ulong) gep (Ty*)null, 1
-  Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1);
-  Constant *GEP =
-getGetElementPtr(getNullValue(PointerType::get(Ty)), &GEPIdx, 1);
-  return getCast(Instruction::PtrToInt, GEP, Type::Int64Ty);
+  return getCast(Instruction::PtrToInt, getGetElementPtr(getNullValue(
+PointerType::get(Ty)), std::vector(1, 
+ConstantInt::get(Type::Int32Ty, 1))), Type::Int64Ty);
+}
+
+Constant *ConstantExpr::getPtrPtrFromArrayPtr(Constant *C) {
+  // pointer from array is implemented as: getelementptr arr ptr, 0, 0
+  static std::vector Indices(2, ConstantInt::get(Type::Int32Ty, 0));
+
+  return ConstantExpr::getGetElementPtr(C, Indices);
 }
 
 Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode,
@@ -2023,7 +2029,7 @@
   
   Constant *Replacement = 0;
   if (getOpcode() == Instruction::GetElementPtr) {
-SmallVector Indices;
+std::vector Indices;
 Constant *Pointer = getOperand(0);
 Indices.reserve(getNumOperands()-1);
 if (Pointer == From) Pointer = To;
@@ -2033,8 +2039,7 @@
   if (Val == From) Val = To;
   Indices.push_back(Val);
 }
-Replacement = ConstantExpr::getGetElementPtr(Pointer,
- &Indices[0], Indices.size());
+Replacement = ConstantExpr::getGetElementPtr(Pointer, Indices);
   } else if (isCast()) {
 assert(getOperand(0) == From && "Cast only has one use!");
 Replacement = ConstantExpr::getCast(getOpcode(), To, getType());



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


[llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp

2007-02-19 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Instruction.cpp updated: 1.68 -> 1.69
---
Log message:

remove warning


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

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


Index: llvm/lib/VMCore/Instruction.cpp
diff -u llvm/lib/VMCore/Instruction.cpp:1.68 
llvm/lib/VMCore/Instruction.cpp:1.69
--- llvm/lib/VMCore/Instruction.cpp:1.68Mon Feb 19 13:00:29 2007
+++ llvm/lib/VMCore/Instruction.cpp Mon Feb 19 13:46:17 2007
@@ -237,11 +237,11 @@
   case Instruction::VAArg:
 return true;
   case Instruction::Call:
-if (const IntrinsicInst *II = dyn_cast(this)) {
+//if (const IntrinsicInst *II = dyn_cast(this)) {
   // If the intrinsic doesn't write memory, it is safe.
   // FIXME: this is obviously supposed to determine which  intrinsics 
   // don't write to memory, but hasn't been implemented yet.
-}
+//}
 return true;
   case Instruction::Load:
 return cast(this)->isVolatile();



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


[llvm-commits] [124085] adjust to new ConstantExpr API.

2007-02-19 Thread clattner
Revision: 124085
Author:   clattner
Date: 2007-02-19 11:51:56 -0800 (Mon, 19 Feb 2007)

Log Message:
---
adjust to new ConstantExpr API.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===
--- apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-02-19 08:46:45 UTC 
(rev 124084)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp  2007-02-19 19:51:56 UTC 
(rev 124085)
@@ -5345,7 +5345,7 @@
   if (TREE_CODE (TREE_TYPE(Array)) == ARRAY_TYPE)
 Idx.push_back(ConstantInt::get(Type::Int32Ty, 0));
   Idx.push_back(IndexVal);
-  return ConstantExpr::getGetElementPtr(ArrayAddr, Idx);
+  return ConstantExpr::getGetElementPtr(ArrayAddr, &Idx[0], Idx.size());
 }
 
 Constant *TreeConstantToLLVM::EmitLV_COMPONENT_REF(tree exp) {
@@ -5378,7 +5378,8 @@
   std::vector Idxs;
   Idxs.push_back(Constant::getNullValue(Type::Int32Ty));
   Idxs.push_back(CI);
-  FieldPtr = ConstantExpr::getGetElementPtr(StructAddrLV, Idxs);
+  FieldPtr = ConstantExpr::getGetElementPtr(StructAddrLV, &Idxs[0], 
+Idxs.size());
   
   // Now that we did an offset from the start of the struct, subtract off
   // the offset from BitStart.


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


[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

2007-02-19 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.213 -> 1.214
---
Log message:

llvm-gcc issue fixed, revert reversal :)


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

 Constants.cpp |   35 +++
 1 files changed, 15 insertions(+), 20 deletions(-)


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.213 llvm/lib/VMCore/Constants.cpp:1.214
--- llvm/lib/VMCore/Constants.cpp:1.213 Mon Feb 19 13:23:41 2007
+++ llvm/lib/VMCore/Constants.cpp   Mon Feb 19 14:01:23 2007
@@ -22,6 +22,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include 
 #include 
 using namespace llvm;
@@ -482,13 +483,14 @@
 Op2 = (OpNo == 2) ? Op : getOperand(2);
 return ConstantExpr::getShuffleVector(Op0, Op1, Op2);
   case Instruction::GetElementPtr: {
-std::vector Ops;
+SmallVector Ops;
+Ops.resize(getNumOperands());
 for (unsigned i = 1, e = getNumOperands(); i != e; ++i)
-  Ops.push_back(getOperand(i));
+  Ops[i] = getOperand(i);
 if (OpNo == 0)
-  return ConstantExpr::getGetElementPtr(Op, Ops);
+  return ConstantExpr::getGetElementPtr(Op, &Ops[0], Ops.size());
 Ops[OpNo-1] = Op;
-return ConstantExpr::getGetElementPtr(getOperand(0), Ops);
+return ConstantExpr::getGetElementPtr(getOperand(0), &Ops[0], Ops.size());
   }
   default:
 assert(getNumOperands() == 2 && "Must be binary operator?");
@@ -535,10 +537,8 @@
 return ConstantExpr::getExtractElement(Ops[0], Ops[1]);
   case Instruction::ShuffleVector:
 return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]);
-  case Instruction::GetElementPtr: {
-std::vector ActualOps(Ops.begin()+1, Ops.end());
-return ConstantExpr::getGetElementPtr(Ops[0], ActualOps);
-  }
+  case Instruction::GetElementPtr:
+return ConstantExpr::getGetElementPtr(Ops[0], &Ops[1], Ops.size()-1);
   case Instruction::ICmp:
   case Instruction::FCmp:
 return ConstantExpr::getCompare(getPredicate(), Ops[0], Ops[1]);
@@ -1578,16 +1578,10 @@
 
 Constant *ConstantExpr::getSizeOf(const Type *Ty) {
   // sizeof is implemented as: (ulong) gep (Ty*)null, 1
-  return getCast(Instruction::PtrToInt, getGetElementPtr(getNullValue(
-PointerType::get(Ty)), std::vector(1, 
-ConstantInt::get(Type::Int32Ty, 1))), Type::Int64Ty);
-}
-
-Constant *ConstantExpr::getPtrPtrFromArrayPtr(Constant *C) {
-  // pointer from array is implemented as: getelementptr arr ptr, 0, 0
-  static std::vector Indices(2, ConstantInt::get(Type::Int32Ty, 0));
-
-  return ConstantExpr::getGetElementPtr(C, Indices);
+  Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1);
+  Constant *GEP =
+getGetElementPtr(getNullValue(PointerType::get(Ty)), &GEPIdx, 1);
+  return getCast(Instruction::PtrToInt, GEP, Type::Int64Ty);
 }
 
 Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode,
@@ -2029,7 +2023,7 @@
   
   Constant *Replacement = 0;
   if (getOpcode() == Instruction::GetElementPtr) {
-std::vector Indices;
+SmallVector Indices;
 Constant *Pointer = getOperand(0);
 Indices.reserve(getNumOperands()-1);
 if (Pointer == From) Pointer = To;
@@ -2039,7 +2033,8 @@
   if (Val == From) Val = To;
   Indices.push_back(Val);
 }
-Replacement = ConstantExpr::getGetElementPtr(Pointer, Indices);
+Replacement = ConstantExpr::getGetElementPtr(Pointer,
+ &Indices[0], Indices.size());
   } else if (isCast()) {
 assert(getOperand(0) == From && "Cast only has one use!");
 Replacement = ConstantExpr::getCast(getOpcode(), To, getType());



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


[llvm-commits] CVS: llvm/include/llvm/Constants.h

2007-02-19 Thread Chris Lattner


Changes in directory llvm/include/llvm:

Constants.h updated: 1.127 -> 1.128
---
Log message:

llvm-gcc issue fixed, revert reversal :)


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

 Constants.h |   14 --
 1 files changed, 14 deletions(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.127 llvm/include/llvm/Constants.h:1.128
--- llvm/include/llvm/Constants.h:1.127 Mon Feb 19 13:22:52 2007
+++ llvm/include/llvm/Constants.h   Mon Feb 19 14:01:23 2007
@@ -550,10 +550,6 @@
   ///
   static Constant *getSizeOf(const Type *Ty);
 
-  /// getPtrPtrFromArrayPtr constant expr - given a pointer to a constant 
array,
-  /// return a pointer to a pointer of the array element type.
-  static Constant *getPtrPtrFromArrayPtr(Constant *C);
-
   /// ConstantExpr::get - Return a binary or shift operator constant 
expression,
   /// folding if possible.
   ///
@@ -593,16 +589,6 @@
   static Constant *getGetElementPtr(Constant *C,
 Value* const *IdxList, unsigned NumIdx);
   
-  // FIXME: Remove these.
-  static Constant *getGetElementPtr(Constant *C,
-const std::vector &IdxList) {
-return getGetElementPtr(C, &IdxList[0], IdxList.size());
-  }
-  static Constant *getGetElementPtr(Constant *C,
-const std::vector &IdxList) {
-return getGetElementPtr(C, &IdxList[0], IdxList.size());
-  }
-  
   static Constant *getExtractElement(Constant *Vec, Constant *Idx);
   static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant 
*Idx);
   static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant 
*Mask);



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


[llvm-commits] [124086] don't dereference a null type-size field.

2007-02-19 Thread clattner
Revision: 124086
Author:   clattner
Date: 2007-02-19 12:15:12 -0800 (Mon, 19 Feb 2007)

Log Message:
---
don't dereference a null type-size field.

Modified Paths:
--
apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===
--- apple-local/branches/llvm/gcc/llvm-types.cpp2007-02-19 19:51:56 UTC 
(rev 124085)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp2007-02-19 20:15:12 UTC 
(rev 124086)
@@ -212,7 +212,8 @@
 bool isPassedByInvisibleReference(tree Type) {
   // FIXME: Search for TREE_ADDRESSABLE in calls.c, and see if there are other
   // cases that make arguments automatically passed in by reference.
-  return TREE_ADDRESSABLE(Type) || TREE_CODE(TYPE_SIZE(Type)) != INTEGER_CST;
+  return TREE_ADDRESSABLE(Type) || TYPE_SIZE(Type) == 0 ||
+ TREE_CODE(TYPE_SIZE(Type)) != INTEGER_CST;
 }
 
 /// GetTypeName - Return a fully qualified (with namespace prefixes) name for


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


[llvm-commits] CVS: llvm/test/CFrontend/2007-02-04-WITH_SIZE_EXPR.c

2007-02-19 Thread Chris Lattner


Changes in directory llvm/test/CFrontend:

2007-02-04-WITH_SIZE_EXPR.c updated: 1.1 -> 1.2
---
Log message:

this passes now


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

 2007-02-04-WITH_SIZE_EXPR.c |1 -
 1 files changed, 1 deletion(-)


Index: llvm/test/CFrontend/2007-02-04-WITH_SIZE_EXPR.c
diff -u llvm/test/CFrontend/2007-02-04-WITH_SIZE_EXPR.c:1.1 
llvm/test/CFrontend/2007-02-04-WITH_SIZE_EXPR.c:1.2
--- llvm/test/CFrontend/2007-02-04-WITH_SIZE_EXPR.c:1.1 Sun Feb  4 21:56:59 2007
+++ llvm/test/CFrontend/2007-02-04-WITH_SIZE_EXPR.c Mon Feb 19 14:20:04 2007
@@ -1,6 +1,5 @@
 // RUN: %llvmgcc %s -O3 -S -o - -emit-llvm
 // PR1174
-// XFAIL: *
 
 void zzz (char *s1, char *s2, int len, int *q)
 {



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


[llvm-commits] [llvm-gcc] Arbitrary Precition Integer Support

2007-02-19 Thread Reid Spencer
Devang / Jim / Chris,

The attached patch has been reviewed by Devang and provides the
"bitwidth" attribute and 3 builtin functions for arbitrary precision
integers (concat, bit select, part select). This is the same as the last
version except it has an additional check for a null pointer that
produced a failure in bootstrap.  That problem is now gone and this
patch passes the Integer test suite as well as MultiSource/Benchmarks. 

I would appreciate it if you could commit this one or indicate why it
could not be committed.

Thanks,

Reid.

P.S. There's likely to be two merge conflicts as this patch includes the
changes to fix the getGetElementPtr interface change as well as Chris'
version of the change to llvm-types.cpp that I suggested today.
Fortunately these should be easy to resolve: just take the llvm-gcc
version in each case .. hopefully svn is smart enough to recognize the
changes as being equivalent.


Index: gcc/tree.h
===
--- gcc/tree.h	(revision 277)
+++ gcc/tree.h	(working copy)
@@ -1711,6 +1711,21 @@
 #define TYPE_CONTAINS_PLACEHOLDER_INTERNAL(NODE) \
   (TYPE_CHECK (NODE)->type.contains_placeholder_bits)
 
+/* APPLE LOCAL begin LLVM bit accurate integer types - ras */
+#ifdef ENABLE_LLVM
+/* 1 if the bitwidth for this type was set with the "bitwidth" attribute,
+   0 otherwise.  */
+#define TYPE_USER_BITWIDTH(NODE) (TYPE_CHECK (NODE)->type.user_bitwidth)
+/* Extracts the bitwidth field that holds the user's requested
+ * bitwidth from the bitwidth attribute. Depending on the usage this
+ * may or may not be honored due to limitations of how the type is
+ * used. See the handle_bitwidth_attribute function in c-common.c for
+ * details. Note that this field always contains the bitwidth requested
+ * in the attribute but that may differ from the precision used by the type.*/
+#define TYPE_BITWIDTH(NODE) (TYPE_CHECK (NODE)->type.bitwidth)
+#endif
+/* APPLE LOCAL end LLVM bit accurate integer types - ras */
+
 struct die_struct;
 
 struct tree_type GTY(())
@@ -1741,6 +1756,10 @@
   unsigned lang_flag_5 : 1;
   unsigned lang_flag_6 : 1;
   unsigned user_align : 1;
+  /* APPLE LOCAL begin LLVM bit accurate integer types - ras */
+  unsigned user_bitwidth : 1;
+  unsigned bitwidth : 23;
+  /* APPLE LOCAL end LLVM bit accurate integer types - ras */
 
   unsigned int align;
   tree pointer_to;
Index: gcc/llvm.h
===
--- gcc/llvm.h	(revision 277)
+++ gcc/llvm.h	(working copy)
@@ -92,6 +92,12 @@
 /* llvm_asm_file_end - Finish the .s file. */
 void llvm_asm_file_end(void);
 
+/* A function that can be used to see if a function is one of the LLVM
+ * pseudo_builtin functions that permits integer arguments of any size.
+ * A non-negative result indicates which pseudo-builtin it is. A 
+ * negative result indicates it is not a pseudo-builtin. */
+int llvm_get_pseudo_builtin_index(const char *);
+
 #endif /* ENABLE_LLVM */
 
 #endif
Index: gcc/cp/typeck.c
===
--- gcc/cp/typeck.c	(revision 277)
+++ gcc/cp/typeck.c	(working copy)
@@ -42,6 +42,11 @@
 #include "target.h"
 #include "convert.h"
 #include "c-common.h"
+/* APPLE LOCAL begin LLVM bit accurate integer types - ras */
+#ifdef ENABLE_LLVM
+#include "llvm.h"
+#endif
+/* APPLE LOCAL end LLVM bit accurate integer types - ras */
 
 static tree convert_for_assignment (tree, tree, const char *, tree, int);
 static tree cp_pointer_int_sum (enum tree_code, tree, tree);
@@ -2620,6 +2625,11 @@
   tree result = NULL_TREE;
   const char *called_thing = 0;
   int i = 0;
+/* APPLE LOCAL begin LLVM bit accurate integer types - ras */
+#ifdef ENABLE_LLVM
+  int is_pseudo_builtin = 0;
+#endif
+/* APPLE LOCAL end LLVM bit accurate integer types - ras */
 
   /* Argument passing is always copy-initialization.  */
   flags |= LOOKUP_ONLYCONVERTING;
@@ -2635,7 +2645,18 @@
 	called_thing = "member function";
 	}
   else
+/* APPLE LOCAL begin LLVM bit accurate integer types - ras */
+#ifdef ENABLE_LLVM
+{
+  is_pseudo_builtin = 
+llvm_get_pseudo_builtin_index(IDENTIFIER_POINTER(DECL_NAME(fndecl)))
+  >= 0;
+  called_thing = "function";
+}
+#else
 	called_thing = "function";
+#endif
+/* APPLE LOCAL end LLVM bit accurate integer types - ras */
 }
 
   for (valtail = values, typetail = typelist;
@@ -2683,6 +2704,18 @@
   if (val == error_mark_node)
 	return error_mark_node;
 
+/* APPLE LOCAL begin LLVM bit accurate integer types - ras */
+#ifdef ENABLE_LLVM
+  /* If its a pseudo-builtin function, just defeat all the type checking
+ below and tack the value on to the result. The type is checked later
+ in llvm-convert.cpp when the builtin is handled. */
+  if (is_pseudo_builtin) 
+{
+	  result = tree_cons (NULL_TREE, val, result);
+} 
+  else
+#endif
+/* APPLE LOCAL end LLVM bit

[llvm-commits] CVS: llvm/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll

2007-02-19 Thread Evan Cheng


Changes in directory llvm/test/CodeGen/PowerPC:

LargeAbsoluteAddr.ll updated: 1.2 -> 1.3
---
Log message:

Fix test case.

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

 LargeAbsoluteAddr.ll |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


Index: llvm/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll
diff -u llvm/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll:1.2 
llvm/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll:1.3
--- llvm/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll:1.2  Sat Feb 17 00:57:11 2007
+++ llvm/test/CodeGen/PowerPC/LargeAbsoluteAddr.ll  Mon Feb 19 15:47:02 2007
@@ -1,6 +1,6 @@
-; RUN: llvm-as < %s | llc -march=ppc32 | grep 'stw r3, 32751' &&
-; RUN: llvm-as < %s | llc -march=ppc64 | grep 'stw r3, 32751' &&
-; RUN: llvm-as < %s | llc -march=ppc64 | grep 'std r2, 9024' &&
+; RUN: llvm-as < %s | llc -march=ppc32 -mtriple=powerpc-apple-darwin | grep 
'stw r3, 32751' &&
+; RUN: llvm-as < %s | llc -march=ppc64 -mtriple=powerpc-apple-darwin | grep 
'stw r3, 32751' &&
+; RUN: llvm-as < %s | llc -march=ppc64 -mtriple=powerpc-apple-darwin | grep 
'std r2, 9024' &&
 ; RUN: llvm-as < %s | llc
 
 define void @test() {



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


[llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp LiveVariables.cpp MachineBasicBlock.cpp MachineInstr.cpp RegAllocLinearScan.cpp

2007-02-19 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

LiveIntervalAnalysis.cpp updated: 1.208 -> 1.209
LiveVariables.cpp updated: 1.67 -> 1.68
MachineBasicBlock.cpp updated: 1.41 -> 1.42
MachineInstr.cpp updated: 1.143 -> 1.144
RegAllocLinearScan.cpp updated: 1.139 -> 1.140
---
Log message:

Re-apply my liveintervalanalysis changes. Now with PR1207: 
http://llvm.org/PR1207  fixes.

---
Diffs of the changes:  (+164 -85)

 LiveIntervalAnalysis.cpp |  189 +--
 LiveVariables.cpp|   36 +---
 MachineBasicBlock.cpp|8 +
 MachineInstr.cpp |   11 ++
 RegAllocLinearScan.cpp   |5 -
 5 files changed, 164 insertions(+), 85 deletions(-)


Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.208 
llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.209
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.208 Sun Feb 18 21:20:00 2007
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp   Mon Feb 19 15:49:53 2007
@@ -98,28 +98,6 @@
 // Set the MBB2IdxMap entry for this MBB.
 MBB2IdxMap[MBB->getNumber()] = MIIndex;
 
-// If this BB has any live ins, insert a dummy instruction at the
-// beginning of the function that we will pretend "defines" the values. 
This
-// is to make the interval analysis simpler by providing a number.
-if (MBB->livein_begin() != MBB->livein_end()) {
-  unsigned FirstLiveIn = *MBB->livein_begin();
-
-  // Find a reg class that contains this live in.
-  const TargetRegisterClass *RC = 0;
-  for (MRegisterInfo::regclass_iterator RCI = mri_->regclass_begin(),
- RCE = mri_->regclass_end(); RCI != RCE; ++RCI)
-if ((*RCI)->contains(FirstLiveIn)) {
-  RC = *RCI;
-  break;
-}
-
-  MachineInstr *OldFirstMI = MBB->begin();
-  mri_->copyRegToReg(*MBB, MBB->begin(),
- FirstLiveIn, FirstLiveIn, RC);
-  assert(OldFirstMI != MBB->begin() &&
- "copyRetToReg didn't insert anything!");
-}
-
 for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
  I != E; ++I) {
   bool inserted = mi2iMap_.insert(std::make_pair(I, MIIndex)).second;
@@ -161,7 +139,17 @@
   if (tii_->isMoveInstr(*mii, srcReg, dstReg) &&
   (RegRep = rep(srcReg)) == rep(dstReg)) {
 // remove from def list
-getOrCreateInterval(RegRep);
+LiveInterval &RegInt = getOrCreateInterval(RegRep);
+MachineOperand *MO = mii->findRegisterDefOperand(dstReg);
+// If def of this move instruction is dead, remove its live range from
+// the dstination register's live interval.
+if (MO->isDead()) {
+  unsigned MoveIdx = getDefIndex(getInstructionIndex(mii));
+  LiveInterval::iterator MLR = RegInt.FindLiveRangeContaining(MoveIdx);
+  RegInt.removeRange(MLR->start, MoveIdx+1);
+  if (RegInt.empty())
+removeInterval(RegRep);
+}
 RemoveMachineInstrFromMaps(mii);
 mii = mbbi->erase(mii);
 ++numPeep;
@@ -185,7 +173,6 @@
 }
   }
 
-  
   for (iterator I = begin(), E = end(); I != E; ++I) {
 LiveInterval &LI = I->second;
 if (MRegisterInfo::isVirtualRegister(LI.reg)) {
@@ -670,6 +657,43 @@
   }
 }
 
+void LiveIntervals::handleLiveInRegister(MachineBasicBlock *MBB,
+ LiveInterval &interval) {
+  DOUT << "\t\tlivein register: "; DEBUG(printRegName(interval.reg));
+
+  // Look for kills, if it reaches a def before it's killed, then it shouldn't
+  // be considered a livein.
+  MachineBasicBlock::iterator mi = MBB->begin();
+  unsigned baseIndex = 0;
+  unsigned start = 0;
+  unsigned end = start;
+  while (mi != MBB->end()) {
+if (lv_->KillsRegister(mi, interval.reg)) {
+  DOUT << " killed";
+  end = getUseIndex(baseIndex) + 1;
+  goto exit;
+} else if (lv_->ModifiesRegister(mi, interval.reg)) {
+  // Another instruction redefines the register before it is ever read.
+  // Then the register is essentially dead at the instruction that defines
+  // it. Hence its interval is:
+  // [defSlot(def), defSlot(def)+1)
+  DOUT << " dead";
+  end = getDefIndex(start) + 1;
+  goto exit;
+}
+
+baseIndex += InstrSlots::NUM;
+++mi;
+  }
+
+exit:
+  assert(start < end && "did not find end of interval?");
+
+  LiveRange LR(start, end, interval.getNextValue(~0U, 0));
+  interval.addRange(LR);
+  DOUT << " +" << LR << '\n';
+}
+
 /// computeIntervals - computes the live intervals for virtual
 /// registers. for some ordering of the machine instructions [1,N] a
 /// live interval is an interval [i, j) where 1 <= i <= j < N for
@@ -688,17 +712,13 @@
 MachineBasicBlock::iterator MI = MBB->begin(), miEnd = MBB->end();
 
 if (MBB->livein_begin() != MBB->livein_end()) {
-  // Process live-ins to this BB first.
-  for (MachineBasicBlock::livein_iterator LI = MBB->livein_begin(),
+   

[llvm-commits] CVS: llvm/lib/Target/ARM/ARMRegisterInfo.cpp ARMRegisterInfo.h

2007-02-19 Thread Evan Cheng


Changes in directory llvm/lib/Target/ARM:

ARMRegisterInfo.cpp updated: 1.68 -> 1.69
ARMRegisterInfo.h updated: 1.9 -> 1.10
---
Log message:

Re-apply my liveintervalanalysis changes. Now with PR1207: 
http://llvm.org/PR1207  fixes.

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

 ARMRegisterInfo.cpp |   15 +++
 ARMRegisterInfo.h   |2 ++
 2 files changed, 17 insertions(+)


Index: llvm/lib/Target/ARM/ARMRegisterInfo.cpp
diff -u llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.68 
llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.69
--- llvm/lib/Target/ARM/ARMRegisterInfo.cpp:1.68Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/ARM/ARMRegisterInfo.cpp Mon Feb 19 15:49:53 2007
@@ -28,6 +28,7 @@
 #include "llvm/Target/TargetFrameInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
+#include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include 
@@ -297,6 +298,20 @@
   return CalleeSavedRegClasses;
 }
 
+BitVector ARMRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
+  BitVector Reserved(getNumRegs());
+  Reserved.set(ARM::SP);
+  if (STI.isTargetDarwin() || hasFP(MF))
+Reserved.set(FramePtr);
+  // Some targets reserve R9.
+  if (STI.isR9Reserved())
+Reserved.set(ARM::R9);
+  // At PEI time, if LR is used, it will be spilled upon entry.
+  if (MF.getUsedPhysregs() && !MF.isPhysRegUsed((unsigned)ARM::LR))
+Reserved.set(ARM::LR);
+  return Reserved;
+}
+
 /// hasFP - Return true if the specified function should have a dedicated frame
 /// pointer register.  This is true if the function has variable sized allocas
 /// or if frame pointer elimination is disabled.


Index: llvm/lib/Target/ARM/ARMRegisterInfo.h
diff -u llvm/lib/Target/ARM/ARMRegisterInfo.h:1.9 
llvm/lib/Target/ARM/ARMRegisterInfo.h:1.10
--- llvm/lib/Target/ARM/ARMRegisterInfo.h:1.9   Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/ARM/ARMRegisterInfo.h   Mon Feb 19 15:49:53 2007
@@ -67,6 +67,8 @@
 
   const TargetRegisterClass* const* getCalleeSavedRegClasses() const;
 
+  BitVector getReservedRegs(const MachineFunction &MF) const;
+
   bool hasFP(const MachineFunction &MF) const;
 
   void eliminateCallFramePseudoInstr(MachineFunction &MF,



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


[llvm-commits] CVS: llvm/lib/Target/Sparc/SparcRegisterInfo.cpp SparcRegisterInfo.h

2007-02-19 Thread Evan Cheng


Changes in directory llvm/lib/Target/Sparc:

SparcRegisterInfo.cpp updated: 1.53 -> 1.54
SparcRegisterInfo.h updated: 1.19 -> 1.20
---
Log message:

Re-apply my liveintervalanalysis changes. Now with PR1207: 
http://llvm.org/PR1207  fixes.

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

 SparcRegisterInfo.cpp |   17 +
 SparcRegisterInfo.h   |2 ++
 2 files changed, 19 insertions(+)


Index: llvm/lib/Target/Sparc/SparcRegisterInfo.cpp
diff -u llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.53 
llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.54
--- llvm/lib/Target/Sparc/SparcRegisterInfo.cpp:1.53Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/Sparc/SparcRegisterInfo.cpp Mon Feb 19 15:49:54 2007
@@ -20,6 +20,7 @@
 #include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Type.h"
+#include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/STLExtras.h"
 using namespace llvm;
 
@@ -116,6 +117,22 @@
   return CalleeSavedRegs;
 }
 
+BitVector SparcRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
+  BitVector Reserved(getNumRegs());
+  Reserved.set(SP::G2);
+  Reserved.set(SP::G3);
+  Reserved.set(SP::G4);
+  Reserved.set(SP::O6);
+  Reserved.set(SP::I6);
+  Reserved.set(SP::I7);
+  Reserved.set(SP::G0);
+  Reserved.set(SP::G5);
+  Reserved.set(SP::G6);
+  Reserved.set(SP::G7);
+  return Reserved;
+}
+
+
 const TargetRegisterClass* const*
 SparcRegisterInfo::getCalleeSavedRegClasses() const {
   static const TargetRegisterClass * const CalleeSavedRegClasses[] = { 0 };


Index: llvm/lib/Target/Sparc/SparcRegisterInfo.h
diff -u llvm/lib/Target/Sparc/SparcRegisterInfo.h:1.19 
llvm/lib/Target/Sparc/SparcRegisterInfo.h:1.20
--- llvm/lib/Target/Sparc/SparcRegisterInfo.h:1.19  Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/Sparc/SparcRegisterInfo.h   Mon Feb 19 15:49:54 2007
@@ -52,6 +52,8 @@
 
   const TargetRegisterClass* const* getCalleeSavedRegClasses() const;
 
+  BitVector getReservedRegs(const MachineFunction &MF) const;
+
   bool hasFP(const MachineFunction &MF) const;
 
   void eliminateCallFramePseudoInstr(MachineFunction &MF,



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


[llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h LiveVariables.h MachineBasicBlock.h MachineInstr.h

2007-02-19 Thread Evan Cheng


Changes in directory llvm/include/llvm/CodeGen:

LiveIntervalAnalysis.h updated: 1.70 -> 1.71
LiveVariables.h updated: 1.34 -> 1.35
MachineBasicBlock.h updated: 1.57 -> 1.58
MachineInstr.h updated: 1.211 -> 1.212
---
Log message:

Re-apply my liveintervalanalysis changes. Now with PR1207: 
http://llvm.org/PR1207  fixes.

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

 LiveIntervalAnalysis.h |   18 --
 LiveVariables.h|9 +
 MachineBasicBlock.h|   13 ++---
 MachineInstr.h |4 
 4 files changed, 35 insertions(+), 9 deletions(-)


Index: llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h
diff -u llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.70 
llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.71
--- llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h:1.70   Sun Feb 18 
21:20:00 2007
+++ llvm/include/llvm/CodeGen/LiveIntervalAnalysis.hMon Feb 19 15:49:53 2007
@@ -118,6 +118,11 @@
   return I->second;
 }
 
+bool hasInterval(unsigned reg) const {
+  Reg2IntervalMap::const_iterator I = r2iMap_.find(reg);
+  return I != r2iMap_.end();
+}
+
 /// getMBBStartIdx - Return the base index of the first instruction in the
 /// specified MachineBasicBlock.
 unsigned getMBBStartIdx(MachineBasicBlock *MBB) const {
@@ -189,6 +194,7 @@
 /// copies that cannot yet be coallesced into the "TryAgain" list.
 void CopyCoallesceInMBB(MachineBasicBlock *MBB,
 std::vector &TryAgain);
+
 /// JoinCopy - Attempt to join intervals corresponding to SrcReg/DstReg,
 /// which are the src/dst of the copy instruction CopyMI.  This returns 
true
 /// if the copy was successfully coallesced away, or if it is never 
possible
@@ -233,6 +239,9 @@
LiveInterval &interval,
unsigned SrcReg);
 
+/// handleLiveInRegister - Create interval for a livein register.
+void handleLiveInRegister(MachineBasicBlock* mbb, LiveInterval &interval);
+
 /// Return true if the two specified registers belong to different
 /// register classes.  The registers may be either phys or virt regs.
 bool differingRegisterClasses(unsigned RegA, unsigned RegB) const;
@@ -241,11 +250,16 @@
 bool AdjustCopiesBackFrom(LiveInterval &IntA, LiveInterval &IntB,
   MachineInstr *CopyMI);
 
-bool overlapsAliases(const LiveInterval *lhs,
- const LiveInterval *rhs) const;
+/// hasRegisterUse - Returns true if there is any use of the specific
+/// reg between indexes Start and End.
+bool hasRegisterUse(unsigned Reg, unsigned Start, unsigned End);
 
 static LiveInterval createInterval(unsigned Reg);
 
+void removeInterval(unsigned Reg) {
+  r2iMap_.erase(Reg);
+}
+
 LiveInterval &getOrCreateInterval(unsigned reg) {
   Reg2IntervalMap::iterator I = r2iMap_.find(reg);
   if (I == r2iMap_.end())


Index: llvm/include/llvm/CodeGen/LiveVariables.h
diff -u llvm/include/llvm/CodeGen/LiveVariables.h:1.34 
llvm/include/llvm/CodeGen/LiveVariables.h:1.35
--- llvm/include/llvm/CodeGen/LiveVariables.h:1.34  Sun Feb 18 21:20:00 2007
+++ llvm/include/llvm/CodeGen/LiveVariables.h   Mon Feb 19 15:49:53 2007
@@ -36,6 +36,7 @@
 namespace llvm {
 
 class MRegisterInfo;
+class BitVector;
 
 class LiveVariables : public MachineFunctionPass {
 public:
@@ -108,11 +109,11 @@
   ///
   std::vector VirtRegInfo;
 
-  /// AllocatablePhysicalRegisters - This vector keeps track of which registers
-  /// are actually register allocatable by the target machine.  We can not 
track
-  /// liveness for values that are not in this set.
+  /// ReservedRegisters - This vector keeps track of which registers
+  /// are reserved register which are not allocatable by the target machine.
+  /// We can not track liveness for values that are in this set.
   ///
-  BitVector AllocatablePhysicalRegisters;
+  BitVector ReservedRegisters;
 
 private:   // Intermediate data structures
   const MRegisterInfo *RegInfo;


Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h
diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.57 
llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.58
--- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.57  Sun Feb 18 21:20:00 2007
+++ llvm/include/llvm/CodeGen/MachineBasicBlock.h   Mon Feb 19 15:49:53 2007
@@ -138,11 +138,18 @@
   /// is an error to add the same register to the same set more than once.
   void addLiveIn(unsigned Reg)  { LiveIns.push_back(Reg); }
 
+  /// removeLiveIn - Remove the specified register from the live in set.
+  ///
+  void removeLiveIn(unsigned Reg);
+
   // Iteration support for live in sets.  These sets are kept in sorted
   // order by their register number.
-  typedef std::vector::const_iterator livein_iterator;
-  livein_iterator livein_begin() const { return LiveIns.begin(); }
-  livein_iterator livein_end()   const { return LiveIns.end(); }

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

2007-02-19 Thread Evan Cheng


Changes in directory llvm/lib/Target/X86:

X86RegisterInfo.cpp updated: 1.202 -> 1.203
X86RegisterInfo.h updated: 1.47 -> 1.48
---
Log message:

Re-apply my liveintervalanalysis changes. Now with PR1207: 
http://llvm.org/PR1207  fixes.

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

 X86RegisterInfo.cpp |   16 
 X86RegisterInfo.h   |6 ++
 2 files changed, 22 insertions(+)


Index: llvm/lib/Target/X86/X86RegisterInfo.cpp
diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.202 
llvm/lib/Target/X86/X86RegisterInfo.cpp:1.203
--- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.202   Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/X86/X86RegisterInfo.cpp Mon Feb 19 15:49:54 2007
@@ -31,6 +31,7 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/STLExtras.h"
 using namespace llvm;
 
@@ -883,6 +884,21 @@
   return Is64Bit ? CalleeSavedRegClasses64Bit : CalleeSavedRegClasses32Bit;
 }
 
+BitVector X86RegisterInfo::getReservedRegs(const MachineFunction &MF) const {
+  BitVector Reserved(getNumRegs());
+  Reserved.set(X86::RSP);
+  Reserved.set(X86::ESP);
+  Reserved.set(X86::SP);
+  Reserved.set(X86::SPL);
+  if (hasFP(MF)) {
+Reserved.set(X86::RBP);
+Reserved.set(X86::EBP);
+Reserved.set(X86::BP);
+Reserved.set(X86::BPL);
+  }
+  return Reserved;
+}
+
 
//===--===//
 // Stack Frame Processing methods
 
//===--===//


Index: llvm/lib/Target/X86/X86RegisterInfo.h
diff -u llvm/lib/Target/X86/X86RegisterInfo.h:1.47 
llvm/lib/Target/X86/X86RegisterInfo.h:1.48
--- llvm/lib/Target/X86/X86RegisterInfo.h:1.47  Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/X86/X86RegisterInfo.h   Mon Feb 19 15:49:54 2007
@@ -78,6 +78,12 @@
   /// length of this list match the getCalleeSavedRegs() list.
   const TargetRegisterClass* const* getCalleeSavedRegClasses() const;
 
+  /// getReservedRegs - Returns a bitset indexed by physical register number
+  /// indicating if a register is a special register that has particular uses 
and
+  /// should be considered unavailable at all times, e.g. SP, RA. This is used 
by
+  /// register scavenger to determine what registers are free.
+  BitVector getReservedRegs(const MachineFunction &MF) const;
+
   bool hasFP(const MachineFunction &MF) const;
 
   void eliminateCallFramePseudoInstr(MachineFunction &MF,



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


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

2007-02-19 Thread Evan Cheng


Changes in directory llvm/lib/Target:

MRegisterInfo.cpp updated: 1.21 -> 1.22
---
Log message:

Re-apply my liveintervalanalysis changes. Now with PR1207: 
http://llvm.org/PR1207  fixes.

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

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


Index: llvm/lib/Target/MRegisterInfo.cpp
diff -u llvm/lib/Target/MRegisterInfo.cpp:1.21 
llvm/lib/Target/MRegisterInfo.cpp:1.22
--- llvm/lib/Target/MRegisterInfo.cpp:1.21  Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/MRegisterInfo.cpp   Mon Feb 19 15:49:53 2007
@@ -41,7 +41,7 @@
 const TargetRegisterClass *RC = *I;
 for (TargetRegisterClass::iterator I = RC->allocation_order_begin(MF),
E = RC->allocation_order_end(MF); I != E; ++I)
-  Allocatable[*I] = true;
+  Allocatable.set(*I);
   }
   return Allocatable;
 }



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


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

2007-02-19 Thread Evan Cheng


Changes in directory llvm/lib/Target/IA64:

IA64RegisterInfo.cpp updated: 1.30 -> 1.31
IA64RegisterInfo.h updated: 1.13 -> 1.14
---
Log message:

Re-apply my liveintervalanalysis changes. Now with PR1207: 
http://llvm.org/PR1207  fixes.

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

 IA64RegisterInfo.cpp |   14 ++
 IA64RegisterInfo.h   |2 ++
 2 files changed, 16 insertions(+)


Index: llvm/lib/Target/IA64/IA64RegisterInfo.cpp
diff -u llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.30 
llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.31
--- llvm/lib/Target/IA64/IA64RegisterInfo.cpp:1.30  Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/IA64/IA64RegisterInfo.cpp   Mon Feb 19 15:49:54 2007
@@ -28,6 +28,7 @@
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/STLExtras.h"
 using namespace llvm;
 
@@ -106,6 +107,19 @@
   return CalleeSavedRegClasses;
 }
 
+BitVector IA64RegisterInfo::getReservedRegs(const MachineFunction &MF) const {
+  BitVector Reserved(getNumRegs());
+  Reserved.set(IA64::r0);
+  Reserved.set(IA64::r1);
+  Reserved.set(IA64::r2);
+  Reserved.set(IA64::r5);
+  Reserved.set(IA64::r12);
+  Reserved.set(IA64::r13);
+  Reserved.set(IA64::r22);
+  Reserved.set(IA64::rp);
+  return Reserved;
+}
+
 
//===--===//
 // Stack Frame Processing methods
 
//===--===//


Index: llvm/lib/Target/IA64/IA64RegisterInfo.h
diff -u llvm/lib/Target/IA64/IA64RegisterInfo.h:1.13 
llvm/lib/Target/IA64/IA64RegisterInfo.h:1.14
--- llvm/lib/Target/IA64/IA64RegisterInfo.h:1.13Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/IA64/IA64RegisterInfo.h Mon Feb 19 15:49:54 2007
@@ -48,6 +48,8 @@
 
   const TargetRegisterClass* const* getCalleeSavedRegClasses() const;
 
+  BitVector getReservedRegs(const MachineFunction &MF) const;
+
   bool hasFP(const MachineFunction &MF) const;
 
   void eliminateCallFramePseudoInstr(MachineFunction &MF,



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


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

2007-02-19 Thread Evan Cheng


Changes in directory llvm/lib/Target/Alpha:

AlphaRegisterInfo.cpp updated: 1.59 -> 1.60
AlphaRegisterInfo.h updated: 1.19 -> 1.20
---
Log message:

Re-apply my liveintervalanalysis changes. Now with PR1207: 
http://llvm.org/PR1207  fixes.

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

 AlphaRegisterInfo.cpp |9 +
 AlphaRegisterInfo.h   |2 ++
 2 files changed, 11 insertions(+)


Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp
diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.59 
llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.60
--- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.59Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Mon Feb 19 15:49:54 2007
@@ -28,6 +28,7 @@
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include 
 using namespace llvm;
@@ -178,6 +179,14 @@
   return CalleeSavedRegClasses;
 }
 
+BitVector AlphaRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
+  BitVector Reserved(getNumRegs());
+  Reserved.set(Alpha::R15);
+  Reserved.set(Alpha::R30);
+  Reserved.set(Alpha::R31);
+  return Reserved;
+}
+
 
//===--===//
 // Stack Frame Processing methods
 
//===--===//


Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.h
diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.h:1.19 
llvm/lib/Target/Alpha/AlphaRegisterInfo.h:1.20
--- llvm/lib/Target/Alpha/AlphaRegisterInfo.h:1.19  Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/Alpha/AlphaRegisterInfo.h   Mon Feb 19 15:49:54 2007
@@ -49,6 +49,8 @@
 
   const TargetRegisterClass* const* getCalleeSavedRegClasses() const;
 
+  BitVector getReservedRegs(const MachineFunction &MF) const;
+
   bool hasFP(const MachineFunction &MF) const;
 
   void eliminateCallFramePseudoInstr(MachineFunction &MF,



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


[llvm-commits] CVS: llvm/include/llvm/Target/MRegisterInfo.h

2007-02-19 Thread Evan Cheng


Changes in directory llvm/include/llvm/Target:

MRegisterInfo.h updated: 1.93 -> 1.94
---
Log message:

Re-apply my liveintervalanalysis changes. Now with PR1207: 
http://llvm.org/PR1207  fixes.

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

 MRegisterInfo.h |   17 +
 1 files changed, 17 insertions(+)


Index: llvm/include/llvm/Target/MRegisterInfo.h
diff -u llvm/include/llvm/Target/MRegisterInfo.h:1.93 
llvm/include/llvm/Target/MRegisterInfo.h:1.94
--- llvm/include/llvm/Target/MRegisterInfo.h:1.93   Sun Feb 18 21:20:00 2007
+++ llvm/include/llvm/Target/MRegisterInfo.hMon Feb 19 15:49:53 2007
@@ -284,6 +284,17 @@
 return false;
   }
 
+  /// regsOverlap - Returns true if the two registers are equal or alias
+  /// each other. The registers may be virtual register.
+  bool regsOverlap(unsigned regA, unsigned regB) const {
+if (regA == regB)
+  return true;
+
+if (isVirtualRegister(regA) || isVirtualRegister(regB))
+  return false;
+return areAliases(regA, regB);
+  }
+
   /// getCalleeSavedRegs - Return a null-terminated list of all of the
   /// callee saved registers on this target. The register should be in the
   /// order of desired callee-save stack frame offset. The first register is
@@ -295,6 +306,12 @@
   /// length of this list match the getCalleeSaveRegs() list.
   virtual const TargetRegisterClass* const *getCalleeSavedRegClasses() const 
=0;
 
+  /// getReservedRegs - Returns a bitset indexed by physical register number
+  /// indicating if a register is a special register that has particular uses 
and
+  /// should be considered unavailable at all times, e.g. SP, RA. This is used 
by
+  /// register scavenger to determine what registers are free.
+  virtual BitVector getReservedRegs(const MachineFunction &MF) const = 0;
+
   
//======//
   // Register Class Information
   //



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


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

2007-02-19 Thread Evan Cheng


Changes in directory llvm/lib/Target/PowerPC:

PPCRegisterInfo.cpp updated: 1.107 -> 1.108
PPCRegisterInfo.h updated: 1.26 -> 1.27
---
Log message:

Re-apply my liveintervalanalysis changes. Now with PR1207: 
http://llvm.org/PR1207  fixes.

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

 PPCRegisterInfo.cpp |   39 ++-
 PPCRegisterInfo.h   |2 ++
 2 files changed, 32 insertions(+), 9 deletions(-)


Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.107 
llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.108
--- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.107   Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Mon Feb 19 15:49:54 2007
@@ -34,6 +34,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include 
 using namespace llvm;
@@ -338,6 +339,35 @@
Darwin32_CalleeSavedRegClasses;
 }
 
+// needsFP - Return true if the specified function should have a dedicated 
frame
+// pointer register.  This is true if the function has variable sized allocas 
or
+// if frame pointer elimination is disabled.
+//
+static bool needsFP(const MachineFunction &MF) {
+  const MachineFrameInfo *MFI = MF.getFrameInfo();
+  return NoFramePointerElim || MFI->hasVarSizedObjects();
+}
+
+BitVector PPCRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
+  BitVector Reserved(getNumRegs());
+  Reserved.set(PPC::R0);
+  Reserved.set(PPC::R1);
+  Reserved.set(PPC::LR);
+  // In Linux, r2 is reserved for the OS.
+  if (!Subtarget.isDarwin())
+Reserved.set(PPC::R2);
+  // On PPC64, r13 is the thread pointer.  Never allocate this register.
+  // Note that this is overconservative, as it also prevents allocation of
+  // R31 when the FP is not needed.
+  if (Subtarget.isPPC64()) {
+Reserved.set(PPC::R13);
+Reserved.set(PPC::R31);
+  }
+  if (needsFP(MF))
+Reserved.set(PPC::R31);
+  return Reserved;
+}
+
 /// foldMemoryOperand - PowerPC (like most RISC's) can only fold spills into
 /// copy instructions, turning them into load/store instructions.
 MachineInstr *PPCRegisterInfo::foldMemoryOperand(MachineInstr *MI,
@@ -398,15 +428,6 @@
 // Stack Frame Processing methods
 
//===--===//
 
-// needsFP - Return true if the specified function should have a dedicated 
frame
-// pointer register.  This is true if the function has variable sized allocas 
or
-// if frame pointer elimination is disabled.
-//
-static bool needsFP(const MachineFunction &MF) {
-  const MachineFrameInfo *MFI = MF.getFrameInfo();
-  return NoFramePointerElim || MFI->hasVarSizedObjects();
-}
-
 // hasFP - Return true if the specified function actually has a dedicated frame
 // pointer register.  This is true if the function needs a frame pointer and 
has
 // a non-zero stack size.


Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.h
diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.26 
llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.27
--- llvm/lib/Target/PowerPC/PPCRegisterInfo.h:1.26  Sun Feb 18 21:20:00 2007
+++ llvm/lib/Target/PowerPC/PPCRegisterInfo.h   Mon Feb 19 15:49:54 2007
@@ -58,6 +58,8 @@
 
   const TargetRegisterClass* const* getCalleeSavedRegClasses() const;
 
+  BitVector getReservedRegs(const MachineFunction &MF) const;
+
   /// targetHandlesStackFrameRounding - Returns true if the target is
   /// responsible for rounding up the stack frame (probably at emitPrologue
   /// time).



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


[llvm-commits] CVS: llvm/test/CodeGen/X86/2007-02-19-LiveIntervalAssert.cpp

2007-02-19 Thread Evan Cheng


Changes in directory llvm/test/CodeGen/X86:

2007-02-19-LiveIntervalAssert.cpp added (r1.1)
---
Log message:

Added test case for PR1207: http://llvm.org/PR1207 .

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

 2007-02-19-LiveIntervalAssert.cpp |   21 +
 1 files changed, 21 insertions(+)


Index: llvm/test/CodeGen/X86/2007-02-19-LiveIntervalAssert.cpp
diff -c /dev/null llvm/test/CodeGen/X86/2007-02-19-LiveIntervalAssert.cpp:1.1
*** /dev/null   Mon Feb 19 15:54:09 2007
--- llvm/test/CodeGen/X86/2007-02-19-LiveIntervalAssert.cpp Mon Feb 19 
15:53:59 2007
***
*** 0 
--- 1,21 
+ ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i686-pc-linux-gnu 
-relocation-model=pic
+ ; PR1027
+ 
+   %struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, 
i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i32, i16, i8, 
[1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i32, i32, [40 x i8] }
+   %struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 
}
+ @stderr = external global %struct._IO_FILE*
+ 
+ define void @__eprintf(i8* %string, i8* %expression, i32 %line, i8* 
%filename) {
+   %tmp = load %struct._IO_FILE** @stderr
+   %tmp5 = tail call i32 (%struct._IO_FILE*, i8*, ...)* @fprintf( 
%struct._IO_FILE* %tmp, i8* %string, i8* %expression, i32 %line, i8* %filename )
+   %tmp6 = load %struct._IO_FILE** @stderr
+   %tmp7 = tail call i32 @fflush( %struct._IO_FILE* %tmp6 )
+   tail call void @abort( )
+   unreachable
+ }
+ 
+ declare i32 @fprintf(%struct._IO_FILE*, i8*, ...)
+ 
+ declare i32 @fflush(%struct._IO_FILE*)
+ 
+ declare void @abort()



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


Re: [llvm-commits] [llvm-gcc] Arbitrary Precition Integer Support

2007-02-19 Thread Devang Patel

On Feb 19, 2007, at 12:37 PM, Reid Spencer wrote:

> Devang / Jim / Chris,
>
> The attached patch has been reviewed by Devang and provides the
> "bitwidth" attribute and 3 builtin functions for arbitrary precision
> integers (concat, bit select, part select). This is the same as the  
> last
> version except it has an additional check for a null pointer that
> produced a failure in bootstrap.  That problem is now gone and this
> patch passes the Integer test suite as well as MultiSource/Benchmarks.
>
> I would appreciate it if you could commit this one or indicate why it
> could not be committed.

Where you able to complete  bootstrap successfully ?
Chris, do you want to take a look at this patch, specially C++ FE  
changes?

-
Devang



>
> Thanks,
>
> Reid.
>
> P.S. There's likely to be two merge conflicts as this patch includes  
> the
> changes to fix the getGetElementPtr interface change as well as Chris'
> version of the change to llvm-types.cpp that I suggested today.
> Fortunately these should be easy to resolve: just take the llvm-gcc
> version in each case .. hopefully svn is smart enough to recognize the
> changes as being equivalent.
>
>
> 

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


[llvm-commits] CVS: llvm-test/MultiSource/Applications/SIBsim4/Makefile

2007-02-19 Thread Evan Cheng


Changes in directory llvm-test/MultiSource/Applications/SIBsim4:

Makefile updated: 1.1 -> 1.2
---
Log message:

Fix RUN_OPTIONS.

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

 Makefile |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm-test/MultiSource/Applications/SIBsim4/Makefile
diff -u llvm-test/MultiSource/Applications/SIBsim4/Makefile:1.1 
llvm-test/MultiSource/Applications/SIBsim4/Makefile:1.2
--- llvm-test/MultiSource/Applications/SIBsim4/Makefile:1.1 Thu Feb 15 
17:46:09 2007
+++ llvm-test/MultiSource/Applications/SIBsim4/Makefile Mon Feb 19 16:03:13 2007
@@ -4,6 +4,6 @@
 CPPFLAGS =
 LDFLAGS  =
 
-RUN_OPTIONS="$(PROJ_SRC_DIR)/x.fa $(PROJ_SRC_DIR)/y.fa -A4"
+RUN_OPTIONS= -A4 $(PROJ_SRC_DIR)/x.fa $(PROJ_SRC_DIR)/y.fa
 
 include ../../Makefile.multisrc



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


[llvm-commits] [124087] The buildit command on X86 was failing because the gcse. o file was being

2007-02-19 Thread bwendlin
Revision: 124087
Author:   bwendlin
Date: 2007-02-19 14:14:13 -0800 (Mon, 19 Feb 2007)

Log Message:
---
The buildit command on X86 was failing because the gcse.o file was being
included in the garbage collection when LLVM was built into a dylib. (Thanks to
Chris for discovering this.) We need to not include gcse.c in the gty stuff when
building as dylib.

Modified Paths:
--
apple-local/branches/llvm/gcc/Makefile.in

Modified: apple-local/branches/llvm/gcc/Makefile.in
===
--- apple-local/branches/llvm/gcc/Makefile.in   2007-02-19 20:15:12 UTC (rev 
124086)
+++ apple-local/branches/llvm/gcc/Makefile.in   2007-02-19 22:14:13 UTC (rev 
124087)
@@ -1098,6 +1098,13 @@
 OBJS-common := $(filter-out bt-load.o caller-save.o combine.o cse.o ifcvt.o \
 simplify-rtx.o, $(OBJS-common))
 
+# APPLE LOCAL begin LLVM - Remove gcse.o
+# Remove RTL optimization that requires a function we don't link in.
+ifdef BUILD_LLVM_INTO_A_DYLIB
+OBJS-common := $(filter-out gcse.o, $(OBJS-common))
+endif
+# APPLE LOCAL end LLVM - Remove gcse.o
+
 # Remove generated files.
 OBJS-common := $(filter-out insn-attrtab.o insn-recog.o insn-extract.o, \
 $(OBJS-common))
@@ -2762,6 +2769,12 @@
   $(out_file) \
   @all_gtfiles@
 
+# APPLE LOCAL begin LLVM - Remove gcse.c
+ifdef BUILD_LLVM_INTO_A_DYLIB
+GTFILES := $(filter-out $(srcdir)/gcse.c, $(GTFILES))
+endif
+# APPLE LOCAL end LLVM - Remove gcse.c
+
 GTFILES_FILES_LANGS = @all_gtfiles_files_langs@
 GTFILES_FILES_FILES = @all_gtfiles_files_files@
 GTFILES_LANG_DIR_NAMES = @subdirs@


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


Re: [llvm-commits] [llvm-gcc] Arbitrary Precition Integer Support

2007-02-19 Thread Reid Spencer
On Mon, 2007-02-19 at 13:55 -0800, Devang Patel wrote:
> On Feb 19, 2007, at 12:37 PM, Reid Spencer wrote:
> 
> > Devang / Jim / Chris,
> >
> > The attached patch has been reviewed by Devang and provides the
> > "bitwidth" attribute and 3 builtin functions for arbitrary precision
> > integers (concat, bit select, part select). This is the same as the  
> > last
> > version except it has an additional check for a null pointer that
> > produced a failure in bootstrap.  That problem is now gone and this
> > patch passes the Integer test suite as well as MultiSource/Benchmarks.
> >
> > I would appreciate it if you could commit this one or indicate why it
> > could not be committed.
> 
> Where you able to complete  bootstrap successfully ?

"make bootstrap" from clean directory worked.

> Chris, do you want to take a look at this patch, specially C++ FE  
> changes?
> 
> -
> Devang
> 
> 
> 
> >
> > Thanks,
> >
> > Reid.
> >
> > P.S. There's likely to be two merge conflicts as this patch includes  
> > the
> > changes to fix the getGetElementPtr interface change as well as Chris'
> > version of the change to llvm-types.cpp that I suggested today.
> > Fortunately these should be easy to resolve: just take the llvm-gcc
> > version in each case .. hopefully svn is smart enough to recognize the
> > changes as being equivalent.
> >
> >
> > 
> 

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


[llvm-commits] CVS: llvm/include/llvm/Target/TargetData.h

2007-02-19 Thread Reid Spencer


Changes in directory llvm/include/llvm/Target:

TargetData.h updated: 1.57 -> 1.58
---
Log message:

Implement support for non-standard integer bit widths of any size. The 
rules alignment is to pick the alignment that corresponds to the smallest 
specified alignment that is larger than the bit width of the type or the 
largest specified integer alignment if none are larger than the bitwidth
of the type. For the byte size, the size returned is the next larger 
multiple of the alignment for that type (using the above rule). This patch
also changes bit widths from "short" to "uint32_t" to ensure there are 
enough bits to specify any bit width that LLVM can handle (currently 2^23);
16-bits isn't enough.


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

 TargetData.h |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)


Index: llvm/include/llvm/Target/TargetData.h
diff -u llvm/include/llvm/Target/TargetData.h:1.57 
llvm/include/llvm/Target/TargetData.h:1.58
--- llvm/include/llvm/Target/TargetData.h:1.57  Fri Feb 16 18:41:42 2007
+++ llvm/include/llvm/Target/TargetData.h   Mon Feb 19 16:35:00 2007
@@ -51,11 +51,11 @@
   AlignTypeEnum   AlignType : 8;  //< Alignment type (AlignTypeEnum)
   unsigned char   ABIAlign;   //< ABI alignment for this type/bitw
   unsigned char   PrefAlign;  //< Pref. alignment for this type/bitw
-  short   TypeBitWidth;   //< Type bit width
+  uint32_tTypeBitWidth;   //< Type bit width
 
   /// Initializer
   static TargetAlignElem get(AlignTypeEnum align_type, unsigned char abi_align,
- unsigned char pref_align, short bit_width);
+ unsigned char pref_align, uint32_t bit_width);
   /// Equality predicate
   bool operator==(const TargetAlignElem &rhs) const;
   /// output stream operator
@@ -89,8 +89,8 @@
 
   //! Set/initialize target alignments
   void setAlignment(AlignTypeEnum align_type, unsigned char abi_align,
-unsigned char pref_align, short bit_width);
-  unsigned getAlignmentInfo(AlignTypeEnum align_type, short bit_width,
+unsigned char pref_align, uint32_t bit_width);
+  unsigned getAlignmentInfo(AlignTypeEnum align_type, uint32_t bit_width,
 bool ABIAlign) const;
   //! Internal helper method that returns requested alignment for type.
   unsigned char getAlignment(const Type *Ty, bool abi_or_pref) const;
@@ -161,11 +161,11 @@
   /// specified type.
   uint64_t getTypeSizeInBits(const Type* Ty) const;
 
-  /// getTypeAlignmentABI - Return the minimum ABI-required alignment for the
+  /// getABITypeAlignment - Return the minimum ABI-required alignment for the
   /// specified type.
   unsigned char getABITypeAlignment(const Type *Ty) const;
 
-  /// getTypeAlignmentPref - Return the preferred stack/global alignment for
+  /// getPrefTypeAlignment - Return the preferred stack/global alignment for
   /// the specified type.
   unsigned char getPrefTypeAlignment(const Type *Ty) const;
 



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


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

2007-02-19 Thread Reid Spencer


Changes in directory llvm/lib/Target:

TargetData.cpp updated: 1.101 -> 1.102
---
Log message:

Implement support for non-standard integer bit widths of any size. The 
rules alignment is to pick the alignment that corresponds to the smallest 
specified alignment that is larger than the bit width of the type or the 
largest specified integer alignment if none are larger than the bitwidth
of the type. For the byte size, the size returned is the next larger 
multiple of the alignment for that type (using the above rule). This patch
also changes bit widths from "short" to "uint32_t" to ensure there are 
enough bits to specify any bit width that LLVM can handle (currently 2^23);
16-bits isn't enough.


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

 TargetData.cpp |   43 +--
 1 files changed, 33 insertions(+), 10 deletions(-)


Index: llvm/lib/Target/TargetData.cpp
diff -u llvm/lib/Target/TargetData.cpp:1.101 
llvm/lib/Target/TargetData.cpp:1.102
--- llvm/lib/Target/TargetData.cpp:1.101Fri Feb 16 18:41:42 2007
+++ llvm/lib/Target/TargetData.cpp  Mon Feb 19 16:35:00 2007
@@ -94,7 +94,7 @@
 
 TargetAlignElem
 TargetAlignElem::get(AlignTypeEnum align_type, unsigned char abi_align,
- unsigned char pref_align, short bit_width) {
+ unsigned char pref_align, uint32_t bit_width) {
   TargetAlignElem retval;
   retval.AlignType = align_type;
   retval.ABIAlign = abi_align;
@@ -188,7 +188,7 @@
 std::string arg0 = getToken(token, ":");
 const char *p = arg0.c_str();
 AlignTypeEnum align_type;
-short size;
+uint32_t size;
 unsigned char abi_align;
 unsigned char pref_align;
 
@@ -213,7 +213,7 @@
   align_type = (*p == 'i' ? INTEGER_ALIGN :
 (*p == 'f' ? FLOAT_ALIGN :
  (*p == 'v' ? VECTOR_ALIGN : AGGREGATE_ALIGN)));
-  size = (short) atoi(++p);
+  size = (uint32_t) atoi(++p);
   abi_align = atoi(getToken(token, ":").c_str()) / 8;
   pref_align = atoi(getToken(token, ":").c_str()) / 8;
   if (pref_align == 0)
@@ -233,7 +233,7 @@
 
 void
 TargetData::setAlignment(AlignTypeEnum align_type, unsigned char abi_align,
- unsigned char pref_align, short bit_width) {
+ unsigned char pref_align, uint32_t bit_width) {
   for (unsigned i = 0, e = Alignments.size(); i != e; ++i) {
 if (Alignments[i].AlignType == align_type &&
 Alignments[i].TypeBitWidth == bit_width) {
@@ -250,10 +250,11 @@
 
 /// getAlignmentInfo - Return the alignment (either ABI if ABIInfo = true or 
 /// preferred if ABIInfo = false) the target wants for the specified datatype.
-unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType, short BitWidth,
-  bool ABIInfo) const {
+unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType, 
+  uint32_t BitWidth, bool ABIInfo) const {
   // Check to see if we have an exact match and remember the best match we see.
   int BestMatchIdx = -1;
+  int LargestInt = -1;
   for (unsigned i = 0, e = Alignments.size(); i != e; ++i) {
 if (Alignments[i].AlignType == AlignType &&
 Alignments[i].TypeBitWidth == BitWidth)
@@ -271,14 +272,30 @@
 Alignments[BestMatchIdx].TypeBitWidth < BitWidth)
   BestMatchIdx = i;
   }
+} else if (AlignType == INTEGER_ALIGN && 
+   Alignments[i].AlignType == INTEGER_ALIGN) {
+  // The "best match" for integers is the smallest size that is larger than
+  // the BitWidth requested.
+  if (Alignments[i].TypeBitWidth > BitWidth && (BestMatchIdx == -1 || 
+   Alignments[i].TypeBitWidth < Alignments[BestMatchIdx].TypeBitWidth))
+BestMatchIdx = i;
+  // However, if there isn't one that's larger, then we must use the
+  // largest one we have (see below)
+  if (LargestInt == -1 || 
+  Alignments[i].TypeBitWidth > Alignments[LargestInt].TypeBitWidth)
+LargestInt = i;
 }
-
-// FIXME: handle things like i37.
   }
 
+  // For integers, if we didn't find a best match, use the largest one found.
+  if (BestMatchIdx == -1)
+BestMatchIdx = LargestInt;
+
   // Okay, we didn't find an exact solution.  Fall back here depending on what
   // is being looked for.
   assert(BestMatchIdx != -1 && "Didn't find alignment info for this 
datatype!");
+
+  // Since we got a "best match" index, just return it.
   return ABIInfo ? Alignments[BestMatchIdx].ABIAlign
  : Alignments[BestMatchIdx].PrefAlign;
 }
@@ -407,8 +424,14 @@
   return 4;
 } else if (BitWidth <= 64) {
   return 8;
-} else
-  assert(0 && "Integer types > 64 bits not supported.");
+} else {
+  // The size of this > 64 bit type is chosen as a multiple of the
+  // preferred alignment of the largest "native" size the target supports. 
+  // We first obtain the the alignment info for 

Re: [llvm-commits] [llvm-gcc] Arbitrary Precition Integer Support

2007-02-19 Thread Chris Lattner

On Feb 19, 2007, at 12:37 PM, Reid Spencer wrote:

> Devang / Jim / Chris,
>
> The attached patch has been reviewed by Devang and provides the
> "bitwidth" attribute and 3 builtin functions for arbitrary precision
> integers (concat, bit select, part select). This is the same as the  
> last
> version except it has an additional check for a null pointer that
> produced a failure in bootstrap.  That problem is now gone and this
> patch passes the Integer test suite as well as MultiSource/Benchmarks.
>
> I would appreciate it if you could commit this one or indicate why it
> could not be committed.

Problems:

@@ -1741,6 +1756,10 @@
unsigned lang_flag_5 : 1;
unsigned lang_flag_6 : 1;
unsigned user_align : 1;
+  /* APPLE LOCAL begin LLVM bit accurate integer types - ras */
+  unsigned user_bitwidth : 1;
+  unsigned bitwidth : 23;
+  /* APPLE LOCAL end LLVM bit accurate integer types - ras */

This increases the size of tree_type by an extra word.  Can you find  
a place to store this that doesn't penalize the non-bitwidth-aware  
case (e.g. a hash table on the side)?


The changes around llvm_get_pseudo_builtin_index are quite invasive,  
disabling many places in the compiler.  I don't know that there is a  
better solution, but have you tried treating the builtins as if they  
were varargs?  Alternatively, why not lazily create specific builtins  
as you hit them.  For example if the user writes:

myint13 A, B;
...
   __builtin_bit_concat(A, B);

the CFE would synthesize "__builtin_bit_concat13", with i13  
arguments.  This seems like a simpler and more-local change than the  
various pieces you have now.

BTW, bsearch is totally overkill (i.e. much slower than a linear  
search) if you have an array of 3 entries to search.


+  if (Callee) {
+// Handle arbitrary precision integer bit manipulation builtins
+Value* Res = 0;
+Function* Func = 0;
+if (ConstantExpr* CE = dyn_cast(Callee)) {
+  if (CE->getOpcode() == Instruction::BitCast)
+Func = dyn_cast(CE->getOperand(0));
+} else
+  Func = dyn_cast(Callee);
+if (Func) {
+  switch (llvm_get_pseudo_builtin_index(Func->getName().c_str())) {
+default: assert(0 && "Unexpected pseudo-builtin index");

This significantly slows down codegen (by calling  
llvm_get_pseudo_builtin_index, which is implemented in terms of  
string compares) of every single direct call compiled.  This isn't  
acceptable.  Instead, do by-pointer comparisons (of decls), and only  
after you first see one of the builtins being used.

+  // Set the result type on the expression since it might be != i32.
+  llvm_set_type(TREE_TYPE(exp), Result->getType());

Why are you doing this?  Setting the type of an expression needs to  
be done in the FE, now at expansion to llvm time.


+  // FIXME: For some reason if we set the type of this expression,  
the type of
+  // "main" and all its variables become i1 too. This is a complete  
mystery. In
+  // the bit_concat.c test case, this function is called from a  
function that
+  // main calls. There's no way that "exp" refers to "main". How  
could it?
+  // ***BOGGLE***

I believe this is an artifact of the above: you're modifying the  
GLOBAL, SHARED, INT TYPE!  Don't do this.
Please figure out the right solution in the F.E.



+  /* The tree_type structure (tree.h) reserves 23 bits for the  
bitwidth field.
+   * Consequently we must ensure that the value provided fits within  
23 bits.
+   * The number 23 is an artifact of LLVM's implementation of arbitrary
+   * precision integer types as there were 23 bits left over in the  
Type class.
+   * (see include/llvm/Type.h). 2^23 > 8 million which should be  
sufficient
+   * for any foreseeable application.
+   */

The GCC F.E. should allow any bitwidth (i.e. up to 2^32), the GCC- 
 >LLVM converter should check for and reject anything greater than  
2^23 bits.

nitpick:

* markers like "- ras" (which I assume is you) shouldn't exist.

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


Re: [llvm-commits] [llvm-gcc] Arbitrary Precition Integer Support

2007-02-19 Thread Reid Spencer
On Mon, 2007-02-19 at 14:41 -0800, Chris Lattner wrote:
> On Feb 19, 2007, at 12:37 PM, Reid Spencer wrote:
> 
> > Devang / Jim / Chris,
> >
> > The attached patch has been reviewed by Devang and provides the
> > "bitwidth" attribute and 3 builtin functions for arbitrary precision
> > integers (concat, bit select, part select). This is the same as the  
> > last
> > version except it has an additional check for a null pointer that
> > produced a failure in bootstrap.  That problem is now gone and this
> > patch passes the Integer test suite as well as MultiSource/Benchmarks.
> >
> > I would appreciate it if you could commit this one or indicate why it
> > could not be committed.
> 
> Problems:
> 
> @@ -1741,6 +1756,10 @@
> unsigned lang_flag_5 : 1;
> unsigned lang_flag_6 : 1;
> unsigned user_align : 1;
> +  /* APPLE LOCAL begin LLVM bit accurate integer types - ras */
> +  unsigned user_bitwidth : 1;
> +  unsigned bitwidth : 23;
> +  /* APPLE LOCAL end LLVM bit accurate integer types - ras */
> 
> This increases the size of tree_type by an extra word.  Can you find  
> a place to store this that doesn't penalize the non-bitwidth-aware  
> case (e.g. a hash table on the side)?

No. Been down that road. Every attribute uses its own field, bitwidth is
no different. Given the huge size of these tree nodes, this isn't a huge
increment.  I understand the impact, but there's just no other way to do
it.  I tried using precision at one time but that just breaks 98% of the
gcc code.

> The changes around llvm_get_pseudo_builtin_index are quite invasive,  
> disabling many places in the compiler.  I don't know that there is a  
> better solution,

I don't like it either, but its either that or the gcc code gets nearly
totally rewritten (modes are useless, many assumptions about sizes of
things are useless, etc. etc.)

> but have you tried treating the builtins as if they  
> were varargs? 

that's how they are being treated.  I originally thought I could get
away with a varargs solution using regular builtins. Unfortunately,
there's nothing in C or GCC that allows the result of the function to be
"any bit width". So, the result type is i32 through gcc processing and
then fixed up by llvm-convert.cpp when it emits. Not great, but I can't
find another way to do this without re-writting 1/2 of gcc.

>  Alternatively, why not lazily create specific builtins  
> as you hit them.  For example if the user writes:
> 
> myint13 A, B;
> ...
>__builtin_bit_concat(A, B);
> 
> the CFE would synthesize "__builtin_bit_concat13", with i13  
> arguments.  This seems like a simpler and more-local change than the  
> various pieces you have now.

Because gcc just can't do that. You can't define builtin functions "on
the fly". They have to be in the builtins.def file, for a variety of
reasons. If I've missed something, please enlighten me, but I went down
this road too while trying to come up with a solution.

Furthermore, for the intended use case (chip design), there could be a
lot of different prototypes create (100s to 1000s).

> 
> BTW, bsearch is totally overkill (i.e. much slower than a linear  
> search) if you have an array of 3 entries to search.

There were originally 9, but we got rid of 6. There could be more in the
future. I'll know more about this in 2-3 weeks. I left it in as bsearch
to facilitate easy extension. If there isn't any more in the future,
I'll turn this into linear scan, but not yet.

> 
> +  if (Callee) {
> +// Handle arbitrary precision integer bit manipulation builtins
> +Value* Res = 0;
> +Function* Func = 0;
> +if (ConstantExpr* CE = dyn_cast(Callee)) {
> +  if (CE->getOpcode() == Instruction::BitCast)
> +Func = dyn_cast(CE->getOperand(0));
> +} else
> +  Func = dyn_cast(Callee);
> +if (Func) {
> +  switch (llvm_get_pseudo_builtin_index(Func->getName().c_str())) {
> +default: assert(0 && "Unexpected pseudo-builtin index");
> 
> This significantly slows down codegen (by calling  
> llvm_get_pseudo_builtin_index, which is implemented in terms of  
> string compares) of every single direct call compiled.  This isn't  
> acceptable.  Instead, do by-pointer comparisons (of decls), and only  
> after you first see one of the builtins being used.

There's no "decl" that corresponds to these pseudo-builtin functions,
just an identifier node.

> 
> +  // Set the result type on the expression since it might be != i32.
> +  llvm_set_type(TREE_TYPE(exp), Result->getType());
> 
> Why are you doing this?  Setting the type of an expression needs to  
> be done in the FE, now at expansion to llvm time.

How do you say in GCC tree parlance, "this type is any bit width and use
the actual bit width returned". Unfortunately, you can't. I don't have a
good solution for this. The problem is that the result gets
truncated/extended to what gcc thinks the expression is and gcc has no
way of dealing with integers > 64-bits (no applicable mode). Attempting
to mak

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

2007-02-19 Thread Reid Spencer


Changes in directory llvm/lib/Target:

TargetData.cpp updated: 1.102 -> 1.103
---
Log message:

Simplify some code by moving variable declarations into the only block that
uses them.


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

 TargetData.cpp |   18 ++
 1 files changed, 6 insertions(+), 12 deletions(-)


Index: llvm/lib/Target/TargetData.cpp
diff -u llvm/lib/Target/TargetData.cpp:1.102 
llvm/lib/Target/TargetData.cpp:1.103
--- llvm/lib/Target/TargetData.cpp:1.102Mon Feb 19 16:35:00 2007
+++ llvm/lib/Target/TargetData.cpp  Mon Feb 19 17:30:10 2007
@@ -184,14 +184,8 @@
   
   while (!temp.empty()) {
 std::string token = getToken(temp, "-");
-
 std::string arg0 = getToken(token, ":");
 const char *p = arg0.c_str();
-AlignTypeEnum align_type;
-uint32_t size;
-unsigned char abi_align;
-unsigned char pref_align;
-
 switch(*p) {
 case 'E':
   LittleEndian = false;
@@ -210,12 +204,12 @@
 case 'v':
 case 'f':
 case 'a': {
-  align_type = (*p == 'i' ? INTEGER_ALIGN :
-(*p == 'f' ? FLOAT_ALIGN :
- (*p == 'v' ? VECTOR_ALIGN : AGGREGATE_ALIGN)));
-  size = (uint32_t) atoi(++p);
-  abi_align = atoi(getToken(token, ":").c_str()) / 8;
-  pref_align = atoi(getToken(token, ":").c_str()) / 8;
+  AlignTypeEnum align_type = 
+(*p == 'i' ? INTEGER_ALIGN : (*p == 'f' ? FLOAT_ALIGN :
+   (*p == 'v' ? VECTOR_ALIGN : AGGREGATE_ALIGN)));
+  uint32_t size = (uint32_t) atoi(++p);
+  unsigned char abi_align = atoi(getToken(token, ":").c_str()) / 8;
+  unsigned char pref_align = atoi(getToken(token, ":").c_str()) / 8;
   if (pref_align == 0)
 pref_align = abi_align;
   setAlignment(align_type, abi_align, pref_align, size);



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


[llvm-commits] CVS: llvm/lib/Target/X86/X86InstrSSE.td

2007-02-19 Thread Evan Cheng


Changes in directory llvm/lib/Target/X86:

X86InstrSSE.td updated: 1.176 -> 1.177
---
Log message:

How the heck did I forget patterns for llvm.x86.sse2.cmp.sd?

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

 X86InstrSSE.td |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)


Index: llvm/lib/Target/X86/X86InstrSSE.td
diff -u llvm/lib/Target/X86/X86InstrSSE.td:1.176 
llvm/lib/Target/X86/X86InstrSSE.td:1.177
--- llvm/lib/Target/X86/X86InstrSSE.td:1.176Fri Jan  5 15:37:56 2007
+++ llvm/lib/Target/X86/X86InstrSSE.td  Mon Feb 19 18:39:09 2007
@@ -544,10 +544,14 @@
  (load addr:$src), imm:$cc))]>;
 def Int_CMPSDrr : SDI<0xC2, MRMSrcReg, 
   (ops VR128:$dst, VR128:$src1, VR128:$src, SSECC:$cc),
-  "cmp${cc}sd {$src, $dst|$dst, $src}", []>;
+  "cmp${cc}sd {$src, $dst|$dst, $src}",
+  [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
+ VR128:$src, imm:$cc))]>;
 def Int_CMPSDrm : SDI<0xC2, MRMSrcMem, 
   (ops VR128:$dst, VR128:$src1, f64mem:$src, SSECC:$cc),
-  "cmp${cc}sd {$src, $dst|$dst, $src}", []>;
+  "cmp${cc}sd {$src, $dst|$dst, $src}",
+  [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1,
+ (load addr:$src), imm:$cc))]>;
 }
 
 def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (ops VR128:$src1, VR128:$src2),



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


Re: [llvm-commits] [123995] Fix PR1170 and test/CFrontend/2007-02-16-VariableSizeStructArg.c

2007-02-19 Thread Duncan Sands
> @@ -108,7 +112,8 @@
>  tree Domain = TYPE_DOMAIN(type);
>  if (!Domain || !TYPE_MIN_VALUE(Domain) || !TYPE_MAX_VALUE(Domain))
>return 0;
> -if (TREE_CODE(TYPE_MIN_VALUE(Domain)) != INTEGER_CST ||
> +if (TREE_CODE(TYPE_SIZE(type)) != INTEGER_CST ||
> +TREE_CODE(TYPE_MIN_VALUE(Domain)) != INTEGER_CST ||
>  TREE_CODE(TYPE_MAX_VALUE(Domain)) != INTEGER_CST)
>return 0;
>  if (TREE_INT_CST_LOW(TYPE_MAX_VALUE(Domain)) !=

Is this bit of the patch actually needed?  I can see how it
might be an optimization, in that you detect early if the
array component has non-constant size, and avoid a call to
isSingleElementStructOrArray.  But is it really needed for
correctness?

Thanks,

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


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

2007-02-19 Thread Evan Cheng


Changes in directory llvm/lib/CodeGen:

VirtRegMap.cpp updated: 1.95 -> 1.96
---
Log message:

Dead code.

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

 VirtRegMap.cpp |6 --
 1 files changed, 6 deletions(-)


Index: llvm/lib/CodeGen/VirtRegMap.cpp
diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.95 
llvm/lib/CodeGen/VirtRegMap.cpp:1.96
--- llvm/lib/CodeGen/VirtRegMap.cpp:1.95Thu Feb  8 00:04:54 2007
+++ llvm/lib/CodeGen/VirtRegMap.cpp Mon Feb 19 19:29:10 2007
@@ -233,12 +233,6 @@
 }
   private:
 void RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM);
-void ClobberPhysReg(unsigned PR, std::map &SpillSlots,
-std::multimap &PhysRegs);
-void ClobberPhysRegOnly(unsigned PR, std::map &SpillSlots,
-std::multimap &PhysRegs);
-void ModifyStackSlot(int Slot, std::map &SpillSlots,
- std::multimap &PhysRegs);
   };
 }
 



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


[llvm-commits] CVS: llvm/lib/VMCore/Type.cpp

2007-02-19 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Type.cpp updated: 1.174 -> 1.175
---
Log message:

remove dead method


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

 Type.cpp |   10 +-
 1 files changed, 1 insertion(+), 9 deletions(-)


Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.174 llvm/lib/VMCore/Type.cpp:1.175
--- llvm/lib/VMCore/Type.cpp:1.174  Wed Feb 14 21:39:18 2007
+++ llvm/lib/VMCore/Type.cppMon Feb 19 23:29:47 2007
@@ -783,15 +783,7 @@
 print("add");
   }
   
-  void clear(std::vector &DerivedTypes) {
-for (typename std::map::iterator I = Map.begin(),
- E = Map.end(); I != E; ++I)
-  DerivedTypes.push_back(I->second.get());
-TypesByHash.clear();
-Map.clear();
-  }
-
- /// RefineAbstractType - This method is called after we have merged a type
+  /// RefineAbstractType - This method is called after we have merged a type
   /// with another one.  We must now either merge the type away with
   /// some other type or reinstall it in the map with it's new configuration.
   void RefineAbstractType(TypeClass *Ty, const DerivedType *OldType,



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


[llvm-commits] CVS: llvm/include/llvm/LinkAllPasses.h

2007-02-19 Thread Chris Lattner


Changes in directory llvm/include/llvm:

LinkAllPasses.h updated: 1.9 -> 1.10
---
Log message:

remove some passes


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

 LinkAllPasses.h |2 --
 1 files changed, 2 deletions(-)


Index: llvm/include/llvm/LinkAllPasses.h
diff -u llvm/include/llvm/LinkAllPasses.h:1.9 
llvm/include/llvm/LinkAllPasses.h:1.10
--- llvm/include/llvm/LinkAllPasses.h:1.9   Mon Feb  5 14:47:19 2007
+++ llvm/include/llvm/LinkAllPasses.h   Mon Feb 19 23:31:04 2007
@@ -61,7 +61,6 @@
   (void) llvm::createDeadStoreEliminationPass();
   (void) llvm::createDeadTypeEliminationPass();
   (void) llvm::createEdgeProfilerPass();
-  (void) llvm::createEmitFunctionTablePass();
   (void) llvm::createFunctionInliningPass();
   (void) llvm::createFunctionProfilerPass();
   (void) llvm::createGCSEPass();
@@ -103,7 +102,6 @@
   (void) llvm::createStripSymbolsPass();
   (void) llvm::createTailCallEliminationPass();
   (void) llvm::createTailDuplicationPass();
-  (void) llvm::createTraceBasicBlockPass();
   (void) llvm::createUnifyFunctionExitNodesPass();
   (void) llvm::createCondPropagationPass();
   (void) llvm::createNullProfilerRSPass();



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


[llvm-commits] CVS: llvm/include/llvm/Transforms/Instrumentation.h

2007-02-19 Thread Chris Lattner


Changes in directory llvm/include/llvm/Transforms:

Instrumentation.h updated: 1.11 -> 1.12
---
Log message:

remove some dead passes and stuff specific to the reoptimizer.


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

 Instrumentation.h |   21 +++--
 1 files changed, 3 insertions(+), 18 deletions(-)


Index: llvm/include/llvm/Transforms/Instrumentation.h
diff -u llvm/include/llvm/Transforms/Instrumentation.h:1.11 
llvm/include/llvm/Transforms/Instrumentation.h:1.12
--- llvm/include/llvm/Transforms/Instrumentation.h:1.11 Sun Jan  7 12:12:13 2007
+++ llvm/include/llvm/Transforms/Instrumentation.h  Mon Feb 19 23:31:35 2007
@@ -19,30 +19,15 @@
 class ModulePass;
 class FunctionPass;
 
-// Reoptimizer support pass: add instrumentation calls to back-edges of loops
-FunctionPass *createLoopInstrumentationPass ();
-
-// Reoptimizer support pass: combine multiple back-edges w/ same target into 
one
-FunctionPass *createCombineBranchesPass();
-
-// Reoptimizer support pass: emit table of global functions
-ModulePass *createEmitFunctionTablePass ();
-
-// Reoptimizer support pass: insert function profiling instrumentation
+// Insert function profiling instrumentation
 ModulePass *createFunctionProfilerPass();
 
-// Reoptimizer support pass: insert block profiling instrumentation
+// Insert block profiling instrumentation
 ModulePass *createBlockProfilerPass();
 
-// Reoptimizer support pass: insert edge profiling instrumentation
+// Insert edge profiling instrumentation
 ModulePass *createEdgeProfilerPass();
 
-// Reoptimizer support pass: insert basic block tracing instrumentation
-ModulePass *createTraceBasicBlockPass();
-
-// Reoptimizer support pass: insert counting of execute paths instrumentation
-FunctionPass *createProfilePathsPass();
-
 // Random Sampling Profiling Framework
 ModulePass* createNullProfilerRSPass();
 FunctionPass* createRSProfilingPass();



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


[llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp TraceBasicBlocks.cpp

2007-02-19 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Instrumentation:

EmitFunctions.cpp (r1.29) removed
TraceBasicBlocks.cpp (r1.23) removed
---
Log message:

remove reoptimizer-specific passes


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

 0 files changed



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


[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

2007-02-19 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.214 -> 1.215
---
Log message:

simplify some code that was not llvm_shutdown safe


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

 Constants.cpp |   41 +
 1 files changed, 5 insertions(+), 36 deletions(-)


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.214 llvm/lib/VMCore/Constants.cpp:1.215
--- llvm/lib/VMCore/Constants.cpp:1.214 Mon Feb 19 14:01:23 2007
+++ llvm/lib/VMCore/Constants.cpp   Mon Feb 19 23:46:39 2007
@@ -89,45 +89,14 @@
   }
 }
 
-
 // Static constructor to create a '0' constant of arbitrary type...
 Constant *Constant::getNullValue(const Type *Ty) {
   switch (Ty->getTypeID()) {
-  case Type::IntegerTyID: {
-const IntegerType *ITy = dyn_cast(Ty);
-switch (ITy->getBitWidth()) {
-case 1: {
-  static Constant *NullBool = ConstantInt::get(Ty, false);
-  return NullBool;
-} 
-case 8: {
-  static Constant *NullInt8 = ConstantInt::get(Ty, 0);
-  return NullInt8;
-} 
-case 16: {
-  static Constant *NullInt16 = ConstantInt::get(Ty, 0);
-  return NullInt16;
-} 
-case 32: {
-  static Constant *NullInt32 = ConstantInt::get(Ty, 0);
-  return NullInt32;
-} 
-case 64: {
-  static Constant *NullInt64 = ConstantInt::get(Ty, 0);
-  return NullInt64;
-}
-default:
-  return ConstantInt::get(Ty, 0);
-}
-  }
-  case Type::FloatTyID: {
-static Constant *NullFloat = ConstantFP::get(Type::FloatTy, 0);
-return NullFloat;
-  }
-  case Type::DoubleTyID: {
-static Constant *NullDouble = ConstantFP::get(Type::DoubleTy, 0);
-return NullDouble;
-  }
+  case Type::IntegerTyID:
+return ConstantInt::get(Ty, 0);
+  case Type::FloatTyID:
+  case Type::DoubleTyID:
+return ConstantFP::get(Ty, 0.0);
   case Type::PointerTyID:
 return ConstantPointerNull::get(cast(Ty));
   case Type::StructTyID:



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


[llvm-commits] CVS: llvm/include/llvm/Constants.h

2007-02-19 Thread Chris Lattner


Changes in directory llvm/include/llvm:

Constants.h updated: 1.128 -> 1.129
---
Log message:

Clean up the internals of the ConstantInt machinery


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

 Constants.h |   10 --
 1 files changed, 4 insertions(+), 6 deletions(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.128 llvm/include/llvm/Constants.h:1.129
--- llvm/include/llvm/Constants.h:1.128 Mon Feb 19 14:01:23 2007
+++ llvm/include/llvm/Constants.h   Mon Feb 19 23:55:46 2007
@@ -44,10 +44,8 @@
   uint64_t Val;
 protected:
   ConstantInt(const ConstantInt &);  // DO NOT IMPLEMENT
-  ConstantInt(const Type *Ty, uint64_t V);
-  ConstantInt(const Type *Ty, int64_t V);
-  ConstantInt(bool V);
-  friend struct ConstantCreator;
+  ConstantInt(const IntegerType *Ty, uint64_t V);
+  friend struct ConstantCreator;
 public:
   /// Return the constant as a 64-bit unsigned integer value after it
   /// has been zero extended as appropriate for the type of this constant.
@@ -77,12 +75,12 @@
   static inline ConstantInt *getTrue() {
 static ConstantInt *T = 0;
 if (T) return T;
-return T = new ConstantInt(true);
+return T = new ConstantInt(Type::Int1Ty, 1);
   }
   static inline ConstantInt *getFalse() {
 static ConstantInt *F = 0;
 if (F) return F;
-return F = new ConstantInt(false);
+return F = new ConstantInt(Type::Int1Ty, 0);
   }
 
   /// Return a ConstantInt with the specified value for the specified type. The



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


[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

2007-02-19 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.215 -> 1.216
---
Log message:

Clean up the internals of the ConstantInt machinery


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

 Constants.cpp |   15 ++-
 1 files changed, 6 insertions(+), 9 deletions(-)


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.215 llvm/lib/VMCore/Constants.cpp:1.216
--- llvm/lib/VMCore/Constants.cpp:1.215 Mon Feb 19 23:46:39 2007
+++ llvm/lib/VMCore/Constants.cpp   Mon Feb 19 23:55:46 2007
@@ -140,12 +140,8 @@
 
//===--===//
 // Normal Constructors
 
-ConstantInt::ConstantInt(bool V) 
-  : Constant(Type::Int1Ty, ConstantIntVal, 0, 0), Val(uint64_t(V)) {
-}
-
-ConstantInt::ConstantInt(const Type *Ty, uint64_t V)
-  : Constant(Ty, ConstantIntVal, 0, 0), Val(Ty == Type::Int1Ty ? bool(V) : V) {
+ConstantInt::ConstantInt(const IntegerType *Ty, uint64_t V)
+  : Constant(Ty, ConstantIntVal, 0, 0), Val(V) {
 }
 
 ConstantFP::ConstantFP(const Type *Ty, double V)
@@ -802,7 +798,7 @@
 
 // ConstantInt::get() implementations...
 //
-static ManagedStatic > IntConstants;
+static ManagedStatic 
>IntConstants;
 
 // Get a ConstantInt from an int64_t. Note here that we canoncialize the value
 // to a uint64_t value that has been zero extended down to the size of the
@@ -810,12 +806,13 @@
 // just return the stored value while getSExtValue has to convert back to sign
 // extended. getZExtValue is more common in LLVM than getSExtValue().
 ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) {
-  if (Ty == Type::Int1Ty) 
+  const IntegerType *ITy = cast(Ty);
+  if (Ty == Type::Int1Ty)
 if (V & 1)
   return getTrue();
 else
   return getFalse();
-  return IntConstants->getOrCreate(Ty, V & 
cast(Ty)->getBitMask());
+  return IntConstants->getOrCreate(ITy, V & ITy->getBitMask());
 }
 
 // ConstantFP::get() implementation...



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


[llvm-commits] CVS: llvm/include/llvm/Support/ManagedStatic.h

2007-02-19 Thread Chris Lattner


Changes in directory llvm/include/llvm/Support:

ManagedStatic.h updated: 1.3 -> 1.4
---
Log message:

add a way to register an arbitrary cleanup function.


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

 ManagedStatic.h |6 ++
 1 files changed, 6 insertions(+)


Index: llvm/include/llvm/Support/ManagedStatic.h
diff -u llvm/include/llvm/Support/ManagedStatic.h:1.3 
llvm/include/llvm/Support/ManagedStatic.h:1.4
--- llvm/include/llvm/Support/ManagedStatic.h:1.3   Sat Feb 10 13:54:24 2007
+++ llvm/include/llvm/Support/ManagedStatic.h   Tue Feb 20 00:08:37 2007
@@ -73,6 +73,12 @@
   }
 };
 
+template
+class ManagedCleanup : public ManagedStaticBase {
+public:
+  void Register() { RegisterManagedStatic(0, CleanupFn); }
+};
+
 
 /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
 void llvm_shutdown();



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


[llvm-commits] CVS: llvm/include/llvm/Constants.h

2007-02-19 Thread Chris Lattner


Changes in directory llvm/include/llvm:

Constants.h updated: 1.129 -> 1.130
---
Log message:

Make ConstantInt::getTrue/getFalse be llvm_shutdown safe.


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

 Constants.h |   14 --
 1 files changed, 8 insertions(+), 6 deletions(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.129 llvm/include/llvm/Constants.h:1.130
--- llvm/include/llvm/Constants.h:1.129 Mon Feb 19 23:55:46 2007
+++ llvm/include/llvm/Constants.h   Tue Feb 20 00:11:36 2007
@@ -40,6 +40,7 @@
 /// represents both boolean and integral constants.
 /// @brief Class for constant integers.
 class ConstantInt : public Constant {
+  static ConstantInt *TheTrueVal, *TheFalseVal;
 protected:
   uint64_t Val;
 protected:
@@ -73,14 +74,12 @@
 
   /// getTrue/getFalse - Return the singleton true/false values.
   static inline ConstantInt *getTrue() {
-static ConstantInt *T = 0;
-if (T) return T;
-return T = new ConstantInt(Type::Int1Ty, 1);
+if (TheTrueVal) return TheTrueVal;
+return CreateTrueFalseVals(true);
   }
   static inline ConstantInt *getFalse() {
-static ConstantInt *F = 0;
-if (F) return F;
-return F = new ConstantInt(Type::Int1Ty, 0);
+if (TheFalseVal) return TheFalseVal;
+return CreateTrueFalseVals(false);
   }
 
   /// Return a ConstantInt with the specified value for the specified type. The
@@ -165,6 +164,9 @@
   static bool classof(const Value *V) {
 return V->getValueType() == ConstantIntVal;
   }
+  static void ResetTrueFalse() { TheTrueVal = TheFalseVal = 0; }
+private:
+  static ConstantInt *CreateTrueFalseVals(bool WhichOne);
 };
 
 



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


[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

2007-02-19 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.216 -> 1.217
---
Log message:

Make ConstantInt::getTrue/getFalse be llvm_shutdown safe.


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

 Constants.cpp |   29 -
 1 files changed, 24 insertions(+), 5 deletions(-)


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.216 llvm/lib/VMCore/Constants.cpp:1.217
--- llvm/lib/VMCore/Constants.cpp:1.216 Mon Feb 19 23:55:46 2007
+++ llvm/lib/VMCore/Constants.cpp   Tue Feb 20 00:11:36 2007
@@ -800,6 +800,7 @@
 //
 static ManagedStatic 
>IntConstants;
 
+
 // Get a ConstantInt from an int64_t. Note here that we canoncialize the value
 // to a uint64_t value that has been zero extended down to the size of the
 // integer type of the ConstantInt. This allows the getZExtValue method to 
@@ -807,14 +808,32 @@
 // extended. getZExtValue is more common in LLVM than getSExtValue().
 ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) {
   const IntegerType *ITy = cast(Ty);
-  if (Ty == Type::Int1Ty)
-if (V & 1)
-  return getTrue();
-else
-  return getFalse();
   return IntConstants->getOrCreate(ITy, V & ITy->getBitMask());
 }
 
+ConstantInt *ConstantInt::TheTrueVal = 0;
+ConstantInt *ConstantInt::TheFalseVal = 0;
+
+void CleanupTrueFalse(void *) {
+  ConstantInt::ResetTrueFalse();
+}
+
+static ManagedCleanup TrueFalseCleanup;
+
+ConstantInt *ConstantInt::CreateTrueFalseVals(bool WhichOne) {
+  assert(TheTrueVal == 0 && TheFalseVal == 0);
+  TheTrueVal  = get(Type::Int1Ty, 1);
+  TheFalseVal = get(Type::Int1Ty, 0);
+  
+  // Ensure that llvm_shutdown nulls out TheTrueVal/TheFalseVal.
+  TrueFalseCleanup.Register();
+  
+  return WhichOne ? TheTrueVal : TheFalseVal;
+}
+
+
+
+
 // ConstantFP::get() implementation...
 //
 namespace llvm {



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


[llvm-commits] CVS: llvm/lib/Support/ManagedStatic.cpp

2007-02-19 Thread Chris Lattner


Changes in directory llvm/lib/Support:

ManagedStatic.cpp updated: 1.2 -> 1.3
---
Log message:

Not all managedstatics need object pointers.


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

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


Index: llvm/lib/Support/ManagedStatic.cpp
diff -u llvm/lib/Support/ManagedStatic.cpp:1.2 
llvm/lib/Support/ManagedStatic.cpp:1.3
--- llvm/lib/Support/ManagedStatic.cpp:1.2  Fri Sep 29 13:43:14 2006
+++ llvm/lib/Support/ManagedStatic.cpp  Tue Feb 20 00:18:57 2007
@@ -30,7 +30,7 @@
 }
 
 void ManagedStaticBase::destroy() const {
-  assert(Ptr && DeleterFn && "ManagedStatic not initialized correctly!");
+  assert(DeleterFn && "ManagedStatic not initialized correctly!");
   assert(StaticList == this &&
  "Not destroyed in reverse order of construction?");
   // Unlink from list.



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


[llvm-commits] CVS: llvm/include/llvm/Constants.h

2007-02-19 Thread Chris Lattner


Changes in directory llvm/include/llvm:

Constants.h updated: 1.130 -> 1.131
---
Log message:

cleanup ConstantInt to use a single DenseMap for uniquing instead of the
heavy-weight ValueMap class.  This reduces mem usage bc reading kc++ by 29K, 
even though it only creates 2955 constant ints!


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

 Constants.h |5 +
 1 files changed, 1 insertion(+), 4 deletions(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.130 llvm/include/llvm/Constants.h:1.131
--- llvm/include/llvm/Constants.h:1.130 Tue Feb 20 00:11:36 2007
+++ llvm/include/llvm/Constants.h   Tue Feb 20 00:39:57 2007
@@ -41,12 +41,9 @@
 /// @brief Class for constant integers.
 class ConstantInt : public Constant {
   static ConstantInt *TheTrueVal, *TheFalseVal;
-protected:
-  uint64_t Val;
-protected:
   ConstantInt(const ConstantInt &);  // DO NOT IMPLEMENT
   ConstantInt(const IntegerType *Ty, uint64_t V);
-  friend struct ConstantCreator;
+  uint64_t Val;
 public:
   /// Return the constant as a 64-bit unsigned integer value after it
   /// has been zero extended as appropriate for the type of this constant.



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


[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

2007-02-19 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.217 -> 1.218
---
Log message:

cleanup ConstantInt to use a single DenseMap for uniquing instead of the
heavy-weight ValueMap class.  This reduces mem usage bc reading kc++ by 29K, 
even though it only creates 2955 constant ints!


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

 Constants.cpp |  113 --
 1 files changed, 63 insertions(+), 50 deletions(-)


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.217 llvm/lib/VMCore/Constants.cpp:1.218
--- llvm/lib/VMCore/Constants.cpp:1.217 Tue Feb 20 00:11:36 2007
+++ llvm/lib/VMCore/Constants.cpp   Tue Feb 20 00:39:57 2007
@@ -22,6 +22,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
 #include 
 #include 
@@ -134,16 +135,74 @@
 
 
 
//===--===//
-//ConstantXXX Classes
-//===--===//
-
+//ConstantInt
 
//===--===//
-// Normal Constructors
 
 ConstantInt::ConstantInt(const IntegerType *Ty, uint64_t V)
   : Constant(Ty, ConstantIntVal, 0, 0), Val(V) {
 }
 
+ConstantInt *ConstantInt::TheTrueVal = 0;
+ConstantInt *ConstantInt::TheFalseVal = 0;
+
+namespace llvm {
+  void CleanupTrueFalse(void *) {
+ConstantInt::ResetTrueFalse();
+  }
+}
+
+static ManagedCleanup TrueFalseCleanup;
+
+ConstantInt *ConstantInt::CreateTrueFalseVals(bool WhichOne) {
+  assert(TheTrueVal == 0 && TheFalseVal == 0);
+  TheTrueVal  = get(Type::Int1Ty, 1);
+  TheFalseVal = get(Type::Int1Ty, 0);
+  
+  // Ensure that llvm_shutdown nulls out TheTrueVal/TheFalseVal.
+  TrueFalseCleanup.Register();
+  
+  return WhichOne ? TheTrueVal : TheFalseVal;
+}
+
+
+// ConstantInt::get() implementations...
+//
+// Provide DenseMapKeyInfo for all pointers.
+namespace {
+  struct DenseMapIntegerKeyInfo {
+typedef std::pair KeyTy;
+static inline KeyTy getEmptyKey() { return KeyTy(0, 0); }
+static inline KeyTy getTombstoneKey() { return KeyTy(1, 0); }
+static unsigned getHashValue(const KeyTy &Key) {
+  return DenseMapKeyInfo::getHashValue(Key.second) ^ Key.first;
+}
+static bool isPod() { return true; }
+  };
+}
+
+
+typedef DenseMap IntMapTy;
+static ManagedStatic IntConstants;
+
+// Get a ConstantInt from an int64_t. Note here that we canoncialize the value
+// to a uint64_t value that has been zero extended down to the size of the
+// integer type of the ConstantInt. This allows the getZExtValue method to 
+// just return the stored value while getSExtValue has to convert back to sign
+// extended. getZExtValue is more common in LLVM than getSExtValue().
+ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) {
+  const IntegerType *ITy = cast(Ty);
+  V &= ITy->getBitMask();
+  ConstantInt *&Slot = (*IntConstants)[std::make_pair(uint64_t(V), ITy)];
+  if (Slot) return Slot;
+  return Slot = new ConstantInt(ITy, V);
+}
+
+//===--===//
+//ConstantXXX Classes
+//===--===//
+
+
 ConstantFP::ConstantFP(const Type *Ty, double V)
   : Constant(Ty, ConstantFPVal, 0, 0) {
   assert(isValueValidForType(Ty, V) && "Value too large for type!");
@@ -598,15 +657,6 @@
 ///
 AbstractTypeMapTy AbstractTypeMap;
 
-  private:
-void clear(std::vector &Constants) {
-  for(typename MapTy::iterator I = Map.begin(); I != Map.end(); ++I)
-Constants.push_back(I->second);
-  Map.clear();
-  AbstractTypeMap.clear();
-  InverseMap.clear();
-}
-
   public:
 typename MapTy::iterator map_end() { return Map.end(); }
 
@@ -796,43 +846,6 @@
 }
 
 
-// ConstantInt::get() implementations...
-//
-static ManagedStatic 
>IntConstants;
-
-
-// Get a ConstantInt from an int64_t. Note here that we canoncialize the value
-// to a uint64_t value that has been zero extended down to the size of the
-// integer type of the ConstantInt. This allows the getZExtValue method to 
-// just return the stored value while getSExtValue has to convert back to sign
-// extended. getZExtValue is more common in LLVM than getSExtValue().
-ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) {
-  const IntegerType *ITy = cast(Ty);
-  return IntConstants->getOrCreate(ITy, V & ITy->getBitMask());
-}
-
-ConstantInt *ConstantInt::TheTrueVal = 0;
-ConstantInt *ConstantInt::TheFalseVal = 0;
-
-void CleanupTrueFalse(void *) {
-  ConstantInt::ResetTrueFalse();
-}
-
-static ManagedCleanup TrueFalseCleanup;
-
-ConstantInt *ConstantInt::CreateTrueFalseVals(bool WhichOne)

[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

2007-02-19 Thread Chris Lattner


Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.218 -> 1.219
---
Log message:

switch ConstantFP's from ValueMap to DenseMap, which is much faster to query
and is more memory efficient.



---
Diffs of the changes:  (+59 -51)

 Constants.cpp |  110 +++---
 1 files changed, 59 insertions(+), 51 deletions(-)


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.218 llvm/lib/VMCore/Constants.cpp:1.219
--- llvm/lib/VMCore/Constants.cpp:1.218 Tue Feb 20 00:39:57 2007
+++ llvm/lib/VMCore/Constants.cpp   Tue Feb 20 01:17:17 2007
@@ -165,12 +165,9 @@
 }
 
 
-// ConstantInt::get() implementations...
-//
-// Provide DenseMapKeyInfo for all pointers.
 namespace {
-  struct DenseMapIntegerKeyInfo {
-typedef std::pair KeyTy;
+  struct DenseMapInt64KeyInfo {
+typedef std::pair KeyTy;
 static inline KeyTy getEmptyKey() { return KeyTy(0, 0); }
 static inline KeyTy getTombstoneKey() { return KeyTy(1, 0); }
 static unsigned getHashValue(const KeyTy &Key) {
@@ -181,8 +178,8 @@
 }
 
 
-typedef DenseMap IntMapTy;
+typedef DenseMap IntMapTy;
 static ManagedStatic IntConstants;
 
 // Get a ConstantInt from an int64_t. Note here that we canoncialize the value
@@ -193,22 +190,74 @@
 ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) {
   const IntegerType *ITy = cast(Ty);
   V &= ITy->getBitMask();
-  ConstantInt *&Slot = (*IntConstants)[std::make_pair(uint64_t(V), ITy)];
+  ConstantInt *&Slot = (*IntConstants)[std::make_pair(uint64_t(V), Ty)];
   if (Slot) return Slot;
   return Slot = new ConstantInt(ITy, V);
 }
 
 
//===--===//
-//ConstantXXX Classes
+//ConstantFP
 
//===--===//
 
 
 ConstantFP::ConstantFP(const Type *Ty, double V)
   : Constant(Ty, ConstantFPVal, 0, 0) {
-  assert(isValueValidForType(Ty, V) && "Value too large for type!");
   Val = V;
 }
 
+bool ConstantFP::isNullValue() const {
+  return DoubleToBits(Val) == 0;
+}
+
+bool ConstantFP::isExactlyValue(double V) const {
+  return DoubleToBits(V) == DoubleToBits(Val);
+}
+
+
+namespace {
+  struct DenseMapInt32KeyInfo {
+typedef std::pair KeyTy;
+static inline KeyTy getEmptyKey() { return KeyTy(0, 0); }
+static inline KeyTy getTombstoneKey() { return KeyTy(1, 0); }
+static unsigned getHashValue(const KeyTy &Key) {
+  return DenseMapKeyInfo::getHashValue(Key.second) ^ Key.first;
+}
+static bool isPod() { return true; }
+  };
+}
+
+// ConstantFP::get() implementation...
+//
+typedef DenseMap FloatMapTy;
+typedef DenseMap DoubleMapTy;
+
+static ManagedStatic FloatConstants;
+static ManagedStatic DoubleConstants;
+
+ConstantFP *ConstantFP::get(const Type *Ty, double V) {
+  if (Ty == Type::FloatTy) {
+uint32_t IntVal = FloatToBits((float)V);
+
+ConstantFP *&Slot = (*FloatConstants)[std::make_pair(IntVal, Ty)];
+if (Slot) return Slot;
+return Slot = new ConstantFP(Ty, (float)V);
+  } else {
+assert(Ty == Type::DoubleTy);
+uint64_t IntVal = DoubleToBits(V);
+ConstantFP *&Slot = (*DoubleConstants)[std::make_pair(IntVal, Ty)];
+if (Slot) return Slot;
+return Slot = new ConstantFP(Ty, (float)V);
+  }
+}
+
+
+//===--===//
+//ConstantXXX Classes
+//===--===//
+
+
 ConstantArray::ConstantArray(const ArrayType *T,
  const std::vector &V)
   : Constant(T, ConstantArrayVal, new Use[V.size()], V.size()) {
@@ -847,47 +896,6 @@
 
 
 
-// ConstantFP::get() implementation...
-//
-namespace llvm {
-  template<>
-  struct ConstantCreator {
-static ConstantFP *create(const Type *Ty, uint64_t V) {
-  assert(Ty == Type::DoubleTy);
-  return new ConstantFP(Ty, BitsToDouble(V));
-}
-  };
-  template<>
-  struct ConstantCreator {
-static ConstantFP *create(const Type *Ty, uint32_t V) {
-  assert(Ty == Type::FloatTy);
-  return new ConstantFP(Ty, BitsToFloat(V));
-}
-  };
-}
-
-static ManagedStatic > DoubleConstants;
-static ManagedStatic > FloatConstants;
-
-bool ConstantFP::isNullValue() const {
-  return DoubleToBits(Val) == 0;
-}
-
-bool ConstantFP::isExactlyValue(double V) const {
-  return DoubleToBits(V) == DoubleToBits(Val);
-}
-
-
-ConstantFP *ConstantFP::get(const Type *Ty, double V) {
-  if (Ty == Type::FloatTy) {
-// Force the value through memory to normalize it.
-return FloatConstants->getOrCreate(Ty, FloatToBits(V));
-  } else {
-assert(Ty == Type::DoubleTy);
-return DoubleConstants->getOrCreate(Ty, DoubleToBits(V));
-  }
-}
-
 // ConstantAggregateZero::get() implementation...
 //
 namespace llvm {




[llvm-commits] CVS: llvm/include/llvm/Constants.h

2007-02-19 Thread Chris Lattner


Changes in directory llvm/include/llvm:

Constants.h updated: 1.131 -> 1.132
---
Log message:

eliminate some dead friends.


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

 Constants.h |2 --
 1 files changed, 2 deletions(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.131 llvm/include/llvm/Constants.h:1.132
--- llvm/include/llvm/Constants.h:1.131 Tue Feb 20 00:39:57 2007
+++ llvm/include/llvm/Constants.h   Tue Feb 20 01:18:01 2007
@@ -172,8 +172,6 @@
 ///
 class ConstantFP : public Constant {
   double Val;
-  friend struct ConstantCreator;
-  friend struct ConstantCreator;
   ConstantFP(const ConstantFP &);  // DO NOT IMPLEMENT
 protected:
   ConstantFP(const Type *Ty, double V);



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