From sabre at nondot.org Mon Mar 5 01:53:14 2007
From: sabre at nondot.org (Chris Lattner)
Date: Mon, 5 Mar 2007 01:53:14 -0600
Subject: [llvm-commits] CVS:
llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
Message-ID: <200703050753.l257rEb4006841@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Transforms/Scalar:
ScalarReplAggregates.cpp updated: 1.75 -> 1.76
---
Log message:
This is the first major step of implementing PR1226: http://llvm.org/PR1226 . We now successfully
scalarrepl things down to elements, but mem2reg can't promote elements that
are memset/memcpy'd. Until then, the code is disabled "0 &&".
---
Diffs of the changes: (+156 -5)
ScalarReplAggregates.cpp | 161 +++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 156 insertions(+), 5 deletions(-)
Index: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
diff -u llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.75 llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.76
--- llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.75 Wed Feb 14 21:39:18 2007
+++ llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp Mon Mar 5 01:52:57 2007
@@ -24,8 +24,9 @@
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
-#include "llvm/Pass.h"
#include "llvm/Instructions.h"
+#include "llvm/IntrinsicInst.h"
+#include "llvm/Pass.h"
#include "llvm/Analysis/Dominators.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Transforms/Utils/PromoteMemToReg.h"
@@ -60,11 +61,15 @@
private:
int isSafeElementUse(Value *Ptr);
- int isSafeUseOfAllocation(Instruction *User);
+ int isSafeUseOfAllocation(Instruction *User, AllocationInst *AI);
+ bool isSafeUseOfBitCastedAllocation(BitCastInst *User, AllocationInst *AI);
int isSafeAllocaToScalarRepl(AllocationInst *AI);
void CanonicalizeAllocaUsers(AllocationInst *AI);
AllocaInst *AddNewAlloca(Function &F, const Type *Ty, AllocationInst *Base);
+ void RewriteBitCastUserOfAlloca(BitCastInst *BCInst, AllocationInst *AI,
+ SmallVector &NewElts);
+
const Type *CanConvertToScalar(Value *V, bool &IsNotTrivial);
void ConvertToScalar(AllocationInst *AI, const Type *Ty);
void ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, unsigned Offset);
@@ -180,7 +185,7 @@
DOUT << "Found inst to xform: " << *AI;
Changed = true;
- std::vector ElementAllocas;
+ SmallVector ElementAllocas;
if (const StructType *ST = dyn_cast(AI->getAllocatedType())) {
ElementAllocas.reserve(ST->getNumContainedTypes());
for (unsigned i = 0, e = ST->getNumContainedTypes(); i != e; ++i) {
@@ -207,6 +212,11 @@
//
while (!AI->use_empty()) {
Instruction *User = cast(AI->use_back());
+ if (BitCastInst *BCInst = dyn_cast(User)) {
+ RewriteBitCastUserOfAlloca(BCInst, AI, ElementAllocas);
+ continue;
+ }
+
GetElementPtrInst *GEPI = cast(User);
// We now know that the GEP is of the form: GEP , 0,
unsigned Idx =
@@ -291,7 +301,9 @@
/// isSafeUseOfAllocation - Check to see if this user is an allowed use for an
/// aggregate allocation.
///
-int SROA::isSafeUseOfAllocation(Instruction *User) {
+int SROA::isSafeUseOfAllocation(Instruction *User, AllocationInst *AI) {
+ if (BitCastInst *C = dyn_cast(User))
+ return 0 && (isSafeUseOfBitCastedAllocation(C, AI) ? 3 : 0);
if (!isa(User)) return 0;
GetElementPtrInst *GEPI = cast(User);
@@ -352,6 +364,145 @@
return isSafeElementUse(GEPI);
}
+/// isSafeUseOfBitCastedAllocation - Return true if all users of this bitcast
+/// are
+bool SROA::isSafeUseOfBitCastedAllocation(BitCastInst *BC, AllocationInst *AI) {
+ for (Value::use_iterator UI = BC->use_begin(), E = BC->use_end();
+ UI != E; ++UI) {
+ if (BitCastInst *BCU = dyn_cast(UI)) {
+ if (!isSafeUseOfBitCastedAllocation(BCU, AI))
+ return false;
+ } else if (MemIntrinsic *MI = dyn_cast(UI)) {
+ // If not constant length, give up.
+ ConstantInt *Length = dyn_cast(MI->getLength());
+ if (!Length) return false;
+
+ // If not the whole aggregate, give up.
+ const TargetData &TD = getAnalysis();
+ if (Length->getZExtValue() !=
+ TD.getTypeSize(AI->getType()->getElementType()))
+ return false;
+
+ // We only know about memcpy/memset/memmove.
+ if (!isa(MI) && !isa(MI) &&
+ !isa(MI))
+ return false;
+ // Otherwise, we can transform it.
+ } else {
+ return false;
+ }
+ }
+ return true;
+}
+
+/// RewriteBitCastUserOfAlloca - BCInst (transitively) casts AI. Transform
+/// users of the cast to use the new values instead.
+void SROA::RewriteBitCastUserOfAlloca(BitCastInst *BCInst, AllocationInst *AI,
+ SmallVector &NewElts) {
+ Constant *Zero = Constant::getNullValue(Type::Int32Ty);
+ const TargetData &TD = getAnalysis();
+ while (!BCInst->use_empty()) {
+ if (BitCastInst *BCU = dyn_cast(BCInst->use_back())) {
+ RewriteBitCastUserOfAlloca(BCU, AI, NewElts);
+ continue;
+ }
+
+ // Otherwise, must be memcpy/memmove/memset of the entire aggregate. Split
+ // into one per element.
+ MemIntrinsic *MI = cast(BCInst->use_back());
+
+ // If this is a memcpy/memmove, construct the other pointer as the
+ // appropriate type.
+ Value *OtherPtr = 0;
+ if (MemCpyInst *MCI = dyn_cast(MI)) {
+ if (BCInst == MCI->getRawDest())
+ OtherPtr = MCI->getRawSource();
+ else {
+ assert(BCInst == MCI->getRawSource());
+ OtherPtr = MCI->getRawDest();
+ }
+ } else if (MemMoveInst *MMI = dyn_cast(MI)) {
+ if (BCInst == MMI->getRawDest())
+ OtherPtr = MMI->getRawSource();
+ else {
+ assert(BCInst == MMI->getRawSource());
+ OtherPtr = MMI->getRawDest();
+ }
+ }
+
+ // If there is an other pointer, we want to convert it to the same pointer
+ // type as AI has, so we can GEP through it.
+ if (OtherPtr) {
+ // It is likely that OtherPtr is a bitcast, if so, remove it.
+ if (BitCastInst *BC = dyn_cast(OtherPtr))
+ OtherPtr = BC->getOperand(0);
+ if (ConstantExpr *BCE = dyn_cast(OtherPtr))
+ if (BCE->getOpcode() == Instruction::BitCast)
+ OtherPtr = BCE->getOperand(0);
+
+ // If the pointer is not the right type, insert a bitcast to the right
+ // type.
+ if (OtherPtr->getType() != AI->getType())
+ OtherPtr = new BitCastInst(OtherPtr, AI->getType(), OtherPtr->getName(),
+ MI);
+ }
+
+ // Process each element of the aggregate.
+ Value *TheFn = MI->getOperand(0);
+ const Type *BytePtrTy = MI->getRawDest()->getType();
+ bool SROADest = MI->getRawDest() == BCInst;
+
+ for (unsigned i = 0, e = NewElts.size(); i != e; ++i) {
+ // If this is a memcpy/memmove, emit a GEP of the other element address.
+ Value *OtherElt = 0;
+ if (OtherPtr) {
+ OtherElt = new GetElementPtrInst(OtherPtr, Zero,
+ ConstantInt::get(Type::Int32Ty, i),
+ OtherPtr->getNameStr()+"."+utostr(i),
+ MI);
+ if (OtherElt->getType() != BytePtrTy)
+ OtherElt = new BitCastInst(OtherElt, BytePtrTy,OtherElt->getNameStr(),
+ MI);
+ }
+
+ Value *EltPtr = NewElts[i];
+ unsigned EltSize =
+ TD.getTypeSize(cast(EltPtr->getType())->getElementType());
+
+ // Cast the element pointer to BytePtrTy.
+ if (EltPtr->getType() != BytePtrTy)
+ EltPtr = new BitCastInst(EltPtr, BytePtrTy, EltPtr->getNameStr(), MI);
+
+
+ // Finally, insert the meminst for this element.
+ if (isa(MI) || isa(MI)) {
+ Value *Ops[] = {
+ SROADest ? EltPtr : OtherElt, // Dest ptr
+ SROADest ? OtherElt : EltPtr, // Src ptr
+ ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size
+ Zero // Align
+ };
+ new CallInst(TheFn, Ops, 4, "", MI);
+ } else if (isa(MI)) {
+ Value *Ops[] = {
+ EltPtr, MI->getOperand(2), // Dest, Value,
+ ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size
+ Zero // Align
+ };
+ new CallInst(TheFn, Ops, 4, "", MI);
+ }
+ }
+
+ // Finally, MI is now dead, as we've modified its actions to occur on all of
+ // the elements of the aggregate.
+ MI->eraseFromParent();
+ }
+
+ // The cast is dead, remove it.
+ BCInst->eraseFromParent();
+}
+
+
/// isSafeStructAllocaToScalarRepl - Check to see if the specified allocation of
/// an aggregate can be broken down into elements. Return 0 if not, 3 if safe,
/// or 1 if safe after canonicalization has been performed.
@@ -363,7 +514,7 @@
int isSafe = 3;
for (Value::use_iterator I = AI->use_begin(), E = AI->use_end();
I != E; ++I) {
- isSafe &= isSafeUseOfAllocation(cast(*I));
+ isSafe &= isSafeUseOfAllocation(cast(*I), AI);
if (isSafe == 0) {
DOUT << "Cannot transform: " << *AI << " due to user: " << **I;
return 0;
From llvm at cs.uiuc.edu Mon Mar 5 02:18:28 2007
From: llvm at cs.uiuc.edu (LLVM)
Date: Mon, 5 Mar 2007 02:18:28 -0600
Subject: [llvm-commits] CVS: llvm/test/AdaFrontend/
Message-ID: <200703050818.l258IS5I014935@zion.cs.uiuc.edu>
Changes in directory llvm/test/AdaFrontend:
---
Log message:
Directory /var/cvs/llvm/llvm/test/AdaFrontend added to the repository
---
Diffs of the changes: (+0 -0)
0 files changed
From baldrick at free.fr Mon Mar 5 02:21:05 2007
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 5 Mar 2007 02:21:05 -0600
Subject: [llvm-commits] CVS: llvm/test/AdaFrontend/non_lvalue.adb
non_lvalue.ads
Message-ID: <200703050821.l258L5T9016325@zion.cs.uiuc.edu>
Changes in directory llvm/test/AdaFrontend:
non_lvalue.adb added (r1.1)
non_lvalue.ads added (r1.1)
---
Log message:
New directory for Ada testcases. Test handling of NON_LVALUE_EXPR.
---
Diffs of the changes: (+18 -0)
non_lvalue.adb | 7 +++++++
non_lvalue.ads | 11 +++++++++++
2 files changed, 18 insertions(+)
Index: llvm/test/AdaFrontend/non_lvalue.adb
diff -c /dev/null llvm/test/AdaFrontend/non_lvalue.adb:1.1
*** /dev/null Mon Mar 5 02:20:58 2007
--- llvm/test/AdaFrontend/non_lvalue.adb Mon Mar 5 02:20:48 2007
***************
*** 0 ****
--- 1,7 ----
+ -- RUN: %llvmgcc -c %s -o /dev/null
+ package body Non_LValue is
+ function A (Y : U) return String is
+ begin
+ return Y.X.B;
+ end;
+ end;
Index: llvm/test/AdaFrontend/non_lvalue.ads
diff -c /dev/null llvm/test/AdaFrontend/non_lvalue.ads:1.1
*** /dev/null Mon Mar 5 02:21:05 2007
--- llvm/test/AdaFrontend/non_lvalue.ads Mon Mar 5 02:20:48 2007
***************
*** 0 ****
--- 1,11 ----
+ package Non_LValue is
+ type T (Length : Natural) is record
+ A : String (1 .. Length);
+ B : String (1 .. Length);
+ end record;
+ type T_Ptr is access all T;
+ type U is record
+ X : T_Ptr;
+ end record;
+ function A (Y : U) return String;
+ end;
From baldrick at free.fr Mon Mar 5 02:34:52 2007
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 5 Mar 2007 02:34:52 -0600
Subject: [llvm-commits] CVS: llvm/test/AdaFrontend/fat_fields.adb
fat_fields.ads
Message-ID: <200703050834.l258YqID016585@zion.cs.uiuc.edu>
Changes in directory llvm/test/AdaFrontend:
fat_fields.adb added (r1.1)
fat_fields.ads added (r1.1)
---
Log message:
Testcase causing the Ada front-end to create bogus constructor fields.
---
Diffs of the changes: (+16 -0)
fat_fields.adb | 10 ++++++++++
fat_fields.ads | 6 ++++++
2 files changed, 16 insertions(+)
Index: llvm/test/AdaFrontend/fat_fields.adb
diff -c /dev/null llvm/test/AdaFrontend/fat_fields.adb:1.1
*** /dev/null Mon Mar 5 02:34:45 2007
--- llvm/test/AdaFrontend/fat_fields.adb Mon Mar 5 02:34:35 2007
***************
*** 0 ****
--- 1,10 ----
+ -- RUN: %llvmgcc -c %s -o /dev/null
+ -- RUN: %llvmgcc -c %s -O2 -o /dev/null
+ package body Fat_Fields is
+ procedure Proc is
+ begin
+ if P = null then
+ null;
+ end if;
+ end;
+ end;
Index: llvm/test/AdaFrontend/fat_fields.ads
diff -c /dev/null llvm/test/AdaFrontend/fat_fields.ads:1.1
*** /dev/null Mon Mar 5 02:34:52 2007
--- llvm/test/AdaFrontend/fat_fields.ads Mon Mar 5 02:34:35 2007
***************
*** 0 ****
--- 1,6 ----
+ package Fat_Fields is
+ pragma Elaborate_Body;
+ type A is array (Positive range <>) of Boolean;
+ type A_Ptr is access A;
+ P : A_Ptr := null;
+ end;
From baldrick at free.fr Mon Mar 5 02:40:15 2007
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 5 Mar 2007 02:40:15 -0600
Subject: [llvm-commits] CVS: llvm/test/AdaFrontend/emit_var.ads
Message-ID: <200703050840.l258eFm7016717@zion.cs.uiuc.edu>
Changes in directory llvm/test/AdaFrontend:
emit_var.ads added (r1.1)
---
Log message:
Testcase for handling of static constant declarations in EmitBIND_EXPR.
---
Diffs of the changes: (+5 -0)
emit_var.ads | 5 +++++
1 files changed, 5 insertions(+)
Index: llvm/test/AdaFrontend/emit_var.ads
diff -c /dev/null llvm/test/AdaFrontend/emit_var.ads:1.1
*** /dev/null Mon Mar 5 02:40:08 2007
--- llvm/test/AdaFrontend/emit_var.ads Mon Mar 5 02:39:58 2007
***************
*** 0 ****
--- 1,5 ----
+ -- RUN: %llvmgcc -c %s -o /dev/null
+ with Ada.Finalization;
+ package Emit_Var is
+ type Search_Type is new Ada.Finalization.Controlled with null record;
+ end;
From nicolas.geoffray at lip6.fr Mon Mar 5 02:58:53 2007
From: nicolas.geoffray at lip6.fr (Nicolas Geoffray)
Date: Mon, 05 Mar 2007 09:58:53 +0100
Subject: [llvm-commits] llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
In-Reply-To:
References: <45E46A95.5000500@lip6.fr>
<061382E6-AE05-4A71-899F-098B91E14DA3@apple.com>
<45E7F5A0.2000604@lip6.fr>
<45E98679.2000908@lip6.fr>
Message-ID: <45EBDBCD.7070509@lip6.fr>
Chris Lattner wrote:
>
> Ok, so it's not related to NoFramePointerElim? If that's the case,
> you should just have Macho and ELF return different sets of callee
> saved regs.
>
No, that's not the issue.
Let me rephrase why I need this patch :)
In PowerPC, whether it's on ELF ABI or MachO, R31 is a normal,
callee-saved register. With one exception: when it is used as a frame
pointer. When it is used as a frame pointer, both MachO and ELF remove
R31 from the callee-saved registers set.
There are two different ways to use R31 as a frame pointer: 1) with an
alloca when the stack is growing in a non-compilation deterministic
size, or 2) when NoFramePointerElim is set.
1) When there is an alloca that modifies the size of the stack,
compilation goes through the LowerDYNAMIC_STACKALLOC method. In this
method, you find the code:
// Find out what the fix offset of the frame pointer save area.
int FPOffset = PPCFrameInfo::getFramePointerSaveOffset(IsPPC64,
isMachoABI);
// Allocate the frame index for frame pointer save area.
FPSI = MF.getFrameInfo()->CreateFixedObject(IsPPC64? 8 : 4, FPOffset);
// Save the result.
FI->setFramePointerSaveIndex(FPSI);
With this code you give the info to the FrameInfo object that the frame
pointer offset is at FPOffset. Therefore, this offset will never be used
as an offset for another purpose. And this is _really_ important for
ELF, because the frame pointer, R31, is saved in the callee-saved area.
With this code, you are sure that no callee-saved register will be
spilled to R31's offset.
2) When NoFramePointerElim is set, R31 is always used as a frame
pointer. However, the stack size may be decided at a compilation time,
therefore the compilation process never goes through the
LowerDYNAMIC_STACKALLOC. And LowerDYNAMIC_STACKALLOC is the only method
that saves the frame pointer offset in the frame info.
The bug arrives here: the frame info object never had the info that R31
is saved in the callee-saved area. Therefore, it may allocate the frame
pointer offset for spilling an other register. This was not an issue for
the MachO ABI because the frame pointer offset in MachO is not in the
callee-saved area.
With this patch I give the info to the FrameInfo object, before the
callee-saved scan, that R31 is saved in the callee-saved area. Thus I am
sure that no register will be spilled in R31's offset.
I hope it's clearer now (maybe it already was, but I was getting
confused by your replies :))
Best,
Nicolas
From baldrick at free.fr Mon Mar 5 03:21:28 2007
From: baldrick at free.fr (Duncan Sands)
Date: Mon, 5 Mar 2007 03:21:28 -0600
Subject: [llvm-commits] CVS: llvm/CREDITS.TXT
Message-ID: <200703050921.l259LS3B017799@zion.cs.uiuc.edu>
Changes in directory llvm:
CREDITS.TXT updated: 1.70 -> 1.71
---
Log message:
Credit self for Ada front-end.
---
Diffs of the changes: (+4 -0)
CREDITS.TXT | 4 ++++
1 files changed, 4 insertions(+)
Index: llvm/CREDITS.TXT
diff -u llvm/CREDITS.TXT:1.70 llvm/CREDITS.TXT:1.71
--- llvm/CREDITS.TXT:1.70 Tue Feb 27 04:44:42 2007
+++ llvm/CREDITS.TXT Mon Mar 5 03:21:11 2007
@@ -169,6 +169,10 @@
E: ghost at cs.msu.su
D: Made inst_iterator behave like a proper iterator, LowerConstantExprs pass
+N: Duncan Sands
+E: baldrick at free.fr
+D: Ada front-end
+
N: Ruchira Sasanka
E: sasanka at uiuc.edu
D: Graph coloring register allocator for the Sparc64 backend
From zhousheng00 at gmail.com Mon Mar 5 10:43:26 2007
From: zhousheng00 at gmail.com (Zhou Sheng)
Date: Mon, 5 Mar 2007 10:43:26 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h
Message-ID: <200703051643.l25GhQb1026554@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm/ADT:
APInt.h updated: 1.39 -> 1.40
---
Log message:
Correct the calculation in APInt::logBase2().
---
Diffs of the changes: (+1 -1)
APInt.h | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
Index: llvm/include/llvm/ADT/APInt.h
diff -u llvm/include/llvm/ADT/APInt.h:1.39 llvm/include/llvm/ADT/APInt.h:1.40
--- llvm/include/llvm/ADT/APInt.h:1.39 Sat Mar 3 02:34:02 2007
+++ llvm/include/llvm/ADT/APInt.h Mon Mar 5 10:42:58 2007
@@ -697,7 +697,7 @@
/// @returns the floor log base 2 of this APInt.
inline uint32_t logBase2() const {
- return getNumWords() * APINT_BITS_PER_WORD - 1 - countLeadingZeros();
+ return BitWidth - 1 - countLeadingZeros();
}
/// @brief Converts this APInt to a double value.
From jeffc at jolt-lang.org Mon Mar 5 11:22:50 2007
From: jeffc at jolt-lang.org (Jeff Cohen)
Date: Mon, 5 Mar 2007 11:22:50 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/ADT/SmallVector.h
Message-ID: <200703051722.l25HMo9s027266@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm/ADT:
SmallVector.h updated: 1.26 -> 1.27
---
Log message:
The hack won't work on VS 2005, and it might not be needed anyway.
---
Diffs of the changes: (+5 -1)
SmallVector.h | 6 +++++-
1 files changed, 5 insertions(+), 1 deletion(-)
Index: llvm/include/llvm/ADT/SmallVector.h
diff -u llvm/include/llvm/ADT/SmallVector.h:1.26 llvm/include/llvm/ADT/SmallVector.h:1.27
--- llvm/include/llvm/ADT/SmallVector.h:1.26 Sun Mar 4 18:46:22 2007
+++ llvm/include/llvm/ADT/SmallVector.h Mon Mar 5 11:22:33 2007
@@ -20,10 +20,10 @@
#ifdef _MSC_VER
namespace std {
+#if _MSC_VER <= 1310
// Work around flawed VC++ implementation of std::uninitialized_copy. Define
// additional overloads so that elements with pointer types are recognized as
// scalars and not objects, causing bizarre type conversion errors.
- // FIXME: this hack may or may not be correct for Visual Studio 2005.
template
inline _Scalar_ptr_iterator_tag _Ptr_cat(T1 **, T2 **) {
_Scalar_ptr_iterator_tag _Cat;
@@ -35,6 +35,10 @@
_Scalar_ptr_iterator_tag _Cat;
return _Cat;
}
+#else
+// FIXME: It is not clear if the problem is fixed in VS 2005. What is clear
+// is that the above hack won't work if it wasn't fixed.
+#endif
}
#endif
From lauro.venancio at gmail.com Mon Mar 5 12:00:15 2007
From: lauro.venancio at gmail.com (Lauro Ramos Venancio)
Date: Mon, 5 Mar 2007 12:00:15 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp
Message-ID: <200703051800.l25I0FLK027935@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/ARM:
ARMTargetAsmInfo.cpp updated: 1.11 -> 1.12
---
Log message:
Use init_array/fini_array sections for static contructors/destructors when the ABI is AAPCS.
Fix SingleSource/Regression/C/ConstructorDestructorAttributes test on arm-linux-gnueabi.
---
Diffs of the changes: (+7 -2)
ARMTargetAsmInfo.cpp | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
Index: llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp
diff -u llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.11 llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.12
--- llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp:1.11 Thu Feb 1 15:43:53 2007
+++ llvm/lib/Target/ARM/ARMTargetAsmInfo.cpp Mon Mar 5 11:59:58 2007
@@ -58,8 +58,13 @@
} else {
PrivateGlobalPrefix = ".L";
WeakRefDirective = "\t.weak\t";
- StaticCtorsSection = "\t.section .ctors,\"aw\",%progbits";
- StaticDtorsSection = "\t.section .dtors,\"aw\",%progbits";
+ if (Subtarget->isAAPCS_ABI()) {
+ StaticCtorsSection = "\t.section .init_array,\"aw\",%init_array";
+ StaticDtorsSection = "\t.section .fini_array,\"aw\",%fini_array";
+ } else {
+ StaticCtorsSection = "\t.section .ctors,\"aw\",%progbits";
+ StaticDtorsSection = "\t.section .dtors,\"aw\",%progbits";
+ }
}
ZeroDirective = "\t.space\t";
From lauro.venancio at gmail.com Mon Mar 5 12:00:17 2007
From: lauro.venancio at gmail.com (Lauro Ramos Venancio)
Date: Mon, 5 Mar 2007 12:00:17 -0600
Subject: [llvm-commits] CVS: llvm/test/CodeGen/ARM/ctors_dtors.ll
Message-ID: <200703051800.l25I0HQ5027940@zion.cs.uiuc.edu>
Changes in directory llvm/test/CodeGen/ARM:
ctors_dtors.ll updated: 1.2 -> 1.3
---
Log message:
Use init_array/fini_array sections for static contructors/destructors when the ABI is AAPCS.
Fix SingleSource/Regression/C/ConstructorDestructorAttributes test on arm-linux-gnueabi.
---
Diffs of the changes: (+4 -2)
ctors_dtors.ll | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
Index: llvm/test/CodeGen/ARM/ctors_dtors.ll
diff -u llvm/test/CodeGen/ARM/ctors_dtors.ll:1.2 llvm/test/CodeGen/ARM/ctors_dtors.ll:1.3
--- llvm/test/CodeGen/ARM/ctors_dtors.ll:1.2 Fri Jan 19 03:20:23 2007
+++ llvm/test/CodeGen/ARM/ctors_dtors.ll Mon Mar 5 11:59:58 2007
@@ -1,8 +1,10 @@
; RUN: llvm-upgrade < %s | llvm-as | llc -march=arm &&
; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-apple-darwin | grep '\.mod_init_func' &&
; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-apple-darwin | grep '\.mod_term_func' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-linux | grep '\.section \.ctors,"aw",.progbits' &&
-; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-linux | grep '\.section \.dtors,"aw",.progbits'
+; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-linux-gnu | grep '\.section \.ctors,"aw",.progbits' &&
+; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-linux-gnu | grep '\.section \.dtors,"aw",.progbits' &&
+; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-linux-gnueabi | grep '\.section \.init_array,"aw",.init_array' &&
+; RUN: llvm-upgrade < %s | llvm-as | llc -mtriple=arm-linux-gnueabi | grep '\.section \.fini_array,"aw",.fini_array'
%llvm.global_ctors = appending global [1 x { int, void ()* }] [ { int, void ()* } { int 65535, void ()* %__mf_init } ] ; <[1 x { int, void ()* }]*> [#uses=0]
%llvm.global_dtors = appending global [1 x { int, void ()* }] [ { int, void ()* } { int 65535, void ()* %__mf_fini } ] ; <[1 x { int, void ()* }]*> [#uses=0]
From dpatel at apple.com Mon Mar 5 12:21:08 2007
From: dpatel at apple.com (Devang Patel)
Date: Mon, 5 Mar 2007 12:21:08 -0600
Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp
Message-ID: <200703051821.l25IL8Ye028298@zion.cs.uiuc.edu>
Changes in directory llvm/lib/VMCore:
PassManager.cpp updated: 1.139 -> 1.140
---
Log message:
Account for time consumed by releaseMemory() properly.
---
Diffs of the changes: (+2 -2)
PassManager.cpp | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
Index: llvm/lib/VMCore/PassManager.cpp
diff -u llvm/lib/VMCore/PassManager.cpp:1.139 llvm/lib/VMCore/PassManager.cpp:1.140
--- llvm/lib/VMCore/PassManager.cpp:1.139 Sun Mar 4 18:00:42 2007
+++ llvm/lib/VMCore/PassManager.cpp Mon Mar 5 12:20:51 2007
@@ -564,9 +564,9 @@
std::string Msg1 = " Freeing Pass '";
dumpPassInfo(*I, Msg1, Msg);
- if (TheTimeInfo) TheTimeInfo->passStarted(P);
+ if (TheTimeInfo) TheTimeInfo->passStarted(*I);
(*I)->releaseMemory();
- if (TheTimeInfo) TheTimeInfo->passEnded(P);
+ if (TheTimeInfo) TheTimeInfo->passEnded(*I);
std::map::iterator Pos =
AvailableAnalysis.find((*I)->getPassInfo());
From dpatel at apple.com Mon Mar 5 14:01:51 2007
From: dpatel at apple.com (Devang Patel)
Date: Mon, 5 Mar 2007 14:01:51 -0600
Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp
Message-ID: <200703052001.l25K1ppM030129@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Analysis/IPA:
CallGraphSCCPass.cpp updated: 1.19 -> 1.20
---
Log message:
Avoid constructing std::strings unless pass debugging is ON.
---
Diffs of the changes: (+5 -10)
CallGraphSCCPass.cpp | 15 +++++----------
1 files changed, 5 insertions(+), 10 deletions(-)
Index: llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp
diff -u llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp:1.19 llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp:1.20
--- llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp:1.19 Tue Feb 27 09:00:39 2007
+++ llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp Mon Mar 5 14:01:30 2007
@@ -77,9 +77,6 @@
CallGraph &CG = getAnalysis();
bool Changed = doInitialization(CG);
- std::string Msg1 = "Executing Pass '";
- std::string Msg3 = "' Made Modification '";
-
// Walk SCC
for (scc_iterator I = scc_begin(&CG), E = scc_end(&CG);
I != E; ++I) {
@@ -91,8 +88,7 @@
AnalysisUsage AnUsage;
P->getAnalysisUsage(AnUsage);
- std::string Msg2 = "' on Call Graph ...\n'";
- dumpPassInfo(P, Msg1, Msg2);
+ dumpPassInfo(P, EXECUTION_MSG, ON_CG_MSG, "");
dumpAnalysisSetInfo("Required", P, AnUsage.getRequiredSet());
initializeAnalysisImpl(P);
@@ -109,21 +105,20 @@
for (unsigned i = 0, e = SCC.size(); i != e; ++i) {
Function *F = SCC[i]->getFunction();
if (F) {
- std::string Msg4 = "' on Function '" + F->getName() + "'...\n";
- dumpPassInfo(P, Msg1, Msg4);
- Changed |= FPP->runOnFunction(*F);
+ dumpPassInfo(P, EXECUTION_MSG, ON_FUNCTION_MSG, F->getName());
+ Changed |= FPP->runOnFunction(*F);
}
}
}
StopPassTimer(P);
if (Changed)
- dumpPassInfo(P, Msg3, Msg2);
+ dumpPassInfo(P, MODIFICATION_MSG, ON_CG_MSG, "");
dumpAnalysisSetInfo("Preserved", P, AnUsage.getPreservedSet());
removeNotPreservedAnalysis(P);
recordAvailableAnalysis(P);
- removeDeadPasses(P, Msg2);
+ removeDeadPasses(P, "", ON_CG_MSG);
}
}
Changed |= doFinalization(CG);
From dpatel at apple.com Mon Mar 5 14:01:52 2007
From: dpatel at apple.com (Devang Patel)
Date: Mon, 5 Mar 2007 14:01:52 -0600
Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoopPass.cpp
Message-ID: <200703052001.l25K1qum030134@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Analysis:
LoopPass.cpp updated: 1.8 -> 1.9
---
Log message:
Avoid constructing std::strings unless pass debugging is ON.
---
Diffs of the changes: (+3 -7)
LoopPass.cpp | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
Index: llvm/lib/Analysis/LoopPass.cpp
diff -u llvm/lib/Analysis/LoopPass.cpp:1.8 llvm/lib/Analysis/LoopPass.cpp:1.9
--- llvm/lib/Analysis/LoopPass.cpp:1.8 Fri Feb 23 12:05:55 2007
+++ llvm/lib/Analysis/LoopPass.cpp Mon Mar 5 14:01:30 2007
@@ -91,9 +91,6 @@
for (LoopInfo::iterator I = LI.begin(), E = LI.end(); I != E; ++I)
addLoopIntoQueue(*I, LQ);
- std::string Msg1 = "Executing Pass '";
- std::string Msg3 = "' Made Modification '";
-
// Walk Loops
while (!LQ->empty()) {
@@ -108,8 +105,7 @@
AnalysisUsage AnUsage;
P->getAnalysisUsage(AnUsage);
- std::string Msg2 = "' on Loop ...\n'";
- dumpPassInfo(P, Msg1, Msg2);
+ dumpPassInfo(P, EXECUTION_MSG, ON_LOOP_MSG, "");
dumpAnalysisSetInfo("Required", P, AnUsage.getRequiredSet());
initializeAnalysisImpl(P);
@@ -121,12 +117,12 @@
StopPassTimer(P);
if (Changed)
- dumpPassInfo(P, Msg3, Msg2);
+ dumpPassInfo(P, MODIFICATION_MSG, ON_LOOP_MSG, "");
dumpAnalysisSetInfo("Preserved", P, AnUsage.getPreservedSet());
removeNotPreservedAnalysis(P);
recordAvailableAnalysis(P);
- removeDeadPasses(P, Msg2);
+ removeDeadPasses(P, "", ON_LOOP_MSG);
if (skipThisLoop)
// Do not run other passes on this loop.
From dpatel at apple.com Mon Mar 5 14:01:57 2007
From: dpatel at apple.com (Devang Patel)
Date: Mon, 5 Mar 2007 14:01:57 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/PassManagers.h
Message-ID: <200703052001.l25K1vId030143@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm:
PassManagers.h updated: 1.10 -> 1.11
---
Log message:
Avoid constructing std::strings unless pass debugging is ON.
---
Diffs of the changes: (+15 -2)
PassManagers.h | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
Index: llvm/include/llvm/PassManagers.h
diff -u llvm/include/llvm/PassManagers.h:1.10 llvm/include/llvm/PassManagers.h:1.11
--- llvm/include/llvm/PassManagers.h:1.10 Tue Feb 27 09:00:39 2007
+++ llvm/include/llvm/PassManagers.h Mon Mar 5 14:01:30 2007
@@ -93,6 +93,18 @@
TLM_Pass // PassManager
};
+// enums for debugging strings
+enum PassDebuggingString {
+ EXECUTION_MSG, // "Executing Pass '"
+ MODIFICATION_MSG, // "' Made Modification '"
+ FREEING_MSG, // " Freeing Pass '"
+ ON_BASICBLOCK_MSG, // "' on BasicBlock '" + PassName + "'...\n"
+ ON_FUNCTION_MSG, // "' on Function '" + FunctionName + "'...\n"
+ ON_MODULE_MSG, // "' on Module '" + ModuleName + "'...\n"
+ ON_LOOP_MSG, // " 'on Loop ...\n'"
+ ON_CG_MSG // "' on Call Graph ...\n'"
+};
+
//===----------------------------------------------------------------------===//
// PMTopLevelManager
//
@@ -202,7 +214,7 @@
void removeNotPreservedAnalysis(Pass *P);
/// Remove dead passes
- void removeDeadPasses(Pass *P, std::string &Msg);
+ void removeDeadPasses(Pass *P, std::string Msg, enum PassDebuggingString);
/// Add pass P into the PassVector. Update
/// AvailableAnalysis appropriately if ProcessAnalysis is true.
@@ -238,7 +250,8 @@
// Print routines used by debug-pass
void dumpLastUses(Pass *P, unsigned Offset) const;
void dumpPassArguments() const;
- void dumpPassInfo(Pass *P, std::string &Msg1, std::string &Msg2) const;
+ void dumpPassInfo(Pass *P, enum PassDebuggingString S1,
+ enum PassDebuggingString S2, std::string Msg);
void dumpAnalysisSetInfo(const char *Msg, Pass *P,
const std::vector &Set) const;
From dpatel at apple.com Mon Mar 5 14:01:57 2007
From: dpatel at apple.com (Devang Patel)
Date: Mon, 5 Mar 2007 14:01:57 -0600
Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp
Message-ID: <200703052001.l25K1vac030140@zion.cs.uiuc.edu>
Changes in directory llvm/lib/VMCore:
PassManager.cpp updated: 1.140 -> 1.141
---
Log message:
Avoid constructing std::strings unless pass debugging is ON.
---
Diffs of the changes: (+52 -32)
PassManager.cpp | 84 ++++++++++++++++++++++++++++++++++----------------------
1 files changed, 52 insertions(+), 32 deletions(-)
Index: llvm/lib/VMCore/PassManager.cpp
diff -u llvm/lib/VMCore/PassManager.cpp:1.140 llvm/lib/VMCore/PassManager.cpp:1.141
--- llvm/lib/VMCore/PassManager.cpp:1.140 Mon Mar 5 12:20:51 2007
+++ llvm/lib/VMCore/PassManager.cpp Mon Mar 5 14:01:30 2007
@@ -553,7 +553,8 @@
}
/// Remove analysis passes that are not used any longer
-void PMDataManager::removeDeadPasses(Pass *P, std::string &Msg) {
+void PMDataManager::removeDeadPasses(Pass *P, std::string Msg,
+ enum PassDebuggingString DBG_STR) {
std::vector DeadPasses;
TPM->collectLastUses(DeadPasses, P);
@@ -561,8 +562,7 @@
for (std::vector::iterator I = DeadPasses.begin(),
E = DeadPasses.end(); I != E; ++I) {
- std::string Msg1 = " Freeing Pass '";
- dumpPassInfo(*I, Msg1, Msg);
+ dumpPassInfo(*I, FREEING_MSG, DBG_STR, Msg);
if (TheTimeInfo) TheTimeInfo->passStarted(*I);
(*I)->releaseMemory();
@@ -720,14 +720,44 @@
}
}
-void PMDataManager:: dumpPassInfo(Pass *P, std::string &Msg1,
- std::string &Msg2) const {
+void PMDataManager:: dumpPassInfo(Pass *P, enum PassDebuggingString S1,
+ enum PassDebuggingString S2,
+ std::string Msg) {
if (PassDebugging < Executions)
return;
cerr << (void*)this << std::string(getDepth()*2+1, ' ');
- cerr << Msg1;
- cerr << P->getPassName();
- cerr << Msg2;
+ switch (S1) {
+ case EXECUTION_MSG:
+ cerr << "Executing Pass '" << P->getPassName();
+ break;
+ case MODIFICATION_MSG:
+ cerr << "' Made Modification '" << P->getPassName();
+ break;
+ case FREEING_MSG:
+ cerr << " Freeing Pass '" << P->getPassName();
+ break;
+ default:
+ break;
+ }
+ switch (S2) {
+ case ON_BASICBLOCK_MSG:
+ cerr << "' on BasicBlock '" << Msg << "...\n";
+ break;
+ case ON_FUNCTION_MSG:
+ cerr << "' on Function '" << Msg << "...\n";
+ break;
+ case ON_MODULE_MSG:
+ cerr << "' on Module '" << Msg << "...\n";
+ break;
+ case ON_LOOP_MSG:
+ cerr << "' on Loop " << Msg << "...\n";
+ break;
+ case ON_CG_MSG:
+ cerr << "' on Call Graph " << Msg << "...\n";
+ break;
+ default:
+ break;
+ }
}
void PMDataManager::dumpAnalysisSetInfo(const char *Msg, Pass *P,
@@ -774,17 +804,13 @@
bool Changed = doInitialization(F);
- std::string Msg1 = "Executing Pass '";
- std::string Msg3 = "' Made Modification '";
-
for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
BasicBlockPass *BP = getContainedPass(Index);
AnalysisUsage AnUsage;
BP->getAnalysisUsage(AnUsage);
- std::string Msg2 = "' on BasicBlock '" + (*I).getName() + "'...\n";
- dumpPassInfo(BP, Msg1, Msg2);
+ dumpPassInfo(BP, EXECUTION_MSG, ON_BASICBLOCK_MSG, (*I).getName());
dumpAnalysisSetInfo("Required", BP, AnUsage.getRequiredSet());
initializeAnalysisImpl(BP);
@@ -793,13 +819,14 @@
Changed |= BP->runOnBasicBlock(*I);
if (TheTimeInfo) TheTimeInfo->passEnded(BP);
- if (Changed)
- dumpPassInfo(BP, Msg3, Msg2);
+ if (Changed)
+ dumpPassInfo(BP, MODIFICATION_MSG, ON_BASICBLOCK_MSG, (*I).getName());
dumpAnalysisSetInfo("Preserved", BP, AnUsage.getPreservedSet());
removeNotPreservedAnalysis(BP);
recordAvailableAnalysis(BP);
- removeDeadPasses(BP, Msg2);
+ removeDeadPasses(BP, (*I).getName(), ON_BASICBLOCK_MSG);
+
}
return Changed |= doFinalization(F);
}
@@ -973,17 +1000,13 @@
if (F.isDeclaration())
return false;
- std::string Msg1 = "Executing Pass '";
- std::string Msg3 = "' Made Modification '";
-
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
FunctionPass *FP = getContainedPass(Index);
AnalysisUsage AnUsage;
FP->getAnalysisUsage(AnUsage);
- std::string Msg2 = "' on Function '" + F.getName() + "'...\n";
- dumpPassInfo(FP, Msg1, Msg2);
+ dumpPassInfo(FP, EXECUTION_MSG, ON_FUNCTION_MSG, F.getName());
dumpAnalysisSetInfo("Required", FP, AnUsage.getRequiredSet());
initializeAnalysisImpl(FP);
@@ -992,13 +1015,13 @@
Changed |= FP->runOnFunction(F);
if (TheTimeInfo) TheTimeInfo->passEnded(FP);
- if (Changed)
- dumpPassInfo(FP, Msg3, Msg2);
+ if (Changed)
+ dumpPassInfo(FP, MODIFICATION_MSG, ON_FUNCTION_MSG, F.getName());
dumpAnalysisSetInfo("Preserved", FP, AnUsage.getPreservedSet());
removeNotPreservedAnalysis(FP);
recordAvailableAnalysis(FP);
- removeDeadPasses(FP, Msg2);
+ removeDeadPasses(FP, F.getName(), ON_FUNCTION_MSG);
}
return Changed;
}
@@ -1045,17 +1068,13 @@
MPPassManager::runOnModule(Module &M) {
bool Changed = false;
- std::string Msg1 = "Executing Pass '";
- std::string Msg3 = "' Made Modification '";
-
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
ModulePass *MP = getContainedPass(Index);
AnalysisUsage AnUsage;
MP->getAnalysisUsage(AnUsage);
- std::string Msg2 = "' on Module '" + M.getModuleIdentifier() + "'...\n";
- dumpPassInfo(MP, Msg1, Msg2);
+ dumpPassInfo(MP, EXECUTION_MSG, ON_MODULE_MSG, M.getModuleIdentifier());
dumpAnalysisSetInfo("Required", MP, AnUsage.getRequiredSet());
initializeAnalysisImpl(MP);
@@ -1064,13 +1083,14 @@
Changed |= MP->runOnModule(M);
if (TheTimeInfo) TheTimeInfo->passEnded(MP);
- if (Changed)
- dumpPassInfo(MP, Msg3, Msg2);
+ if (Changed)
+ dumpPassInfo(MP, MODIFICATION_MSG, ON_MODULE_MSG,
+ M.getModuleIdentifier());
dumpAnalysisSetInfo("Preserved", MP, AnUsage.getPreservedSet());
removeNotPreservedAnalysis(MP);
recordAvailableAnalysis(MP);
- removeDeadPasses(MP, Msg2);
+ removeDeadPasses(MP, M.getModuleIdentifier(), ON_MODULE_MSG);
}
return Changed;
}
From lauro.venancio at gmail.com Mon Mar 5 14:28:47 2007
From: lauro.venancio at gmail.com (Lauro Ramos Venancio)
Date: Mon, 5 Mar 2007 14:28:47 -0600
Subject: [llvm-commits] CVS: llvm-test/SingleSource/Regression/C/casts.c
Message-ID: <200703052028.l25KSlsu030722@zion.cs.uiuc.edu>
Changes in directory llvm-test/SingleSource/Regression/C:
casts.c updated: 1.5 -> 1.6
---
Log message:
Fix test bug: int64_t isn't the same thing that long
---
Diffs of the changes: (+2 -2)
casts.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
Index: llvm-test/SingleSource/Regression/C/casts.c
diff -u llvm-test/SingleSource/Regression/C/casts.c:1.5 llvm-test/SingleSource/Regression/C/casts.c:1.6
--- llvm-test/SingleSource/Regression/C/casts.c:1.5 Sat Nov 11 08:31:54 2006
+++ llvm-test/SingleSource/Regression/C/casts.c Mon Mar 5 14:28:30 2007
@@ -23,8 +23,8 @@
int i1, i;
unsigned ui1;
- int64_t L, l1;
- uint64_t ul1;
+ long L, l1;
+ unsigned long ul1;
float F;
double D;
From rspencer at reidspencer.com Mon Mar 5 15:39:31 2007
From: rspencer at reidspencer.com (Reid Spencer)
Date: Mon, 05 Mar 2007 13:39:31 -0800
Subject: [llvm-commits] Bug In InstCombine?
Message-ID: <1173130771.24497.95.camel@bashful.x10sys.com>
Chris,
While reviewing some of Sheng's patches, I think I found an existing bug
in InstCombine. Please review this and if its okay I'll commit the
patch:
Index: InstructionCombining.cpp
===================================================================
RCS
file: /var/cvs/llvm/llvm/lib/Transforms/Scalar/InstructionCombining.cpp,v
retrieving revision 1.647
diff -t -d -u -p -5 -r1.647 InstructionCombining.cpp
--- InstructionCombining.cpp 5 Mar 2007 00:11:19 -0000 1.647
+++ InstructionCombining.cpp 5 Mar 2007 21:37:17 -0000
@@ -2408,11 +2408,11 @@ Instruction *InstCombiner::visitUDiv(Bin
// udiv X, (Select Cond, C1, C2) --> Select Cond, (shr X, C1), (shr
X, C2)
// where C1&C2 are powers of two.
if (SelectInst *SI = dyn_cast(Op1)) {
if (ConstantInt *STO = dyn_cast(SI->getOperand(1)))
if (ConstantInt *SFO = dyn_cast(SI->getOperand(2)))
- if (!STO->isNullValue() && !STO->isNullValue()) {
+ if (!STO->isZero() && !SFO->isZero()) {
While I've changed it to use the less expensive isZero, the real bug is
that this is testing X & X. That is, the second term should check SF0
against zero, not ST0. I can't think of any reason why testing ST0 twice
would be correct.
uint64_t TVA = STO->getZExtValue(), FVA =
SFO->getZExtValue();
if (isPowerOf2_64(TVA) && isPowerOf2_64(FVA)) {
// Compute the shift amounts
unsigned TSA = Log2_64(TVA), FSA = Log2_64(FVA);
// Construct the "on true" case of the select
From dpatel at apple.com Mon Mar 5 16:40:20 2007
From: dpatel at apple.com (dpatel at apple.com)
Date: Mon, 5 Mar 2007 14:40:20 -0800 (PST)
Subject: [llvm-commits] [124571] While reading PCH,
Parse Bytecodes directly from memory.
Message-ID: <20070305224020.336968008AF7@src>
Revision: 124571
Author: dpatel
Date: 2007-03-05 14:40:18 -0800 (Mon, 05 Mar 2007)
Log Message:
-----------
While reading PCH, Parse Bytecodes directly from memory.
Modified Paths:
--------------
apple-local/branches/llvm/gcc/c-pch.c
apple-local/branches/llvm/gcc/llvm-backend.cpp
apple-local/branches/llvm/gcc/llvm.h
Modified: apple-local/branches/llvm/gcc/c-pch.c
===================================================================
--- apple-local/branches/llvm/gcc/c-pch.c 2007-03-05 11:35:52 UTC (rev 124570)
+++ apple-local/branches/llvm/gcc/c-pch.c 2007-03-05 22:40:18 UTC (rev 124571)
@@ -415,6 +415,13 @@
if (!flag_preprocess_only)
{
+ /* APPLE LOCAL begin LLVM */
+#ifdef ENABLE_LLVM
+ unsigned char *buf = xmalloc (h.asm_size);
+ if (fread (buf, h.asm_size, 1, f) != 1)
+ cpp_errno (pfile, CPP_DL_ERROR, "reading");
+ llvm_pch_read(buf, h.asm_size);
+#else
unsigned long written;
char * buf = xmalloc (16384);
@@ -428,13 +435,9 @@
cpp_errno (pfile, CPP_DL_ERROR, "reading");
written += size;
}
+#endif
+ /* APPLE LOCAL end LLVM */
free (buf);
- /* APPLE LOCAL begin LLVM */
-#ifdef ENABLE_LLVM
- llvm_pch_read();
-#endif
- /* APPLE LOCAL end LLVM */
-
}
else
{
Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-03-05 11:35:52 UTC (rev 124570)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-03-05 22:40:18 UTC (rev 124571)
@@ -189,16 +189,16 @@
/// Read bytecode from PCH file. Initialize TheModue and setup
/// LTypes vector.
-void llvm_pch_read(void) {
+void llvm_pch_read(const unsigned char *Buffer, unsigned Size) {
+ std::string ModuleName = TheModule->getModuleIdentifier();
if (TheModule)
delete TheModule;
- fclose (asm_out_file);
-
- std::string ErrMsg;
clearTargetBuiltinCache();
- TheModule = ParseBytecodeFile(asm_file_name,
+
+ std::string ErrMsg;
+ TheModule = ParseBytecodeBuffer(Buffer, Size, ModuleName,
Compressor::decompressToNewBuffer,
&ErrMsg);
if (!TheModule) {
@@ -207,12 +207,6 @@
exit(1);
}
- // Reopen asm_out_file for the rest of the compiler's use.
- // This also removes llvm byte code from the asm_out_file.
- asm_out_file = fopen (asm_file_name, "w+b");
- if (asm_out_file == 0)
- fatal_error ("can%'t open %s for writing: %m", asm_file_name);
-
// Read LLVM Types string table
readLLVMTypesStringTable();
readLLVMValuesStringTable();
Modified: apple-local/branches/llvm/gcc/llvm.h
===================================================================
--- apple-local/branches/llvm/gcc/llvm.h 2007-03-05 11:35:52 UTC (rev 124570)
+++ apple-local/branches/llvm/gcc/llvm.h 2007-03-05 22:40:18 UTC (rev 124571)
@@ -89,7 +89,7 @@
void llvm_pch_write_init(void);
/* Read bytecodes from PCH file. */
-void llvm_pch_read(void);
+void llvm_pch_read(const unsigned char *, unsigned);
/* llvm_asm_file_start - Start the .s file. */
void llvm_asm_file_start(void);
From clattner at apple.com Mon Mar 5 16:51:23 2007
From: clattner at apple.com (Chris Lattner)
Date: Mon, 5 Mar 2007 14:51:23 -0800
Subject: [llvm-commits] Bug In InstCombine?
In-Reply-To: <1173130771.24497.95.camel@bashful.x10sys.com>
References: <1173130771.24497.95.camel@bashful.x10sys.com>
Message-ID:
On Mar 5, 2007, at 1:39 PM, Reid Spencer wrote:
> Chris,
>
> While reviewing some of Sheng's patches, I think I found an
> existing bug
> in InstCombine. Please review this and if its okay I'll commit the
> patch:
>
> Index: InstructionCombining.cpp
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm/lib/Transforms/Scalar/
> InstructionCombining.cpp,v
> retrieving revision 1.647
> diff -t -d -u -p -5 -r1.647 InstructionCombining.cpp
> --- InstructionCombining.cpp 5 Mar 2007 00:11:19 -0000 1.647
> +++ InstructionCombining.cpp 5 Mar 2007 21:37:17 -0000
> @@ -2408,11 +2408,11 @@ Instruction *InstCombiner::visitUDiv(Bin
> // udiv X, (Select Cond, C1, C2) --> Select Cond, (shr X, C1), (shr
> X, C2)
> // where C1&C2 are powers of two.
> if (SelectInst *SI = dyn_cast(Op1)) {
> if (ConstantInt *STO = dyn_cast(SI->getOperand(1)))
> if (ConstantInt *SFO = dyn_cast(SI->getOperand
> (2)))
> - if (!STO->isNullValue() && !STO->isNullValue()) {
> + if (!STO->isZero() && !SFO->isZero()) {
>
> While I've changed it to use the less expensive isZero, the real
> bug is
> that this is testing X & X. That is, the second term should check SF0
> against zero, not ST0. I can't think of any reason why testing ST0
> twice
> would be correct.
Interesting case. the full code looks like this:
if (!STO->isNullValue() && !STO->isNullValue()) {
uint64_t TVA = STO->getZExtValue(), FVA = SFO->getZExtValue
();
if (isPowerOf2_64(TVA) && isPowerOf2_64(FVA)) {
The isPowerOf2_64 calls check that the argument is not zero. As
such, you can drop the isNullValue checks entirely.
Thanks Reid,
-Chris
From reid at x10sys.com Mon Mar 5 16:51:31 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 16:51:31 -0600
Subject: [llvm-commits] CVS:
llvm/test/Transforms/InstCombine/udiv_select_to_select_shift.ll
Message-ID: <200703052251.l25MpVkS003482@zion.cs.uiuc.edu>
Changes in directory llvm/test/Transforms/InstCombine:
udiv_select_to_select_shift.ll added (r1.1)
---
Log message:
Add a test case for a particular udiv/select transform.
---
Diffs of the changes: (+17 -0)
udiv_select_to_select_shift.ll | 17 +++++++++++++++++
1 files changed, 17 insertions(+)
Index: llvm/test/Transforms/InstCombine/udiv_select_to_select_shift.ll
diff -c /dev/null llvm/test/Transforms/InstCombine/udiv_select_to_select_shift.ll:1.1
*** /dev/null Mon Mar 5 16:51:18 2007
--- llvm/test/Transforms/InstCombine/udiv_select_to_select_shift.ll Mon Mar 5 16:51:08 2007
***************
*** 0 ****
--- 1,17 ----
+ ; This tests that this transform:
+ ; udiv X, (Select Cond, C1, C2) --> Select Cond, (shr X, C1), (shr X, C2)
+ ;
+ ; RUN: llvm-as %s -o - | opt -instcombine | llvm-dis -f -o %t && \
+ ; RUN: grep select %t | wc -l | grep 1 && \
+ ; RUN: grep lshr %t | wc -l | grep 2 && \
+ ; RUN: grep udiv %t | wc -l | grep 0
+
+ define i64 @test(i64 %X, i1 %Cond ) {
+ entry:
+ %divisor1 = select i1 %Cond, i64 8, i64 16
+ %quotient1 = udiv i64 %X, %divisor1
+ %divisor2 = select i1 %Cond, i64 8, i64 0
+ %quotient2 = udiv i64 %X, %divisor2
+ %sum = add i64 %quotient1, %quotient2
+ ret i64 %sum
+ }
From dpatel at apple.com Mon Mar 5 16:58:06 2007
From: dpatel at apple.com (Devang Patel)
Date: Mon, 5 Mar 2007 16:58:06 -0600
Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp
Message-ID: <200703052258.l25Mw6Gs003616@zion.cs.uiuc.edu>
Changes in directory llvm/lib/VMCore:
PassManager.cpp updated: 1.141 -> 1.142
---
Log message:
Current pass manager, not the parent pass manager, assumes the role of
last user when one of the managed pass uses info provided by parent pass
manager.
This was exposed by LPPassManager work.
---
Diffs of the changes: (+10 -22)
PassManager.cpp | 32 ++++++++++----------------------
1 files changed, 10 insertions(+), 22 deletions(-)
Index: llvm/lib/VMCore/PassManager.cpp
diff -u llvm/lib/VMCore/PassManager.cpp:1.141 llvm/lib/VMCore/PassManager.cpp:1.142
--- llvm/lib/VMCore/PassManager.cpp:1.141 Mon Mar 5 14:01:30 2007
+++ llvm/lib/VMCore/PassManager.cpp Mon Mar 5 16:57:49 2007
@@ -158,7 +158,6 @@
recordAvailableAnalysis(IP);
} else {
P->assignPassManager(activeStack);
- activeStack.handleLastUserOverflow();
}
}
@@ -259,7 +258,6 @@
recordAvailableAnalysis(IP);
} else {
P->assignPassManager(activeStack);
- activeStack.handleLastUserOverflow();
}
}
@@ -587,6 +585,10 @@
AnalysisResolver *AR = new AnalysisResolver(*this);
P->setResolver(AR);
+ // If a FunctionPass F is the last user of ModulePass info M
+ // then the F's manager, not F, records itself as a last user of M.
+ std::vector TransferLastUses;
+
if (ProcessAnalysis) {
// At the moment, this pass is the last user of all required passes.
@@ -622,6 +624,12 @@
LastUses.push_back(P);
TPM->setLastUser(LastUses, P);
+ if (!TransferLastUses.empty()) {
+ Pass *My_PM = dynamic_cast(this);
+ TPM->setLastUser(TransferLastUses, My_PM);
+ TransferLastUses.clear();
+ }
+
// Take a note of analysis required and made available by this pass.
// Remove the analysis not preserved by this pass
removeNotPreservedAnalysis(P);
@@ -1231,26 +1239,6 @@
printf ("\n");
}
-// Walk Pass Manager stack and set LastUse markers if any
-// manager is transfering this priviledge to its parent manager
-void PMStack::handleLastUserOverflow() {
-
- for(PMStack::iterator I = this->begin(), E = this->end(); I != E;) {
-
- PMDataManager *Child = *I++;
- if (I != E) {
- PMDataManager *Parent = *I++;
- PMTopLevelManager *TPM = Parent->getTopLevelManager();
- std::vector &TLU = Child->getTransferredLastUses();
- if (!TLU.empty()) {
- Pass *P = dynamic_cast(Parent);
- TPM->setLastUser(TLU, P);
- TLU.clear();
- }
- }
- }
-}
-
/// Find appropriate Module Pass Manager in the PM Stack and
/// add self into that manager.
void ModulePass::assignPassManager(PMStack &PMS,
From dpatel at apple.com Mon Mar 5 16:58:08 2007
From: dpatel at apple.com (Devang Patel)
Date: Mon, 5 Mar 2007 16:58:08 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/PassManagers.h
Message-ID: <200703052258.l25Mw867003622@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm:
PassManagers.h updated: 1.11 -> 1.12
---
Log message:
Current pass manager, not the parent pass manager, assumes the role of
last user when one of the managed pass uses info provided by parent pass
manager.
This was exposed by LPPassManager work.
---
Diffs of the changes: (+0 -11)
PassManagers.h | 11 -----------
1 files changed, 11 deletions(-)
Index: llvm/include/llvm/PassManagers.h
diff -u llvm/include/llvm/PassManagers.h:1.11 llvm/include/llvm/PassManagers.h:1.12
--- llvm/include/llvm/PassManagers.h:1.11 Mon Mar 5 14:01:30 2007
+++ llvm/include/llvm/PassManagers.h Mon Mar 5 16:57:49 2007
@@ -222,7 +222,6 @@
/// Initialize available analysis information.
void initializeAnalysisInfo() {
- TransferLastUses.clear();
AvailableAnalysis.clear();
}
@@ -255,10 +254,6 @@
void dumpAnalysisSetInfo(const char *Msg, Pass *P,
const std::vector &Set) const;
- std::vector& getTransferredLastUses() {
- return TransferLastUses;
- }
-
virtual unsigned getNumContainedPasses() {
return PassVector.size();
}
@@ -269,12 +264,6 @@
}
protected:
- // If a FunctionPass F is the last user of ModulePass info M
- // then the F's manager, not F, records itself as a last user of M.
- // Current pass manage is requesting parent manager to record parent
- // manager as the last user of these TrransferLastUses passes.
- std::vector TransferLastUses;
-
// Top level manager.
PMTopLevelManager *TPM;
From reid at x10sys.com Mon Mar 5 17:06:49 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 17:06:49 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/Value.h
Message-ID: <200703052306.l25N6nT1003786@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm:
Value.h updated: 1.98 -> 1.99
---
Log message:
Document the use of getValueType() more accurately, specifically explain
that the instruction opcode is added to the InstructionVal value and the
consequences of that.
---
Diffs of the changes: (+6 -4)
Value.h | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
Index: llvm/include/llvm/Value.h
diff -u llvm/include/llvm/Value.h:1.98 llvm/include/llvm/Value.h:1.99
--- llvm/include/llvm/Value.h:1.98 Thu Feb 15 12:53:54 2007
+++ llvm/include/llvm/Value.h Mon Mar 5 17:06:32 2007
@@ -181,10 +181,12 @@
/// getValueType - Return an ID for the concrete type of this object. This is
/// used to implement the classof checks. This should not be used for any
/// other purpose, as the values may change as LLVM evolves. Also, note that
- /// starting with the InstructionVal value, the value stored is actually the
- /// Instruction opcode, so there are more than just these values possible here
- /// (and Instruction must be last).
- ///
+ /// for instructions, the Instruction's opcode is added to InstructionVal. So
+ /// this means three things:
+ /// # there is no value with code InstructionVal (no opcode==0).
+ /// # there are more possible values for the value type than in ValueTy enum.
+ /// # the InstructionVal enumerator must be the highest valued enumerator in
+ /// the ValueTy enum.
unsigned getValueType() const {
return SubclassID;
}
From isanbard at gmail.com Mon Mar 5 17:10:05 2007
From: isanbard at gmail.com (Bill Wendling)
Date: Mon, 5 Mar 2007 17:10:05 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/IntrinsicsX86.td
Message-ID: <200703052310.l25NA5Yp003905@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm:
IntrinsicsX86.td updated: 1.31 -> 1.32
---
Log message:
Add the emms intrinsic for MMX support.
---
Diffs of the changes: (+9 -0)
IntrinsicsX86.td | 9 +++++++++
1 files changed, 9 insertions(+)
Index: llvm/include/llvm/IntrinsicsX86.td
diff -u llvm/include/llvm/IntrinsicsX86.td:1.31 llvm/include/llvm/IntrinsicsX86.td:1.32
--- llvm/include/llvm/IntrinsicsX86.td:1.31 Sun Dec 31 16:24:55 2006
+++ llvm/include/llvm/IntrinsicsX86.td Mon Mar 5 17:09:45 2007
@@ -535,3 +535,12 @@
Intrinsic<[llvm_void_ty, llvm_i32_ty,
llvm_i32_ty], [IntrWriteMem]>;
}
+
+//===----------------------------------------------------------------------===//
+// MMX
+
+// Empty MMX state op.
+let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
+ def int_x86_mmx_emms : GCCBuiltin<"__builtin_ia32_emms">,
+ Intrinsic<[llvm_void_ty], [IntrWriteMem]>;
+}
From isanbard at gmail.com Mon Mar 5 17:10:07 2007
From: isanbard at gmail.com (Bill Wendling)
Date: Mon, 5 Mar 2007 17:10:07 -0600
Subject: [llvm-commits] CVS: llvm/test/CodeGen/X86/mmx-emms.ll
Message-ID: <200703052310.l25NA77B003910@zion.cs.uiuc.edu>
Changes in directory llvm/test/CodeGen/X86:
mmx-emms.ll added (r1.1)
---
Log message:
Add the emms intrinsic for MMX support.
---
Diffs of the changes: (+11 -0)
mmx-emms.ll | 11 +++++++++++
1 files changed, 11 insertions(+)
Index: llvm/test/CodeGen/X86/mmx-emms.ll
diff -c /dev/null llvm/test/CodeGen/X86/mmx-emms.ll:1.1
*** /dev/null Mon Mar 5 17:09:55 2007
--- llvm/test/CodeGen/X86/mmx-emms.ll Mon Mar 5 17:09:45 2007
***************
*** 0 ****
--- 1,11 ----
+ ; RUN: llvm-as < %s | llc -march=x86 -mattr=+mmx | grep emms
+ define void @foo() {
+ entry:
+ call void @llvm.x86.mmx.emms( )
+ br label %return
+
+ return: ; preds = %entry
+ ret void
+ }
+
+ declare void @llvm.x86.mmx.emms()
From isanbard at gmail.com Mon Mar 5 17:10:07 2007
From: isanbard at gmail.com (Bill Wendling)
Date: Mon, 5 Mar 2007 17:10:07 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrMMX.td
Message-ID: <200703052310.l25NA7tl003915@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/X86:
X86InstrMMX.td updated: 1.13 -> 1.14
---
Log message:
Add the emms intrinsic for MMX support.
---
Diffs of the changes: (+4 -1)
X86InstrMMX.td | 5 ++++-
1 files changed, 4 insertions(+), 1 deletion(-)
Index: llvm/lib/Target/X86/X86InstrMMX.td
diff -u llvm/lib/Target/X86/X86InstrMMX.td:1.13 llvm/lib/Target/X86/X86InstrMMX.td:1.14
--- llvm/lib/Target/X86/X86InstrMMX.td:1.13 Tue Jul 18 19:27:29 2006
+++ llvm/lib/Target/X86/X86InstrMMX.td Mon Mar 5 17:09:45 2007
@@ -33,6 +33,10 @@
def : Pat<(v4i16 (undef)), (IMPLICIT_DEF_VR64)>, Requires<[HasMMX]>;
def : Pat<(v2i32 (undef)), (IMPLICIT_DEF_VR64)>, Requires<[HasMMX]>;
+// EMMS
+def EMMS : I<0x77, RawFrm, (ops), "emms", [(int_x86_mmx_emms)]>, TB,
+ Requires<[HasMMX]>;
+
// Move Instructions
def MOVD64rr : I<0x6E, MRMSrcReg, (ops VR64:$dst, GR32:$src),
"movd {$src, $dst|$dst, $src}", []>, TB,
@@ -94,4 +98,3 @@
def MASKMOVQ : I<0xF7, MRMDestMem, (ops VR64:$src, VR64:$mask),
"maskmovq {$mask, $src|$src, $mask}", []>, TB,
Requires<[HasMMX]>;
-
From rspencer at reidspencer.com Mon Mar 5 17:10:20 2007
From: rspencer at reidspencer.com (Reid Spencer)
Date: Mon, 05 Mar 2007 15:10:20 -0800
Subject: [llvm-commits] Bug In InstCombine?
In-Reply-To:
References: <1173130771.24497.95.camel@bashful.x10sys.com>
Message-ID: <1173136220.24497.130.camel@bashful.x10sys.com>
On Mon, 2007-03-05 at 14:51 -0800, Chris Lattner wrote:
> Interesting case. the full code looks like this:
>
> if (!STO->isNullValue() && !STO->isNullValue()) {
> uint64_t TVA = STO->getZExtValue(), FVA = SFO->getZExtValue
> ();
> if (isPowerOf2_64(TVA) && isPowerOf2_64(FVA)) {
>
> The isPowerOf2_64 calls check that the argument is not zero. As
> such, you can drop the isNullValue checks entirely.
Yup! Even better.
Thanks,
Reid.
From reid at x10sys.com Mon Mar 5 17:36:30 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 17:36:30 -0600
Subject: [llvm-commits] CVS:
llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Message-ID: <200703052336.l25NaUQU004366@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.647 -> 1.648
---
Log message:
Remove an unnecessary if statement and adjust indentation.
---
Diffs of the changes: (+20 -22)
InstructionCombining.cpp | 42 ++++++++++++++++++++----------------------
1 files changed, 20 insertions(+), 22 deletions(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.647 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.648
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.647 Sun Mar 4 18:11:19 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Mar 5 17:36:13 2007
@@ -2407,31 +2407,29 @@
// udiv X, (Select Cond, C1, C2) --> Select Cond, (shr X, C1), (shr X, C2)
// where C1&C2 are powers of two.
- if (SelectInst *SI = dyn_cast(Op1)) {
+ if (SelectInst *SI = dyn_cast(Op1))
if (ConstantInt *STO = dyn_cast(SI->getOperand(1)))
- if (ConstantInt *SFO = dyn_cast(SI->getOperand(2)))
- if (!STO->isNullValue() && !STO->isNullValue()) {
- uint64_t TVA = STO->getZExtValue(), FVA = SFO->getZExtValue();
- if (isPowerOf2_64(TVA) && isPowerOf2_64(FVA)) {
- // Compute the shift amounts
- unsigned TSA = Log2_64(TVA), FSA = Log2_64(FVA);
- // Construct the "on true" case of the select
- Constant *TC = ConstantInt::get(Op0->getType(), TSA);
- Instruction *TSI = BinaryOperator::createLShr(
- Op0, TC, SI->getName()+".t");
- TSI = InsertNewInstBefore(TSI, I);
-
- // Construct the "on false" case of the select
- Constant *FC = ConstantInt::get(Op0->getType(), FSA);
- Instruction *FSI = BinaryOperator::createLShr(
- Op0, FC, SI->getName()+".f");
- FSI = InsertNewInstBefore(FSI, I);
+ if (ConstantInt *SFO = dyn_cast(SI->getOperand(2))) {
+ uint64_t TVA = STO->getZExtValue(), FVA = SFO->getZExtValue();
+ if (isPowerOf2_64(TVA) && isPowerOf2_64(FVA)) {
+ // Compute the shift amounts
+ unsigned TSA = Log2_64(TVA), FSA = Log2_64(FVA);
+ // Construct the "on true" case of the select
+ Constant *TC = ConstantInt::get(Op0->getType(), TSA);
+ Instruction *TSI = BinaryOperator::createLShr(
+ Op0, TC, SI->getName()+".t");
+ TSI = InsertNewInstBefore(TSI, I);
+
+ // Construct the "on false" case of the select
+ Constant *FC = ConstantInt::get(Op0->getType(), FSA);
+ Instruction *FSI = BinaryOperator::createLShr(
+ Op0, FC, SI->getName()+".f");
+ FSI = InsertNewInstBefore(FSI, I);
- // construct the select instruction and return it.
- return new SelectInst(SI->getOperand(0), TSI, FSI, SI->getName());
- }
+ // construct the select instruction and return it.
+ return new SelectInst(SI->getOperand(0), TSI, FSI, SI->getName());
}
- }
+ }
return 0;
}
From dpatel at apple.com Mon Mar 5 18:42:35 2007
From: dpatel at apple.com (dpatel at apple.com)
Date: Mon, 5 Mar 2007 16:42:35 -0800 (PST)
Subject: [llvm-commits] [124572] Handle -mllvm.
Message-ID: <20070306004235.53B0B80B17A6@src>
Revision: 124572
Author: dpatel
Date: 2007-03-05 16:42:33 -0800 (Mon, 05 Mar 2007)
Log Message:
-----------
Handle -mllvm.
Modified Paths:
--------------
apple-local/branches/llvm/gcc/config/darwin.h
apple-local/branches/llvm/gcc/gcc.c
Modified: apple-local/branches/llvm/gcc/config/darwin.h
===================================================================
--- apple-local/branches/llvm/gcc/config/darwin.h 2007-03-05 22:40:18 UTC (rev 124571)
+++ apple-local/branches/llvm/gcc/config/darwin.h 2007-03-06 00:42:33 UTC (rev 124572)
@@ -156,6 +156,8 @@
{ "-image_base", "-Zimage_base" }, \
{ "-init", "-Zinit" }, \
{ "-install_name", "-Zinstall_name" }, \
+ /* APPLE LOCAL llvm */ \
+ { "-mllvm", "-Zmllvm" }, \
/* APPLE LOCAL mainline */ \
{ "-mkernel", "-mkernel -static -Wa,-static" }, \
{ "-multiply_defined_unused", "-Zmultiplydefinedunused" }, \
@@ -305,6 +307,8 @@
!strcmp (STR, "Zimage_base") ? 1 : \
!strcmp (STR, "Zinit") ? 1 : \
!strcmp (STR, "Zinstall_name") ? 1 : \
+ /* APPLE LOCAL llvm */ \
+ !strcmp (STR, "Zmllvm") ? 1 : \
!strcmp (STR, "Zmultiplydefinedunused") ? 1 : \
!strcmp (STR, "Zmultiply_defined") ? 1 : \
!strcmp (STR, "precomp-trustfile") ? 1 : \
Modified: apple-local/branches/llvm/gcc/gcc.c
===================================================================
--- apple-local/branches/llvm/gcc/gcc.c 2007-03-05 22:40:18 UTC (rev 124571)
+++ apple-local/branches/llvm/gcc/gcc.c 2007-03-06 00:42:33 UTC (rev 124572)
@@ -829,7 +829,8 @@
%{fastcp:-O3}"
/* APPLE LOCAL end -fast */
"%{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
- %1 %{!Q:-quiet} -dumpbase %B %{d*} %{m*} %{a*}\
+"/* APPLE LOCAL llvm */"\
+ %1 %{!Q:-quiet} -dumpbase %B %{d*} %{Zmllvm*: -mllvm %*} %{m*} %{a*}\
%{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}%{!c:%{!S:-auxbase %b}}\
%{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs}\
%{v:-version} %{pg:-p} %{p} %{f*} %{undef}\
From sabre at nondot.org Mon Mar 5 19:00:16 2007
From: sabre at nondot.org (Chris Lattner)
Date: Mon, 5 Mar 2007 19:00:16 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCCallingConv.td
Makefile PPC.td PPCISelLowering.cpp
Message-ID: <200703060100.l2610GAr005887@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/PowerPC:
PPCCallingConv.td added (r1.1)
Makefile updated: 1.23 -> 1.24
PPC.td updated: 1.19 -> 1.20
PPCISelLowering.cpp updated: 1.259 -> 1.260
---
Log message:
Switch PPC return lower to use an autogenerated CC description.
---
Diffs of the changes: (+103 -41)
Makefile | 3 +-
PPC.td | 6 ++++
PPCCallingConv.td | 65 ++++++++++++++++++++++++++++++++++++++++++++++++
PPCISelLowering.cpp | 70 ++++++++++++++++++++++------------------------------
4 files changed, 103 insertions(+), 41 deletions(-)
Index: llvm/lib/Target/PowerPC/PPCCallingConv.td
diff -c /dev/null llvm/lib/Target/PowerPC/PPCCallingConv.td:1.1
*** /dev/null Mon Mar 5 19:00:09 2007
--- llvm/lib/Target/PowerPC/PPCCallingConv.td Mon Mar 5 18:59:59 2007
***************
*** 0 ****
--- 1,65 ----
+ //===- PPCCallingConv.td - Calling Conventions for PowerPC ------*- C++ -*-===//
+ //
+ // The LLVM Compiler Infrastructure
+ //
+ // This file was developed by Chris Lattner and is distributed under
+ // the University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This describes the calling conventions for the PowerPC 32- and 64-bit
+ // architectures.
+ //
+ //===----------------------------------------------------------------------===//
+
+ /// CCIfSubtarget - Match if the current subtarget has a feature F.
+ class CCIfSubtarget
+ : CCIf().", F), A>;
+
+ //===----------------------------------------------------------------------===//
+ // Return Value Calling Convention
+ //===----------------------------------------------------------------------===//
+
+ // Return-value convention for PowerPC
+ def RetCC_PPC : CallingConv<[
+ CCIfType<[i32], CCAssignToReg<[R3, R4]>>,
+ CCIfType<[i64], CCAssignToReg<[X3, X4]>>,
+
+ CCIfType<[f32, f64], CCAssignToReg<[F1]>>,
+
+ // Vector types are always returned in V2.
+ CCIfType<[v16i8, v8i16, v4i32, v4f32], CCAssignToReg<[V2]>>
+ ]>;
+
+
+ //===----------------------------------------------------------------------===//
+ // PowerPC Argument Calling Conventions
+ //===----------------------------------------------------------------------===//
+ /*
+ def CC_PPC : CallingConv<[
+ // The first 8 integer arguments are passed in integer registers.
+ CCIfType<[i32], CCAssignToReg<[R3, R4, R5, R6, R7, R8, R9, R10]>>,
+ CCIfType<[i64], CCAssignToReg<[X3, X4, X5, X6, X7, X8, X9, X10]>>,
+
+ // Darwin passes FP values in F1 - F13
+ CCIfType<[f32, f64], CCIfSubtarget<"isMachoABI()",
+ CCAssignToReg<[F1, F2, F3, F4, F5, F6, F7, F8,F9,F10,F11,F12,F13]>>>,
+ // Other sub-targets pass FP values in F1-10.
+ CCIfType<[f32, f64], CCAssignToReg<[F1, F2, F3, F4, F5, F6, F7, F8, F9,F10]>>,
+
+ // The first 12 Vector arguments are passed in altivec registers.
+ CCIfType<[v16i8, v8i16, v4i32, v4f32],
+ CCAssignToReg<[V2, V3, V4, V5, V6, V7, V8, V9, V10,V11,V12,V13]>>
+
+ /*
+ // Integer/FP values get stored in stack slots that are 8 bytes in size and
+ // 8-byte aligned if there are no more registers to hold them.
+ CCIfType<[i32, i64, f32, f64], CCAssignToStack<8, 8>>,
+
+ // Vectors get 16-byte stack slots that are 16-byte aligned.
+ CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64],
+ CCAssignToStack<16, 16>>*/
+ ]>;
+
+ */
+
Index: llvm/lib/Target/PowerPC/Makefile
diff -u llvm/lib/Target/PowerPC/Makefile:1.23 llvm/lib/Target/PowerPC/Makefile:1.24
--- llvm/lib/Target/PowerPC/Makefile:1.23 Fri Oct 27 19:49:54 2006
+++ llvm/lib/Target/PowerPC/Makefile Mon Mar 5 18:59:59 2007
@@ -14,6 +14,7 @@
BUILT_SOURCES = PPCGenInstrNames.inc PPCGenRegisterNames.inc \
PPCGenAsmWriter.inc PPCGenCodeEmitter.inc \
PPCGenRegisterInfo.h.inc PPCGenRegisterInfo.inc \
- PPCGenInstrInfo.inc PPCGenDAGISel.inc PPCGenSubtarget.inc
+ PPCGenInstrInfo.inc PPCGenDAGISel.inc \
+ PPCGenSubtarget.inc PPCGenCallingConv.inc
include $(LEVEL)/Makefile.common
Index: llvm/lib/Target/PowerPC/PPC.td
diff -u llvm/lib/Target/PowerPC/PPC.td:1.19 llvm/lib/Target/PowerPC/PPC.td:1.20
--- llvm/lib/Target/PowerPC/PPC.td:1.19 Tue Dec 12 14:57:07 2006
+++ llvm/lib/Target/PowerPC/PPC.td Mon Mar 5 18:59:59 2007
@@ -89,6 +89,12 @@
Feature64Bit /*, Feature64BitRegs */]>;
+//===----------------------------------------------------------------------===//
+// Calling Conventions
+//===----------------------------------------------------------------------===//
+
+include "PPCCallingConv.td"
+
def PPCInstrInfo : InstrInfo {
// Define how we want to layout our TargetSpecific information field... This
// should be kept up-to-date with the fields in the PPCInstrInfo.h file.
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.259 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.260
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.259 Thu Mar 1 07:11:38 2007
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Mon Mar 5 18:59:59 2007
@@ -18,6 +18,7 @@
#include "PPCPerfectShuffle.h"
#include "llvm/ADT/VectorExtras.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
+#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -1096,6 +1097,8 @@
SV->getOffset());
}
+#include "PPCGenCallingConv.inc"
+
/// GetFPR - Get the set of FP registers that should be allocated for arguments,
/// depending on which subtarget is selected.
static const unsigned *GetFPR(const PPCSubtarget &Subtarget) {
@@ -1626,47 +1629,34 @@
return Res.getValue(Op.ResNo);
}
-static SDOperand LowerRET(SDOperand Op, SelectionDAG &DAG) {
- SDOperand Chain = Op.getOperand(0);
- switch(Op.getNumOperands()) {
- default:
- assert(0 && "Do not know how to return this many arguments!");
- abort();
- case 1:
- return DAG.getNode(PPCISD::RET_FLAG, MVT::Other, Chain);
- case 3: {
- MVT::ValueType ArgVT = Op.getOperand(1).getValueType();
- unsigned ArgReg;
- if (ArgVT == MVT::i32) {
- ArgReg = PPC::R3;
- } else if (ArgVT == MVT::i64) {
- ArgReg = PPC::X3;
- } else if (MVT::isVector(ArgVT)) {
- ArgReg = PPC::V2;
- } else {
- assert(MVT::isFloatingPoint(ArgVT));
- ArgReg = PPC::F1;
- }
-
- Chain = DAG.getCopyToReg(Chain, ArgReg, Op.getOperand(1), SDOperand());
-
- // If we haven't noted the R3/F1 are live out, do so now.
- if (DAG.getMachineFunction().liveout_empty())
- DAG.getMachineFunction().addLiveOut(ArgReg);
- break;
+static SDOperand LowerRET(SDOperand Op, SelectionDAG &DAG, TargetMachine &TM) {
+ SmallVector RVLocs;
+ unsigned CC = DAG.getMachineFunction().getFunction()->getCallingConv();
+ CCState CCInfo(CC, TM, RVLocs);
+ CCInfo.AnalyzeReturn(Op.Val, RetCC_PPC);
+
+ // If this is the first return lowered for this function, add the regs to the
+ // liveout set for the function.
+ if (DAG.getMachineFunction().liveout_empty()) {
+ for (unsigned i = 0; i != RVLocs.size(); ++i)
+ DAG.getMachineFunction().addLiveOut(RVLocs[i].getLocReg());
}
- case 5:
- Chain = DAG.getCopyToReg(Chain, PPC::R3, Op.getOperand(3), SDOperand());
- Chain = DAG.getCopyToReg(Chain, PPC::R4, Op.getOperand(1),
- Chain.getValue(1));
- // If we haven't noted the R3+R4 are live out, do so now.
- if (DAG.getMachineFunction().liveout_empty()) {
- DAG.getMachineFunction().addLiveOut(PPC::R3);
- DAG.getMachineFunction().addLiveOut(PPC::R4);
- }
- break;
+
+ SDOperand Chain = Op.getOperand(0);
+ SDOperand Flag;
+
+ // Copy the result values into the output registers.
+ for (unsigned i = 0; i != RVLocs.size(); ++i) {
+ CCValAssign &VA = RVLocs[i];
+ assert(VA.isRegLoc() && "Can only return in registers!");
+ Chain = DAG.getCopyToReg(Chain, VA.getLocReg(), Op.getOperand(i*2+1), Flag);
+ Flag = Chain.getValue(1);
}
- return DAG.getNode(PPCISD::RET_FLAG, MVT::Other, Chain, Chain.getValue(1));
+
+ if (Flag.Val)
+ return DAG.getNode(PPCISD::RET_FLAG, MVT::Other, Chain, Flag);
+ else
+ return DAG.getNode(PPCISD::RET_FLAG, MVT::Other, Chain);
}
static SDOperand LowerSTACKRESTORE(SDOperand Op, SelectionDAG &DAG,
@@ -2677,7 +2667,7 @@
case ISD::FORMAL_ARGUMENTS:
return LowerFORMAL_ARGUMENTS(Op, DAG, VarArgsFrameIndex, PPCSubTarget);
case ISD::CALL: return LowerCALL(Op, DAG, PPCSubTarget);
- case ISD::RET: return LowerRET(Op, DAG);
+ case ISD::RET: return LowerRET(Op, DAG, getTargetMachine());
case ISD::STACKRESTORE: return LowerSTACKRESTORE(Op, DAG, PPCSubTarget);
case ISD::DYNAMIC_STACKALLOC:
return LowerDYNAMIC_STACKALLOC(Op, DAG, PPCSubTarget);
From dpatel at apple.com Mon Mar 5 19:06:38 2007
From: dpatel at apple.com (Devang Patel)
Date: Mon, 5 Mar 2007 19:06:38 -0600
Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp
Message-ID: <200703060106.l2616cwG006029@zion.cs.uiuc.edu>
Changes in directory llvm/lib/VMCore:
PassManager.cpp updated: 1.142 -> 1.143
---
Log message:
Add preparePassManager() hook. This allows each pass to check whether
current active pass manager is appropriate or not.
A loop pass may consider current LPPassManager in appropraite if loop
pass is not preserving analysis information that is used by other
passes managed by current LPPassManager. In such situation, loop pass
can pop current LPPassManager from the PMStack using this hook
and use new LPPassManager for itself.
---
Diffs of the changes: (+3 -0)
PassManager.cpp | 3 +++
1 files changed, 3 insertions(+)
Index: llvm/lib/VMCore/PassManager.cpp
diff -u llvm/lib/VMCore/PassManager.cpp:1.142 llvm/lib/VMCore/PassManager.cpp:1.143
--- llvm/lib/VMCore/PassManager.cpp:1.142 Mon Mar 5 16:57:49 2007
+++ llvm/lib/VMCore/PassManager.cpp Mon Mar 5 19:06:16 2007
@@ -385,6 +385,9 @@
if (findAnalysisPass(P->getPassInfo()))
return;
+ // Give pass a chance to prepare the stage.
+ P->preparePassManager(activeStack);
+
AnalysisUsage AnUsage;
P->getAnalysisUsage(AnUsage);
const std::vector &RequiredSet = AnUsage.getRequiredSet();
From dpatel at apple.com Mon Mar 5 19:06:38 2007
From: dpatel at apple.com (Devang Patel)
Date: Mon, 5 Mar 2007 19:06:38 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/Pass.h
Message-ID: <200703060106.l2616cb8006032@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm:
Pass.h updated: 1.79 -> 1.80
---
Log message:
Add preparePassManager() hook. This allows each pass to check whether
current active pass manager is appropriate or not.
A loop pass may consider current LPPassManager in appropraite if loop
pass is not preserving analysis information that is used by other
passes managed by current LPPassManager. In such situation, loop pass
can pop current LPPassManager from the PMStack using this hook
and use new LPPassManager for itself.
---
Diffs of the changes: (+5 -0)
Pass.h | 5 +++++
1 files changed, 5 insertions(+)
Index: llvm/include/llvm/Pass.h
diff -u llvm/include/llvm/Pass.h:1.79 llvm/include/llvm/Pass.h:1.80
--- llvm/include/llvm/Pass.h:1.79 Thu Jan 25 18:23:00 2007
+++ llvm/include/llvm/Pass.h Mon Mar 5 19:06:16 2007
@@ -119,8 +119,13 @@
void print(std::ostream *O, const Module *M) const { if (O) print(*O, M); }
void dump() const; // dump - call print(std::cerr, 0);
+ /// Each pass is responsible for assigning a pass manager to itself.
+ /// PMS is the stack of available pass manager.
virtual void assignPassManager(PMStack &PMS,
PassManagerType T = PMT_Unknown) {}
+ /// Check if available pass managers are suitable for this pass or not.
+ virtual void preparePassManager(PMStack &PMS) {}
+
// Access AnalysisResolver
inline void setResolver(AnalysisResolver *AR) { Resolver = AR; }
inline AnalysisResolver *getResolver() { return Resolver; }
From clattner at apple.com Mon Mar 5 19:07:11 2007
From: clattner at apple.com (clattner at apple.com)
Date: Mon, 5 Mar 2007 17:07:11 -0800 (PST)
Subject: [llvm-commits] [124573] Fix
http://llvm.org/bugs/show_bug.cgi?id=1242, by emitting a more-complete
Message-ID: <20070306010711.DDC9380CE0CF@src>
Revision: 124573
Author: clattner
Date: 2007-03-05 17:07:09 -0800 (Mon, 05 Mar 2007)
Log Message:
-----------
Fix http://llvm.org/bugs/show_bug.cgi?id=1242, by emitting a more-complete
target data string. On darwin, we now emit:
target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"
instead of:
target datalayout = "E-p:32:32"
Modified Paths:
--------------
apple-local/branches/llvm/gcc/llvm-backend.cpp
Modified: apple-local/branches/llvm/gcc/llvm-backend.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-03-06 00:42:33 UTC (rev 124572)
+++ apple-local/branches/llvm/gcc/llvm-backend.cpp 2007-03-06 01:07:09 UTC (rev 124573)
@@ -140,11 +140,6 @@
#endif
TheModule->setTargetTriple(TargetTriple);
- std::string DataLayout;
- DataLayout.append(BITS_BIG_ENDIAN ? "E" : "e");
- DataLayout.append(POINTER_SIZE == 32 ? "-p:32:32" : "-p:64:64");
- TheModule->setDataLayout(DataLayout);
-
TheTypeConverter = new TypeConverter();
// Create the TargetMachine we will be generating code with.
@@ -156,7 +151,7 @@
cerr << "Did not get a target machine!\n";
exit(1);
}
-
+
// Figure out the subtarget feature string we pass to the target.
std::string FeatureStr;
// The target can set LLVM_SET_SUBTARGET_FEATURES to configure the LLVM
@@ -168,6 +163,11 @@
#endif
TheTarget = TME->CtorFn(*TheModule, FeatureStr);
+ // Install information about target datalayout stuff into the module for
+ // optimizer use.
+ TheModule->setDataLayout(TheTarget->getTargetData()->
+ getStringRepresentation());
+
if (optimize) {
RegisterScheduler::setDefault(createDefaultScheduler);
} else {
From dpatel at apple.com Mon Mar 5 19:56:07 2007
From: dpatel at apple.com (Devang Patel)
Date: Mon, 5 Mar 2007 19:56:07 -0600
Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp
Message-ID: <200703060156.l261u74b006953@zion.cs.uiuc.edu>
Changes in directory llvm/lib/VMCore:
PassManager.cpp updated: 1.143 -> 1.144
---
Log message:
Keep track of inherited analysis. For example, if a loop pass does not
preserve dominator info then it should update parent FPPassManager's
available analysis info to reflect this.
---
Diffs of the changes: (+21 -0)
PassManager.cpp | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+)
Index: llvm/lib/VMCore/PassManager.cpp
diff -u llvm/lib/VMCore/PassManager.cpp:1.143 llvm/lib/VMCore/PassManager.cpp:1.144
--- llvm/lib/VMCore/PassManager.cpp:1.143 Mon Mar 5 19:06:16 2007
+++ llvm/lib/VMCore/PassManager.cpp Mon Mar 5 19:55:46 2007
@@ -551,6 +551,27 @@
AvailableAnalysis.erase(Info);
}
}
+
+ // Check inherited analysis also. If P is not preserving analysis
+ // provided by parent manager then remove it here.
+ for (unsigned Index = 0; Index < PMT_Last; ++Index) {
+
+ if (!InheritedAnalysis[Index])
+ continue;
+
+ for (std::map::iterator
+ I = InheritedAnalysis[Index]->begin(),
+ E = InheritedAnalysis[Index]->end(); I != E; ) {
+ std::map::iterator Info = I++;
+ if (std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) ==
+ PreservedSet.end()) {
+ // Remove this analysis
+ if (!dynamic_cast(Info->second))
+ InheritedAnalysis[Index]->erase(Info);
+ }
+ }
+ }
+
}
/// Remove analysis passes that are not used any longer
From dpatel at apple.com Mon Mar 5 19:56:07 2007
From: dpatel at apple.com (Devang Patel)
Date: Mon, 5 Mar 2007 19:56:07 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/Pass.h PassManagers.h
Message-ID: <200703060156.l261u7SO006960@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm:
Pass.h updated: 1.80 -> 1.81
PassManagers.h updated: 1.12 -> 1.13
---
Log message:
Keep track of inherited analysis. For example, if a loop pass does not
preserve dominator info then it should update parent FPPassManager's
available analysis info to reflect this.
---
Diffs of the changes: (+23 -1)
Pass.h | 3 ++-
PassManagers.h | 21 +++++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
Index: llvm/include/llvm/Pass.h
diff -u llvm/include/llvm/Pass.h:1.80 llvm/include/llvm/Pass.h:1.81
--- llvm/include/llvm/Pass.h:1.80 Mon Mar 5 19:06:16 2007
+++ llvm/include/llvm/Pass.h Mon Mar 5 19:55:46 2007
@@ -64,7 +64,8 @@
PMT_CallGraphPassManager, /// CGPassManager
PMT_FunctionPassManager, /// FPPassManager
PMT_LoopPassManager, /// LPPassManager
- PMT_BasicBlockPassManager /// BBPassManager
+ PMT_BasicBlockPassManager, /// BBPassManager
+ PMT_Last
};
typedef enum PassManagerType PassManagerType;
Index: llvm/include/llvm/PassManagers.h
diff -u llvm/include/llvm/PassManagers.h:1.12 llvm/include/llvm/PassManagers.h:1.13
--- llvm/include/llvm/PassManagers.h:1.12 Mon Mar 5 16:57:49 2007
+++ llvm/include/llvm/PassManagers.h Mon Mar 5 19:55:46 2007
@@ -197,6 +197,7 @@
/// used by pass managers.
class PMDataManager {
public:
+
PMDataManager(int Depth) : TPM(NULL), Depth(Depth) {
initializeAnalysisInfo();
}
@@ -223,6 +224,8 @@
/// Initialize available analysis information.
void initializeAnalysisInfo() {
AvailableAnalysis.clear();
+ for (unsigned i = 0; i < PMT_Last; ++i)
+ InheritedAnalysis[i] = NULL;
}
/// Populate RequiredPasses with the analysis pass that are required by
@@ -262,6 +265,19 @@
assert ( 0 && "Invalid use of getPassManagerType");
return PMT_Unknown;
}
+
+ std::map *getAvailableAnalysis() {
+ return &AvailableAnalysis;
+ }
+
+ // Collect AvailableAnalysis from all the active Pass Managers.
+ void populateInheritedAnalysis(PMStack &PMS) {
+ unsigned Index = 0;
+ for (PMStack::iterator I = PMS.begin(), E = PMS.end();
+ I != E; ++I)
+ InheritedAnalysis[Index++] = (*I)->getAvailableAnalysis();
+ }
+
protected:
// Top level manager.
@@ -270,6 +286,11 @@
// Collection of pass that are managed by this manager
std::vector PassVector;
+ // Collection of Analysis provided by Parent pass manager and
+ // used by current pass manager. At at time there can not be more
+ // then PMT_Last active pass mangers.
+ std::map *InheritedAnalysis[PMT_Last];
+
private:
// Set of available Analysis. This information is used while scheduling
// pass. If a pass requires an analysis which is not not available then
From dpatel at apple.com Mon Mar 5 20:31:06 2007
From: dpatel at apple.com (Devang Patel)
Date: Mon, 5 Mar 2007 20:31:06 -0600
Subject: [llvm-commits] CVS: llvm/lib/Analysis/LoopPass.cpp
Message-ID: <200703060231.l262V6gq007700@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Analysis:
LoopPass.cpp updated: 1.9 -> 1.10
---
Log message:
Use std::deque to manage loop queue inside LPPassManager.
---
Diffs of the changes: (+6 -40)
LoopPass.cpp | 46 ++++++----------------------------------------
1 files changed, 6 insertions(+), 40 deletions(-)
Index: llvm/lib/Analysis/LoopPass.cpp
diff -u llvm/lib/Analysis/LoopPass.cpp:1.9 llvm/lib/Analysis/LoopPass.cpp:1.10
--- llvm/lib/Analysis/LoopPass.cpp:1.9 Mon Mar 5 14:01:30 2007
+++ llvm/lib/Analysis/LoopPass.cpp Mon Mar 5 20:30:46 2007
@@ -14,38 +14,9 @@
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/LoopPass.h"
-#include
using namespace llvm;
//===----------------------------------------------------------------------===//
-// LoopQueue
-
-namespace llvm {
-
-// Compare Two loops based on their depth in loop nest.
-class LoopCompare {
-public:
- bool operator()( Loop *L1, Loop *L2) const {
- // Loops with highest depth has the highest priority.
- return L1->getLoopDepth() < L2->getLoopDepth();
- }
-};
-
-// Loop queue used by Loop Pass Manager. This is a wrapper class
-// that hides implemenation detail (use of priority_queue) inside .cpp file.
-class LoopQueue {
-public:
- inline void push(Loop *L) { LPQ.push(L); }
- inline void pop() { LPQ.pop(); }
- inline Loop *top() { return LPQ.top(); }
- inline bool empty() { return LPQ.empty(); }
-private:
- std::priority_queue, LoopCompare> LPQ;
-};
-
-} // End of LLVM namespace
-
-//===----------------------------------------------------------------------===//
// LPPassManager
//
/// LPPassManager manages FPPassManagers and CalLGraphSCCPasses.
@@ -53,11 +24,6 @@
LPPassManager::LPPassManager(int Depth) : PMDataManager(Depth) {
skipThisLoop = false;
redoThisLoop = false;
- LQ = new LoopQueue();
-}
-
-LPPassManager::~LPPassManager() {
- delete LQ;
}
/// Delete loop from the loop queue. This is used by Loop pass to inform
@@ -75,10 +41,10 @@
}
// Recurse through all subloops and all loops into LQ.
-static void addLoopIntoQueue(Loop *L, LoopQueue *LQ) {
+static void addLoopIntoQueue(Loop *L, std::deque &LQ) {
for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
addLoopIntoQueue(*I, LQ);
- LQ->push(L);
+ LQ.push_back(L);
}
/// run - Execute all of the passes scheduled for execution. Keep track of
@@ -92,9 +58,9 @@
addLoopIntoQueue(*I, LQ);
// Walk Loops
- while (!LQ->empty()) {
+ while (!LQ.empty()) {
- Loop *L = LQ->top();
+ Loop *L = LQ.back();
skipThisLoop = false;
redoThisLoop = false;
@@ -130,10 +96,10 @@
}
// Pop the loop from queue after running all passes.
- LQ->pop();
+ LQ.pop_back();
if (redoThisLoop)
- LQ->push(L);
+ LQ.push_back(L);
}
return Changed;
From dpatel at apple.com Mon Mar 5 20:31:07 2007
From: dpatel at apple.com (Devang Patel)
Date: Mon, 5 Mar 2007 20:31:07 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/LoopPass.h
Message-ID: <200703060231.l262V74k007705@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm/Analysis:
LoopPass.h updated: 1.7 -> 1.8
---
Log message:
Use std::deque to manage loop queue inside LPPassManager.
---
Diffs of the changes: (+1 -3)
LoopPass.h | 4 +---
1 files changed, 1 insertion(+), 3 deletions(-)
Index: llvm/include/llvm/Analysis/LoopPass.h
diff -u llvm/include/llvm/Analysis/LoopPass.h:1.7 llvm/include/llvm/Analysis/LoopPass.h:1.8
--- llvm/include/llvm/Analysis/LoopPass.h:1.7 Tue Feb 27 09:00:39 2007
+++ llvm/include/llvm/Analysis/LoopPass.h Mon Mar 5 20:30:46 2007
@@ -25,7 +25,6 @@
class LPPassManager;
class Loop;
class Function;
-class LoopQueue;
class LoopPass : public Pass {
@@ -47,7 +46,6 @@
public:
LPPassManager(int Depth);
- ~LPPassManager();
/// run - Execute all of the passes scheduled for execution. Keep track of
/// whether any of the passes modifies the module, and if so, return true.
@@ -95,7 +93,7 @@
// utility may send LPPassManager into infinite loops so use caution.
void redoLoop(Loop *L);
private:
- LoopQueue *LQ;
+ std::deque LQ;
bool skipThisLoop;
bool redoThisLoop;
};
From reid at x10sys.com Mon Mar 5 21:00:33 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 21:00:33 -0600
Subject: [llvm-commits] CVS: llvm/test/CFrontend/2007-03-05-DataLayout.c
Message-ID: <200703060300.l2630XOM008327@zion.cs.uiuc.edu>
Changes in directory llvm/test/CFrontend:
2007-03-05-DataLayout.c added (r1.1)
---
Log message:
Test to ensure that data layout is generated correctly for host platform.
This is for PR1242: http://llvm.org/PR1242 .
---
Diffs of the changes: (+51 -0)
2007-03-05-DataLayout.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+)
Index: llvm/test/CFrontend/2007-03-05-DataLayout.c
diff -c /dev/null llvm/test/CFrontend/2007-03-05-DataLayout.c:1.1
*** /dev/null Mon Mar 5 21:00:27 2007
--- llvm/test/CFrontend/2007-03-05-DataLayout.c Mon Mar 5 21:00:17 2007
***************
*** 0 ****
--- 1,51 ----
+ // Testcase for PR1242
+ // RUN: %llvmgcc -c %s -o %t && lli --force-interpreter=1 %t
+ #include
+ #define NDIM 3
+ #define BODY 01
+ typedef double vector[NDIM];
+ typedef struct bnode* bodyptr;
+ // { i16, double, [3 x double], i32, i32, [3 x double], [3 x double], [3 x
+ // double], double, \2 *, \2 * }
+ struct bnode {
+ short int type;
+ double mass;
+ vector pos;
+ int proc;
+ int new_proc;
+ vector vel;
+ vector acc;
+ vector new_acc;
+ double phi;
+ bodyptr next;
+ bodyptr proc_next;
+ } body;
+
+ #define Type(x) ((x)->type)
+ #define Mass(x) ((x)->mass)
+ #define Pos(x) ((x)->pos)
+ #define Proc(x) ((x)->proc)
+ #define New_Proc(x) ((x)->new_proc)
+ #define Vel(x) ((x)->vel)
+ #define Acc(x) ((x)->acc)
+ #define New_Acc(x) ((x)->new_acc)
+ #define Phi(x) ((x)->phi)
+ #define Next(x) ((x)->next)
+ #define Proc_Next(x) ((x)->proc_next)
+
+ bodyptr ubody_alloc(int p)
+ {
+ register bodyptr tmp;
+ tmp = (bodyptr)malloc(sizeof(body));
+
+ Type(tmp) = BODY;
+ Proc(tmp) = p;
+ Proc_Next(tmp) = NULL;
+ New_Proc(tmp) = p;
+ return tmp;
+ }
+
+ int main(int argc, char** argv) {
+ bodyptr b = ubody_alloc(17);
+ return 0;
+ }
From reid at x10sys.com Mon Mar 5 21:02:11 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 21:02:11 -0600
Subject: [llvm-commits] CVS:
llvm/include/llvm/ExecutionEngine/ExecutionEngine.h GenericValue.h
Message-ID: <200703060302.l2632BKl008376@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm/ExecutionEngine:
ExecutionEngine.h updated: 1.43 -> 1.44
GenericValue.h updated: 1.10 -> 1.11
---
Log message:
Make GenericeValue into a struct with a union instead of just a union. This
allows an APInt value to be constructed. Remove all the native integer types
from the union. These are replaced with the single IntVal of type APInt.
---
Diffs of the changes: (+16 -23)
ExecutionEngine.h | 2 +-
GenericValue.h | 37 +++++++++++++++----------------------
2 files changed, 16 insertions(+), 23 deletions(-)
Index: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h
diff -u llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:1.43 llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:1.44
--- llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:1.43 Sat Mar 3 12:18:11 2007
+++ llvm/include/llvm/ExecutionEngine/ExecutionEngine.h Mon Mar 5 21:01:54 2007
@@ -24,7 +24,7 @@
namespace llvm {
-union GenericValue;
+struct GenericValue;
class Constant;
class Function;
class GlobalVariable;
Index: llvm/include/llvm/ExecutionEngine/GenericValue.h
diff -u llvm/include/llvm/ExecutionEngine/GenericValue.h:1.10 llvm/include/llvm/ExecutionEngine/GenericValue.h:1.11
--- llvm/include/llvm/ExecutionEngine/GenericValue.h:1.10 Sat Mar 3 01:36:44 2007
+++ llvm/include/llvm/ExecutionEngine/GenericValue.h Mon Mar 5 21:01:54 2007
@@ -15,37 +15,30 @@
#ifndef GENERIC_VALUE_H
#define GENERIC_VALUE_H
+#include "llvm/ADT/APInt.h"
#include "llvm/Support/DataTypes.h"
namespace llvm {
-typedef uintptr_t PointerTy;
+typedef void* PointerTy;
class APInt;
-class Type;
-union GenericValue {
- bool Int1Val;
- unsigned char Int8Val;
- unsigned short Int16Val;
- unsigned int Int32Val;
- uint64_t Int64Val;
- APInt *APIntVal;
- double DoubleVal;
- float FloatVal;
- struct { unsigned int first; unsigned int second; } UIntPairVal;
- PointerTy PointerVal;
- unsigned char Untyped[8];
-
- GenericValue() {}
- GenericValue(void *V) {
- PointerVal = (PointerTy)(intptr_t)V;
- }
+struct GenericValue {
+ union {
+ double DoubleVal;
+ float FloatVal;
+ PointerTy PointerVal;
+ struct { unsigned int first; unsigned int second; } UIntPairVal;
+ unsigned char Untyped[8];
+ };
+ APInt IntVal;
+
+ GenericValue() : DoubleVal(0.0), IntVal(1,0) {}
+ GenericValue(void *V) : PointerVal(V), IntVal(1,0) { }
};
inline GenericValue PTOGV(void *P) { return GenericValue(P); }
-inline void* GVTOP(const GenericValue &GV) {
- return (void*)(intptr_t)GV.PointerVal;
-}
+inline void* GVTOP(const GenericValue &GV) { return GV.PointerVal; }
} // End llvm namespace
#endif
From reid at x10sys.com Mon Mar 5 21:04:21 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 21:04:21 -0600
Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
Message-ID: <200703060304.l2634LZs008420@zion.cs.uiuc.edu>
Changes in directory llvm/lib/ExecutionEngine:
ExecutionEngine.cpp updated: 1.110 -> 1.111
---
Log message:
Simplify things significantly because GenericValue now has a single integer
field, of type APInt, instead of multiple integer fields. Also, get rid of
the special endianness code in StoreValueToMemory and LoadValueToMemory.
ExecutionEngine is always used to execute on the host platform so this is
now unnecessary.
---
Diffs of the changes: (+72 -281)
ExecutionEngine.cpp | 353 ++++++++++------------------------------------------
1 files changed, 72 insertions(+), 281 deletions(-)
Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.110 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.111
--- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.110 Sat Mar 3 12:19:18 2007
+++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp Mon Mar 5 21:04:04 2007
@@ -229,7 +229,7 @@
const char * const * envp) {
std::vector GVArgs;
GenericValue GVArgc;
- GVArgc.Int32Val = argv.size();
+ GVArgc.IntVal = APInt(32, argv.size());
unsigned NumArgs = Fn->getFunctionType()->getNumParams();
if (NumArgs) {
GVArgs.push_back(GVArgc); // Arg #0 = argc.
@@ -245,7 +245,7 @@
}
}
}
- return runFunction(Fn, GVArgs).Int32Val;
+ return runFunction(Fn, GVArgs).IntVal.getZExtValue();
}
/// If possible, create a JIT, unless the caller specifically requests an
@@ -298,28 +298,6 @@
return state.getGlobalAddressMap(locked)[GV];
}
-/// This macro is used to handle a variety of situations involing integer
-/// values where the action should be done to one of the GenericValue members.
-/// THEINTTY is a const Type * for the integer type. ACTION1 comes before
-/// the GenericValue, ACTION2 comes after.
-#define DO_FOR_INTEGER(THEINTTY, ACTION) \
- { \
- unsigned BitWidth = cast(THEINTTY)->getBitWidth(); \
- if (BitWidth == 1) {\
- ACTION(Int1Val); \
- } else if (BitWidth <= 8) {\
- ACTION(Int8Val); \
- } else if (BitWidth <= 16) {\
- ACTION(Int16Val); \
- } else if (BitWidth <= 32) { \
- ACTION(Int32Val); \
- } else if (BitWidth <= 64) { \
- ACTION(Int64Val); \
- } else {\
- assert(0 && "Not implemented: integer types > 64 bits"); \
- } \
- }
-
/// This function converts a Constant* into a GenericValue. The interesting
/// part is if C is a ConstantExpr.
/// @brief Get a GenericValue for a Constnat*
@@ -341,10 +319,8 @@
TD->getIndexedOffset(CE->getOperand(0)->getType(),
&Indices[0], Indices.size());
- if (getTargetData()->getPointerSize() == 4)
- Result.Int32Val += Offset;
- else
- Result.Int64Val += Offset;
+ char* tmp = (char*) Result.PointerVal;
+ Result = PTOGV(tmp + Offset);
return Result;
}
case Instruction::Trunc:
@@ -375,21 +351,15 @@
// IntToPtr casts are just so special. Cast to intptr_t first.
Constant *Op = CE->getOperand(0);
GenericValue GV = getConstantValue(Op);
-#define INT_TO_PTR_ACTION(FIELD) \
- return PTOGV((void*)(uintptr_t)GV.FIELD)
- DO_FOR_INTEGER(Op->getType(), INT_TO_PTR_ACTION)
-#undef INT_TO_PTR_ACTION
+ return PTOGV((void*)(uintptr_t)GV.IntVal.getZExtValue());
break;
}
case Instruction::Add:
switch (CE->getOperand(0)->getType()->getTypeID()) {
default: assert(0 && "Bad add type!"); abort();
case Type::IntegerTyID:
-#define ADD_ACTION(FIELD) \
- Result.FIELD = getConstantValue(CE->getOperand(0)).FIELD + \
- getConstantValue(CE->getOperand(1)).FIELD;
- DO_FOR_INTEGER(CE->getOperand(0)->getType(),ADD_ACTION);
-#undef ADD_ACTION
+ Result.IntVal = getConstantValue(CE->getOperand(0)).IntVal + \
+ getConstantValue(CE->getOperand(1)).IntVal;
break;
case Type::FloatTyID:
Result.FloatVal = getConstantValue(CE->getOperand(0)).FloatVal +
@@ -409,28 +379,15 @@
}
switch (C->getType()->getTypeID()) {
-#define GET_CONST_VAL(TY, CTY, CLASS, GETMETH) \
- case Type::TY##TyID: Result.TY##Val = (CTY)cast(C)->GETMETH(); break
- GET_CONST_VAL(Float , float , ConstantFP, getValue);
- GET_CONST_VAL(Double, double , ConstantFP, getValue);
-#undef GET_CONST_VAL
- case Type::IntegerTyID: {
- unsigned BitWidth = cast(C->getType())->getBitWidth();
- if (BitWidth == 1)
- Result.Int1Val = (bool)cast(C)->getZExtValue();
- else if (BitWidth <= 8)
- Result.Int8Val = (uint8_t )cast(C)->getZExtValue();
- else if (BitWidth <= 16)
- Result.Int16Val = (uint16_t )cast(C)->getZExtValue();
- else if (BitWidth <= 32)
- Result.Int32Val = (uint32_t )cast(C)->getZExtValue();
- else if (BitWidth <= 64)
- Result.Int64Val = (uint64_t )cast(C)->getZExtValue();
- else
- Result.APIntVal = const_cast(&cast(C)->getValue());
+ case Type::FloatTyID:
+ Result.FloatVal = (float)cast(C)->getValue();
+ break;
+ case Type::DoubleTyID:
+ Result.DoubleVal = (double)cast(C)->getValue();
+ break;
+ case Type::IntegerTyID:
+ Result.IntVal = cast(C)->getValue();
break;
- }
-
case Type::PointerTyID:
if (isa(C))
Result.PointerVal = 0;
@@ -455,126 +412,37 @@
///
void ExecutionEngine::StoreValueToMemory(GenericValue Val, GenericValue *Ptr,
const Type *Ty) {
- if (getTargetData()->isLittleEndian()) {
- switch (Ty->getTypeID()) {
- case Type::IntegerTyID: {
- unsigned BitWidth = cast(Ty)->getBitWidth();
- uint64_t BitMask = cast(Ty)->getBitMask();
- GenericValue TmpVal = Val;
- if (BitWidth <= 8)
- Ptr->Untyped[0] = Val.Int8Val & BitMask;
- else if (BitWidth <= 16) {
- TmpVal.Int16Val &= BitMask;
- Ptr->Untyped[0] = TmpVal.Int16Val & 255;
- Ptr->Untyped[1] = (TmpVal.Int16Val >> 8) & 255;
- } else if (BitWidth <= 32) {
- TmpVal.Int32Val &= BitMask;
- Ptr->Untyped[0] = TmpVal.Int32Val & 255;
- Ptr->Untyped[1] = (TmpVal.Int32Val >> 8) & 255;
- Ptr->Untyped[2] = (TmpVal.Int32Val >> 16) & 255;
- Ptr->Untyped[3] = (TmpVal.Int32Val >> 24) & 255;
- } else if (BitWidth <= 64) {
- TmpVal.Int64Val &= BitMask;
- Ptr->Untyped[0] = (unsigned char)(TmpVal.Int64Val );
- Ptr->Untyped[1] = (unsigned char)(TmpVal.Int64Val >> 8);
- Ptr->Untyped[2] = (unsigned char)(TmpVal.Int64Val >> 16);
- Ptr->Untyped[3] = (unsigned char)(TmpVal.Int64Val >> 24);
- Ptr->Untyped[4] = (unsigned char)(TmpVal.Int64Val >> 32);
- Ptr->Untyped[5] = (unsigned char)(TmpVal.Int64Val >> 40);
- Ptr->Untyped[6] = (unsigned char)(TmpVal.Int64Val >> 48);
- Ptr->Untyped[7] = (unsigned char)(TmpVal.Int64Val >> 56);
- } else {
- uint64_t *Dest = (uint64_t*)Ptr;
- const uint64_t *Src = Val.APIntVal->getRawData();
- for (uint32_t i = 0; i < Val.APIntVal->getNumWords(); ++i)
- Dest[i] = Src[i];
- }
- break;
- }
-Store4BytesLittleEndian:
- case Type::FloatTyID:
- Ptr->Untyped[0] = Val.Int32Val & 255;
- Ptr->Untyped[1] = (Val.Int32Val >> 8) & 255;
- Ptr->Untyped[2] = (Val.Int32Val >> 16) & 255;
- Ptr->Untyped[3] = (Val.Int32Val >> 24) & 255;
- break;
- case Type::PointerTyID:
- if (getTargetData()->getPointerSize() == 4)
- goto Store4BytesLittleEndian;
- /* FALL THROUGH */
- case Type::DoubleTyID:
- Ptr->Untyped[0] = (unsigned char)(Val.Int64Val );
- Ptr->Untyped[1] = (unsigned char)(Val.Int64Val >> 8);
- Ptr->Untyped[2] = (unsigned char)(Val.Int64Val >> 16);
- Ptr->Untyped[3] = (unsigned char)(Val.Int64Val >> 24);
- Ptr->Untyped[4] = (unsigned char)(Val.Int64Val >> 32);
- Ptr->Untyped[5] = (unsigned char)(Val.Int64Val >> 40);
- Ptr->Untyped[6] = (unsigned char)(Val.Int64Val >> 48);
- Ptr->Untyped[7] = (unsigned char)(Val.Int64Val >> 56);
- break;
- default:
- cerr << "Cannot store value of type " << *Ty << "!\n";
- }
- } else {
- switch (Ty->getTypeID()) {
- case Type::IntegerTyID: {
- unsigned BitWidth = cast(Ty)->getBitWidth();
- uint64_t BitMask = cast(Ty)->getBitMask();
- GenericValue TmpVal = Val;
- if (BitWidth <= 8)
- Ptr->Untyped[0] = Val.Int8Val & BitMask;
- else if (BitWidth <= 16) {
- TmpVal.Int16Val &= BitMask;
- Ptr->Untyped[1] = TmpVal.Int16Val & 255;
- Ptr->Untyped[0] = (TmpVal.Int16Val >> 8) & 255;
- } else if (BitWidth <= 32) {
- TmpVal.Int32Val &= BitMask;
- Ptr->Untyped[3] = TmpVal.Int32Val & 255;
- Ptr->Untyped[2] = (TmpVal.Int32Val >> 8) & 255;
- Ptr->Untyped[1] = (TmpVal.Int32Val >> 16) & 255;
- Ptr->Untyped[0] = (TmpVal.Int32Val >> 24) & 255;
- } else if (BitWidth <= 64) {
- TmpVal.Int64Val &= BitMask;
- Ptr->Untyped[7] = (unsigned char)(TmpVal.Int64Val );
- Ptr->Untyped[6] = (unsigned char)(TmpVal.Int64Val >> 8);
- Ptr->Untyped[5] = (unsigned char)(TmpVal.Int64Val >> 16);
- Ptr->Untyped[4] = (unsigned char)(TmpVal.Int64Val >> 24);
- Ptr->Untyped[3] = (unsigned char)(TmpVal.Int64Val >> 32);
- Ptr->Untyped[2] = (unsigned char)(TmpVal.Int64Val >> 40);
- Ptr->Untyped[1] = (unsigned char)(TmpVal.Int64Val >> 48);
- Ptr->Untyped[0] = (unsigned char)(TmpVal.Int64Val >> 56);
- } else {
- uint64_t *Dest = (uint64_t*)Ptr;
- const uint64_t *Src = Val.APIntVal->getRawData();
- for (uint32_t i = 0; i < Val.APIntVal->getNumWords(); ++i)
- Dest[i] = Src[i];
- }
- break;
- }
- Store4BytesBigEndian:
- case Type::FloatTyID:
- Ptr->Untyped[3] = Val.Int32Val & 255;
- Ptr->Untyped[2] = (Val.Int32Val >> 8) & 255;
- Ptr->Untyped[1] = (Val.Int32Val >> 16) & 255;
- Ptr->Untyped[0] = (Val.Int32Val >> 24) & 255;
- break;
- case Type::PointerTyID:
- if (getTargetData()->getPointerSize() == 4)
- goto Store4BytesBigEndian;
- /* FALL THROUGH */
- case Type::DoubleTyID:
- Ptr->Untyped[7] = (unsigned char)(Val.Int64Val );
- Ptr->Untyped[6] = (unsigned char)(Val.Int64Val >> 8);
- Ptr->Untyped[5] = (unsigned char)(Val.Int64Val >> 16);
- Ptr->Untyped[4] = (unsigned char)(Val.Int64Val >> 24);
- Ptr->Untyped[3] = (unsigned char)(Val.Int64Val >> 32);
- Ptr->Untyped[2] = (unsigned char)(Val.Int64Val >> 40);
- Ptr->Untyped[1] = (unsigned char)(Val.Int64Val >> 48);
- Ptr->Untyped[0] = (unsigned char)(Val.Int64Val >> 56);
- break;
- default:
- cerr << "Cannot store value of type " << *Ty << "!\n";
+ switch (Ty->getTypeID()) {
+ case Type::IntegerTyID: {
+ unsigned BitWidth = cast(Ty)->getBitWidth();
+ GenericValue TmpVal = Val;
+ if (BitWidth <= 8)
+ *((uint8_t*)Ptr) = uint8_t(Val.IntVal.getZExtValue());
+ else if (BitWidth <= 16) {
+ *((uint16_t*)Ptr) = uint16_t(Val.IntVal.getZExtValue());
+ } else if (BitWidth <= 32) {
+ *((uint32_t*)Ptr) = uint32_t(Val.IntVal.getZExtValue());
+ } else if (BitWidth <= 64) {
+ *((uint64_t*)Ptr) = uint32_t(Val.IntVal.getZExtValue());
+ } else {
+ uint64_t *Dest = (uint64_t*)Ptr;
+ const uint64_t *Src = Val.IntVal.getRawData();
+ for (uint32_t i = 0; i < Val.IntVal.getNumWords(); ++i)
+ Dest[i] = Src[i];
}
+ break;
+ }
+ case Type::FloatTyID:
+ *((float*)Ptr) = Val.FloatVal;
+ break;
+ case Type::DoubleTyID:
+ *((double*)Ptr) = Val.DoubleVal;
+ break;
+ case Type::PointerTyID:
+ *((PointerTy*)Ptr) = Val.PointerVal;
+ break;
+ default:
+ cerr << "Cannot store value of type " << *Ty << "!\n";
}
}
@@ -583,110 +451,33 @@
void ExecutionEngine::LoadValueFromMemory(GenericValue &Result,
GenericValue *Ptr,
const Type *Ty) {
- if (getTargetData()->isLittleEndian()) {
- switch (Ty->getTypeID()) {
- case Type::IntegerTyID: {
- unsigned BitWidth = cast(Ty)->getBitWidth();
- if (BitWidth <= 8)
- Result.Int8Val = Ptr->Untyped[0];
- else if (BitWidth <= 16) {
- Result.Int16Val = (unsigned)Ptr->Untyped[0] |
- ((unsigned)Ptr->Untyped[1] << 8);
- } else if (BitWidth <= 32) {
- Result.Int32Val = (unsigned)Ptr->Untyped[0] |
- ((unsigned)Ptr->Untyped[1] << 8) |
- ((unsigned)Ptr->Untyped[2] << 16) |
- ((unsigned)Ptr->Untyped[3] << 24);
- } else if (BitWidth <= 64) {
- Result.Int64Val = (uint64_t)Ptr->Untyped[0] |
- ((uint64_t)Ptr->Untyped[1] << 8) |
- ((uint64_t)Ptr->Untyped[2] << 16) |
- ((uint64_t)Ptr->Untyped[3] << 24) |
- ((uint64_t)Ptr->Untyped[4] << 32) |
- ((uint64_t)Ptr->Untyped[5] << 40) |
- ((uint64_t)Ptr->Untyped[6] << 48) |
- ((uint64_t)Ptr->Untyped[7] << 56);
- } else
- *(Result.APIntVal) = APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
- break;
- }
- Load4BytesLittleEndian:
- case Type::FloatTyID:
- Result.Int32Val = (unsigned)Ptr->Untyped[0] |
- ((unsigned)Ptr->Untyped[1] << 8) |
- ((unsigned)Ptr->Untyped[2] << 16) |
- ((unsigned)Ptr->Untyped[3] << 24);
- break;
- case Type::PointerTyID:
- if (getTargetData()->getPointerSize() == 4)
- goto Load4BytesLittleEndian;
- /* FALL THROUGH */
- case Type::DoubleTyID:
- Result.Int64Val = (uint64_t)Ptr->Untyped[0] |
- ((uint64_t)Ptr->Untyped[1] << 8) |
- ((uint64_t)Ptr->Untyped[2] << 16) |
- ((uint64_t)Ptr->Untyped[3] << 24) |
- ((uint64_t)Ptr->Untyped[4] << 32) |
- ((uint64_t)Ptr->Untyped[5] << 40) |
- ((uint64_t)Ptr->Untyped[6] << 48) |
- ((uint64_t)Ptr->Untyped[7] << 56);
- break;
- default:
- cerr << "Cannot load value of type " << *Ty << "!\n";
- abort();
- }
- } else {
- switch (Ty->getTypeID()) {
- case Type::IntegerTyID: {
- uint32_t BitWidth = cast(Ty)->getBitWidth();
- if (BitWidth <= 8)
- Result.Int8Val = Ptr->Untyped[0];
- else if (BitWidth <= 16) {
- Result.Int16Val = (unsigned)Ptr->Untyped[1] |
- ((unsigned)Ptr->Untyped[0] << 8);
- } else if (BitWidth <= 32) {
- Result.Int32Val = (unsigned)Ptr->Untyped[3] |
- ((unsigned)Ptr->Untyped[2] << 8) |
- ((unsigned)Ptr->Untyped[1] << 16) |
- ((unsigned)Ptr->Untyped[0] << 24);
- } else if (BitWidth <= 64) {
- Result.Int64Val = (uint64_t)Ptr->Untyped[7] |
- ((uint64_t)Ptr->Untyped[6] << 8) |
- ((uint64_t)Ptr->Untyped[5] << 16) |
- ((uint64_t)Ptr->Untyped[4] << 24) |
- ((uint64_t)Ptr->Untyped[3] << 32) |
- ((uint64_t)Ptr->Untyped[2] << 40) |
- ((uint64_t)Ptr->Untyped[1] << 48) |
- ((uint64_t)Ptr->Untyped[0] << 56);
- } else
- *(Result.APIntVal) = APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
- break;
- }
- Load4BytesBigEndian:
- case Type::FloatTyID:
- Result.Int32Val = (unsigned)Ptr->Untyped[3] |
- ((unsigned)Ptr->Untyped[2] << 8) |
- ((unsigned)Ptr->Untyped[1] << 16) |
- ((unsigned)Ptr->Untyped[0] << 24);
- break;
- case Type::PointerTyID:
- if (getTargetData()->getPointerSize() == 4)
- goto Load4BytesBigEndian;
- /* FALL THROUGH */
- case Type::DoubleTyID:
- Result.Int64Val = (uint64_t)Ptr->Untyped[7] |
- ((uint64_t)Ptr->Untyped[6] << 8) |
- ((uint64_t)Ptr->Untyped[5] << 16) |
- ((uint64_t)Ptr->Untyped[4] << 24) |
- ((uint64_t)Ptr->Untyped[3] << 32) |
- ((uint64_t)Ptr->Untyped[2] << 40) |
- ((uint64_t)Ptr->Untyped[1] << 48) |
- ((uint64_t)Ptr->Untyped[0] << 56);
- break;
- default:
- cerr << "Cannot load value of type " << *Ty << "!\n";
- abort();
- }
+ switch (Ty->getTypeID()) {
+ case Type::IntegerTyID: {
+ unsigned BitWidth = cast(Ty)->getBitWidth();
+ if (BitWidth <= 8)
+ Result.IntVal = APInt(BitWidth, *((uint8_t*)Ptr));
+ else if (BitWidth <= 16) {
+ Result.IntVal = APInt(BitWidth, *((uint16_t*)Ptr));
+ } else if (BitWidth <= 32) {
+ Result.IntVal = APInt(BitWidth, *((uint32_t*)Ptr));
+ } else if (BitWidth <= 64) {
+ Result.IntVal = APInt(BitWidth, *((uint64_t*)Ptr));
+ } else
+ Result.IntVal = APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
+ break;
+ }
+ case Type::FloatTyID:
+ Result.FloatVal = *((float*)Ptr);
+ break;
+ case Type::DoubleTyID:
+ Result.DoubleVal = *((double*)Ptr);
+ break;
+ case Type::PointerTyID:
+ Result.PointerVal = *((PointerTy*)Ptr);
+ break;
+ default:
+ cerr << "Cannot load value of type " << *Ty << "!\n";
+ abort();
}
}
From reid at x10sys.com Mon Mar 5 21:06:14 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 21:06:14 -0600
Subject: [llvm-commits] CVS:
llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp
Message-ID: <200703060306.l2636EWT008457@zion.cs.uiuc.edu>
Changes in directory llvm/lib/ExecutionEngine/Interpreter:
Interpreter.cpp updated: 1.38 -> 1.39
---
Log message:
Remove the insufficient code in Interpreter::create that computed the
Target DataLayout incorrectly. For now, we'll trust that the module has
got the correct DataLayout. In the future, this needs to be changed to
tell the TargetData to be "current host".
---
Diffs of the changes: (+0 -12)
Interpreter.cpp | 12 ------------
1 files changed, 12 deletions(-)
Index: llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp:1.38 llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp:1.39
--- llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp:1.38 Sat Mar 3 12:29:16 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp Mon Mar 5 21:05:57 2007
@@ -46,18 +46,6 @@
// when the module is deleted via the ExistingModuleProvide via EE.
delete MP;
- // FIXME: This should probably compute the entire data layout
- std::string DataLayout;
- int Test = 0;
- *(char*)&Test = 1; // Return true if the host is little endian
- bool isLittleEndian = (Test == 1);
- DataLayout.append(isLittleEndian ? "e" : "E");
-
- bool Ptr64 = sizeof(void*) == 8;
- DataLayout.append(Ptr64 ? "-p:64:64" : "-p:32:32");
-
- M->setDataLayout(DataLayout);
-
return new Interpreter(M);
}
From reid at x10sys.com Mon Mar 5 21:07:05 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 21:07:05 -0600
Subject: [llvm-commits] CVS:
llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
Message-ID: <200703060307.l263752E008484@zion.cs.uiuc.edu>
Changes in directory llvm/lib/ExecutionEngine/Interpreter:
Interpreter.h updated: 1.85 -> 1.86
---
Log message:
APInt's are no longer allocated on the heap because they are direct
members of GenericValue. Consequently the code to clean them up isn't
needed.
---
Diffs of the changes: (+0 -12)
Interpreter.h | 12 ------------
1 files changed, 12 deletions(-)
Index: llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
diff -u llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.85 llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.86
--- llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.85 Sat Mar 3 12:19:18 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Interpreter.h Mon Mar 5 21:06:48 2007
@@ -76,18 +76,6 @@
CallSite Caller; // Holds the call that called subframes.
// NULL if main func or debugger invoked fn
AllocaHolderHandle Allocas; // Track memory allocated by alloca
- std::vector APInts; // Track memory allocated for APInts
- APInt* getAPInt(uint32_t BitWidth) {
- APInt* Result = new APInt(BitWidth, 0);
- APInts.push_back(Result);
- return Result;
- }
- ~ExecutionContext() {
- while (!APInts.empty()) {
- delete APInts.back();
- APInts.pop_back();
- }
- }
};
// Interpreter - This class represents the entirety of the interpreter.
From dalej at apple.com Mon Mar 5 21:08:17 2007
From: dalej at apple.com (Dale Johannesen)
Date: Mon, 5 Mar 2007 21:08:17 -0600
Subject: [llvm-commits] CVS: llvm-test/Makefile.programs
Message-ID: <200703060308.l2638H1S008528@zion.cs.uiuc.edu>
Changes in directory llvm-test:
Makefile.programs updated: 1.257 -> 1.258
---
Log message:
Add -enable-tail-merge to PPC flags.
---
Diffs of the changes: (+1 -1)
Makefile.programs | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
Index: llvm-test/Makefile.programs
diff -u llvm-test/Makefile.programs:1.257 llvm-test/Makefile.programs:1.258
--- llvm-test/Makefile.programs:1.257 Thu Feb 8 21:43:45 2007
+++ llvm-test/Makefile.programs Mon Mar 5 21:07:59 2007
@@ -211,7 +211,7 @@
endif#DISABLE_DIFFS
ifeq ($(ARCH),PowerPC)
-LLCBETAOPTION := --enable-ppc-preinc
+LLCBETAOPTION := --enable-ppc-preinc --enable-tail-merge
#--enable-tail-merge
#-regalloc=local -fast
endif
From reid at x10sys.com Mon Mar 5 21:08:29 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 21:08:29 -0600
Subject: [llvm-commits] CVS:
llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
Message-ID: <200703060308.l2638TOH008542@zion.cs.uiuc.edu>
Changes in directory llvm/lib/ExecutionEngine/Interpreter:
ExternalFunctions.cpp updated: 1.95 -> 1.96
---
Log message:
Adjust and simplify external function processing now that GenericValue has
a single integer field of type APInt.
---
Diffs of the changes: (+41 -33)
ExternalFunctions.cpp | 74 +++++++++++++++++++++++++++-----------------------
1 files changed, 41 insertions(+), 33 deletions(-)
Index: llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.95 llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.96
--- llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp:1.95 Fri Jan 12 01:05:13 2007
+++ llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Mon Mar 5 21:08:12 2007
@@ -114,19 +114,19 @@
// void putchar(sbyte)
GenericValue lle_VB_putchar(FunctionType *M, const vector &Args) {
- cout << Args[0].Int8Val;
+ cout << ((char)Args[0].IntVal.getZExtValue());
return GenericValue();
}
// int putchar(int)
GenericValue lle_ii_putchar(FunctionType *M, const vector &Args) {
- cout << ((char)Args[0].Int32Val) << std::flush;
+ cout << ((char)Args[0].IntVal.getZExtValue()) << std::flush;
return Args[0];
}
// void putchar(ubyte)
GenericValue lle_Vb_putchar(FunctionType *M, const vector &Args) {
- cout << Args[0].Int8Val << std::flush;
+ cout << ((char)Args[0].IntVal.getZExtValue()) << std::flush;
return Args[0];
}
@@ -135,7 +135,7 @@
assert(Args.size() == 1);
TheInterpreter->addAtExitHandler((Function*)GVTOP(Args[0]));
GenericValue GV;
- GV.Int32Val = 0;
+ GV.IntVal = 0;
return GV;
}
@@ -154,13 +154,14 @@
// void *malloc(uint)
GenericValue lle_X_malloc(FunctionType *M, const vector &Args) {
assert(Args.size() == 1 && "Malloc expects one argument!");
- return PTOGV(malloc(Args[0].Int32Val));
+ return PTOGV(malloc(Args[0].IntVal.getZExtValue()));
}
// void *calloc(uint, uint)
GenericValue lle_X_calloc(FunctionType *M, const vector &Args) {
assert(Args.size() == 2 && "calloc expects two arguments!");
- return PTOGV(calloc(Args[0].Int32Val, Args[1].Int32Val));
+ return PTOGV(calloc(Args[0].IntVal.getZExtValue(),
+ Args[1].IntVal.getZExtValue()));
}
// void free(void *)
@@ -174,7 +175,7 @@
GenericValue lle_X_atoi(FunctionType *M, const vector &Args) {
assert(Args.size() == 1);
GenericValue GV;
- GV.Int32Val = atoi((char*)GVTOP(Args[0]));
+ GV.IntVal = APInt(32, atoi((char*)GVTOP(Args[0])));
return GV;
}
@@ -249,14 +250,14 @@
GenericValue lle_X_rand(FunctionType *M, const vector &Args) {
assert(Args.size() == 0);
GenericValue GV;
- GV.Int32Val = rand();
+ GV.IntVal = APInt(32, rand());
return GV;
}
// void srand(uint)
GenericValue lle_X_srand(FunctionType *M, const vector &Args) {
assert(Args.size() == 1);
- srand(Args[0].Int32Val);
+ srand(Args[0].IntVal.getZExtValue());
return GenericValue();
}
@@ -264,7 +265,7 @@
GenericValue lle_X_puts(FunctionType *M, const vector &Args) {
assert(Args.size() == 1);
GenericValue GV;
- GV.Int32Val = puts((char*)GVTOP(Args[0]));
+ GV.IntVal = APInt(32, puts((char*)GVTOP(Args[0])));
return GV;
}
@@ -277,7 +278,8 @@
// printf should return # chars printed. This is completely incorrect, but
// close enough for now.
- GenericValue GV; GV.Int32Val = strlen(FmtStr);
+ GenericValue GV;
+ GV.IntVal = APInt(32, strlen(FmtStr));
while (1) {
switch (*FmtStr) {
case 0: return GV; // Null terminator...
@@ -308,7 +310,8 @@
case '%':
sprintf(Buffer, FmtBuf); break;
case 'c':
- sprintf(Buffer, FmtBuf, Args[ArgNo++].Int32Val); break;
+ sprintf(Buffer, FmtBuf, uint32_t(Args[ArgNo++].IntVal.getZExtValue()));
+ break;
case 'd': case 'i':
case 'u': case 'o':
case 'x': case 'X':
@@ -323,9 +326,10 @@
FmtBuf[Size+1] = 0;
FmtBuf[Size-1] = 'l';
}
- sprintf(Buffer, FmtBuf, Args[ArgNo++].Int64Val);
+ sprintf(Buffer, FmtBuf, Args[ArgNo++].IntVal.getZExtValue());
} else
- sprintf(Buffer, FmtBuf, Args[ArgNo++].Int32Val); break;
+ sprintf(Buffer, FmtBuf,uint32_t(Args[ArgNo++].IntVal.getZExtValue()));
+ break;
case 'e': case 'E': case 'g': case 'G': case 'f':
sprintf(Buffer, FmtBuf, Args[ArgNo++].DoubleVal); break;
case 'p':
@@ -439,8 +443,8 @@
Args[i] = (char*)GVTOP(args[i]);
GenericValue GV;
- GV.Int32Val = sscanf(Args[0], Args[1], Args[2], Args[3], Args[4],
- Args[5], Args[6], Args[7], Args[8], Args[9]);
+ GV.IntVal = APInt(32, sscanf(Args[0], Args[1], Args[2], Args[3], Args[4],
+ Args[5], Args[6], Args[7], Args[8], Args[9]));
ByteswapSCANFResults(Args[1], Args[2], Args[3], Args[4],
Args[5], Args[6], Args[7], Args[8], Args[9], 0);
return GV;
@@ -455,8 +459,8 @@
Args[i] = (char*)GVTOP(args[i]);
GenericValue GV;
- GV.Int32Val = scanf( Args[0], Args[1], Args[2], Args[3], Args[4],
- Args[5], Args[6], Args[7], Args[8], Args[9]);
+ GV.IntVal = APInt(32, scanf( Args[0], Args[1], Args[2], Args[3], Args[4],
+ Args[5], Args[6], Args[7], Args[8], Args[9]));
ByteswapSCANFResults(Args[0], Args[1], Args[2], Args[3], Args[4],
Args[5], Args[6], Args[7], Args[8], Args[9]);
return GV;
@@ -466,7 +470,8 @@
// int clock(void) - Profiling implementation
GenericValue lle_i_clock(FunctionType *M, const vector &Args) {
extern unsigned int clock(void);
- GenericValue GV; GV.Int32Val = clock();
+ GenericValue GV;
+ GV.IntVal = APInt(32, clock());
return GV;
}
@@ -479,7 +484,7 @@
GenericValue lle_X_strcmp(FunctionType *M, const vector &Args) {
assert(Args.size() == 2);
GenericValue Ret;
- Ret.Int32Val = strcmp((char*)GVTOP(Args[0]), (char*)GVTOP(Args[1]));
+ Ret.IntVal = APInt(32, strcmp((char*)GVTOP(Args[0]), (char*)GVTOP(Args[1])));
return Ret;
}
@@ -498,10 +503,10 @@
static GenericValue size_t_to_GV (size_t n) {
GenericValue Ret;
if (sizeof (size_t) == sizeof (uint64_t)) {
- Ret.Int64Val = n;
+ Ret.IntVal = APInt(64, n);
} else {
assert (sizeof (size_t) == sizeof (unsigned int));
- Ret.Int32Val = n;
+ Ret.IntVal = APInt(32, n);
}
return Ret;
}
@@ -509,10 +514,10 @@
static size_t GV_to_size_t (GenericValue GV) {
size_t count;
if (sizeof (size_t) == sizeof (uint64_t)) {
- count = (size_t)GV.Int64Val;
+ count = (size_t)GV.IntVal.getZExtValue();
} else {
assert (sizeof (size_t) == sizeof (unsigned int));
- count = (size_t)GV.Int32Val;
+ count = (size_t)GV.IntVal.getZExtValue();
}
return count;
}
@@ -540,7 +545,8 @@
GenericValue lle_X_memset(FunctionType *M, const vector &Args) {
assert(Args.size() == 3);
size_t count = GV_to_size_t (Args[2]);
- return PTOGV(memset(GVTOP(Args[0]), Args[1].Int32Val, count));
+ return PTOGV(memset(GVTOP(Args[0]), uint32_t(Args[1].IntVal.getZExtValue()),
+ count));
}
// void *memcpy(void *Dest, void *src, size_t Size);
@@ -569,7 +575,7 @@
GenericValue lle_X_fclose(FunctionType *M, const vector &Args) {
assert(Args.size() == 1);
GenericValue GV;
- GV.Int32Val = fclose(getFILE(GVTOP(Args[0])));
+ GV.IntVal = APInt(32, fclose(getFILE(GVTOP(Args[0]))));
return GV;
}
@@ -578,7 +584,7 @@
assert(Args.size() == 1);
GenericValue GV;
- GV.Int32Val = feof(getFILE(GVTOP(Args[0])));
+ GV.IntVal = APInt(32, feof(getFILE(GVTOP(Args[0]))));
return GV;
}
@@ -605,7 +611,7 @@
// char *fgets(char *s, int n, FILE *stream);
GenericValue lle_X_fgets(FunctionType *M, const vector &Args) {
assert(Args.size() == 3);
- return GVTOP(fgets((char*)GVTOP(Args[0]), Args[1].Int32Val,
+ return GVTOP(fgets((char*)GVTOP(Args[0]), Args[1].IntVal.getZExtValue(),
getFILE(GVTOP(Args[2]))));
}
@@ -620,7 +626,7 @@
GenericValue lle_X_fflush(FunctionType *M, const vector &Args) {
assert(Args.size() == 1);
GenericValue GV;
- GV.Int32Val = fflush(getFILE(GVTOP(Args[0])));
+ GV.IntVal = APInt(32, fflush(getFILE(GVTOP(Args[0]))));
return GV;
}
@@ -628,7 +634,7 @@
GenericValue lle_X_getc(FunctionType *M, const vector &Args) {
assert(Args.size() == 1);
GenericValue GV;
- GV.Int32Val = getc(getFILE(GVTOP(Args[0])));
+ GV.IntVal = APInt(32, getc(getFILE(GVTOP(Args[0]))));
return GV;
}
@@ -641,7 +647,8 @@
GenericValue lle_X_fputc(FunctionType *M, const vector &Args) {
assert(Args.size() == 2);
GenericValue GV;
- GV.Int32Val = fputc(Args[0].Int32Val, getFILE(GVTOP(Args[1])));
+ GV.IntVal = APInt(32, fputc(Args[0].IntVal.getZExtValue(),
+ getFILE(GVTOP(Args[1]))));
return GV;
}
@@ -649,7 +656,8 @@
GenericValue lle_X_ungetc(FunctionType *M, const vector &Args) {
assert(Args.size() == 2);
GenericValue GV;
- GV.Int32Val = ungetc(Args[0].Int32Val, getFILE(GVTOP(Args[1])));
+ GV.IntVal = APInt(32, ungetc(Args[0].IntVal.getZExtValue(),
+ getFILE(GVTOP(Args[1]))));
return GV;
}
@@ -657,7 +665,7 @@
GenericValue lle_X_ferror(FunctionType *M, const vector &Args) {
assert(Args.size() == 1);
GenericValue GV;
- GV.Int32Val = ferror (getFILE(GVTOP(Args[0])));
+ GV.IntVal = APInt(32, ferror (getFILE(GVTOP(Args[0]))));
return GV;
}
From reid at x10sys.com Mon Mar 5 21:09:48 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 21:09:48 -0600
Subject: [llvm-commits] CVS:
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
Message-ID: <200703060309.l2639mNT008581@zion.cs.uiuc.edu>
Changes in directory llvm/lib/ExecutionEngine/Interpreter:
Execution.cpp updated: 1.172 -> 1.173
---
Log message:
Radically simplify execution. This patch gets rid of all the special
handling for integer of various sizes. GenericValue now has just a single
integer field of type APInt. We use its facilities directly in the
execution of all instructions.
---
Diffs of the changes: (+128 -636)
Execution.cpp | 764 +++++++++-------------------------------------------------
1 files changed, 128 insertions(+), 636 deletions(-)
Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.172 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.173
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.172 Sat Mar 3 02:38:04 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Mon Mar 5 21:09:31 2007
@@ -32,12 +32,6 @@
// Various Helper Functions
//===----------------------------------------------------------------------===//
-inline void initializeAPInt(GenericValue &GV, const Type* Ty,
- ExecutionContext &SF) {
- if (const IntegerType *ITy = dyn_cast(Ty))
- GV.APIntVal = SF.getAPInt(ITy->getBitWidth());
-}
-
static inline uint64_t doSignExtension(uint64_t Val, const IntegerType* ITy) {
// Determine if the value is signed or not
bool isSigned = (Val & (1 << (ITy->getBitWidth()-1))) != 0;
@@ -47,22 +41,6 @@
return Val;
}
-static inline void maskToBitWidth(GenericValue& GV, unsigned BitWidth) {
- uint64_t BitMask = ~(uint64_t)(0ull) >> (64-BitWidth);
- if (BitWidth <= 8)
- GV.Int8Val &= BitMask;
- else if (BitWidth <= 16)
- GV.Int16Val &= BitMask;
- else if (BitWidth <= 32)
- GV.Int32Val &= BitMask;
- else if (BitWidth <= 64)
- GV.Int64Val &= BitMask;
- else {
- assert(GV.APIntVal && "Unallocated GV.APIntVal");
- *(GV.APIntVal) &= APInt::getAllOnesValue(BitWidth);
- }
-}
-
static void SetValue(Value *V, GenericValue Val, ExecutionContext &SF) {
SF.Values[V] = Val;
}
@@ -76,79 +54,21 @@
//===----------------------------------------------------------------------===//
#define IMPLEMENT_BINARY_OPERATOR(OP, TY) \
- case Type::TY##TyID: Dest.TY##Val = Src1.TY##Val OP Src2.TY##Val; break
+ case Type::TY##TyID: \
+ Dest.TY##Val = Src1.TY##Val OP Src2.TY##Val; \
+ break
-#define IMPLEMENT_INTEGER_BINOP(OP, TY) \
+#define IMPLEMENT_INTEGER_BINOP1(OP, TY) \
case Type::IntegerTyID: { \
- unsigned BitWidth = cast(TY)->getBitWidth(); \
- if (BitWidth == 1) {\
- Dest.Int1Val = Src1.Int1Val OP Src2.Int1Val; \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 8) {\
- Dest.Int8Val = Src1.Int8Val OP Src2.Int8Val; \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 16) {\
- Dest.Int16Val = Src1.Int16Val OP Src2.Int16Val; \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 32) {\
- Dest.Int32Val = Src1.Int32Val OP Src2.Int32Val; \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 64) {\
- Dest.Int64Val = Src1.Int64Val OP Src2.Int64Val; \
- maskToBitWidth(Dest, BitWidth); \
- } else \
- *(Dest.APIntVal) = *(Src1.APIntVal) OP *(Src2.APIntVal); \
+ Dest.IntVal = Src1.IntVal OP Src2.IntVal; \
break; \
}
-#define IMPLEMENT_SIGNED_BINOP(OP, TY, APOP) \
- if (const IntegerType *ITy = dyn_cast(TY)) { \
- unsigned BitWidth = ITy->getBitWidth(); \
- if (BitWidth <= 8) { \
- Dest.Int8Val = ((int8_t)Src1.Int8Val) OP ((int8_t)Src2.Int8Val); \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 16) { \
- Dest.Int16Val = ((int16_t)Src1.Int16Val) OP ((int16_t)Src2.Int16Val); \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 32) { \
- Dest.Int32Val = ((int32_t)Src1.Int32Val) OP ((int32_t)Src2.Int32Val); \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 64) { \
- Dest.Int64Val = ((int64_t)Src1.Int64Val) OP ((int64_t)Src2.Int64Val); \
- maskToBitWidth(Dest, BitWidth); \
- } else \
- *(Dest.APIntVal) = Src1.APIntVal->APOP(*(Src2.APIntVal)); \
- } else { \
- cerr << "Unhandled type for " #OP " operator: " << *Ty << "\n"; \
- abort(); \
- }
-
-#define IMPLEMENT_UNSIGNED_BINOP(OP, TY, APOP) \
- if (const IntegerType *ITy = dyn_cast(TY)) { \
- unsigned BitWidth = ITy->getBitWidth(); \
- if (BitWidth <= 8) {\
- Dest.Int8Val = ((uint8_t)Src1.Int8Val) OP ((uint8_t)Src2.Int8Val); \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 16) {\
- Dest.Int16Val = ((uint16_t)Src1.Int16Val) OP ((uint16_t)Src2.Int16Val); \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 32) {\
- Dest.Int32Val = ((uint32_t)Src1.Int32Val) OP ((uint32_t)Src2.Int32Val); \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 64) {\
- Dest.Int64Val = ((uint64_t)Src1.Int64Val) OP ((uint64_t)Src2.Int64Val); \
- maskToBitWidth(Dest, BitWidth); \
- } else \
- *(Dest.APIntVal) = Src1.APIntVal->APOP(*(Src2.APIntVal)); \
- } else { \
- cerr << "Unhandled type for " #OP " operator: " << *Ty << "\n"; \
- abort(); \
- }
static void executeAddInst(GenericValue &Dest, GenericValue Src1,
GenericValue Src2, const Type *Ty) {
switch (Ty->getTypeID()) {
- IMPLEMENT_INTEGER_BINOP(+, Ty);
+ IMPLEMENT_INTEGER_BINOP1(+, Ty);
IMPLEMENT_BINARY_OPERATOR(+, Float);
IMPLEMENT_BINARY_OPERATOR(+, Double);
default:
@@ -160,7 +80,7 @@
static void executeSubInst(GenericValue &Dest, GenericValue Src1,
GenericValue Src2, const Type *Ty) {
switch (Ty->getTypeID()) {
- IMPLEMENT_INTEGER_BINOP(-, Ty);
+ IMPLEMENT_INTEGER_BINOP1(-, Ty);
IMPLEMENT_BINARY_OPERATOR(-, Float);
IMPLEMENT_BINARY_OPERATOR(-, Double);
default:
@@ -172,7 +92,7 @@
static void executeMulInst(GenericValue &Dest, GenericValue Src1,
GenericValue Src2, const Type *Ty) {
switch (Ty->getTypeID()) {
- IMPLEMENT_INTEGER_BINOP(*, Ty);
+ IMPLEMENT_INTEGER_BINOP1(*, Ty);
IMPLEMENT_BINARY_OPERATOR(*, Float);
IMPLEMENT_BINARY_OPERATOR(*, Double);
default:
@@ -181,16 +101,6 @@
}
}
-static void executeUDivInst(GenericValue &Dest, GenericValue Src1,
- GenericValue Src2, const Type *Ty) {
- IMPLEMENT_UNSIGNED_BINOP(/,Ty,udiv)
-}
-
-static void executeSDivInst(GenericValue &Dest, GenericValue Src1,
- GenericValue Src2, const Type *Ty) {
- IMPLEMENT_SIGNED_BINOP(/,Ty,sdiv)
-}
-
static void executeFDivInst(GenericValue &Dest, GenericValue Src1,
GenericValue Src2, const Type *Ty) {
switch (Ty->getTypeID()) {
@@ -202,16 +112,6 @@
}
}
-static void executeURemInst(GenericValue &Dest, GenericValue Src1,
- GenericValue Src2, const Type *Ty) {
- IMPLEMENT_UNSIGNED_BINOP(%,Ty,urem)
-}
-
-static void executeSRemInst(GenericValue &Dest, GenericValue Src1,
- GenericValue Src2, const Type *Ty) {
- IMPLEMENT_SIGNED_BINOP(%,Ty,srem)
-}
-
static void executeFRemInst(GenericValue &Dest, GenericValue Src1,
GenericValue Src2, const Type *Ty) {
switch (Ty->getTypeID()) {
@@ -227,71 +127,10 @@
}
}
-static void executeAndInst(GenericValue &Dest, GenericValue Src1,
- GenericValue Src2, const Type *Ty) {
- IMPLEMENT_UNSIGNED_BINOP(&,Ty,And)
-}
-
-static void executeOrInst(GenericValue &Dest, GenericValue Src1,
- GenericValue Src2, const Type *Ty) {
- IMPLEMENT_UNSIGNED_BINOP(|,Ty,Or)
-}
-
-static void executeXorInst(GenericValue &Dest, GenericValue Src1,
- GenericValue Src2, const Type *Ty) {
- IMPLEMENT_UNSIGNED_BINOP(^,Ty,Xor)
-}
-
-#define IMPLEMENT_SIGNED_ICMP(OP, TY, APOP) \
- case Type::IntegerTyID: { \
- const IntegerType* ITy = cast(TY); \
- unsigned BitWidth = ITy->getBitWidth(); \
- int64_t LHS = 0, RHS = 0; \
- if (BitWidth <= 8) { \
- LHS = int64_t(doSignExtension(uint64_t(Src1.Int8Val), ITy)); \
- RHS = int64_t(doSignExtension(uint64_t(Src2.Int8Val), ITy)); \
- Dest.Int1Val = LHS OP RHS; \
- } else if (BitWidth <= 16) { \
- LHS = int64_t(doSignExtension(uint64_t(Src1.Int16Val), ITy)); \
- RHS = int64_t(doSignExtension(uint64_t(Src2.Int16Val), ITy)); \
- Dest.Int1Val = LHS OP RHS; \
- } else if (BitWidth <= 32) { \
- LHS = int64_t(doSignExtension(uint64_t(Src1.Int32Val), ITy)); \
- RHS = int64_t(doSignExtension(uint64_t(Src2.Int32Val), ITy)); \
- Dest.Int1Val = LHS OP RHS; \
- } else if (BitWidth <= 64) { \
- LHS = int64_t(doSignExtension(uint64_t(Src1.Int64Val), ITy)); \
- RHS = int64_t(doSignExtension(uint64_t(Src2.Int64Val), ITy)); \
- Dest.Int1Val = LHS OP RHS; \
- } else { \
- Dest.Int1Val = Src1.APIntVal->APOP(*(Src2.APIntVal)); \
- } \
- break; \
- }
-
-#define IMPLEMENT_UNSIGNED_ICMP(OP, TY, APOP) \
- case Type::IntegerTyID: { \
- unsigned BitWidth = cast(TY)->getBitWidth(); \
- if (BitWidth == 1) { \
- Dest.Int1Val = ((uint8_t)Src1.Int1Val) OP ((uint8_t)Src2.Int1Val); \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 8) { \
- Dest.Int1Val = ((uint8_t)Src1.Int8Val) OP ((uint8_t)Src2.Int8Val); \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 16) { \
- Dest.Int1Val = ((uint16_t)Src1.Int16Val) OP ((uint16_t)Src2.Int16Val); \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 32) { \
- Dest.Int1Val = ((uint32_t)Src1.Int32Val) OP ((uint32_t)Src2.Int32Val); \
- maskToBitWidth(Dest, BitWidth); \
- } else if (BitWidth <= 64) { \
- Dest.Int1Val = ((uint64_t)Src1.Int64Val) OP ((uint64_t)Src2.Int64Val); \
- maskToBitWidth(Dest, BitWidth); \
- } else { \
- Dest.Int1Val = Src1.APIntVal->APOP(*(Src2.APIntVal)); \
- } \
- break; \
- }
+#define IMPLEMENT_INTEGER_ICMP(OP, TY) \
+ case Type::IntegerTyID: \
+ Dest.IntVal = APInt(1,Src1.IntVal.OP(Src2.IntVal)); \
+ break;
// Handle pointers specially because they must be compared with only as much
// width as the host has. We _do not_ want to be comparing 64 bit values when
@@ -299,14 +138,15 @@
// comparisons if they contain garbage.
#define IMPLEMENT_POINTER_ICMP(OP) \
case Type::PointerTyID: \
- Dest.Int1Val = (void*)(intptr_t)Src1.PointerVal OP \
- (void*)(intptr_t)Src2.PointerVal; break
+ Dest.IntVal = APInt(1,(void*)(intptr_t)Src1.PointerVal OP \
+ (void*)(intptr_t)Src2.PointerVal); \
+ break;
static GenericValue executeICMP_EQ(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
switch (Ty->getTypeID()) {
- IMPLEMENT_UNSIGNED_ICMP(==, Ty, eq);
+ IMPLEMENT_INTEGER_ICMP(eq,Ty);
IMPLEMENT_POINTER_ICMP(==);
default:
cerr << "Unhandled type for ICMP_EQ predicate: " << *Ty << "\n";
@@ -319,7 +159,7 @@
const Type *Ty) {
GenericValue Dest;
switch (Ty->getTypeID()) {
- IMPLEMENT_UNSIGNED_ICMP(!=, Ty, ne);
+ IMPLEMENT_INTEGER_ICMP(ne,Ty);
IMPLEMENT_POINTER_ICMP(!=);
default:
cerr << "Unhandled type for ICMP_NE predicate: " << *Ty << "\n";
@@ -332,7 +172,7 @@
const Type *Ty) {
GenericValue Dest;
switch (Ty->getTypeID()) {
- IMPLEMENT_UNSIGNED_ICMP(<, Ty, ult);
+ IMPLEMENT_INTEGER_ICMP(ult,Ty);
IMPLEMENT_POINTER_ICMP(<);
default:
cerr << "Unhandled type for ICMP_ULT predicate: " << *Ty << "\n";
@@ -345,7 +185,7 @@
const Type *Ty) {
GenericValue Dest;
switch (Ty->getTypeID()) {
- IMPLEMENT_SIGNED_ICMP(<, Ty, slt);
+ IMPLEMENT_INTEGER_ICMP(slt,Ty);
IMPLEMENT_POINTER_ICMP(<);
default:
cerr << "Unhandled type for ICMP_SLT predicate: " << *Ty << "\n";
@@ -358,7 +198,7 @@
const Type *Ty) {
GenericValue Dest;
switch (Ty->getTypeID()) {
- IMPLEMENT_UNSIGNED_ICMP(>, Ty, ugt);
+ IMPLEMENT_INTEGER_ICMP(ugt,Ty);
IMPLEMENT_POINTER_ICMP(>);
default:
cerr << "Unhandled type for ICMP_UGT predicate: " << *Ty << "\n";
@@ -371,7 +211,7 @@
const Type *Ty) {
GenericValue Dest;
switch (Ty->getTypeID()) {
- IMPLEMENT_SIGNED_ICMP(>, Ty, sgt);
+ IMPLEMENT_INTEGER_ICMP(sgt,Ty);
IMPLEMENT_POINTER_ICMP(>);
default:
cerr << "Unhandled type for ICMP_SGT predicate: " << *Ty << "\n";
@@ -384,7 +224,7 @@
const Type *Ty) {
GenericValue Dest;
switch (Ty->getTypeID()) {
- IMPLEMENT_UNSIGNED_ICMP(<=, Ty, ule);
+ IMPLEMENT_INTEGER_ICMP(ule,Ty);
IMPLEMENT_POINTER_ICMP(<=);
default:
cerr << "Unhandled type for ICMP_ULE predicate: " << *Ty << "\n";
@@ -397,7 +237,7 @@
const Type *Ty) {
GenericValue Dest;
switch (Ty->getTypeID()) {
- IMPLEMENT_SIGNED_ICMP(<=, Ty, sle);
+ IMPLEMENT_INTEGER_ICMP(sle,Ty);
IMPLEMENT_POINTER_ICMP(<=);
default:
cerr << "Unhandled type for ICMP_SLE predicate: " << *Ty << "\n";
@@ -410,7 +250,7 @@
const Type *Ty) {
GenericValue Dest;
switch (Ty->getTypeID()) {
- IMPLEMENT_UNSIGNED_ICMP(>=, Ty, uge);
+ IMPLEMENT_INTEGER_ICMP(uge,Ty);
IMPLEMENT_POINTER_ICMP(>=);
default:
cerr << "Unhandled type for ICMP_UGE predicate: " << *Ty << "\n";
@@ -423,7 +263,7 @@
const Type *Ty) {
GenericValue Dest;
switch (Ty->getTypeID()) {
- IMPLEMENT_SIGNED_ICMP(>=, Ty, sge);
+ IMPLEMENT_INTEGER_ICMP(sge,Ty);
IMPLEMENT_POINTER_ICMP(>=);
default:
cerr << "Unhandled type for ICMP_SGE predicate: " << *Ty << "\n";
@@ -459,7 +299,9 @@
}
#define IMPLEMENT_FCMP(OP, TY) \
- case Type::TY##TyID: Dest.Int1Val = Src1.TY##Val OP Src2.TY##Val; break
+ case Type::TY##TyID: \
+ Dest.IntVal = APInt(1,Src1.TY##Val OP Src2.TY##Val); \
+ break
static GenericValue executeFCMP_OEQ(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
@@ -543,11 +385,11 @@
#define IMPLEMENT_UNORDERED(TY, X,Y) \
if (TY == Type::FloatTy) \
if (X.FloatVal != X.FloatVal || Y.FloatVal != Y.FloatVal) { \
- Dest.Int1Val = true; \
+ Dest.IntVal = APInt(1,true); \
return Dest; \
} \
else if (X.DoubleVal != X.DoubleVal || Y.DoubleVal != Y.DoubleVal) { \
- Dest.Int1Val = true; \
+ Dest.IntVal = APInt(1,true); \
return Dest; \
}
@@ -598,11 +440,11 @@
const Type *Ty) {
GenericValue Dest;
if (Ty == Type::FloatTy)
- Dest.Int1Val = (Src1.FloatVal == Src1.FloatVal &&
- Src2.FloatVal == Src2.FloatVal);
+ Dest.IntVal = APInt(1,(Src1.FloatVal == Src1.FloatVal &&
+ Src2.FloatVal == Src2.FloatVal));
else
- Dest.Int1Val = (Src1.DoubleVal == Src1.DoubleVal &&
- Src2.DoubleVal == Src2.DoubleVal);
+ Dest.IntVal = APInt(1,(Src1.DoubleVal == Src1.DoubleVal &&
+ Src2.DoubleVal == Src2.DoubleVal));
return Dest;
}
@@ -610,11 +452,11 @@
const Type *Ty) {
GenericValue Dest;
if (Ty == Type::FloatTy)
- Dest.Int1Val = (Src1.FloatVal != Src1.FloatVal ||
- Src2.FloatVal != Src2.FloatVal);
+ Dest.IntVal = APInt(1,(Src1.FloatVal != Src1.FloatVal ||
+ Src2.FloatVal != Src2.FloatVal));
else
- Dest.Int1Val = (Src1.DoubleVal != Src1.DoubleVal ||
- Src2.DoubleVal != Src2.DoubleVal);
+ Dest.IntVal = APInt(1,(Src1.DoubleVal != Src1.DoubleVal ||
+ Src2.DoubleVal != Src2.DoubleVal));
return Dest;
}
@@ -626,8 +468,8 @@
GenericValue R; // Result
switch (I.getPredicate()) {
- case FCmpInst::FCMP_FALSE: R.Int1Val = false; break;
- case FCmpInst::FCMP_TRUE: R.Int1Val = true; break;
+ case FCmpInst::FCMP_FALSE: R.IntVal = APInt(1,false); break;
+ case FCmpInst::FCMP_TRUE: R.IntVal = APInt(1,true); break;
case FCmpInst::FCMP_ORD: R = executeFCMP_ORD(Src1, Src2, Ty); break;
case FCmpInst::FCMP_UNO: R = executeFCMP_UNO(Src1, Src2, Ty); break;
case FCmpInst::FCMP_UEQ: R = executeFCMP_UEQ(Src1, Src2, Ty); break;
@@ -680,12 +522,12 @@
case FCmpInst::FCMP_UGE: return executeFCMP_UGE(Src1, Src2, Ty);
case FCmpInst::FCMP_FALSE: {
GenericValue Result;
- Result.Int1Val = false;
+ Result.IntVal = APInt(1, false);
return Result;
}
case FCmpInst::FCMP_TRUE: {
GenericValue Result;
- Result.Int1Val = true;
+ Result.IntVal = APInt(1, true);
return Result;
}
default:
@@ -700,21 +542,20 @@
GenericValue Src1 = getOperandValue(I.getOperand(0), SF);
GenericValue Src2 = getOperandValue(I.getOperand(1), SF);
GenericValue R; // Result
- initializeAPInt(R, Ty, SF);
switch (I.getOpcode()) {
case Instruction::Add: executeAddInst (R, Src1, Src2, Ty); break;
case Instruction::Sub: executeSubInst (R, Src1, Src2, Ty); break;
case Instruction::Mul: executeMulInst (R, Src1, Src2, Ty); break;
- case Instruction::UDiv: executeUDivInst (R, Src1, Src2, Ty); break;
- case Instruction::SDiv: executeSDivInst (R, Src1, Src2, Ty); break;
case Instruction::FDiv: executeFDivInst (R, Src1, Src2, Ty); break;
- case Instruction::URem: executeURemInst (R, Src1, Src2, Ty); break;
- case Instruction::SRem: executeSRemInst (R, Src1, Src2, Ty); break;
case Instruction::FRem: executeFRemInst (R, Src1, Src2, Ty); break;
- case Instruction::And: executeAndInst (R, Src1, Src2, Ty); break;
- case Instruction::Or: executeOrInst (R, Src1, Src2, Ty); break;
- case Instruction::Xor: executeXorInst (R, Src1, Src2, Ty); break;
+ case Instruction::UDiv: R.IntVal = Src1.IntVal.udiv(Src2.IntVal); break;
+ case Instruction::SDiv: R.IntVal = Src1.IntVal.sdiv(Src2.IntVal); break;
+ case Instruction::URem: R.IntVal = Src1.IntVal.urem(Src2.IntVal); break;
+ case Instruction::SRem: R.IntVal = Src1.IntVal.srem(Src2.IntVal); break;
+ case Instruction::And: R.IntVal = Src1.IntVal & Src2.IntVal; break;
+ case Instruction::Or: R.IntVal = Src1.IntVal | Src2.IntVal; break;
+ case Instruction::Xor: R.IntVal = Src1.IntVal ^ Src2.IntVal; break;
default:
cerr << "Don't know how to handle this binary operator!\n-->" << I;
abort();
@@ -725,7 +566,7 @@
static GenericValue executeSelectInst(GenericValue Src1, GenericValue Src2,
GenericValue Src3) {
- return Src1.Int1Val ? Src2 : Src3;
+ return Src1.IntVal == 0 ? Src3 : Src2;
}
void Interpreter::visitSelectInst(SelectInst &I) {
@@ -733,9 +574,7 @@
GenericValue Src1 = getOperandValue(I.getOperand(0), SF);
GenericValue Src2 = getOperandValue(I.getOperand(1), SF);
GenericValue Src3 = getOperandValue(I.getOperand(2), SF);
- GenericValue R;
- initializeAPInt(R, I.getOperand(1)->getType(), SF);
- R = executeSelectInst(Src1, Src2, Src3);
+ GenericValue R = executeSelectInst(Src1, Src2, Src3);
SetValue(&I, R, SF);
}
@@ -750,7 +589,7 @@
// the stack before interpreting atexit handlers.
ECStack.clear ();
runAtExitHandlers ();
- exit (GV.Int32Val);
+ exit (GV.IntVal.zextOrTrunc(32).getZExtValue());
}
/// Pop the last stack frame off of ECStack and then copy the result
@@ -830,7 +669,7 @@
Dest = I.getSuccessor(0); // Uncond branches have a fixed dest...
if (!I.isUnconditional()) {
Value *Cond = I.getCondition();
- if (getOperandValue(Cond, SF).Int1Val == 0) // If false cond...
+ if (getOperandValue(Cond, SF).IntVal == 0) // If false cond...
Dest = I.getSuccessor(1);
}
SwitchToNewBasicBlock(Dest, SF);
@@ -844,8 +683,8 @@
// Check to see if any of the cases match...
BasicBlock *Dest = 0;
for (unsigned i = 2, e = I.getNumOperands(); i != e; i += 2)
- if (executeICMP_EQ(CondVal,
- getOperandValue(I.getOperand(i), SF), ElTy).Int1Val) {
+ if (executeICMP_EQ(CondVal, getOperandValue(I.getOperand(i), SF), ElTy)
+ .IntVal != 0) {
Dest = cast(I.getOperand(i+1));
break;
}
@@ -902,10 +741,19 @@
const Type *Ty = I.getType()->getElementType(); // Type to be allocated
// Get the number of elements being allocated by the array...
- unsigned NumElements = getOperandValue(I.getOperand(0), SF).Int32Val;
+ unsigned NumElements =
+ getOperandValue(I.getOperand(0), SF).IntVal.getZExtValue();
+
+ unsigned TypeSize = (size_t)TD.getTypeSize(Ty);
+
+ unsigned MemToAlloc = NumElements * TypeSize;
// Allocate enough memory to hold the type...
- void *Memory = malloc(NumElements * (size_t)TD.getTypeSize(Ty));
+ void *Memory = malloc(MemToAlloc);
+
+ DOUT << "Allocated Type: " << *Ty << " (" << TypeSize << " bytes) x "
+ << NumElements << " (Total: " << MemToAlloc << ") at "
+ << unsigned(Memory) << '\n';
GenericValue Result = PTOGV(Memory);
assert(Result.PointerVal != 0 && "Null pointer returned by malloc!");
@@ -931,7 +779,7 @@
assert(isa(Ptr->getType()) &&
"Cannot getElementOffset of a nonpointer type!");
- PointerTy Total = 0;
+ uint64_t Total = 0;
for (; I != E; ++I) {
if (const StructType *STy = dyn_cast(*I)) {
@@ -940,7 +788,7 @@
const ConstantInt *CPU = cast(I.getOperand());
unsigned Index = unsigned(CPU->getZExtValue());
- Total += (PointerTy)SLO->getElementOffset(Index);
+ Total += SLO->getElementOffset(Index);
} else {
const SequentialType *ST = cast(*I);
// Get the index number for the array... which must be long type...
@@ -950,17 +798,18 @@
unsigned BitWidth =
cast(I.getOperand()->getType())->getBitWidth();
if (BitWidth == 32)
- Idx = (int64_t)(int32_t)IdxGV.Int32Val;
+ Idx = (int64_t)(int32_t)IdxGV.IntVal.getZExtValue();
else if (BitWidth == 64)
- Idx = (int64_t)IdxGV.Int64Val;
+ Idx = (int64_t)IdxGV.IntVal.getZExtValue();
else
assert(0 && "Invalid index type for getelementptr");
- Total += PointerTy(TD.getTypeSize(ST->getElementType())*Idx);
+ Total += TD.getTypeSize(ST->getElementType())*Idx;
}
}
GenericValue Result;
- Result.PointerVal = getOperandValue(Ptr, SF).PointerVal + Total;
+ Result.PointerVal = ((char*)getOperandValue(Ptr, SF).PointerVal) + Total;
+ DOUT << "GEP Index " << Total << " bytes.\n";
return Result;
}
@@ -975,7 +824,6 @@
GenericValue SRC = getOperandValue(I.getPointerOperand(), SF);
GenericValue *Ptr = (GenericValue*)GVTOP(SRC);
GenericValue Result;
- initializeAPInt(Result, I.getType(), SF);
LoadValueFromMemory(Result, Ptr, I.getType());
SetValue(&I, Result, SF);
}
@@ -1044,14 +892,9 @@
// this by zero or sign extending the value as appropriate according to the
// source type.
const Type *Ty = V->getType();
- if (Ty->isInteger()) {
- if (Ty->getPrimitiveSizeInBits() == 1)
- ArgVals.back().Int32Val = ArgVals.back().Int1Val;
- else if (Ty->getPrimitiveSizeInBits() <= 8)
- ArgVals.back().Int32Val = ArgVals.back().Int8Val;
- else if (Ty->getPrimitiveSizeInBits() <= 16)
- ArgVals.back().Int32Val = ArgVals.back().Int16Val;
- }
+ if (Ty->isInteger())
+ if (ArgVals.back().IntVal.getBitWidth() < 32)
+ ArgVals.back().IntVal = ArgVals.back().IntVal.sext(32);
}
// To handle indirect calls, we must get the pointer value from the argument
@@ -1060,129 +903,33 @@
callFunction((Function*)GVTOP(SRC), ArgVals);
}
-static void executeShlInst(GenericValue &Dest, GenericValue Src1,
- GenericValue Src2, const Type *Ty) {
- if (const IntegerType *ITy = cast(Ty)) {
- unsigned BitWidth = ITy->getBitWidth();
- if (BitWidth <= 8) {
- Dest.Int8Val = ((uint8_t)Src1.Int8Val) << ((uint32_t)Src2.Int8Val);
- maskToBitWidth(Dest, BitWidth);
- } else if (BitWidth <= 16) {
- Dest.Int16Val = ((uint16_t)Src1.Int16Val) << ((uint32_t)Src2.Int16Val);
- maskToBitWidth(Dest, BitWidth);
- } else if (BitWidth <= 32) {
- Dest.Int32Val = ((uint32_t)Src1.Int32Val) << ((uint32_t)Src2.Int32Val);
- maskToBitWidth(Dest, BitWidth);
- } else if (BitWidth <= 64) {
- Dest.Int64Val = ((uint64_t)Src1.Int64Val) << ((uint32_t)Src2.Int64Val);
- maskToBitWidth(Dest, BitWidth);
- } else {
- *(Dest.APIntVal) = Src1.APIntVal->shl(Src2.APIntVal->getZExtValue());
- }
- } else {
- cerr << "Unhandled type for Shl instruction: " << *Ty << "\n";
- abort();
- }
-}
-
-static void executeLShrInst(GenericValue &Dest, GenericValue Src1,
- GenericValue Src2, const Type *Ty) {
- if (const IntegerType *ITy = cast(Ty)) {
- unsigned BitWidth = ITy->getBitWidth();
- if (BitWidth <= 8) {
- Dest.Int8Val = ((uint8_t)Src1.Int8Val) >> ((uint32_t)Src2.Int8Val);
- maskToBitWidth(Dest, BitWidth);
- } else if (BitWidth <= 16) {
- Dest.Int16Val = ((uint16_t)Src1.Int16Val) >> ((uint32_t)Src2.Int16Val);
- maskToBitWidth(Dest, BitWidth);
- } else if (BitWidth <= 32) {
- Dest.Int32Val = ((uint32_t)Src1.Int32Val) >> ((uint32_t)Src2.Int32Val);
- maskToBitWidth(Dest, BitWidth);
- } else if (BitWidth <= 64) {
- Dest.Int64Val = ((uint64_t)Src1.Int64Val) >> ((uint32_t)Src2.Int64Val);
- maskToBitWidth(Dest, BitWidth);
- } else {
- *(Dest.APIntVal) = Src1.APIntVal->lshr(Src2.APIntVal->getZExtValue());
- }
- } else {
- cerr << "Unhandled type for LShr instruction: " << *Ty << "\n";
- abort();
- }
-}
-
-static void executeAShrInst(GenericValue &Dest, GenericValue Src1,
- GenericValue Src2, const Type *Ty) {
- if (const IntegerType *ITy = cast(Ty)) {
- unsigned BitWidth = ITy->getBitWidth();
- if (BitWidth <= 8) {
- Dest.Int8Val = ((int8_t)Src1.Int8Val) >> ((int32_t)Src2.Int8Val);
- maskToBitWidth(Dest, BitWidth);
- } else if (BitWidth <= 16) {
- Dest.Int16Val = ((int16_t)Src1.Int16Val) >> ((int32_t)Src2.Int8Val);
- maskToBitWidth(Dest, BitWidth);
- } else if (BitWidth <= 32) {
- Dest.Int32Val = ((int32_t)Src1.Int32Val) >> ((int32_t)Src2.Int8Val);
- maskToBitWidth(Dest, BitWidth);
- } else if (BitWidth <= 64) {
- Dest.Int64Val = ((int64_t)Src1.Int64Val) >> ((int32_t)Src2.Int8Val);
- maskToBitWidth(Dest, BitWidth);
- } else {
- *(Dest.APIntVal) = Src1.APIntVal->ashr(Src2.APIntVal->getZExtValue());
- }
- } else {
- cerr << "Unhandled type for AShr instruction: " << *Ty << "\n";
- abort();
- }
-}
-
void Interpreter::visitShl(BinaryOperator &I) {
ExecutionContext &SF = ECStack.back();
- const Type *Ty = I.getOperand(0)->getType();
GenericValue Src1 = getOperandValue(I.getOperand(0), SF);
GenericValue Src2 = getOperandValue(I.getOperand(1), SF);
GenericValue Dest;
- initializeAPInt(Dest, Ty, SF);
- executeShlInst (Dest, Src1, Src2, Ty);
+ Dest.IntVal = Src1.IntVal.shl(Src2.IntVal.getZExtValue());
SetValue(&I, Dest, SF);
}
void Interpreter::visitLShr(BinaryOperator &I) {
ExecutionContext &SF = ECStack.back();
- const Type *Ty = I.getOperand(0)->getType();
GenericValue Src1 = getOperandValue(I.getOperand(0), SF);
GenericValue Src2 = getOperandValue(I.getOperand(1), SF);
GenericValue Dest;
- initializeAPInt(Dest, Ty, SF);
- executeLShrInst (Dest, Src1, Src2, Ty);
+ Dest.IntVal = Src1.IntVal.lshr(Src2.IntVal.getZExtValue());
SetValue(&I, Dest, SF);
}
void Interpreter::visitAShr(BinaryOperator &I) {
ExecutionContext &SF = ECStack.back();
- const Type *Ty = I.getOperand(0)->getType();
GenericValue Src1 = getOperandValue(I.getOperand(0), SF);
GenericValue Src2 = getOperandValue(I.getOperand(1), SF);
- GenericValue Dest;
- initializeAPInt(Dest, Ty, SF);
- executeAShrInst (Dest, Src1, Src2, Ty);
+ GenericValue Dest;
+ Dest.IntVal = Src1.IntVal.ashr(Src2.IntVal.getZExtValue());
SetValue(&I, Dest, SF);
}
-#define INTEGER_ASSIGN(DEST, BITWIDTH, VAL) \
- { \
- uint64_t Mask = ~(uint64_t)(0ull) >> (64-BITWIDTH); \
- if (BITWIDTH == 1) { \
- Dest.Int1Val = (bool) (VAL & Mask); \
- } else if (BITWIDTH <= 8) { \
- Dest.Int8Val = (uint8_t) (VAL & Mask); \
- } else if (BITWIDTH <= 16) { \
- Dest.Int16Val = (uint16_t) (VAL & Mask); \
- } else if (BITWIDTH <= 32) { \
- Dest.Int32Val = (uint32_t) (VAL & Mask); \
- } else \
- Dest.Int64Val = (uint64_t) (VAL & Mask); \
- }
-
GenericValue Interpreter::executeTruncInst(Value *SrcVal, const Type *DstTy,
ExecutionContext &SF) {
const Type *SrcTy = SrcVal->getType();
@@ -1192,31 +939,7 @@
unsigned DBitWidth = DITy->getBitWidth();
unsigned SBitWidth = SITy->getBitWidth();
assert(SBitWidth > DBitWidth && "Invalid truncate");
-
- if (DBitWidth > 64) {
- // Both values are APInt, just use the APInt trunc
- initializeAPInt(Dest, DstTy, SF);
- *(Dest.APIntVal) = Src.APIntVal->trunc(DBitWidth);
- return Dest;
- }
-
- uint64_t MaskedVal = 0;
- uint64_t Mask = (1ULL << DBitWidth) - 1;
-
- // Mask the source value to its actual bit width. This ensures that any
- // high order bits are cleared.
- if (SBitWidth <= 8)
- MaskedVal = Src.Int8Val & Mask;
- else if (SBitWidth <= 16)
- MaskedVal = Src.Int16Val & Mask;
- else if (SBitWidth <= 32)
- MaskedVal = Src.Int32Val & Mask;
- else if (SBitWidth <= 64)
- MaskedVal = Src.Int64Val & Mask;
- else
- MaskedVal = Src.APIntVal->trunc(DBitWidth).getZExtValue();
-
- INTEGER_ASSIGN(Dest, DBitWidth, MaskedVal);
+ Dest.IntVal = Src.IntVal.trunc(DBitWidth);
return Dest;
}
@@ -1229,36 +952,7 @@
unsigned DBitWidth = DITy->getBitWidth();
unsigned SBitWidth = SITy->getBitWidth();
assert(SBitWidth < DBitWidth && "Invalid sign extend");
-
- if (SBitWidth > 64) {
- // Both values are APInt, just use the APInt::sext method;
- initializeAPInt(Dest, DstTy, SF);
- *(Dest.APIntVal) = Src.APIntVal->sext(DBitWidth);
- return Dest;
- }
-
- // Normalize to a 64-bit value.
- uint64_t Normalized = 0;
- if (SBitWidth <= 8)
- Normalized = Src.Int8Val;
- else if (SBitWidth <= 16)
- Normalized = Src.Int16Val;
- else if (SBitWidth <= 32)
- Normalized = Src.Int32Val;
- else
- Normalized = Src.Int64Val;
-
- if (DBitWidth > 64) {
- // Destination is an APint, construct it and return
- initializeAPInt(Dest, DstTy, SF);
- *(Dest.APIntVal) = APInt(SBitWidth, Normalized).sext(DBitWidth);
- return Dest;
- }
-
- Normalized = doSignExtension(Normalized, SITy);
-
- // Now that we have a sign extended value, assign it to the destination
- INTEGER_ASSIGN(Dest, DBitWidth, Normalized);
+ Dest.IntVal = Src.IntVal.sext(DBitWidth);
return Dest;
}
@@ -1271,36 +965,7 @@
unsigned DBitWidth = DITy->getBitWidth();
unsigned SBitWidth = SITy->getBitWidth();
assert(SBitWidth < DBitWidth && "Invalid sign extend");
-
- if (SBitWidth > 64) {
- // Both values are APInt, just use the APInt::sext method;
- initializeAPInt(Dest, DstTy, SF);
- *(Dest.APIntVal) = Src.APIntVal->zext(DBitWidth);
- return Dest;
- }
-
- uint64_t Extended = 0;
- if (SBitWidth == 1)
- // For sign extension from bool, we must extend the source bits.
- Extended = (uint64_t) (Src.Int1Val & 1);
- else if (SBitWidth <= 8)
- Extended = (uint64_t) (uint8_t)Src.Int8Val;
- else if (SBitWidth <= 16)
- Extended = (uint64_t) (uint16_t)Src.Int16Val;
- else if (SBitWidth <= 32)
- Extended = (uint64_t) (uint32_t)Src.Int32Val;
- else
- Extended = (uint64_t) Src.Int64Val;
-
- if (DBitWidth > 64) {
- // Destination is an APint, construct it and return
- initializeAPInt(Dest, DstTy, SF);
- *(Dest.APIntVal) = APInt(SBitWidth, Extended).zext(DBitWidth);
- return Dest;
- }
-
- // Now that we have a sign extended value, assign it to the destination
- INTEGER_ASSIGN(Dest, DBitWidth, Extended);
+ Dest.IntVal = Src.IntVal.zext(DBitWidth);
return Dest;
}
@@ -1327,167 +992,73 @@
GenericValue Interpreter::executeFPToUIInst(Value *SrcVal, const Type *DstTy,
ExecutionContext &SF) {
const Type *SrcTy = SrcVal->getType();
+ uint32_t DBitWidth = cast(DstTy)->getBitWidth();
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- const IntegerType *DITy = cast(DstTy);
- unsigned DBitWidth = DITy->getBitWidth();
assert(SrcTy->isFloatingPoint() && "Invalid FPToUI instruction");
- if (DBitWidth > 64) {
- initializeAPInt(Dest, DITy, SF);
- if (SrcTy->getTypeID() == Type::FloatTyID)
- *(Dest.APIntVal) = APIntOps::RoundFloatToAPInt(Src.FloatVal, DBitWidth);
- else
- *(Dest.APIntVal) = APIntOps::RoundDoubleToAPInt(Src.DoubleVal, DBitWidth);
- return Dest;
- }
-
- uint64_t Converted = 0;
if (SrcTy->getTypeID() == Type::FloatTyID)
- Converted = (uint64_t) Src.FloatVal;
+ Dest.IntVal = APIntOps::RoundFloatToAPInt(Src.FloatVal, DBitWidth);
else
- Converted = (uint64_t) Src.DoubleVal;
-
- INTEGER_ASSIGN(Dest, DBitWidth, Converted);
+ Dest.IntVal = APIntOps::RoundDoubleToAPInt(Src.DoubleVal, DBitWidth);
return Dest;
}
GenericValue Interpreter::executeFPToSIInst(Value *SrcVal, const Type *DstTy,
ExecutionContext &SF) {
const Type *SrcTy = SrcVal->getType();
+ uint32_t DBitWidth = cast(DstTy)->getBitWidth();
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- const IntegerType *DITy = cast(DstTy);
- unsigned DBitWidth = DITy->getBitWidth();
assert(SrcTy->isFloatingPoint() && "Invalid FPToSI instruction");
- if (DBitWidth > 64) {
- initializeAPInt(Dest, DITy, SF);
- if (SrcTy->getTypeID() == Type::FloatTyID)
- *(Dest.APIntVal) = APIntOps::RoundFloatToAPInt(Src.FloatVal, DBitWidth);
- else
- *(Dest.APIntVal) = APIntOps::RoundDoubleToAPInt(Src.DoubleVal, DBitWidth);
- return Dest;
- }
-
- int64_t Converted = 0;
if (SrcTy->getTypeID() == Type::FloatTyID)
- Converted = (int64_t) Src.FloatVal;
+ Dest.IntVal = APIntOps::RoundFloatToAPInt(Src.FloatVal, DBitWidth);
else
- Converted = (int64_t) Src.DoubleVal;
-
- INTEGER_ASSIGN(Dest, DBitWidth, Converted);
+ Dest.IntVal = APIntOps::RoundDoubleToAPInt(Src.DoubleVal, DBitWidth);
return Dest;
}
GenericValue Interpreter::executeUIToFPInst(Value *SrcVal, const Type *DstTy,
ExecutionContext &SF) {
- const Type *SrcTy = SrcVal->getType();
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- const IntegerType *SITy = cast(SrcTy);
- unsigned SBitWidth = SITy->getBitWidth();
assert(DstTy->isFloatingPoint() && "Invalid UIToFP instruction");
- if (SBitWidth > 64) {
- if (DstTy->getTypeID() == Type::FloatTyID)
- Dest.FloatVal = APIntOps::RoundAPIntToFloat(*(Src.APIntVal));
- else
- Dest.DoubleVal = APIntOps::RoundAPIntToDouble(*(Src.APIntVal));
- return Dest;
- }
-
- uint64_t Converted = 0;
- if (SBitWidth == 1)
- Converted = (uint64_t) Src.Int1Val;
- else if (SBitWidth <= 8)
- Converted = (uint64_t) Src.Int8Val;
- else if (SBitWidth <= 16)
- Converted = (uint64_t) Src.Int16Val;
- else if (SBitWidth <= 32)
- Converted = (uint64_t) Src.Int32Val;
- else
- Converted = (uint64_t) Src.Int64Val;
-
if (DstTy->getTypeID() == Type::FloatTyID)
- Dest.FloatVal = (float) Converted;
+ Dest.FloatVal = APIntOps::RoundAPIntToFloat(Src.IntVal);
else
- Dest.DoubleVal = (double) Converted;
+ Dest.DoubleVal = APIntOps::RoundAPIntToDouble(Src.IntVal);
return Dest;
}
GenericValue Interpreter::executeSIToFPInst(Value *SrcVal, const Type *DstTy,
ExecutionContext &SF) {
- const Type *SrcTy = SrcVal->getType();
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- const IntegerType *SITy = cast(SrcTy);
- unsigned SBitWidth = SITy->getBitWidth();
assert(DstTy->isFloatingPoint() && "Invalid SIToFP instruction");
- if (SBitWidth > 64) {
- if (DstTy->getTypeID() == Type::FloatTyID)
- Dest.FloatVal = APIntOps::RoundSignedAPIntToFloat(*(Src.APIntVal));
- else
- Dest.DoubleVal = APIntOps::RoundSignedAPIntToDouble(*(Src.APIntVal));
- return Dest;
- }
-
- int64_t Converted = 0;
- if (SBitWidth == 1)
- Converted = 0LL - Src.Int1Val;
- else if (SBitWidth <= 8)
- Converted = (int64_t) (int8_t)Src.Int8Val;
- else if (SBitWidth <= 16)
- Converted = (int64_t) (int16_t)Src.Int16Val;
- else if (SBitWidth <= 32)
- Converted = (int64_t) (int32_t)Src.Int32Val;
- else
- Converted = (int64_t) Src.Int64Val;
-
if (DstTy->getTypeID() == Type::FloatTyID)
- Dest.FloatVal = (float) Converted;
+ Dest.FloatVal = APIntOps::RoundSignedAPIntToFloat(Src.IntVal);
else
- Dest.DoubleVal = (double) Converted;
+ Dest.DoubleVal = APIntOps::RoundSignedAPIntToDouble(Src.IntVal);
return Dest;
+
}
GenericValue Interpreter::executePtrToIntInst(Value *SrcVal, const Type *DstTy,
ExecutionContext &SF) {
const Type *SrcTy = SrcVal->getType();
+ uint32_t DBitWidth = cast(DstTy)->getBitWidth();
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- const IntegerType *DITy = cast(DstTy);
- unsigned DBitWidth = DITy->getBitWidth();
assert(isa(SrcTy) && "Invalid PtrToInt instruction");
- if (DBitWidth > 64) {
- initializeAPInt(Dest, DstTy, SF);
- *(Dest.APIntVal) = (intptr_t) Src.PointerVal;
- }
-
- INTEGER_ASSIGN(Dest, DBitWidth, (intptr_t) Src.PointerVal);
+ Dest.IntVal = APInt(DBitWidth, (intptr_t) Src.PointerVal);
return Dest;
}
GenericValue Interpreter::executeIntToPtrInst(Value *SrcVal, const Type *DstTy,
ExecutionContext &SF) {
- const Type *SrcTy = SrcVal->getType();
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- const IntegerType *SITy = cast(SrcTy);
- unsigned SBitWidth = SITy->getBitWidth();
assert(isa(DstTy) && "Invalid PtrToInt instruction");
- uint64_t Converted = 0;
- if (SBitWidth == 1)
- Converted = (uint64_t) Src.Int1Val;
- else if (SBitWidth <= 8)
- Converted = (uint64_t) Src.Int8Val;
- else if (SBitWidth <= 16)
- Converted = (uint64_t) Src.Int16Val;
- else if (SBitWidth <= 32)
- Converted = (uint64_t) Src.Int32Val;
- else if (SBitWidth <= 64)
- Converted = (uint64_t) Src.Int64Val;
- else
- Converted = (uint64_t) Src.APIntVal->trunc(64).getZExtValue();
-
- Dest.PointerVal = (PointerTy) Converted;
+ Dest.PointerVal = (PointerTy) Src.IntVal.trunc(64).getZExtValue();
return Dest;
}
@@ -1500,44 +1071,22 @@
assert(isa(SrcTy) && "Invalid BitCast");
Dest.PointerVal = Src.PointerVal;
} else if (DstTy->isInteger()) {
- const IntegerType *DITy = cast(DstTy);
- unsigned DBitWidth = DITy->getBitWidth();
if (SrcTy == Type::FloatTy) {
- Dest.Int32Val = FloatToBits(Src.FloatVal);
+ Dest.IntVal.floatToBits(Src.FloatVal);
} else if (SrcTy == Type::DoubleTy) {
- Dest.Int64Val = DoubleToBits(Src.DoubleVal);
+ Dest.IntVal.doubleToBits(Src.DoubleVal);
} else if (SrcTy->isInteger()) {
- const IntegerType *SITy = cast(SrcTy);
- unsigned SBitWidth = SITy->getBitWidth();
- assert(SBitWidth == DBitWidth && "Invalid BitCast");
- if (SBitWidth == 1) {
- Dest.Int1Val = Src.Int1Val;
- maskToBitWidth(Dest, DBitWidth);
- } else if (SBitWidth <= 8) {
- Dest.Int8Val = Src.Int8Val;
- maskToBitWidth(Dest, DBitWidth);
- } else if (SBitWidth <= 16) {
- Dest.Int16Val = Src.Int16Val;
- maskToBitWidth(Dest, DBitWidth);
- } else if (SBitWidth <= 32) {
- Dest.Int32Val = Src.Int32Val;
- maskToBitWidth(Dest, DBitWidth);
- } else if (SBitWidth <= 64) {
- Dest.Int64Val = Src.Int64Val;
- maskToBitWidth(Dest, DBitWidth);
- } else {
- *(Dest.APIntVal) = *(Src.APIntVal);
- }
+ Dest.IntVal = Src.IntVal;
} else
assert(0 && "Invalid BitCast");
} else if (DstTy == Type::FloatTy) {
if (SrcTy->isInteger())
- Dest.FloatVal = BitsToFloat(Src.Int32Val);
+ Dest.FloatVal = Src.IntVal.bitsToFloat();
else
Dest.FloatVal = Src.FloatVal;
} else if (DstTy == Type::DoubleTy) {
if (SrcTy->isInteger())
- Dest.DoubleVal = BitsToDouble(Src.Int64Val);
+ Dest.DoubleVal = Src.IntVal.bitsToDouble();
else
Dest.DoubleVal = Src.DoubleVal;
} else
@@ -1617,30 +1166,10 @@
GenericValue VAList = getOperandValue(I.getOperand(0), SF);
GenericValue Dest;
GenericValue Src = ECStack[VAList.UIntPairVal.first]
- .VarArgs[VAList.UIntPairVal.second];
+ .VarArgs[VAList.UIntPairVal.second];
const Type *Ty = I.getType();
switch (Ty->getTypeID()) {
- case Type::IntegerTyID: {
- unsigned BitWidth = cast(Ty)->getBitWidth();
- if (BitWidth == 1) {
- Dest.Int1Val = Src.Int1Val;
- maskToBitWidth(Dest, BitWidth);
- } else if (BitWidth <= 8) {
- Dest.Int8Val = Src.Int8Val;
- maskToBitWidth(Dest, BitWidth);
- } else if (BitWidth <= 16) {
- Dest.Int16Val = Src.Int16Val;
- maskToBitWidth(Dest, BitWidth);
- } else if (BitWidth <= 32) {
- Dest.Int32Val = Src.Int32Val;
- maskToBitWidth(Dest, BitWidth);
- } else if (BitWidth <= 64) {
- Dest.Int64Val = Src.Int64Val;
- maskToBitWidth(Dest, BitWidth);
- } else {
- *(Dest.APIntVal) = *(Src.APIntVal);
- }
- }
+ case Type::IntegerTyID: Dest.IntVal = Src.IntVal;
IMPLEMENT_VAARG(Pointer);
IMPLEMENT_VAARG(Float);
IMPLEMENT_VAARG(Double);
@@ -1702,69 +1231,32 @@
// The cases below here require a GenericValue parameter for the result
// so we initialize one, compute it and then return it.
+ GenericValue Op0 = getOperandValue(CE->getOperand(0), SF);
+ GenericValue Op1 = getOperandValue(CE->getOperand(1), SF);
GenericValue Dest;
- initializeAPInt(Dest, CE->getType(), SF);
+ const Type * Ty = CE->getOperand(0)->getType();
switch (CE->getOpcode()) {
- case Instruction::Add:
- executeAddInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::Sub:
- executeSubInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::Mul:
- executeMulInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::SDiv:
- executeSDivInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::UDiv:
- executeUDivInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::FDiv:
- executeFDivInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::URem:
- executeURemInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::SRem:
- executeSRemInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::FRem:
- executeFRemInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::And:
- executeAndInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::Or:
- executeOrInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::Xor:
- executeXorInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::Shl:
- executeShlInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::LShr:
- executeLShrInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
- case Instruction::AShr:
- executeAShrInst(Dest, getOperandValue(CE->getOperand(0), SF),
- getOperandValue(CE->getOperand(1), SF),
- CE->getOperand(0)->getType());
+ case Instruction::Add: executeAddInst (Dest, Op0, Op1, Ty); break;
+ case Instruction::Sub: executeSubInst (Dest, Op0, Op1, Ty); break;
+ case Instruction::Mul: executeMulInst (Dest, Op0, Op1, Ty); break;
+ case Instruction::FDiv: executeFDivInst(Dest, Op0, Op1, Ty); break;
+ case Instruction::FRem: executeFRemInst(Dest, Op0, Op1, Ty); break;
+ case Instruction::SDiv: Dest.IntVal = Op0.IntVal.sdiv(Op1.IntVal); break;
+ case Instruction::UDiv: Dest.IntVal = Op0.IntVal.udiv(Op1.IntVal); break;
+ case Instruction::URem: Dest.IntVal = Op0.IntVal.urem(Op1.IntVal); break;
+ case Instruction::SRem: Dest.IntVal = Op0.IntVal.srem(Op1.IntVal); break;
+ case Instruction::And: Dest.IntVal = Op0.IntVal.And(Op1.IntVal); break;
+ case Instruction::Or: Dest.IntVal = Op0.IntVal.Or(Op1.IntVal); break;
+ case Instruction::Xor: Dest.IntVal = Op0.IntVal.Xor(Op1.IntVal); break;
+ case Instruction::Shl:
+ Dest.IntVal = Op0.IntVal.shl(Op1.IntVal.getZExtValue());
+ break;
+ case Instruction::LShr:
+ Dest.IntVal = Op0.IntVal.lshr(Op1.IntVal.getZExtValue());
+ break;
+ case Instruction::AShr:
+ Dest.IntVal = Op0.IntVal.ashr(Op1.IntVal.getZExtValue());
+ break;
default:
cerr << "Unhandled ConstantExpr: " << *CE << "\n";
abort();
From reid at x10sys.com Mon Mar 5 21:11:48 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 21:11:48 -0600
Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/JIT.cpp
Message-ID: <200703060311.l263Bmv3008639@zion.cs.uiuc.edu>
Changes in directory llvm/lib/ExecutionEngine/JIT:
JIT.cpp updated: 1.93 -> 1.94
---
Log message:
Simplify code as a result of the change in GenericValue to have a single
integer field of type APInt instead of different sized integer fields.
---
Diffs of the changes: (+15 -28)
JIT.cpp | 43 +++++++++++++++----------------------------
1 files changed, 15 insertions(+), 28 deletions(-)
Index: llvm/lib/ExecutionEngine/JIT/JIT.cpp
diff -u llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.93 llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.94
--- llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.93 Tue Feb 13 23:52:17 2007
+++ llvm/lib/ExecutionEngine/JIT/JIT.cpp Mon Mar 5 21:11:31 2007
@@ -107,8 +107,9 @@
// Call the function.
GenericValue rv;
- rv.Int32Val = PF(ArgValues[0].Int32Val, (char **)GVTOP(ArgValues[1]),
- (const char **)GVTOP(ArgValues[2]));
+ rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue(),
+ (char **)GVTOP(ArgValues[1]),
+ (const char **)GVTOP(ArgValues[2])));
return rv;
}
break;
@@ -120,7 +121,8 @@
// Call the function.
GenericValue rv;
- rv.Int32Val = PF(ArgValues[0].Int32Val, (char **)GVTOP(ArgValues[1]));
+ rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue(),
+ (char **)GVTOP(ArgValues[1])));
return rv;
}
break;
@@ -130,7 +132,7 @@
FTy->getParamType(0) == Type::Int32Ty)) {
GenericValue rv;
int (*PF)(int) = (int(*)(int))(intptr_t)FPtr;
- rv.Int32Val = PF(ArgValues[0].Int32Val);
+ rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue()));
return rv;
}
break;
@@ -145,21 +147,21 @@
case Type::IntegerTyID: {
unsigned BitWidth = cast(RetTy)->getBitWidth();
if (BitWidth == 1)
- rv.Int1Val = ((bool(*)())(intptr_t)FPtr)();
+ rv.IntVal = APInt(BitWidth, ((bool(*)())(intptr_t)FPtr)());
else if (BitWidth <= 8)
- rv.Int8Val = ((char(*)())(intptr_t)FPtr)();
+ rv.IntVal = APInt(BitWidth, ((char(*)())(intptr_t)FPtr)());
else if (BitWidth <= 16)
- rv.Int16Val = ((short(*)())(intptr_t)FPtr)();
+ rv.IntVal = APInt(BitWidth, ((short(*)())(intptr_t)FPtr)());
else if (BitWidth <= 32)
- rv.Int32Val = ((int(*)())(intptr_t)FPtr)();
+ rv.IntVal = APInt(BitWidth, ((int(*)())(intptr_t)FPtr)());
else if (BitWidth <= 64)
- rv.Int64Val = ((int64_t(*)())(intptr_t)FPtr)();
+ rv.IntVal = APInt(BitWidth, ((int64_t(*)())(intptr_t)FPtr)());
else
assert(0 && "Integer types > 64 bits not supported");
return rv;
}
case Type::VoidTyID:
- rv.Int32Val = ((int(*)())(intptr_t)FPtr)();
+ rv.IntVal = APInt(32, ((int(*)())(intptr_t)FPtr)());
return rv;
case Type::FloatTyID:
rv.FloatVal = ((float(*)())(intptr_t)FPtr)();
@@ -194,24 +196,9 @@
const GenericValue &AV = ArgValues[i];
switch (ArgTy->getTypeID()) {
default: assert(0 && "Unknown argument type for function call!");
- case Type::IntegerTyID: {
- unsigned BitWidth = cast(ArgTy)->getBitWidth();
- if (BitWidth == 1)
- C = ConstantInt::get(ArgTy, AV.Int1Val);
- else if (BitWidth <= 8)
- C = ConstantInt::get(ArgTy, AV.Int8Val);
- else if (BitWidth <= 16)
- C = ConstantInt::get(ArgTy, AV.Int16Val);
- else if (BitWidth <= 32)
- C = ConstantInt::get(ArgTy, AV.Int32Val);
- else if (BitWidth <= 64)
- C = ConstantInt::get(ArgTy, AV.Int64Val);
- else
- assert(0 && "Integer types > 64 bits not supported");
- break;
- }
- case Type::FloatTyID: C = ConstantFP ::get(ArgTy, AV.FloatVal); break;
- case Type::DoubleTyID: C = ConstantFP ::get(ArgTy, AV.DoubleVal); break;
+ case Type::IntegerTyID: C = ConstantInt::get(AV.IntVal); break;
+ case Type::FloatTyID: C = ConstantFP ::get(ArgTy, AV.FloatVal); break;
+ case Type::DoubleTyID: C = ConstantFP ::get(ArgTy, AV.DoubleVal); break;
case Type::PointerTyID:
void *ArgPtr = GVTOP(AV);
if (sizeof(void*) == 4) {
From reid at x10sys.com Mon Mar 5 21:13:12 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 21:13:12 -0600
Subject: [llvm-commits] CVS: llvm/tools/lli/lli.cpp
Message-ID: <200703060313.l263DCGU008674@zion.cs.uiuc.edu>
Changes in directory llvm/tools/lli:
lli.cpp updated: 1.68 -> 1.69
---
Log message:
Obtain the exit function before execution just in case the module
disappears before we get to calling the exit function.
---
Diffs of the changes: (+7 -5)
lli.cpp | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
Index: llvm/tools/lli/lli.cpp
diff -u llvm/tools/lli/lli.cpp:1.68 llvm/tools/lli/lli.cpp:1.69
--- llvm/tools/lli/lli.cpp:1.68 Sat Mar 3 12:21:44 2007
+++ llvm/tools/lli/lli.cpp Mon Mar 5 21:12:55 2007
@@ -124,6 +124,10 @@
return -1;
}
+ // If the program doesn't explicitly call exit, we will need the Exit
+ // function later on to make an explicit call, so get the function now.
+ Constant *Exit = Mod->getOrInsertFunction("exit", Type::VoidTy,
+ Type::Int32Ty, NULL);
// Run static constructors.
EE->runStaticConstructorsDestructors(false);
@@ -133,14 +137,12 @@
// Run static destructors.
EE->runStaticConstructorsDestructors(true);
- // If the program didn't explicitly call exit, call exit now, for the
- // program. This ensures that any atexit handlers get called correctly.
- Constant *Exit = Mod->getOrInsertFunction("exit", Type::VoidTy,
- Type::Int32Ty, NULL);
+ // If the program didn't call exit explicitly, we should call it now.
+ // This ensures that any atexit handlers get called correctly.
if (Function *ExitF = dyn_cast(Exit)) {
std::vector Args;
GenericValue ResultGV;
- ResultGV.Int32Val = Result;
+ ResultGV.IntVal = APInt(32, Result);
Args.push_back(ResultGV);
EE->runFunction(ExitF, Args);
std::cerr << "ERROR: exit(" << Result << ") returned!\n";
From reid at x10sys.com Mon Mar 5 21:42:08 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 21:42:08 -0600
Subject: [llvm-commits] CVS:
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
Message-ID: <200703060342.l263g8eS009205@zion.cs.uiuc.edu>
Changes in directory llvm/lib/ExecutionEngine/Interpreter:
Execution.cpp updated: 1.173 -> 1.174
---
Log message:
Fix a bug in IntToPtr. Truncating to 64-bits only works if the integer
is larger. Adjust so that it truncates to pointer width, only if necessary.
---
Diffs of the changes: (+5 -1)
Execution.cpp | 6 +++++-
1 files changed, 5 insertions(+), 1 deletion(-)
Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.173 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.174
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.173 Mon Mar 5 21:09:31 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Mon Mar 5 21:41:50 2007
@@ -1058,7 +1058,11 @@
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
assert(isa(DstTy) && "Invalid PtrToInt instruction");
- Dest.PointerVal = (PointerTy) Src.IntVal.trunc(64).getZExtValue();
+ uint32_t PtrSize = TD.getPointerSize();
+ if (PtrSize != Src.IntVal.getBitWidth())
+ Src.IntVal = Src.IntVal.trunc(PtrSize);
+
+ Dest.PointerVal = (PointerTy) Src.IntVal.getZExtValue();
return Dest;
}
From reid at x10sys.com Mon Mar 5 21:46:58 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 21:46:58 -0600
Subject: [llvm-commits] CVS:
llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
Message-ID: <200703060346.l263kwLx009281@zion.cs.uiuc.edu>
Changes in directory llvm/lib/ExecutionEngine/Interpreter:
Execution.cpp updated: 1.174 -> 1.175
---
Log message:
Fix some thinko's in the last patch. PtrSize has to be in bits and we
might need to zext not just trunc the value.
---
Diffs of the changes: (+2 -2)
Execution.cpp | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.174 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.175
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.174 Mon Mar 5 21:41:50 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Mon Mar 5 21:46:41 2007
@@ -1058,9 +1058,9 @@
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
assert(isa(DstTy) && "Invalid PtrToInt instruction");
- uint32_t PtrSize = TD.getPointerSize();
+ uint32_t PtrSize = TD.getPointerSizeInBits();
if (PtrSize != Src.IntVal.getBitWidth())
- Src.IntVal = Src.IntVal.trunc(PtrSize);
+ Src.IntVal = Src.IntVal.zextOrTrunc(PtrSize);
Dest.PointerVal = (PointerTy) Src.IntVal.getZExtValue();
return Dest;
From johannes at apple.com Mon Mar 5 20:43:51 2007
From: johannes at apple.com (johannes at apple.com)
Date: Mon, 5 Mar 2007 18:43:51 -0800 (PST)
Subject: [llvm-commits] [124625] Don't enable unrolling at -Os.
Message-ID: <20070306024351.6C5698116748@src>
Revision: 124625
Author: johannes
Date: 2007-03-05 18:43:49 -0800 (Mon, 05 Mar 2007)
Log Message:
-----------
Don't enable unrolling at -Os.
Modified Paths:
--------------
apple-local/branches/llvm/gcc/opts.c
Modified: apple-local/branches/llvm/gcc/opts.c
===================================================================
--- apple-local/branches/llvm/gcc/opts.c 2007-03-06 02:26:56 UTC (rev 124624)
+++ apple-local/branches/llvm/gcc/opts.c 2007-03-06 02:43:49 UTC (rev 124625)
@@ -576,7 +576,7 @@
}
/* APPLE LOCAL begin LLVM */
/* Enable loop unrolling at -O2 if -f[no-]unroll-loops is not used. */
- if (!flag_unroll_loops_set)
+ if (!flag_unroll_loops_set && !optimize_size)
flag_unroll_loops = 1;
/* APPLE LOCAL end LLVM */
}
From sabre at nondot.org Mon Mar 5 22:54:02 2007
From: sabre at nondot.org (Chris Lattner)
Date: Mon, 5 Mar 2007 22:54:02 -0600
Subject: [llvm-commits] CVS: llvm-test/Makefile.programs
Message-ID: <200703060454.l264s2tX010518@zion.cs.uiuc.edu>
Changes in directory llvm-test:
Makefile.programs updated: 1.258 -> 1.259
---
Log message:
ppc llc-beta can be just tail merging.
---
Diffs of the changes: (+2 -2)
Makefile.programs | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
Index: llvm-test/Makefile.programs
diff -u llvm-test/Makefile.programs:1.258 llvm-test/Makefile.programs:1.259
--- llvm-test/Makefile.programs:1.258 Mon Mar 5 21:07:59 2007
+++ llvm-test/Makefile.programs Mon Mar 5 22:53:45 2007
@@ -211,8 +211,8 @@
endif#DISABLE_DIFFS
ifeq ($(ARCH),PowerPC)
-LLCBETAOPTION := --enable-ppc-preinc --enable-tail-merge
-#--enable-tail-merge
+LLCBETAOPTION := --enable-tail-merge
+# --enable-ppc-preinc
#-regalloc=local -fast
endif
ifeq ($(ARCH),Alpha)
From reid at x10sys.com Mon Mar 5 23:02:45 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 23:02:45 -0600
Subject: [llvm-commits] CVS:
llvm/include/llvm/ExecutionEngine/ExecutionEngine.h
Message-ID: <200703060502.l2652j9v010688@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm/ExecutionEngine:
ExecutionEngine.h updated: 1.44 -> 1.45
---
Log message:
Make StoreValueToMemory a little more efficient by not copying a
GenericValue to a temporary.
---
Diffs of the changes: (+1 -1)
ExecutionEngine.h | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
Index: llvm/include/llvm/ExecutionEngine/ExecutionEngine.h
diff -u llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:1.44 llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:1.45
--- llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:1.44 Mon Mar 5 21:01:54 2007
+++ llvm/include/llvm/ExecutionEngine/ExecutionEngine.h Mon Mar 5 23:02:28 2007
@@ -176,7 +176,7 @@
const GlobalValue *getGlobalValueAtAddress(void *Addr);
- void StoreValueToMemory(GenericValue Val, GenericValue *Ptr, const Type *Ty);
+ void StoreValueToMemory(const GenericValue &Val, GenericValue *Ptr, const Type *Ty);
void InitializeMemory(const Constant *Init, void *Addr);
/// recompileAndRelinkFunction - This method is used to force a function
From reid at x10sys.com Mon Mar 5 23:03:34 2007
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 5 Mar 2007 23:03:34 -0600
Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
Message-ID: <200703060503.l2653YAR010721@zion.cs.uiuc.edu>
Changes in directory llvm/lib/ExecutionEngine:
ExecutionEngine.cpp updated: 1.111 -> 1.112
---
Log message:
1. Make StoreValueToMemory a little more efficient by not requiring caller
to make a copy of the GenericValue.
2. Fix a copy & paste bug in StoreValueToMemory where 64-bit values were
truncated to 32
---
Diffs of the changes: (+2 -2)
ExecutionEngine.cpp | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.111 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.112
--- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.111 Mon Mar 5 21:04:04 2007
+++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp Mon Mar 5 23:03:16 2007
@@ -410,7 +410,7 @@
/// It is not a pointer to a GenericValue containing the address at which to
/// store Val.
///
-void ExecutionEngine::StoreValueToMemory(GenericValue Val, GenericValue *Ptr,
+void ExecutionEngine::StoreValueToMemory(const GenericValue &Val, GenericValue *Ptr,
const Type *Ty) {
switch (Ty->getTypeID()) {
case Type::IntegerTyID: {
@@ -423,7 +423,7 @@
} else if (BitWidth <= 32) {
*((uint32_t*)Ptr) = uint32_t(Val.IntVal.getZExtValue());
} else if (BitWidth <= 64) {
- *((uint64_t*)Ptr) = uint32_t(Val.IntVal.getZExtValue());
+ *((uint64_t*)Ptr) = uint64_t(Val.IntVal.getZExtValue());
} else {
uint64_t *Dest = (uint64_t*)Ptr;
const uint64_t *Src = Val.IntVal.getRawData();
From asl at math.spbu.ru Mon Mar 5 23:33:08 2007
From: asl at math.spbu.ru (Anton Korobeynikov)
Date: Mon, 5 Mar 2007 23:33:08 -0600
Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp
Message-ID: <200703060533.l265X8ZR011220@zion.cs.uiuc.edu>
Changes in directory llvm/lib/ExecutionEngine/JIT:
JITEmitter.cpp updated: 1.130 -> 1.131
---
Log message:
Implement PR1240: http://llvm.org/PR1240
---
Diffs of the changes: (+3 -2)
JITEmitter.cpp | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
Index: llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp
diff -u llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp:1.130 llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp:1.131
--- llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp:1.130 Fri Feb 23 20:57:03 2007
+++ llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp Mon Mar 5 23:32:48 2007
@@ -876,8 +876,9 @@
Relocations.clear();
#ifndef NDEBUG
- DOUT << "Disassembled code:\n"
- << sys::disassembleBuffer(FnStart, FnEnd-FnStart, (uintptr_t)FnStart);
+ if (sys::hasDisassembler())
+ DOUT << "Disassembled code:\n"
+ << sys::disassembleBuffer(FnStart, FnEnd-FnStart, (uintptr_t)FnStart);
#endif
return false;
From asl at math.spbu.ru Mon Mar 5 23:33:09 2007
From: asl at math.spbu.ru (Anton Korobeynikov)
Date: Mon, 5 Mar 2007 23:33:09 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/System/Disassembler.h
Message-ID: <200703060533.l265X93O011225@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm/System:
Disassembler.h updated: 1.1 -> 1.2
---
Log message:
Implement PR1240: http://llvm.org/PR1240
---
Diffs of the changes: (+4 -0)
Disassembler.h | 4 ++++
1 files changed, 4 insertions(+)
Index: llvm/include/llvm/System/Disassembler.h
diff -u llvm/include/llvm/System/Disassembler.h:1.1 llvm/include/llvm/System/Disassembler.h:1.2
--- llvm/include/llvm/System/Disassembler.h:1.1 Tue Jan 23 04:26:08 2007
+++ llvm/include/llvm/System/Disassembler.h Mon Mar 5 23:32:48 2007
@@ -21,6 +21,10 @@
namespace llvm {
namespace sys {
+/// This function returns true, if there is possible to use some external
+/// disassembler library. False otherwise.
+bool hasDisassembler(void);
+
/// This function provides some "glue" code to call external disassembler
/// libraries.
std::string disassembleBuffer(uint8_t* start, size_t length, uint64_t pc = 0);
From asl at math.spbu.ru Mon Mar 5 23:33:09 2007
From: asl at math.spbu.ru (Anton Korobeynikov)
Date: Mon, 5 Mar 2007 23:33:09 -0600
Subject: [llvm-commits] CVS: llvm/lib/System/Disassembler.cpp
Message-ID: <200703060533.l265X9vm011230@zion.cs.uiuc.edu>
Changes in directory llvm/lib/System:
Disassembler.cpp updated: 1.2 -> 1.3
---
Log message:
Implement PR1240: http://llvm.org/PR1240
---
Diffs of the changes: (+10 -0)
Disassembler.cpp | 10 ++++++++++
1 files changed, 10 insertions(+)
Index: llvm/lib/System/Disassembler.cpp
diff -u llvm/lib/System/Disassembler.cpp:1.2 llvm/lib/System/Disassembler.cpp:1.3
--- llvm/lib/System/Disassembler.cpp:1.2 Sun Mar 4 00:36:24 2007
+++ llvm/lib/System/Disassembler.cpp Mon Mar 5 23:32:48 2007
@@ -26,6 +26,16 @@
using namespace llvm;
+bool llvm::sys::hasDisassembler(void)
+{
+#if defined (__i386__) || defined (__amd64__) || defined (__x86_64__)
+ // We have option to enable udis86 library.
+ return true;
+#else
+ return false;
+#endif
+}
+
std::string llvm::sys::disassembleBuffer(uint8_t* start, size_t length,
uint64_t pc) {
std::stringstream res;
From asl at math.spbu.ru Tue Mar 6 00:10:52 2007
From: asl at math.spbu.ru (Anton Korobeynikov)
Date: Tue, 6 Mar 2007 00:10:52 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/SelectionDAGISel.h
Message-ID: <200703060610.l266Aqj7012420@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm/CodeGen:
SelectionDAGISel.h updated: 1.31 -> 1.32
---
Log message:
Enumerate SDISel formal parameter attributes. Make use of new
enumeration.
---
Diffs of the changes: (+14 -0)
SelectionDAGISel.h | 14 ++++++++++++++
1 files changed, 14 insertions(+)
Index: llvm/include/llvm/CodeGen/SelectionDAGISel.h
diff -u llvm/include/llvm/CodeGen/SelectionDAGISel.h:1.31 llvm/include/llvm/CodeGen/SelectionDAGISel.h:1.32
--- llvm/include/llvm/CodeGen/SelectionDAGISel.h:1.31 Sat Oct 28 13:21:29 2006
+++ llvm/include/llvm/CodeGen/SelectionDAGISel.h Tue Mar 6 00:10:33 2007
@@ -31,6 +31,20 @@
class FunctionLoweringInfo;
class HazardRecognizer;
+ namespace SDISelParamFlags {
+ enum Flags {
+ NoFlagSet = 0,
+ Signed = 1<<0,
+ SignedOffs = 0,
+ InReg = 1<<1,
+ InRegOffs = 1,
+ StructReturn = 1<<2,
+ StructReturnOffs = 2,
+ OrigAlignment = 0x1F<<27,
+ OrigAlignmentOffs = 27
+ };
+ }
+
/// SelectionDAGISel - This is the common base class used for SelectionDAG-based
/// pattern-matching instruction selectors.
class SelectionDAGISel : public FunctionPass {
From asl at math.spbu.ru Tue Mar 6 00:10:51 2007
From: asl at math.spbu.ru (Anton Korobeynikov)
Date: Tue, 6 Mar 2007 00:10:51 -0600
Subject: [llvm-commits] CVS:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Message-ID: <200703060610.l266ApMM012415@zion.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAGISel.cpp updated: 1.380 -> 1.381
---
Log message:
Enumerate SDISel formal parameter attributes. Make use of new
enumeration.
---
Diffs of the changes: (+24 -22)
SelectionDAGISel.cpp | 46 ++++++++++++++++++++++++----------------------
1 files changed, 24 insertions(+), 22 deletions(-)
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.380 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.381
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.380 Sun Mar 4 18:00:42 2007
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Tue Mar 6 00:10:33 2007
@@ -3099,22 +3099,21 @@
for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end();
I != E; ++I, ++j) {
MVT::ValueType VT = getValueType(I->getType());
- bool isInReg = FTy->paramHasAttr(j, FunctionType::InRegAttribute);
- bool isSRet = FTy->paramHasAttr(j, FunctionType::StructRetAttribute);
+ unsigned Flags = SDISelParamFlags::NoFlagSet;
unsigned OriginalAlignment =
getTargetData()->getABITypeAlignment(I->getType());
- // Flags[31:27] -> OriginalAlignment
- // Flags[2] -> isSRet
- // Flags[1] -> isInReg
- // Flags[0] -> isSigned
- unsigned Flags = (isInReg << 1) | (isSRet << 2) | (OriginalAlignment << 27);
// FIXME: Distinguish between a formal with no [sz]ext attribute from one
// that is zero extended!
if (FTy->paramHasAttr(j, FunctionType::ZExtAttribute))
- Flags |= 0;
+ Flags &= ~(SDISelParamFlags::Signed);
if (FTy->paramHasAttr(j, FunctionType::SExtAttribute))
- Flags |= 1;
+ Flags |= SDISelParamFlags::Signed;
+ if (FTy->paramHasAttr(j, FunctionType::InRegAttribute))
+ Flags |= SDISelParamFlags::InReg;
+ if (FTy->paramHasAttr(j, FunctionType::StructRetAttribute))
+ Flags |= SDISelParamFlags::StructReturn;
+ Flags |= (OriginalAlignment << SDISelParamFlags::OrigAlignmentOffs);
switch (getTypeAction(VT)) {
default: assert(0 && "Unknown type action!");
@@ -3136,7 +3135,9 @@
for (unsigned i = 0; i != NumVals; ++i) {
RetVals.push_back(NVT);
// if it isn't first piece, alignment must be 1
- if (i == 1) Flags = (Flags & 0x07ffffff) | (1 << 27);
+ if (i > 0)
+ Flags = (Flags & (~SDISelParamFlags::OrigAlignment)) |
+ (1 << SDISelParamFlags::OrigAlignmentOffs);
Ops.push_back(DAG.getConstant(Flags, MVT::i32));
}
} else {
@@ -3245,7 +3246,8 @@
if (TLI.getTypeAction(VT) != TargetLowering::Expand) {
// if it isn't first piece, alignment must be 1
if (!isFirst)
- Flags = (Flags & 0x07ffffff) | (1 << 27);
+ Flags = (Flags & (~SDISelParamFlags::OrigAlignment)) |
+ (1 << SDISelParamFlags::OrigAlignmentOffs);
Ops.push_back(Arg);
Ops.push_back(DAG.getConstant(Flags, MVT::i32));
return;
@@ -3292,18 +3294,18 @@
for (unsigned i = 0, e = Args.size(); i != e; ++i) {
MVT::ValueType VT = getValueType(Args[i].Ty);
SDOperand Op = Args[i].Node;
- bool isSigned = Args[i].isSigned;
- bool isInReg = Args[i].isInReg;
- bool isSRet = Args[i].isSRet;
+ unsigned Flags = SDISelParamFlags::NoFlagSet;
unsigned OriginalAlignment =
getTargetData()->getABITypeAlignment(Args[i].Ty);
- // Flags[31:27] -> OriginalAlignment
- // Flags[2] -> isSRet
- // Flags[1] -> isInReg
- // Flags[0] -> isSigned
- unsigned Flags = (isSRet << 2) | (isInReg << 1) | unsigned(isSigned) |
- (OriginalAlignment << 27);
-
+
+ if (Args[i].isSigned)
+ Flags |= SDISelParamFlags::Signed;
+ if (Args[i].isInReg)
+ Flags |= SDISelParamFlags::InReg;
+ if (Args[i].isSRet)
+ Flags |= SDISelParamFlags::StructReturn;
+ Flags |= OriginalAlignment << SDISelParamFlags::OrigAlignmentOffs;
+
switch (getTypeAction(VT)) {
default: assert(0 && "Unknown type action!");
case Legal:
@@ -3312,7 +3314,7 @@
break;
case Promote:
if (MVT::isInteger(VT)) {
- unsigned ExtOp = isSigned ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND;
+ unsigned ExtOp = Args[i].isSigned ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND;
Op = DAG.getNode(ExtOp, getTypeToTransformTo(VT), Op);
} else {
assert(MVT::isFloatingPoint(VT) && "Not int or FP?");
From sabre at nondot.org Tue Mar 6 00:27:51 2007
From: sabre at nondot.org (Chris Lattner)
Date: Tue, 6 Mar 2007 00:27:51 -0600
Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html
Message-ID: <200703060627.l266RphQ012826@zion.cs.uiuc.edu>
Changes in directory llvm/docs:
GettingStarted.html updated: 1.155 -> 1.156
---
Log message:
llvm-gcc 3.4 is dead.
---
Diffs of the changes: (+5 -10)
GettingStarted.html | 15 +++++----------
1 files changed, 5 insertions(+), 10 deletions(-)
Index: llvm/docs/GettingStarted.html
diff -u llvm/docs/GettingStarted.html:1.155 llvm/docs/GettingStarted.html:1.156
--- llvm/docs/GettingStarted.html:1.155 Wed Feb 14 01:34:22 2007
+++ llvm/docs/GettingStarted.html Tue Mar 6 00:27:34 2007
@@ -89,7 +89,7 @@
The second piece is the GCC front end. This component provides a version of
GCC that compiles C and C++ code into LLVM bytecode. Currently, the GCC front
-end is a modified version of GCC 3.4 (we track the GCC 3.4 development). Once
+end uses the GCC parser to convert code to LLVM. Once
compiled into LLVM bytecode, a program can be manipulated with the LLVM tools
from the LLVM suite.
@@ -712,14 +712,9 @@
configured by the LLVM configure script as well as automatically updated when
you run cvs update.
-If you would like to get the GCC 3.4 front end source code, you can also get it from the CVS repository:
-
-
- cvs -z3 -d :pserver:anon at llvm.org:/var/cvs/llvm co llvm-gcc
-
-
-Please note that you must follow these
-instructions to successfully build the LLVM GCC front-end.
+If you would like to get the GCC front end source code, you can also get it
+and build it yourself. Please follow these
+instructions to successfully get and build the LLVM GCC front-end.
@@ -1616,7 +1611,7 @@
Chris Lattner
Reid Spencer
The LLVM Compiler Infrastructure
- Last modified: $Date: 2007/02/14 07:34:22 $
+ Last modified: $Date: 2007/03/06 06:27:34 $