[llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp Heuristic.h
Chris Lattner
lattner at cs.uiuc.edu
Wed Mar 2 18:24:52 PST 2005
Changes in directory llvm-poolalloc/lib/PoolAllocate:
Heuristic.cpp updated: 1.5 -> 1.6
Heuristic.h updated: 1.3 -> 1.4
---
Log message:
Expose a new method, make sure to realize that uint64 and pointers are 64-bit
aligned on 64-bit targets.
---
Diffs of the changes: (+19 -3)
Heuristic.cpp | 17 ++++++++++++++---
Heuristic.h | 5 +++++
2 files changed, 19 insertions(+), 3 deletions(-)
Index: llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp
diff -u llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp:1.5 llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp:1.6
--- llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp:1.5 Sun Jan 30 17:51:25 2005
+++ llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp Wed Mar 2 20:24:36 2005
@@ -61,8 +61,16 @@
/// Wants8ByteAlignment - FIXME: this is a complete hack for X86 right now.
static bool Wants8ByteAlignment(const Type *Ty, unsigned Offs,
const TargetData &TD) {
- if (Ty == Type::DoubleTy && (Offs & 7) == 0)
- return true;
+ if ((Offs & 7) == 0) {
+ // Doubles always want to be 8-byte aligned.
+ if (Ty == Type::DoubleTy) return true;
+
+ // If we are on a 64-bit system, we want to align 8-byte integers and
+ // pointers.
+ if (TD.getTypeAlignment(Ty) == 8)
+ return true;
+ }
+
if (Ty->isPrimitiveType() || isa<PointerType>(Ty))
return false;
@@ -82,7 +90,10 @@
return false;
}
-
+unsigned Heuristic::getRecommendedAlignment(const Type *Ty,
+ const TargetData &TD) {
+ return Wants8ByteAlignment(Ty, 0, TD);
+}
/// getRecommendedAlignment - Return the recommended object alignment for this
/// DSNode.
Index: llvm-poolalloc/lib/PoolAllocate/Heuristic.h
diff -u llvm-poolalloc/lib/PoolAllocate/Heuristic.h:1.3 llvm-poolalloc/lib/PoolAllocate/Heuristic.h:1.4
--- llvm-poolalloc/lib/PoolAllocate/Heuristic.h:1.3 Sun Jan 30 17:51:25 2005
+++ llvm-poolalloc/lib/PoolAllocate/Heuristic.h Wed Mar 2 20:24:36 2005
@@ -25,6 +25,9 @@
class DSGraph;
class DSNode;
class PoolAllocate;
+ class TargetData;
+ class Type;
+
namespace PA {
class Heuristic {
protected:
@@ -91,6 +94,8 @@
/// this DSNode.
///
static unsigned getRecommendedAlignment(const DSNode *N);
+ static unsigned getRecommendedAlignment(const Type *Ty,
+ const TargetData &TD);
/// create - This static ctor creates the heuristic, based on the command
/// line argument to choose the heuristic.
More information about the llvm-commits
mailing list