From lattner at cs.uiuc.edu Mon Mar 13 00:08:50 2006
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 13 Mar 2006 00:08:50 -0600
Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Message-ID: <200603130608.AAA13955@zion.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/SelectionDAG:
LegalizeDAG.cpp updated: 1.313 -> 1.314
---
Log message:
For targets with FABS/FNEG support, lower copysign to an integer load,
a select and FABS/FNEG.
This speeds up a trivial (aka stupid) copysign benchmark I wrote from 6.73s
to 2.64s, woo.
---
Diffs of the changes: (+25 -2)
LegalizeDAG.cpp | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.313 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.314
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.313 Tue Mar 7 22:39:05 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Mon Mar 13 00:08:38 2006
@@ -1795,10 +1795,33 @@
case TargetLowering::Custom:
Tmp1 = TLI.LowerOperation(Result, DAG);
if (Tmp1.Val) Result = Tmp1;
- break;
+ break;
case TargetLowering::Legal: break;
case TargetLowering::Expand:
- // Floating point mod -> fmod libcall.
+ // If this target supports fabs/fneg natively, do this efficiently.
+ if (TLI.isOperationLegal(ISD::FABS, Tmp1.getValueType()) &&
+ TLI.isOperationLegal(ISD::FNEG, Tmp1.getValueType())) {
+ // Get the sign bit of the RHS.
+ MVT::ValueType IVT =
+ Tmp2.getValueType() == MVT::f32 ? MVT::i32 : MVT::i64;
+ SDOperand SignBit = DAG.getNode(ISD::BIT_CONVERT, IVT, Tmp2);
+ SignBit = DAG.getSetCC(TLI.getSetCCResultTy(),
+ SignBit, DAG.getConstant(0, IVT), ISD::SETLT);
+ // Get the absolute value of the result.
+ SDOperand AbsVal = DAG.getNode(ISD::FABS, Tmp1.getValueType(), Tmp1);
+ // Select between the nabs and abs value based on the sign bit of
+ // the input.
+ Result = DAG.getNode(ISD::SELECT, AbsVal.getValueType(), SignBit,
+ DAG.getNode(ISD::FNEG, AbsVal.getValueType(),
+ AbsVal),
+ AbsVal);
+ Result = LegalizeOp(Result);
+ break;
+ }
+
+ // Otherwise, do bitwise ops!
+
+ // copysign -> copysignf/copysign libcall.
const char *FnName;
if (Node->getValueType(0) == MVT::f32) {
FnName = "copysignf";
From lattner at cs.uiuc.edu Mon Mar 13 00:26:38 2006
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 13 Mar 2006 00:26:38 -0600
Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Message-ID: <200603130626.AAA14039@zion.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/SelectionDAG:
DAGCombiner.cpp updated: 1.123 -> 1.124
---
Log message:
add a couple of missing folds
---
Diffs of the changes: (+12 -0)
DAGCombiner.cpp | 12 ++++++++++++
1 files changed, 12 insertions(+)
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.123 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.124
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.123 Sun Mar 5 13:53:55 2006
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Mar 13 00:26:26 2006
@@ -2102,6 +2102,18 @@
// fold (fp_round c1fp) -> c1fp
if (N0CFP)
return DAG.getNode(ISD::FP_ROUND, VT, N0);
+
+ // fold (fp_round (fp_extend x)) -> x
+ if (N0.getOpcode() == ISD::FP_EXTEND && VT == N0.getOperand(0).getValueType())
+ return N0.getOperand(0);
+
+ // fold (fp_round (copysign X, Y)) -> (copysign (fp_round X), Y)
+ if (N0.getOpcode() == ISD::FCOPYSIGN && N0.Val->hasOneUse()) {
+ SDOperand Tmp = DAG.getNode(ISD::FP_ROUND, VT, N0.getOperand(0));
+ AddToWorkList(Tmp.Val);
+ return DAG.getNode(ISD::FCOPYSIGN, VT, Tmp, N0.getOperand(1));
+ }
+
return SDOperand();
}
From lattner at cs.uiuc.edu Mon Mar 13 00:42:28 2006
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 13 Mar 2006 00:42:28 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/TargetLowering.cpp
Message-ID: <200603130642.AAA14126@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target:
TargetLowering.cpp updated: 1.44 -> 1.45
---
Log message:
I can't convince myself that this is safe, remove the recursive call.
---
Diffs of the changes: (+2 -18)
TargetLowering.cpp | 20 ++------------------
1 files changed, 2 insertions(+), 18 deletions(-)
Index: llvm/lib/Target/TargetLowering.cpp
diff -u llvm/lib/Target/TargetLowering.cpp:1.44 llvm/lib/Target/TargetLowering.cpp:1.45
--- llvm/lib/Target/TargetLowering.cpp:1.44 Sun Mar 5 13:52:57 2006
+++ llvm/lib/Target/TargetLowering.cpp Mon Mar 13 00:42:16 2006
@@ -565,23 +565,6 @@
break;
}
case ISD::ADD:
- if (ConstantSDNode *AA = dyn_cast(Op.getOperand(1))) {
- if (SimplifyDemandedBits(Op.getOperand(0), DemandedMask, KnownZero,
- KnownOne, TLO, Depth+1))
- return true;
- // Compute the KnownOne/KnownZero masks for the constant, so we can set
- // KnownZero appropriately if we're adding a constant that has all low
- // bits cleared.
- ComputeMaskedBits(Op.getOperand(1),
- MVT::getIntVTBitMask(Op.getValueType()),
- KnownZero2, KnownOne2, Depth+1);
-
- uint64_t KnownZeroOut = std::min(CountTrailingZeros_64(~KnownZero),
- CountTrailingZeros_64(~KnownZero2));
- KnownZero = (1ULL << KnownZeroOut) - 1;
- KnownOne = 0;
- }
- break;
case ISD::SUB:
// Just use ComputeMaskedBits to compute output bits, there are no
// simplifications that can be done here, and sub always demands all input
@@ -843,7 +826,8 @@
assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?");
// Output known-0 bits are known if clear or set in both the low clear bits
- // common to both LHS & RHS;
+ // common to both LHS & RHS. For example, 8+(X<<3) is known to have the
+ // low 3 bits clear.
uint64_t KnownZeroOut = std::min(CountTrailingZeros_64(~KnownZero),
CountTrailingZeros_64(~KnownZero2));
From lattner at cs.uiuc.edu Mon Mar 13 00:50:59 2006
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 13 Mar 2006 00:50:59 -0600
Subject: [llvm-commits] CVS: llvm/test/Regression/CodeGen/PowerPC/and_add.ll
Message-ID: <200603130650.AAA14284@zion.cs.uiuc.edu>
Changes in directory llvm/test/Regression/CodeGen/PowerPC:
and_add.ll added (r1.1)
---
Log message:
new testcase
---
Diffs of the changes: (+11 -0)
and_add.ll | 11 +++++++++++
1 files changed, 11 insertions(+)
Index: llvm/test/Regression/CodeGen/PowerPC/and_add.ll
diff -c /dev/null llvm/test/Regression/CodeGen/PowerPC/and_add.ll:1.1
*** /dev/null Mon Mar 13 00:50:57 2006
--- llvm/test/Regression/CodeGen/PowerPC/and_add.ll Mon Mar 13 00:50:47 2006
***************
*** 0 ****
--- 1,11 ----
+ ; RUN: llvm-as < %s | llc -march=ppc32 | grep slwi &&
+ ; RUN: llvm-as < %s | llc -march=ppc32 | not grep addi &&
+ ; RUN: llvm-as < %s | llc -march=ppc32 | not grep rlwinm
+
+ int %test(int %A) {
+ %B = mul int %A, 8 ;; shift
+ %C = add int %B, 7 ;; dead, no demanded bits.
+ %D = and int %C, -8 ;; dead once add is gone.
+ ret int %D
+ }
+
From lattner at cs.uiuc.edu Mon Mar 13 00:51:42 2006
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 13 Mar 2006 00:51:42 -0600
Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Message-ID: <200603130651.AAA14294@zion.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/SelectionDAG:
DAGCombiner.cpp updated: 1.124 -> 1.125
---
Log message:
Fold X+Y -> X|Y when safe. This implements:
Regression/CodeGen/PowerPC/and_add.ll
a case that occurs with dynamic allocas of constant size.
---
Diffs of the changes: (+19 -1)
DAGCombiner.cpp | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletion(-)
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.124 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.125
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.124 Mon Mar 13 00:26:26 2006
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Mar 13 00:51:27 2006
@@ -714,9 +714,27 @@
// fold (A+(B-A)) -> B
if (N1.getOpcode() == ISD::SUB && N0 == N1.getOperand(1))
return N1.getOperand(0);
- //
+
if (!MVT::isVector(VT) && SimplifyDemandedBits(SDOperand(N, 0)))
return SDOperand();
+
+ // fold (a+b) -> (a|b) iff a and b share no bits.
+ if (MVT::isInteger(VT) && !MVT::isVector(VT)) {
+ uint64_t LHSZero, LHSOne;
+ uint64_t RHSZero, RHSOne;
+ uint64_t Mask = MVT::getIntVTBitMask(VT);
+ TLI.ComputeMaskedBits(N0, Mask, LHSZero, LHSOne);
+ if (LHSZero) {
+ TLI.ComputeMaskedBits(N1, Mask, RHSZero, RHSOne);
+
+ // If all possibly-set bits on the LHS are clear on the RHS, return an OR.
+ // If all possibly-set bits on the RHS are clear on the LHS, return an OR.
+ if ((RHSZero & (~LHSZero & Mask)) == (~LHSZero & Mask) ||
+ (LHSZero & (~RHSZero & Mask)) == (~RHSZero & Mask))
+ return DAG.getNode(ISD::OR, VT, N0, N1);
+ }
+ }
+
return SDOperand();
}
From lattner at cs.uiuc.edu Mon Mar 13 00:52:34 2006
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 13 Mar 2006 00:52:34 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/README.txt
Message-ID: <200603130652.AAA14354@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target:
README.txt updated: 1.17 -> 1.18
---
Log message:
remove two implemented items
---
Diffs of the changes: (+0 -22)
README.txt | 22 ----------------------
1 files changed, 22 deletions(-)
Index: llvm/lib/Target/README.txt
diff -u llvm/lib/Target/README.txt:1.17 llvm/lib/Target/README.txt:1.18
--- llvm/lib/Target/README.txt:1.17 Sat Mar 11 14:20:40 2006
+++ llvm/lib/Target/README.txt Mon Mar 13 00:52:22 2006
@@ -56,20 +56,6 @@
//===---------------------------------------------------------------------===//
-DAG combine this into mul A, 8:
-
-int %test(int %A) {
- %B = mul int %A, 8 ;; shift
- %C = add int %B, 7 ;; dead, no demanded bits.
- %D = and int %C, -8 ;; dead once add is gone.
- ret int %D
-}
-
-This sort of thing occurs in the alloca lowering code and other places that
-are generating alignment of an already aligned value.
-
-//===---------------------------------------------------------------------===//
-
Turn this into a signed shift right in instcombine:
int f(unsigned x) {
@@ -81,14 +67,6 @@
//===---------------------------------------------------------------------===//
-We should reassociate:
-int f(int a, int b){ return a * a + 2 * a * b + b * b; }
-into:
-int f(int a, int b) { return a * (a + 2 * b) + b * b; }
-to eliminate a multiply.
-
-//===---------------------------------------------------------------------===//
-
On targets with expensive 64-bit multiply, we could LSR this:
for (i = ...; ++i) {
From jlaskey at apple.com Mon Mar 13 07:07:56 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 13 Mar 2006 07:07:56 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp
Message-ID: <200603131307.HAA15666@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/CBackend:
Writer.cpp updated: 1.255 -> 1.256
---
Log message:
Handle the removal of the debug chain.
---
Diffs of the changes: (+2 -2)
Writer.cpp | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.255 llvm/lib/Target/CBackend/Writer.cpp:1.256
--- llvm/lib/Target/CBackend/Writer.cpp:1.255 Wed Mar 8 13:31:15 2006
+++ llvm/lib/Target/CBackend/Writer.cpp Mon Mar 13 07:07:37 2006
@@ -1691,8 +1691,8 @@
case Intrinsic::dbg_stoppoint: {
// If we use writeOperand directly we get a "u" suffix which is rejected
// by gcc.
- ConstantUInt *SI = cast(I.getOperand(2));
- GlobalVariable *GV = cast(I.getOperand(4));
+ ConstantUInt *SI = cast(I.getOperand(1));
+ GlobalVariable *GV = cast(I.getOperand(3));
ConstantStruct *CS = cast(GV->getInitializer());
std::string FileName = CS->getOperand(4)->getStringValue();
std::string Directory = CS->getOperand(5)->getStringValue();
From jlaskey at apple.com Mon Mar 13 07:07:56 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 13 Mar 2006 07:07:56 -0600
Subject: [llvm-commits] CVS: llvm/lib/CodeGen/IntrinsicLowering.cpp
Message-ID: <200603131307.HAA15664@zion.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen:
IntrinsicLowering.cpp updated: 1.41 -> 1.42
---
Log message:
Handle the removal of the debug chain.
---
Diffs of the changes: (+0 -2)
IntrinsicLowering.cpp | 2 --
1 files changed, 2 deletions(-)
Index: llvm/lib/CodeGen/IntrinsicLowering.cpp
diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.41 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.42
--- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.41 Thu Mar 9 14:02:42 2006
+++ llvm/lib/CodeGen/IntrinsicLowering.cpp Mon Mar 13 07:07:37 2006
@@ -403,8 +403,6 @@
case Intrinsic::dbg_region_start:
case Intrinsic::dbg_region_end:
case Intrinsic::dbg_func_start:
- if (CI->getType() != Type::VoidTy)
- CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
break; // Simply strip out debugging intrinsics
case Intrinsic::memcpy_i32:
From jlaskey at apple.com Mon Mar 13 07:07:56 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 13 Mar 2006 07:07:56 -0600
Subject: [llvm-commits]
CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Message-ID: <200603131307.HAA15674@zion.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAGISel.cpp updated: 1.187 -> 1.188
---
Log message:
Handle the removal of the debug chain.
---
Diffs of the changes: (+4 -4)
SelectionDAGISel.cpp | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.187 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.188
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.187 Fri Mar 10 17:52:03 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Mar 13 07:07:37 2006
@@ -966,19 +966,19 @@
case Intrinsic::dbg_stoppoint: {
MachineDebugInfo *DebugInfo = DAG.getMachineDebugInfo();
- if (DebugInfo && DebugInfo->Verify(I.getOperand(4))) {
+ if (DebugInfo && DebugInfo->Verify(I.getOperand(3))) {
std::vector Ops;
// Input Chain
Ops.push_back(getRoot());
// line number
- Ops.push_back(getValue(I.getOperand(2)));
+ Ops.push_back(getValue(I.getOperand(1)));
// column
- Ops.push_back(getValue(I.getOperand(3)));
+ Ops.push_back(getValue(I.getOperand(2)));
- DebugInfoDesc *DD = DebugInfo->getDescFor(I.getOperand(4));
+ DebugInfoDesc *DD = DebugInfo->getDescFor(I.getOperand(3));
assert(DD && "Not a debug information descriptor");
CompileUnitDesc *CompileUnit = dyn_cast(DD);
assert(CompileUnit && "Not a compile unit");
From jlaskey at apple.com Mon Mar 13 07:07:56 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 13 Mar 2006 07:07:56 -0600
Subject: [llvm-commits] CVS: llvm/lib/VMCore/AutoUpgrade.cpp
Message-ID: <200603131307.HAA15682@zion.cs.uiuc.edu>
Changes in directory llvm/lib/VMCore:
AutoUpgrade.cpp updated: 1.11 -> 1.12
---
Log message:
Handle the removal of the debug chain.
---
Diffs of the changes: (+99 -47)
AutoUpgrade.cpp | 146 +++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 99 insertions(+), 47 deletions(-)
Index: llvm/lib/VMCore/AutoUpgrade.cpp
diff -u llvm/lib/VMCore/AutoUpgrade.cpp:1.11 llvm/lib/VMCore/AutoUpgrade.cpp:1.12
--- llvm/lib/VMCore/AutoUpgrade.cpp:1.11 Thu Mar 9 12:42:10 2006
+++ llvm/lib/VMCore/AutoUpgrade.cpp Mon Mar 13 07:07:37 2006
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Assembly/AutoUpgrade.h"
+#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/Module.h"
@@ -73,6 +74,31 @@
if (Name == "llvm.ctpop" || Name == "llvm.ctlz" || Name == "llvm.cttz")
return getUpgradedUnaryFn(F);
break;
+ case 'd':
+ if (Name == "llvm.dbg.stoppoint") {
+ if (F->getReturnType() != Type::VoidTy) {
+ return M->getOrInsertFunction(Name, Type::VoidTy,
+ Type::UIntTy,
+ Type::UIntTy,
+ F->getFunctionType()->getParamType(3),
+ NULL);
+ }
+ } else if (Name == "llvm.dbg.func.start") {
+ if (F->getReturnType() != Type::VoidTy) {
+ return M->getOrInsertFunction(Name, Type::VoidTy,
+ F->getFunctionType()->getParamType(0),
+ NULL);
+ }
+ } else if (Name == "llvm.dbg.region.start") {
+ if (F->getReturnType() != Type::VoidTy) {
+ return M->getOrInsertFunction(Name, Type::VoidTy, NULL);
+ }
+ } else if (Name == "llvm.dbg.region.end") {
+ if (F->getReturnType() != Type::VoidTy) {
+ return M->getOrInsertFunction(Name, Type::VoidTy, NULL);
+ }
+ }
+ break;
case 'i':
if (Name == "llvm.isunordered" && F->arg_begin() != F->arg_end()) {
if (F->arg_begin()->getType() == Type::FloatTy)
@@ -106,6 +132,29 @@
return 0;
}
+// Occasionally upgraded function call site arguments need to be permutated to
+// some new order. The result of getArgumentPermutation is an array of size
+// F->getFunctionType()getNumParams() indicating the new operand order. A value
+// of zero in the array indicates replacing with UndefValue for the arg type.
+// NULL is returned if there is no permutation. It's assumed that the function
+// name is in the form "llvm.?????"
+static unsigned *getArgumentPermutation(Function* F) {
+ // Get the Function's name.
+ const std::string& Name = F->getName();
+ switch (Name[5]) {
+ case 'd':
+ if (Name == "llvm.dbg.stoppoint") {
+ static unsigned Permutation[] = { 2, 3, 4 };
+ assert(F->getFunctionType()->getNumParams() ==
+ (sizeof(Permutation) / sizeof(unsigned)) &&
+ "Permutation is wrong length");
+ return Permutation;
+ }
+ break;
+ }
+ return NULL;
+}
+
// UpgradeIntrinsicFunction - Convert overloaded intrinsic function names to
// their non-overloaded variants by appending the appropriate suffix based on
// the argument types.
@@ -157,72 +206,75 @@
return result;
}
-// UpgradeIntrinsicCall - In the BC reader, change a call to some intrinsic to
-// be a called to the specified intrinsic. We expect the callees to have the
-// same number of arguments, but their types may be different.
+// UpgradeIntrinsicCall - In the BC reader, change a call to an intrinsic to be
+// a call to an upgraded intrinsic. We may have to permute the order or promote
+// some arguments with a cast.
void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
Function *F = CI->getCalledFunction();
const FunctionType *NewFnTy = NewFn->getFunctionType();
std::vector Oprnds;
- for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i) {
- Value *V = CI->getOperand(i);
- if (V->getType() != NewFnTy->getParamType(i-1))
- V = new CastInst(V, NewFnTy->getParamType(i-1), V->getName(), CI);
- Oprnds.push_back(V);
+
+ unsigned *Permutation = getArgumentPermutation(NewFn);
+ unsigned N = NewFnTy->getNumParams();
+
+ if (Permutation) {
+ for (unsigned i = 0; i != N; ++i) {
+ unsigned p = Permutation[i];
+
+ if (p) {
+ Value *V = CI->getOperand(p);
+ if (V->getType() != NewFnTy->getParamType(i))
+ V = new CastInst(V, NewFnTy->getParamType(i), V->getName(), CI);
+ Oprnds.push_back(V);
+ } else
+ Oprnds.push_back(UndefValue::get(NewFnTy->getParamType(i)));
+ }
+ } else {
+ assert(N == (CI->getNumOperands() - 1) &&
+ "Upgraded function needs permutation");
+ for (unsigned i = 0; i != N; ++i) {
+ Value *V = CI->getOperand(i + 1);
+ if (V->getType() != NewFnTy->getParamType(i))
+ V = new CastInst(V, NewFnTy->getParamType(i), V->getName(), CI);
+ Oprnds.push_back(V);
+ }
}
- CallInst *NewCI = new CallInst(NewFn, Oprnds, CI->getName(), CI);
+
+ bool NewIsVoid = NewFn->getReturnType() == Type::VoidTy;
+
+ CallInst *NewCI = new CallInst(NewFn, Oprnds,
+ NewIsVoid ? "" : CI->getName(),
+ CI);
NewCI->setTailCall(CI->isTailCall());
NewCI->setCallingConv(CI->getCallingConv());
if (!CI->use_empty()) {
- Instruction *RetVal = NewCI;
- if (F->getReturnType() != NewFn->getReturnType()) {
- RetVal = new CastInst(NewCI, NewFn->getReturnType(),
- NewCI->getName(), CI);
- NewCI->moveBefore(RetVal);
+ if (NewIsVoid) {
+ CI->replaceAllUsesWith(UndefValue::get(CI->getType()));
+ } else {
+ Instruction *RetVal = NewCI;
+
+ if (F->getReturnType() != NewFn->getReturnType()) {
+ RetVal = new CastInst(NewCI, NewFn->getReturnType(),
+ NewCI->getName(), CI);
+ NewCI->moveBefore(RetVal);
+ }
+
+ CI->replaceAllUsesWith(RetVal);
}
- CI->replaceAllUsesWith(RetVal);
}
CI->eraseFromParent();
}
bool llvm::UpgradeCallsToIntrinsic(Function* F) {
- if (Function* newF = UpgradeIntrinsicFunction(F)) {
+ if (Function* NewFn = UpgradeIntrinsicFunction(F)) {
for (Value::use_iterator UI = F->use_begin(), UE = F->use_end();
UI != UE; ) {
- if (CallInst* CI = dyn_cast(*UI++)) {
- std::vector Oprnds;
- User::op_iterator OI = CI->op_begin();
- ++OI;
- for (User::op_iterator OE = CI->op_end(); OI != OE; ++OI) {
- const Type* opTy = OI->get()->getType();
- if (opTy->isSigned()) {
- Oprnds.push_back(
- new CastInst(OI->get(),opTy->getUnsignedVersion(),
- "autoupgrade_cast",CI));
- } else {
- Oprnds.push_back(*OI);
- }
- }
- CallInst* newCI = new CallInst(newF, Oprnds,
- CI->hasName() ? "autoupcall" : "", CI);
- newCI->setTailCall(CI->isTailCall());
- newCI->setCallingConv(CI->getCallingConv());
- if (CI->use_empty()) {
- // noop
- } else if (CI->getType() != newCI->getType()) {
- CastInst *final = new CastInst(newCI, CI->getType(),
- "autoupgrade_uncast", newCI);
- newCI->moveBefore(final);
- CI->replaceAllUsesWith(final);
- } else {
- CI->replaceAllUsesWith(newCI);
- }
- CI->eraseFromParent();
- }
+ if (CallInst* CI = dyn_cast(*UI++))
+ UpgradeIntrinsicCall(CI, NewFn);
}
- if (newF != F)
+ if (NewFn != F)
F->eraseFromParent();
return true;
}
From jlaskey at apple.com Mon Mar 13 07:07:56 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 13 Mar 2006 07:07:56 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/Intrinsics.td
Message-ID: <200603131307.HAA15676@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm:
Intrinsics.td updated: 1.5 -> 1.6
---
Log message:
Handle the removal of the debug chain.
---
Diffs of the changes: (+4 -4)
Intrinsics.td | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
Index: llvm/include/llvm/Intrinsics.td
diff -u llvm/include/llvm/Intrinsics.td:1.5 llvm/include/llvm/Intrinsics.td:1.6
--- llvm/include/llvm/Intrinsics.td:1.5 Sat Mar 11 18:04:28 2006
+++ llvm/include/llvm/Intrinsics.td Mon Mar 13 07:07:37 2006
@@ -181,11 +181,11 @@
//===------------------------ Debugger Intrinsics -------------------------===//
//
-def int_dbg_stoppoint : Intrinsic<[llvm_anchor_ty, llvm_anchor_ty,
+def int_dbg_stoppoint : Intrinsic<[llvm_void_ty,
llvm_uint_ty, llvm_uint_ty,
llvm_descriptor_ty]>;
-def int_dbg_region_start : Intrinsic<[llvm_anchor_ty, llvm_anchor_ty]>;
-def int_dbg_region_end : Intrinsic<[llvm_anchor_ty, llvm_anchor_ty]>;
-def int_dbg_func_start : Intrinsic<[llvm_anchor_ty, llvm_descriptor_ty]>;
+def int_dbg_region_start : Intrinsic<[llvm_void_ty]>;
+def int_dbg_region_end : Intrinsic<[llvm_void_ty]>;
+def int_dbg_func_start : Intrinsic<[llvm_void_ty, llvm_descriptor_ty]>;
// dbg_declare, // Declare a local object
From jlaskey at apple.com Mon Mar 13 07:07:56 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 13 Mar 2006 07:07:56 -0600
Subject: [llvm-commits] CVS: llvm/lib/Debugger/ProgramInfo.cpp
Message-ID: <200603131307.HAA15672@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Debugger:
ProgramInfo.cpp updated: 1.13 -> 1.14
---
Log message:
Handle the removal of the debug chain.
---
Diffs of the changes: (+3 -3)
ProgramInfo.cpp | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
Index: llvm/lib/Debugger/ProgramInfo.cpp
diff -u llvm/lib/Debugger/ProgramInfo.cpp:1.13 llvm/lib/Debugger/ProgramInfo.cpp:1.14
--- llvm/lib/Debugger/ProgramInfo.cpp:1.13 Wed Mar 8 12:11:07 2006
+++ llvm/lib/Debugger/ProgramInfo.cpp Mon Mar 13 07:07:37 2006
@@ -63,11 +63,11 @@
if (F->getIntrinsicID() == Intrinsic::dbg_stoppoint) {
unsigned CurLineNo = ~0, CurColNo = ~0;
const GlobalVariable *CurDesc = 0;
- if (const ConstantInt *C = dyn_cast(CI->getOperand(2)))
+ if (const ConstantInt *C = dyn_cast(CI->getOperand(1)))
CurLineNo = C->getRawValue();
- if (const ConstantInt *C = dyn_cast(CI->getOperand(3)))
+ if (const ConstantInt *C = dyn_cast(CI->getOperand(2)))
CurColNo = C->getRawValue();
- const Value *Op = CI->getOperand(4);
+ const Value *Op = CI->getOperand(3);
if ((CurDesc = dyn_cast(Op)) &&
(LineNo < LastLineNo ||
From jlaskey at apple.com Mon Mar 13 07:07:56 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 13 Mar 2006 07:07:56 -0600
Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/StripSymbols.cpp
Message-ID: <200603131307.HAA15688@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Transforms/IPO:
StripSymbols.cpp updated: 1.5 -> 1.6
---
Log message:
Handle the removal of the debug chain.
---
Diffs of the changes: (+1 -1)
StripSymbols.cpp | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
Index: llvm/lib/Transforms/IPO/StripSymbols.cpp
diff -u llvm/lib/Transforms/IPO/StripSymbols.cpp:1.5 llvm/lib/Transforms/IPO/StripSymbols.cpp:1.6
--- llvm/lib/Transforms/IPO/StripSymbols.cpp:1.5 Thu Mar 9 00:09:41 2006
+++ llvm/lib/Transforms/IPO/StripSymbols.cpp Mon Mar 13 07:07:37 2006
@@ -116,7 +116,7 @@
Value *RV = UndefValue::get(StopPoint->getFunctionType()->getReturnType());
while (!StopPoint->use_empty()) {
CallInst *CI = cast(StopPoint->use_back());
- Value *Arg = CI->getOperand(4);
+ Value *Arg = CI->getOperand(3);
CI->replaceAllUsesWith(RV);
CI->eraseFromParent();
if (Arg->use_empty())
From jlaskey at apple.com Mon Mar 13 07:07:56 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 13 Mar 2006 07:07:56 -0600
Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp
Message-ID: <200603131307.HAA15680@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Bytecode/Reader:
Reader.cpp updated: 1.189 -> 1.190
---
Log message:
Handle the removal of the debug chain.
---
Diffs of the changes: (+2 -2)
Reader.cpp | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.189 llvm/lib/Bytecode/Reader/Reader.cpp:1.190
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.189 Thu Mar 2 17:59:12 2006
+++ llvm/lib/Bytecode/Reader/Reader.cpp Mon Mar 13 07:07:37 2006
@@ -1861,8 +1861,8 @@
if (!upgradedFunctions.empty()) {
for (Function::iterator BI = F->begin(), BE = F->end(); BI != BE; ++BI)
for (BasicBlock::iterator II = BI->begin(), IE = BI->end();
- II != IE; ++II)
- if (CallInst* CI = dyn_cast(II)) {
+ II != IE;)
+ if (CallInst* CI = dyn_cast(II++)) {
std::map::iterator FI =
upgradedFunctions.find(CI->getCalledFunction());
if (FI != upgradedFunctions.end())
From reid at x10sys.com Mon Mar 13 11:57:42 2006
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 13 Mar 2006 11:57:42 -0600
Subject: [llvm-commits] CVS: llvm/lib/VMCore/Makefile
Message-ID: <200603131757.LAA29683@zion.cs.uiuc.edu>
Changes in directory llvm/lib/VMCore:
Makefile updated: 1.10 -> 1.11
---
Log message:
Bring makefile back into compliance with standard by using
$(Echo) instead of @echo
---
Diffs of the changes: (+1 -1)
Makefile | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
Index: llvm/lib/VMCore/Makefile
diff -u llvm/lib/VMCore/Makefile:1.10 llvm/lib/VMCore/Makefile:1.11
--- llvm/lib/VMCore/Makefile:1.10 Thu Mar 9 14:29:41 2006
+++ llvm/lib/VMCore/Makefile Mon Mar 13 11:57:31 2006
@@ -19,6 +19,6 @@
include $(LEVEL)/Makefile.common
$(LEVEL)/include/llvm/Intrinsics.gen: $(LEVEL)/include/llvm/Intrinsics.td $(TBLGEN)
- @echo Building Intrinsics.gen from Intrinsics.td
+ $(Echo) Building Intrinsics.gen from Intrinsics.td
$(Verb) $(TableGen) $< -o $@ -gen-intrinsic
From lattner at cs.uiuc.edu Mon Mar 13 12:37:42 2006
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 13 Mar 2006 12:37:42 -0600
Subject: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Message-ID: <200603131837.MAA30034@zion.cs.uiuc.edu>
Changes in directory llvm/lib/CodeGen/SelectionDAG:
DAGCombiner.cpp updated: 1.125 -> 1.126
---
Log message:
make sure dead token factor nodes are removed by the dag combiner.
---
Diffs of the changes: (+1 -0)
DAGCombiner.cpp | 1 +
1 files changed, 1 insertion(+)
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.125 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.126
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.125 Mon Mar 13 00:51:27 2006
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Mar 13 12:37:30 2006
@@ -665,6 +665,7 @@
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
SDOperand Op = N->getOperand(i);
if (Op.getOpcode() == ISD::TokenFactor && Op.hasOneUse()) {
+ AddToWorkList(Op.Val); // Remove dead node.
Changed = true;
for (unsigned j = 0, e = Op.getNumOperands(); j != e; ++j)
Ops.push_back(Op.getOperand(j));
From llvm at cs.uiuc.edu Mon Mar 13 15:22:55 2006
From: llvm at cs.uiuc.edu (LLVM)
Date: Mon, 13 Mar 2006 15:22:55 -0600
Subject: [llvm-commits] CVS: llvm/runtime/GCCLibraries/libc/memory.c
Message-ID: <200603132122.PAA31070@zion.cs.uiuc.edu>
Changes in directory llvm/runtime/GCCLibraries/libc:
memory.c (r1.5) removed
---
Log message:
Optimizing to calloc() to malloc() + memset() can be bad on some platforms.
---
Diffs of the changes: (+0 -0)
0 files changed
From lattner at cs.uiuc.edu Mon Mar 13 15:52:22 2006
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 13 Mar 2006 15:52:22 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
PPCInstrInfo.td PPCRegisterInfo.cpp PPCRegisterInfo.td
Message-ID: <200603132152.PAA31255@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/PowerPC:
PPCISelDAGToDAG.cpp updated: 1.164 -> 1.165
PPCInstrInfo.td updated: 1.181 -> 1.182
PPCRegisterInfo.cpp updated: 1.43 -> 1.44
PPCRegisterInfo.td updated: 1.29 -> 1.30
---
Log message:
For functions that use vector registers, save VRSAVE, mark used
registers, and update it on entry to each function, then restore it on exit.
This compiles:
void func(vfloat *a, vfloat *b, vfloat *c) {
*a = *b * *c + *c;
}
to this:
_func:
mfspr r2, 256
oris r6, r2, 49152
mtspr 256: http://llvm.cs.uiuc.edu/PR256 , r6
lvx v0, 0, r5
lvx v1, 0, r4
vmaddfp v0, v1, v0, v0
stvx v0, 0, r3
mtspr 256: http://llvm.cs.uiuc.edu/PR256 , r2
blr
GCC produces this (which has additional stack accesses):
_func:
mfspr r0,256
stw r0,-4(r1)
oris r0,r0,0xc000
mtspr 256: http://llvm.cs.uiuc.edu/PR256 ,r0
lvx v0,0,r5
lvx v1,0,r4
lwz r12,-4(r1)
vmaddfp v0,v0,v1,v0
stvx v0,0,r3
mtspr 256: http://llvm.cs.uiuc.edu/PR256 ,r12
blr
---
Diffs of the changes: (+130 -10)
PPCISelDAGToDAG.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++-
PPCInstrInfo.td | 26 ++++++++++++++++------
PPCRegisterInfo.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++
PPCRegisterInfo.td | 4 +--
4 files changed, 130 insertions(+), 10 deletions(-)
Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
diff -u llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.164 llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.165
--- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.164 Sun Mar 12 03:13:49 2006
+++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Mon Mar 13 15:52:10 2006
@@ -196,8 +196,65 @@
CodeGenMap.clear();
DAG.RemoveDeadNodes();
- // Emit machine code to BB.
+ // Emit machine code to BB.
ScheduleAndEmitDAG(DAG);
+
+ // Check to see if this function uses vector registers, which means we have to
+ // save and restore the VRSAVE register and update it with the regs we use.
+ //
+ // In this case, there will be virtual registers of vector type type created
+ // by the scheduler. Detect them now.
+ SSARegMap *RegMap = DAG.getMachineFunction().getSSARegMap();
+ bool HasVectorVReg = false;
+ for (unsigned i = MRegisterInfo::FirstVirtualRegister,
+ e = RegMap->getLastVirtReg(); i != e; ++i)
+ if (RegMap->getRegClass(i) == &PPC::VRRCRegClass) {
+ HasVectorVReg = true;
+ break;
+ }
+
+ // If we have a vector register, we want to emit code into the entry and exit
+ // blocks to save and restore the VRSAVE register. We do this here (instead
+ // of marking all vector instructions as clobbering VRSAVE) for two reasons:
+ //
+ // 1. This (trivially) reduces the load on the register allocator, by not
+ // having to represent the live range of the VRSAVE register.
+ // 2. This (more significantly) allows us to create a temporary virtual
+ // register to hold the saved VRSAVE value, allowing this temporary to be
+ // register allocated, instead of forcing it to be spilled to the stack.
+ if (HasVectorVReg) {
+ // Create two vregs - one to hold the VRSAVE register that is live-in to the
+ // function and one for the value after having bits or'd into it.
+ unsigned InVRSAVE = RegMap->createVirtualRegister(&PPC::GPRCRegClass);
+ unsigned UpdatedVRSAVE = RegMap->createVirtualRegister(&PPC::GPRCRegClass);
+
+ MachineFunction &MF = DAG.getMachineFunction();
+ MachineBasicBlock &EntryBB = *MF.begin();
+ // Emit the following code into the entry block:
+ // InVRSAVE = MFVRSAVE
+ // UpdatedVRSAVE = UPDATE_VRSAVE InVRSAVE
+ // MTVRSAVE UpdatedVRSAVE
+ MachineBasicBlock::iterator IP = EntryBB.begin(); // Insert Point
+ BuildMI(EntryBB, IP, PPC::MFVRSAVE, 0, InVRSAVE);
+ BuildMI(EntryBB, IP, PPC::UPDATE_VRSAVE, 1, UpdatedVRSAVE).addReg(InVRSAVE);
+ BuildMI(EntryBB, IP, PPC::MTVRSAVE, 1).addReg(UpdatedVRSAVE);
+
+ // Find all return blocks, outputting a restore in each epilog.
+ const TargetInstrInfo &TII = *DAG.getTarget().getInstrInfo();
+ for (MachineFunction::iterator BB = MF.begin(), E = MF.end(); BB != E; ++BB)
+ if (!BB->empty() && TII.isReturn(BB->back().getOpcode())) {
+ IP = BB->end(); --IP;
+
+ // Skip over all terminator instructions, which are part of the return
+ // sequence.
+ MachineBasicBlock::iterator I2 = IP;
+ while (I2 != BB->begin() && TII.isTerminatorInstr((--I2)->getOpcode()))
+ IP = I2;
+
+ // Emit: MTVRSAVE InVRSave
+ BuildMI(*BB, IP, PPC::MTVRSAVE, 1).addReg(InVRSAVE);
+ }
+ }
}
/// getGlobalBaseReg - Output the instructions required to put the
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.td
diff -u llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.181 llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.182
--- llvm/lib/Target/PowerPC/PPCInstrInfo.td:1.181 Sun Mar 12 23:15:10 2006
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.td Mon Mar 13 15:52:10 2006
@@ -210,6 +210,9 @@
def ADJCALLSTACKUP : Pseudo<(ops u16imm:$amt),
"; ADJCALLSTACKUP",
[(callseq_end imm:$amt)]>;
+
+def UPDATE_VRSAVE : Pseudo<(ops GPRC:$rD, GPRC:$rS),
+ "UPDATE_VRSAVE $rD, $rS", []>;
}
def IMPLICIT_DEF_GPR : Pseudo<(ops GPRC:$rD), "; $rD = IMPLICIT_DEF_GPRC",
[(set GPRC:$rD, (undef))]>;
@@ -694,8 +697,24 @@
//
def MFCTR : XFXForm_1_ext<31, 339, 9, (ops GPRC:$rT), "mfctr $rT", SprMFSPR>,
PPC970_DGroup_First, PPC970_Unit_FXU;
+def MTCTR : XFXForm_7_ext<31, 467, 9, (ops GPRC:$rS), "mtctr $rS", SprMTSPR>,
+ PPC970_DGroup_First, PPC970_Unit_FXU;
+
+def MTLR : XFXForm_7_ext<31, 467, 8, (ops GPRC:$rS), "mtlr $rS", SprMTSPR>,
+ PPC970_DGroup_First, PPC970_Unit_FXU;
def MFLR : XFXForm_1_ext<31, 339, 8, (ops GPRC:$rT), "mflr $rT", SprMFSPR>,
PPC970_DGroup_First, PPC970_Unit_FXU;
+
+// Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed like
+// a GPR on the PPC970. As such, copies in and out have the same performance
+// characteristics as an OR instruction.
+def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (ops GPRC:$rS),
+ "mtspr 256, $rS", IntGeneral>,
+ PPC970_Unit_FXU;
+def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (ops GPRC:$rT),
+ "mfspr $rT, 256", IntGeneral>,
+ PPC970_Unit_FXU;
+
def MFCR : XFXForm_3<31, 19, (ops GPRC:$rT), "mfcr $rT", SprMFCR>,
PPC970_MicroCode, PPC970_Unit_CRU;
def MTCRF : XFXForm_5<31, 144, (ops crbitm:$FXM, GPRC:$rS),
@@ -704,13 +723,6 @@
def MFOCRF: XFXForm_5a<31, 19, (ops GPRC:$rT, crbitm:$FXM),
"mfcr $rT, $FXM", SprMFCR>,
PPC970_DGroup_First, PPC970_Unit_CRU;
-def MTCTR : XFXForm_7_ext<31, 467, 9, (ops GPRC:$rS), "mtctr $rS", SprMTSPR>,
- PPC970_DGroup_First, PPC970_Unit_FXU;
-def MTLR : XFXForm_7_ext<31, 467, 8, (ops GPRC:$rS), "mtlr $rS", SprMTSPR>,
- PPC970_DGroup_First, PPC970_Unit_FXU;
-def MTSPR : XFXForm_7<31, 467, (ops GPRC:$rS, u16imm:$UIMM), "mtspr $UIMM, $rS",
- SprMTSPR>,
- PPC970_DGroup_Single, PPC970_Unit_FXU;
// XS-Form instructions. Just 'sradi'
//
Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp
diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.43 llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.44
--- llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp:1.43 Thu Feb 2 14:12:32 2006
+++ llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp Mon Mar 13 15:52:10 2006
@@ -266,12 +266,63 @@
}
}
+// HandleVRSaveUpdate - MI is the UPDATE_VRSAVE instruction introduced by the
+// instruction selector. Based on the vector registers that have been used,
+// transform this into the appropriate ORI instruction.
+static void HandleVRSaveUpdate(MachineInstr *MI, const bool *UsedRegs) {
+ unsigned UsedRegMask = 0;
+#define HANDLEREG(N) if (UsedRegs[PPC::V##N]) UsedRegMask |= 1 << (31-N)
+ HANDLEREG( 0); HANDLEREG( 1); HANDLEREG( 2); HANDLEREG( 3);
+ HANDLEREG( 4); HANDLEREG( 5); HANDLEREG( 6); HANDLEREG( 7);
+ HANDLEREG( 8); HANDLEREG( 9); HANDLEREG(10); HANDLEREG(11);
+ HANDLEREG(12); HANDLEREG(13); HANDLEREG(14); HANDLEREG(15);
+ HANDLEREG(16); HANDLEREG(17); HANDLEREG(18); HANDLEREG(19);
+ HANDLEREG(20); HANDLEREG(21); HANDLEREG(22); HANDLEREG(23);
+ HANDLEREG(24); HANDLEREG(25); HANDLEREG(26); HANDLEREG(27);
+ HANDLEREG(28); HANDLEREG(29); HANDLEREG(30); HANDLEREG(31);
+#undef HANDLEREG
+ unsigned SrcReg = MI->getOperand(1).getReg();
+ unsigned DstReg = MI->getOperand(0).getReg();
+ // If no registers are used, turn this into a copy.
+ if (UsedRegMask == 0) {
+ if (SrcReg != DstReg)
+ BuildMI(*MI->getParent(), MI, PPC::OR4, 2, DstReg)
+ .addReg(SrcReg).addReg(SrcReg);
+ } else if ((UsedRegMask & 0xFFFF) == UsedRegMask) {
+ BuildMI(*MI->getParent(), MI, PPC::ORI, 2, DstReg)
+ .addReg(SrcReg).addImm(UsedRegMask);
+ } else if ((UsedRegMask & 0xFFFF0000) == UsedRegMask) {
+ BuildMI(*MI->getParent(), MI, PPC::ORIS, 2, DstReg)
+ .addReg(SrcReg).addImm(UsedRegMask >> 16);
+ } else {
+ BuildMI(*MI->getParent(), MI, PPC::ORIS, 2, DstReg)
+ .addReg(SrcReg).addImm(UsedRegMask >> 16);
+ BuildMI(*MI->getParent(), MI, PPC::ORI, 2, DstReg)
+ .addReg(DstReg).addImm(UsedRegMask & 0xFFFF);
+ }
+
+ // Remove the old UPDATE_VRSAVE instruction.
+ MI->getParent()->erase(MI);
+}
+
void PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB
MachineBasicBlock::iterator MBBI = MBB.begin();
MachineFrameInfo *MFI = MF.getFrameInfo();
+ // Scan the first few instructions of the prolog, looking for an UPDATE_VRSAVE
+ // instruction. If we find it, process it.
+ for (unsigned i = 0; MBBI != MBB.end() && i < 5; ++i, ++MBBI) {
+ if (MBBI->getOpcode() == PPC::UPDATE_VRSAVE) {
+ HandleVRSaveUpdate(MBBI, MF.getUsedPhysregs());
+ break;
+ }
+ }
+
+ // Move MBBI back to the beginning of the function.
+ MBBI = MBB.begin();
+
// Get the number of bytes to allocate from the FrameInfo
unsigned NumBytes = MFI->getStackSize();
Index: llvm/lib/Target/PowerPC/PPCRegisterInfo.td
diff -u llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.29 llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.30
--- llvm/lib/Target/PowerPC/PPCRegisterInfo.td:1.29 Wed Dec 21 20:26:21 2005
+++ llvm/lib/Target/PowerPC/PPCRegisterInfo.td Mon Mar 13 15:52:10 2006
@@ -152,9 +152,9 @@
GPRCClass::iterator
GPRCClass::allocation_order_end(MachineFunction &MF) const {
if (hasFP(MF))
- return end()-4;
+ return end()-4; // don't allocate R31, R0, R1, LR
else
- return end()-3;
+ return end()-3; // don't allocate R0, R1, LR
}
}];
}
From lattner at cs.uiuc.edu Mon Mar 13 16:38:44 2006
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 13 Mar 2006 16:38:44 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/Intrinsics.td
Message-ID: <200603132238.QAA31579@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm:
Intrinsics.td updated: 1.6 -> 1.7
---
Log message:
Add a first ppc altivec intrinsic. Add packed type support.
---
Diffs of the changes: (+30 -0)
Intrinsics.td | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+)
Index: llvm/include/llvm/Intrinsics.td
diff -u llvm/include/llvm/Intrinsics.td:1.6 llvm/include/llvm/Intrinsics.td:1.7
--- llvm/include/llvm/Intrinsics.td:1.6 Mon Mar 13 07:07:37 2006
+++ llvm/include/llvm/Intrinsics.td Mon Mar 13 16:38:32 2006
@@ -54,6 +54,11 @@
string TypeVal = typeval;
}
+class LLVMPackedType : LLVMType<"Type::PackedTyID">{
+ int NumElts = numelts;
+ LLVMType ElTy = elty;
+}
+
def llvm_void_ty : LLVMType<"Type::VoidTyID">;
def llvm_bool_ty : LLVMType<"Type::BoolTyID">;
def llvm_sbyte_ty : LLVMType<"Type::SByteTyID">;
@@ -71,6 +76,10 @@
def llvm_anchor_ty : LLVMType<"Type::PointerTyID">; // {}*
def llvm_descriptor_ty : LLVMType<"Type::PointerTyID">; // global*
+def llvm_v4i32_ty : LLVMPackedType<4, llvm_int_ty>; // 4 x int
+def llvm_v4f32_ty : LLVMPackedType<4, llvm_float_ty>; // 4 x float
+def llvm_v2f64_ty : LLVMPackedType<4, llvm_float_ty>; // 2 x double
+
//===----------------------------------------------------------------------===//
// Intrinsic Definitions.
//===----------------------------------------------------------------------===//
@@ -88,10 +97,18 @@
list properties = [],
string name = ""> {
string LLVMName = name;
+ string GCCBuiltinName = "";
list Types = types;
list Properties = properties;
}
+/// GCCBuiltin - If this intrinsic exactly corresponds to a GCC builtin, this
+/// specifies the name of the builtin. This provides automatic CBE and CFE
+/// support.
+class GCCBuiltin {
+ string GCCBuiltinName = name;
+}
+
//===--------------- Variable Argument Handling Intrinsics ----------------===//
//
@@ -189,3 +206,16 @@
def int_dbg_func_start : Intrinsic<[llvm_void_ty, llvm_descriptor_ty]>;
// dbg_declare, // Declare a local object
+
+
+//===----------------------------------------------------------------------===//
+// Target-specific intrinsics
+//===----------------------------------------------------------------------===//
+
+//===----------------------------------------------------------------------===//
+// PowerPC Intrinsics
+
+def int_ppc_altivec_lvx : Intrinsic<[llvm_v4i32_ty, llvm_int_ty, llvm_ptr_ty],
+ [IntrReadMem]>,
+ GCCBuiltin<"__builtin_altivec_lvx">;
+
From lattner at cs.uiuc.edu Mon Mar 13 16:39:08 2006
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 13 Mar 2006 16:39:08 -0600
Subject: [llvm-commits] CVS: llvm/utils/TableGen/CodeGenIntrinsics.h
IntrinsicEmitter.cpp
Message-ID: <200603132239.QAA31594@zion.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
CodeGenIntrinsics.h updated: 1.3 -> 1.4
IntrinsicEmitter.cpp updated: 1.6 -> 1.7
---
Log message:
Verify that packed type operands have the right size and base type.
---
Diffs of the changes: (+28 -6)
CodeGenIntrinsics.h | 4 ++++
IntrinsicEmitter.cpp | 30 ++++++++++++++++++++++++------
2 files changed, 28 insertions(+), 6 deletions(-)
Index: llvm/utils/TableGen/CodeGenIntrinsics.h
diff -u llvm/utils/TableGen/CodeGenIntrinsics.h:1.3 llvm/utils/TableGen/CodeGenIntrinsics.h:1.4
--- llvm/utils/TableGen/CodeGenIntrinsics.h:1.3 Thu Mar 9 16:05:04 2006
+++ llvm/utils/TableGen/CodeGenIntrinsics.h Mon Mar 13 16:38:57 2006
@@ -30,6 +30,10 @@
/// of the arguments. These are things like Type::UIntTyID.
std::vector ArgTypes;
+ /// ArgTypeDefs - The records for each argument type.
+ ///
+ std::vector ArgTypeDefs;
+
// Memory mod/ref behavior of this intrinsic.
enum {
NoMem, ReadArgMem, ReadMem, WriteArgMem, WriteMem
Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
diff -u llvm/utils/TableGen/IntrinsicEmitter.cpp:1.6 llvm/utils/TableGen/IntrinsicEmitter.cpp:1.7
--- llvm/utils/TableGen/IntrinsicEmitter.cpp:1.6 Fri Mar 10 18:20:47 2006
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp Mon Mar 13 16:38:57 2006
@@ -13,6 +13,7 @@
#include "IntrinsicEmitter.h"
#include "Record.h"
+#include "llvm/ADT/StringExtras.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
@@ -52,6 +53,7 @@
Record *TyEl = DI->getDef();
assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!");
ArgTypes.push_back(TyEl->getValueAsString("TypeVal"));
+ ArgTypeDefs.push_back(TyEl);
}
if (ArgTypes.size() == 0)
throw "Intrinsic '"+DefName+"' needs at least a type for the ret value!";
@@ -151,6 +153,25 @@
OS << "#endif\n\n";
}
+static void EmitTypeVerify(std::ostream &OS, const std::string &Val,
+ Record *ArgType) {
+ OS << " Assert1(" << Val << "->getTypeID() == "
+ << ArgType->getValueAsString("TypeVal") << ",\n"
+ << " \"Illegal intrinsic type!\", IF);\n";
+
+ // If this is a packed type, check that the subtype and size are correct.
+ if (ArgType->isSubClassOf("LLVMPackedType")) {
+ Record *SubType = ArgType->getValueAsDef("ElTy");
+ OS << " Assert1(cast(" << Val
+ << ")->getElementType()->getTypeID() == "
+ << SubType->getValueAsString("TypeVal") << ",\n"
+ << " \"Illegal intrinsic type!\", IF);\n";
+ OS << " Assert1(cast(" << Val << ")->getNumElements() == "
+ << ArgType->getValueAsInt("NumElts") << ",\n"
+ << " \"Illegal intrinsic type!\", IF);\n";
+ }
+}
+
void IntrinsicEmitter::EmitVerifier(const std::vector &Ints,
std::ostream &OS) {
OS << "// Verifier::visitIntrinsicFunctionCall code.\n";
@@ -163,13 +184,10 @@
OS << " Assert1(FTy->getNumParams() == " << Ints[i].ArgTypes.size()-1
<< ",\n"
<< " \"Illegal # arguments for intrinsic function!\", IF);\n";
- OS << " Assert1(FTy->getReturnType()->getTypeID() == "
- << Ints[i].ArgTypes[0] << ",\n"
- << " \"Illegal result type!\", IF);\n";
+ EmitTypeVerify(OS, "FTy->getReturnType()", Ints[i].ArgTypeDefs[0]);
for (unsigned j = 1; j != Ints[i].ArgTypes.size(); ++j)
- OS << " Assert1(FTy->getParamType(" << j-1 << ")->getTypeID() == "
- << Ints[i].ArgTypes[j] << ",\n"
- << " \"Illegal argument type!\", IF);\n";
+ EmitTypeVerify(OS, "FTy->getParamType(" + utostr(j-1) + ")",
+ Ints[i].ArgTypeDefs[j]);
OS << " break;\n";
}
OS << " }\n";
From lattner at cs.uiuc.edu Mon Mar 13 17:08:56 2006
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 13 Mar 2006 17:08:56 -0600
Subject: [llvm-commits] CVS: llvm/utils/TableGen/CodeGenIntrinsics.h
IntrinsicEmitter.cpp IntrinsicEmitter.h
Message-ID: <200603132308.RAA31995@zion.cs.uiuc.edu>
Changes in directory llvm/utils/TableGen:
CodeGenIntrinsics.h updated: 1.4 -> 1.5
IntrinsicEmitter.cpp updated: 1.7 -> 1.8
IntrinsicEmitter.h updated: 1.5 -> 1.6
---
Log message:
emit a mapping from LLVM intrinsic -> GCC builtins.
---
Diffs of the changes: (+30 -8)
CodeGenIntrinsics.h | 3 ++-
IntrinsicEmitter.cpp | 33 ++++++++++++++++++++++++++-------
IntrinsicEmitter.h | 2 ++
3 files changed, 30 insertions(+), 8 deletions(-)
Index: llvm/utils/TableGen/CodeGenIntrinsics.h
diff -u llvm/utils/TableGen/CodeGenIntrinsics.h:1.4 llvm/utils/TableGen/CodeGenIntrinsics.h:1.5
--- llvm/utils/TableGen/CodeGenIntrinsics.h:1.4 Mon Mar 13 16:38:57 2006
+++ llvm/utils/TableGen/CodeGenIntrinsics.h Mon Mar 13 17:08:44 2006
@@ -25,7 +25,8 @@
Record *TheDef; // The actual record defining this instruction.
std::string Name; // The name of the LLVM function "llvm.bswap.i32"
std::string EnumName; // The name of the enum "bswap_i32"
-
+ std::string GCCBuiltinName;// Name of the corresponding GCC builtin, or "".
+
/// ArgTypes - The type primitive enum value for the return value and all
/// of the arguments. These are things like Type::UIntTyID.
std::vector ArgTypes;
Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
diff -u llvm/utils/TableGen/IntrinsicEmitter.cpp:1.7 llvm/utils/TableGen/IntrinsicEmitter.cpp:1.8
--- llvm/utils/TableGen/IntrinsicEmitter.cpp:1.7 Mon Mar 13 16:38:57 2006
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp Mon Mar 13 17:08:44 2006
@@ -33,6 +33,7 @@
std::string(DefName.begin(), DefName.begin()+4) != "int_")
throw "Intrinsic '" + DefName + "' does not start with 'int_'!";
EnumName = std::string(DefName.begin()+4, DefName.end());
+ GCCBuiltinName = R->getValueAsString("GCCBuiltinName");
Name = R->getValueAsString("LLVMName");
if (Name == "") {
@@ -105,6 +106,9 @@
// Emit side effect info for each function.
EmitSideEffectInfo(Ints, OS);
+
+ // Emit a list of intrinsics with corresponding GCC builtins.
+ EmitGCCBuiltinList(Ints, OS);
}
void IntrinsicEmitter::EmitEnumInfo(const std::vector &Ints,
@@ -221,16 +225,31 @@
OS << " default: break;\n";
for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
switch (Ints[i].ModRef) {
- default: break;
- case CodeGenIntrinsic::NoMem:
- case CodeGenIntrinsic::ReadArgMem:
- case CodeGenIntrinsic::ReadMem:
- OS << " case Intrinsic::" << Ints[i].EnumName << ":\n";
- break;
+ default: break;
+ case CodeGenIntrinsic::NoMem:
+ case CodeGenIntrinsic::ReadArgMem:
+ case CodeGenIntrinsic::ReadMem:
+ OS << " case Intrinsic::" << Ints[i].EnumName << ":\n";
+ break;
}
}
OS << " return true; // These intrinsics have no side effects.\n";
OS << " }\n";
OS << "#endif\n\n";
-
}
+
+void IntrinsicEmitter::
+EmitGCCBuiltinList(const std::vector &Ints, std::ostream &OS){
+ OS << "// Get the GCC builtin that corresponds to an LLVM intrinsic.\n";
+ OS << "#ifdef GET_GCC_BUILTIN_NAME\n";
+ OS << " switch (F->getIntrinsicID()) {\n";
+ OS << " default: BuiltinName = \"\"; break;\n";
+ for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
+ if (!Ints[i].GCCBuiltinName.empty()) {
+ OS << " case Intrinsic::" << Ints[i].EnumName << ": BuiltinName = \""
+ << Ints[i].GCCBuiltinName << "\"; break;\n";
+ }
+ }
+ OS << " }\n";
+ OS << "#endif\n\n";
+}
\ No newline at end of file
Index: llvm/utils/TableGen/IntrinsicEmitter.h
diff -u llvm/utils/TableGen/IntrinsicEmitter.h:1.5 llvm/utils/TableGen/IntrinsicEmitter.h:1.6
--- llvm/utils/TableGen/IntrinsicEmitter.h:1.5 Thu Mar 9 16:37:52 2006
+++ llvm/utils/TableGen/IntrinsicEmitter.h Mon Mar 13 17:08:44 2006
@@ -37,6 +37,8 @@
std::ostream &OS);
void EmitSideEffectInfo(const std::vector &Ints,
std::ostream &OS);
+ void EmitGCCBuiltinList(const std::vector &Ints,
+ std::ostream &OS);
};
} // End llvm namespace
From lattner at cs.uiuc.edu Mon Mar 13 17:09:17 2006
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 13 Mar 2006 17:09:17 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp
Message-ID: <200603132309.RAA32028@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/CBackend:
Writer.cpp updated: 1.256 -> 1.257
---
Log message:
Handle builtins that directly correspond to GCC builtins.
---
Diffs of the changes: (+25 -2)
Writer.cpp | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.256 llvm/lib/Target/CBackend/Writer.cpp:1.257
--- llvm/lib/Target/CBackend/Writer.cpp:1.256 Mon Mar 13 07:07:37 2006
+++ llvm/lib/Target/CBackend/Writer.cpp Mon Mar 13 17:09:05 2006
@@ -1602,6 +1602,15 @@
// We directly implement these intrinsics
break;
default:
+ // If this is an intrinsic that directly corresponds to a GCC
+ // builtin, we handle it.
+ const char *BuiltinName = "";
+#define GET_GCC_BUILTIN_NAME
+#include "llvm/Intrinsics.gen"
+#undef GET_GCC_BUILTIN_NAME
+ // If we handle it, don't lower it.
+ if (BuiltinName[0]) break;
+
// All other intrinsic calls we must lower.
Instruction *Before = 0;
if (CI != &BB->front())
@@ -1613,17 +1622,32 @@
} else {
I = BB->begin();
}
+ break;
}
}
void CWriter::visitCallInst(CallInst &I) {
+ bool WroteCallee = false;
+
// Handle intrinsic function calls first...
if (Function *F = I.getCalledFunction())
if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID()) {
switch (ID) {
- default: assert(0 && "Unknown LLVM intrinsic!");
+ default: {
+ // If this is an intrinsic that directly corresponds to a GCC
+ // builtin, we emit it here.
+ const char *BuiltinName = "";
+#define GET_GCC_BUILTIN_NAME
+#include "llvm/Intrinsics.gen"
+#undef GET_GCC_BUILTIN_NAME
+ assert(BuiltinName[0] && "Unknown LLVM intrinsic!");
+
+ Out << BuiltinName;
+ WroteCallee = true;
+ break;
+ }
case Intrinsic::vastart:
Out << "0; ";
@@ -1720,7 +1744,6 @@
// in the common case, we handle casts where the number of arguments passed
// match exactly.
//
- bool WroteCallee = false;
if (I.isTailCall()) Out << " /*tail*/ ";
if (ConstantExpr *CE = dyn_cast(Callee))
if (CE->getOpcode() == Instruction::Cast)
From evan.cheng at apple.com Mon Mar 13 17:14:34 2006
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 13 Mar 2006 17:14:34 -0600
Subject: [llvm-commits]
CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Message-ID: <200603132314.RAA32113@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Transforms/Scalar:
LoopStrengthReduce.cpp updated: 1.75 -> 1.76
---
Log message:
Added target lowering hooks which LSR consults to make more intelligent
transformation decisions.
---
Diffs of the changes: (+33 -25)
LoopStrengthReduce.cpp | 58 +++++++++++++++++++++++++++----------------------
1 files changed, 33 insertions(+), 25 deletions(-)
Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.75 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.76
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.75 Sat Feb 4 03:52:43 2006
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Mon Mar 13 17:14:23 2006
@@ -31,6 +31,7 @@
#include "llvm/Target/TargetData.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Target/TargetLowering.h"
#include
#include
#include
@@ -105,9 +106,14 @@
/// DeadInsts - Keep track of instructions we may have made dead, so that
/// we can remove them after we are done working.
std::set DeadInsts;
+
+ /// TLI - Keep a pointer of a TargetLowering to consult for determining
+ /// transformation profitability.
+ const TargetLowering *TLI;
+
public:
- LoopStrengthReduce(unsigned MTAMS = 1)
- : MaxTargetAMSize(MTAMS) {
+ LoopStrengthReduce(unsigned MTAMS = 1, const TargetLowering *tli = NULL)
+ : MaxTargetAMSize(MTAMS), TLI(tli) {
}
virtual bool runOnFunction(Function &) {
@@ -162,8 +168,9 @@
"Loop Strength Reduction");
}
-FunctionPass *llvm::createLoopStrengthReducePass(unsigned MaxTargetAMSize) {
- return new LoopStrengthReduce(MaxTargetAMSize);
+FunctionPass *llvm::createLoopStrengthReducePass(unsigned MaxTargetAMSize,
+ const TargetLowering *TLI) {
+ return new LoopStrengthReduce(MaxTargetAMSize, TLI);
}
/// getCastedVersionOf - Return the specified value casted to uintptr_t.
@@ -574,25 +581,25 @@
/// isTargetConstant - Return true if the following can be referenced by the
/// immediate field of a target instruction.
-static bool isTargetConstant(const SCEVHandle &V) {
-
- // FIXME: Look at the target to decide if &GV is a legal constant immediate.
+static bool isTargetConstant(const SCEVHandle &V, const TargetLowering *TLI) {
if (SCEVConstant *SC = dyn_cast(V)) {
- // PPC allows a sign-extended 16-bit immediate field.
int64_t V = SC->getValue()->getSExtValue();
- if (V > -(1 << 16) && V < (1 << 16)-1)
- return true;
- return false;
+ if (TLI)
+ return TLI->isLegalAddressImmediate(V);
+ else
+ // Defaults to PPC. PPC allows a sign-extended 16-bit immediate field.
+ return (V > -(1 << 16) && V < (1 << 16)-1);
}
- return false; // ENABLE this for x86
-
if (SCEVUnknown *SU = dyn_cast(V))
if (ConstantExpr *CE = dyn_cast(SU->getValue()))
- if (CE->getOpcode() == Instruction::Cast)
- if (isa(CE->getOperand(0)))
- // FIXME: should check to see that the dest is uintptr_t!
+ if (CE->getOpcode() == Instruction::Cast) {
+ Constant *Op0 = CE->getOperand(0);
+ if (isa(Op0) &&
+ TLI &&
+ TLI->isLegalAddressImmediate(cast(Op0)))
return true;
+ }
return false;
}
@@ -638,7 +645,8 @@
/// MoveImmediateValues - Look at Val, and pull out any additions of constants
/// that can fit into the immediate field of instructions in the target.
/// Accumulate these immediate values into the Imm value.
-static void MoveImmediateValues(SCEVHandle &Val, SCEVHandle &Imm,
+static void MoveImmediateValues(const TargetLowering *TLI,
+ SCEVHandle &Val, SCEVHandle &Imm,
bool isAddress, Loop *L) {
if (SCEVAddExpr *SAE = dyn_cast(Val)) {
std::vector NewOps;
@@ -646,7 +654,7 @@
for (unsigned i = 0; i != SAE->getNumOperands(); ++i) {
SCEVHandle NewOp = SAE->getOperand(i);
- MoveImmediateValues(NewOp, Imm, isAddress, L);
+ MoveImmediateValues(TLI, NewOp, Imm, isAddress, L);
if (!NewOp->isLoopInvariant(L)) {
// If this is a loop-variant expression, it must stay in the immediate
@@ -665,7 +673,7 @@
} else if (SCEVAddRecExpr *SARE = dyn_cast(Val)) {
// Try to pull immediates out of the start value of nested addrec's.
SCEVHandle Start = SARE->getStart();
- MoveImmediateValues(Start, Imm, isAddress, L);
+ MoveImmediateValues(TLI, Start, Imm, isAddress, L);
if (Start != SARE->getStart()) {
std::vector Ops(SARE->op_begin(), SARE->op_end());
@@ -675,12 +683,12 @@
return;
} else if (SCEVMulExpr *SME = dyn_cast(Val)) {
// Transform "8 * (4 + v)" -> "32 + 8*V" if "32" fits in the immed field.
- if (isAddress && isTargetConstant(SME->getOperand(0)) &&
+ if (isAddress && isTargetConstant(SME->getOperand(0), TLI) &&
SME->getNumOperands() == 2 && SME->isLoopInvariant(L)) {
SCEVHandle SubImm = SCEVUnknown::getIntegerSCEV(0, Val->getType());
SCEVHandle NewOp = SME->getOperand(1);
- MoveImmediateValues(NewOp, SubImm, isAddress, L);
+ MoveImmediateValues(TLI, NewOp, SubImm, isAddress, L);
// If we extracted something out of the subexpressions, see if we can
// simplify this!
@@ -688,7 +696,7 @@
// Scale SubImm up by "8". If the result is a target constant, we are
// good.
SubImm = SCEVMulExpr::get(SubImm, SME->getOperand(0));
- if (isTargetConstant(SubImm)) {
+ if (isTargetConstant(SubImm, TLI)) {
// Accumulate the immediate.
Imm = SCEVAddExpr::get(Imm, SubImm);
@@ -702,7 +710,7 @@
// Loop-variant expressions must stay in the immediate field of the
// expression.
- if ((isAddress && isTargetConstant(Val)) ||
+ if ((isAddress && isTargetConstant(Val, TLI)) ||
!Val->isLoopInvariant(L)) {
Imm = SCEVAddExpr::get(Imm, Val);
Val = SCEVUnknown::getIntegerSCEV(0, Val->getType());
@@ -879,7 +887,7 @@
if (SI->getOperand(1) == UsersToProcess[i].OperandValToReplace)
isAddress = true;
- MoveImmediateValues(UsersToProcess[i].Base, UsersToProcess[i].Imm,
+ MoveImmediateValues(TLI, UsersToProcess[i].Base, UsersToProcess[i].Imm,
isAddress, L);
}
}
@@ -941,7 +949,7 @@
// this by forcing a noop cast to be inserted into the preheader in this
// case.
if (Constant *C = dyn_cast(BaseV))
- if (!C->isNullValue() && !isTargetConstant(Base)) {
+ if (!C->isNullValue() && !isTargetConstant(Base, TLI)) {
// We want this constant emitted into the preheader!
BaseV = new CastInst(BaseV, BaseV->getType(), "preheaderinsert",
PreInsertPt);
From evan.cheng at apple.com Mon Mar 13 17:14:35 2006
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 13 Mar 2006 17:14:35 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Scalar.h
Message-ID: <200603132314.RAA32117@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm/Transforms:
Scalar.h updated: 1.60 -> 1.61
---
Log message:
Added target lowering hooks which LSR consults to make more intelligent
transformation decisions.
---
Diffs of the changes: (+8 -2)
Scalar.h | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
Index: llvm/include/llvm/Transforms/Scalar.h
diff -u llvm/include/llvm/Transforms/Scalar.h:1.60 llvm/include/llvm/Transforms/Scalar.h:1.61
--- llvm/include/llvm/Transforms/Scalar.h:1.60 Tue Nov 22 16:14:23 2005
+++ llvm/include/llvm/Transforms/Scalar.h Mon Mar 13 17:14:23 2006
@@ -15,6 +15,8 @@
#ifndef LLVM_TRANSFORMS_SCALAR_H
#define LLVM_TRANSFORMS_SCALAR_H
+#include
+
namespace llvm {
class ModulePass;
@@ -22,6 +24,7 @@
class GetElementPtrInst;
class PassInfo;
class TerminatorInst;
+class TargetLowering;
//===----------------------------------------------------------------------===//
//
@@ -132,9 +135,12 @@
// a loop's canonical induction variable as one of their indices. The
// MaxTargetAMSize is the largest element size that the target architecture
// can handle in its addressing modes. Power of two multipliers less than or
-// equal to this value are not reduced.
+// equal to this value are not reduced. It also takes an optional second
+// parameter used to consult the target machine whether certain transformations
+// are profitable.
//
-FunctionPass *createLoopStrengthReducePass(unsigned MaxTargetAMSize = 1);
+FunctionPass *createLoopStrengthReducePass(unsigned MaxTargetAMSize = 1,
+ const TargetLowering *TLI = NULL);
//===----------------------------------------------------------------------===//
//
From evan.cheng at apple.com Mon Mar 13 17:15:38 2006
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 13 Mar 2006 17:15:38 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetLowering.h
Message-ID: <200603132315.RAA32137@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm/Target:
TargetLowering.h updated: 1.59 -> 1.60
---
Log message:
Add LSR hooks.
---
Diffs of the changes: (+10 -1)
TargetLowering.h | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletion(-)
Index: llvm/include/llvm/Target/TargetLowering.h
diff -u llvm/include/llvm/Target/TargetLowering.h:1.59 llvm/include/llvm/Target/TargetLowering.h:1.60
--- llvm/include/llvm/Target/TargetLowering.h:1.59 Sun Mar 5 17:49:19 2006
+++ llvm/include/llvm/Target/TargetLowering.h Mon Mar 13 17:15:27 2006
@@ -349,7 +349,7 @@
uint64_t &KnownZero,
uint64_t &KnownOne,
unsigned Depth = 0) const;
-
+
struct DAGCombinerInfo {
void *DC; // The DAG Combiner object.
bool BeforeLegalize;
@@ -560,6 +560,15 @@
virtual bool isOperandValidForConstraint(SDOperand Op, char ConstraintLetter);
//===--------------------------------------------------------------------===//
+ // Loop Strength Reduction hooks
+ //
+
+ /// isLegalAddressImmediate - Return true if the integer value or GlobalValue
+ /// can be used as the offset of the target addressing mode.
+ virtual bool isLegalAddressImmediate(int64_t V) const;
+ virtual bool isLegalAddressImmediate(GlobalValue *GV) const;
+
+ //===--------------------------------------------------------------------===//
// Scheduler hooks
//
From evan.cheng at apple.com Mon Mar 13 17:16:43 2006
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 13 Mar 2006 17:16:43 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/TargetLowering.cpp
Message-ID: <200603132316.RAA32157@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target:
TargetLowering.cpp updated: 1.45 -> 1.46
---
Log message:
Add LSR hooks.
---
Diffs of the changes: (+13 -0)
TargetLowering.cpp | 13 +++++++++++++
1 files changed, 13 insertions(+)
Index: llvm/lib/Target/TargetLowering.cpp
diff -u llvm/lib/Target/TargetLowering.cpp:1.45 llvm/lib/Target/TargetLowering.cpp:1.46
--- llvm/lib/Target/TargetLowering.cpp:1.45 Mon Mar 13 00:42:16 2006
+++ llvm/lib/Target/TargetLowering.cpp Mon Mar 13 17:16:31 2006
@@ -976,3 +976,16 @@
return std::pair(0, 0);
}
+
+//===----------------------------------------------------------------------===//
+// Loop Strength Reduction hooks
+//===----------------------------------------------------------------------===//
+
+/// isLegalAddressImmediate - Return true if the integer value or
+/// GlobalValue can be used as the offset of the target addressing mode.
+bool TargetLowering::isLegalAddressImmediate(int64_t V) const {
+ return false;
+}
+bool TargetLowering::isLegalAddressImmediate(GlobalValue *GV) const {
+ return false;
+}
From evan.cheng at apple.com Mon Mar 13 17:17:54 2006
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 13 Mar 2006 17:17:54 -0600
Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetMachine.h
Message-ID: <200603132317.RAA32215@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm/Target:
TargetMachine.h updated: 1.60 -> 1.61
---
Log message:
Added getTargetLowering() - returns DAG lowering info.
---
Diffs of the changes: (+3 -0)
TargetMachine.h | 3 +++
1 files changed, 3 insertions(+)
Index: llvm/include/llvm/Target/TargetMachine.h
diff -u llvm/include/llvm/Target/TargetMachine.h:1.60 llvm/include/llvm/Target/TargetMachine.h:1.61
--- llvm/include/llvm/Target/TargetMachine.h:1.60 Wed Feb 22 14:19:42 2006
+++ llvm/include/llvm/Target/TargetMachine.h Mon Mar 13 17:17:42 2006
@@ -24,6 +24,7 @@
class TargetInstrInfo;
class TargetInstrDescriptor;
class TargetJITInfo;
+class TargetLowering;
class TargetSchedInfo;
class SparcV9RegInfo;
class TargetFrameInfo;
@@ -108,9 +109,11 @@
// -- Instruction opcode and operand information
// -- Pipelines and scheduling information
// -- Stack frame information
+ // -- Selection DAG lowering information
//
virtual const TargetInstrInfo *getInstrInfo() const { return 0; }
virtual const TargetFrameInfo *getFrameInfo() const { return 0; }
+ virtual TargetLowering *getTargetLowering() const { return 0; }
const TargetData &getTargetData() const { return DataLayout; }
/// getSubtarget - This method returns a pointer to the specified type of
From evan.cheng at apple.com Mon Mar 13 17:18:28 2006
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 13 Mar 2006 17:18:28 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp
Message-ID: <200603132318.RAA32230@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/X86:
X86ISelLowering.cpp updated: 1.104 -> 1.105
---
Log message:
Add LSR hooks.
---
Diffs of the changes: (+35 -4)
X86ISelLowering.cpp | 39 +++++++++++++++++++++++++++++++++++----
1 files changed, 35 insertions(+), 4 deletions(-)
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.104 llvm/lib/Target/X86/X86ISelLowering.cpp:1.105
--- llvm/lib/Target/X86/X86ISelLowering.cpp:1.104 Tue Mar 7 17:29:39 2006
+++ llvm/lib/Target/X86/X86ISelLowering.cpp Mon Mar 13 17:18:16 2006
@@ -19,6 +19,8 @@
#include "llvm/CallingConv.h"
#include "llvm/Constants.h"
#include "llvm/Function.h"
+#include "llvm/ADT/VectorExtras.h"
+#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -26,7 +28,6 @@
#include "llvm/CodeGen/SSARegMap.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Target/TargetOptions.h"
-#include "llvm/ADT/VectorExtras.h"
using namespace llvm;
// FIXME: temporary.
@@ -1317,6 +1318,16 @@
// X86 Custom Lowering Hooks
//===----------------------------------------------------------------------===//
+/// DarwinGVRequiresExtraLoad - true if accessing the GV requires an extra
+/// load. For Darwin, external and weak symbols are indirect, loading the value
+/// at address GV rather then the value of GV itself. This means that the
+/// GlobalAddress must be in the base or index register of the address, not the
+/// GV offset field.
+static bool DarwinGVRequiresExtraLoad(GlobalValue *GV) {
+ return (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
+ (GV->isExternal() && !GV->hasNotBeenReadFromBytecode()));
+}
+
/// LowerOperation - Provide custom lowering hooks for some operations.
///
SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
@@ -1986,12 +1997,11 @@
DAG.getNode(X86ISD::GlobalBaseReg, getPointerTy()), Result);
// For Darwin, external and weak symbols are indirect, so we want to load
- // the value at address GV, not the value of GV itself. This means that
+ // the value at address GV, not the value of GV itself. This means that
// the GlobalAddress must be in the base or index register of the address,
// not the GV offset field.
if (getTargetMachine().getRelocationModel() != Reloc::Static &&
- (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
- (GV->isExternal() && !GV->hasNotBeenReadFromBytecode())))
+ DarwinGVRequiresExtraLoad(GV))
Result = DAG.getLoad(MVT::i32, DAG.getEntryNode(),
Result, DAG.getSrcValue(NULL));
}
@@ -2179,3 +2189,24 @@
return std::vector();
}
+
+/// isLegalAddressImmediate - Return true if the integer value or
+/// GlobalValue can be used as the offset of the target addressing mode.
+bool X86TargetLowering::isLegalAddressImmediate(int64_t V) const {
+ // X86 allows a sign-extended 32-bit immediate field.
+ return (V > -(1LL << 32) && V < (1LL << 32)-1);
+}
+
+bool X86TargetLowering::isLegalAddressImmediate(GlobalValue *GV) const {
+ if (getTargetMachine().
+ getSubtarget().isTargetDarwin()) {
+ Reloc::Model RModel = getTargetMachine().getRelocationModel();
+ if (RModel == Reloc::Static)
+ return true;
+ else if (RModel == Reloc::DynamicNoPIC)
+ return DarwinGVRequiresExtraLoad(GV);
+ else
+ return false;
+ } else
+ return true;
+}
From evan.cheng at apple.com Mon Mar 13 17:19:22 2006
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 13 Mar 2006 17:19:22 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/README.txt
Message-ID: <200603132319.RAA32246@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target:
README.txt updated: 1.18 -> 1.19
---
Log message:
Update
---
Diffs of the changes: (+3 -0)
README.txt | 3 +++
1 files changed, 3 insertions(+)
Index: llvm/lib/Target/README.txt
diff -u llvm/lib/Target/README.txt:1.18 llvm/lib/Target/README.txt:1.19
--- llvm/lib/Target/README.txt:1.18 Mon Mar 13 00:52:22 2006
+++ llvm/lib/Target/README.txt Mon Mar 13 17:19:10 2006
@@ -54,6 +54,9 @@
Number 1 is the preferred solution.
+This has been "fixed" by a TableGen hack. But that is a short term workaround
+which will be removed once the proper fix is made.
+
//===---------------------------------------------------------------------===//
Turn this into a signed shift right in instcombine:
From evan.cheng at apple.com Mon Mar 13 17:20:51 2006
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 13 Mar 2006 17:20:51 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC.h PPCAsmPrinter.cpp
PPCISelDAGToDAG.cpp PPCISelLowering.cpp PPCISelLowering.h
PPCJITInfo.h PPCTargetMachine.cpp PPCTargetMachine.h
Message-ID: <200603132320.RAA32301@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/PowerPC:
PPC.h updated: 1.27 -> 1.28
PPCAsmPrinter.cpp updated: 1.157 -> 1.158
PPCISelDAGToDAG.cpp updated: 1.165 -> 1.166
PPCISelLowering.cpp updated: 1.95 -> 1.96
PPCISelLowering.h updated: 1.25 -> 1.26
PPCJITInfo.h updated: 1.8 -> 1.9
PPCTargetMachine.cpp updated: 1.81 -> 1.82
PPCTargetMachine.h updated: 1.16 -> 1.17
---
Log message:
Added getTargetLowering() to TargetMachine. Refactored targets to support this.
---
Diffs of the changes: (+30 -13)
PPC.h | 8 ++++----
PPCAsmPrinter.cpp | 5 +++--
PPCISelDAGToDAG.cpp | 7 ++++---
PPCISelLowering.cpp | 8 ++++++++
PPCISelLowering.h | 4 ++++
PPCJITInfo.h | 6 +++---
PPCTargetMachine.cpp | 2 +-
PPCTargetMachine.h | 3 +++
8 files changed, 30 insertions(+), 13 deletions(-)
Index: llvm/lib/Target/PowerPC/PPC.h
diff -u llvm/lib/Target/PowerPC/PPC.h:1.27 llvm/lib/Target/PowerPC/PPC.h:1.28
--- llvm/lib/Target/PowerPC/PPC.h:1.27 Wed Feb 22 14:19:42 2006
+++ llvm/lib/Target/PowerPC/PPC.h Mon Mar 13 17:20:37 2006
@@ -20,16 +20,16 @@
namespace llvm {
class FunctionPass;
-class TargetMachine;
+class PPCTargetMachine;
enum PPCTargetEnum {
TargetDefault, TargetAIX, TargetDarwin
};
FunctionPass *createPPCBranchSelectionPass();
-FunctionPass *createPPCISelDag(TargetMachine &TM);
-FunctionPass *createDarwinAsmPrinter(std::ostream &OS, TargetMachine &TM);
-FunctionPass *createAIXAsmPrinter(std::ostream &OS, TargetMachine &TM);
+FunctionPass *createPPCISelDag(PPCTargetMachine &TM);
+FunctionPass *createDarwinAsmPrinter(std::ostream &OS, PPCTargetMachine &TM);
+FunctionPass *createAIXAsmPrinter(std::ostream &OS, PPCTargetMachine &TM);
extern PPCTargetEnum PPCTarget;
} // end namespace llvm;
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
diff -u llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.157 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.158
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1.157 Tue Mar 7 16:00:35 2006
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp Mon Mar 13 17:20:37 2006
@@ -307,7 +307,8 @@
/// code for a MachineFunction to the given output stream, in a format that the
/// Darwin assembler can deal with.
///
-FunctionPass *llvm::createDarwinAsmPrinter(std::ostream &o, TargetMachine &tm) {
+FunctionPass *llvm::createDarwinAsmPrinter(std::ostream &o,
+ PPCTargetMachine &tm) {
return new DarwinAsmPrinter(o, tm);
}
@@ -315,7 +316,7 @@
/// for a MachineFunction to the given output stream, in a format that the
/// AIX 5L assembler can deal with.
///
-FunctionPass *llvm::createAIXAsmPrinter(std::ostream &o, TargetMachine &tm) {
+FunctionPass *llvm::createAIXAsmPrinter(std::ostream &o, PPCTargetMachine &tm) {
return new AIXAsmPrinter(o, tm);
}
Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
diff -u llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.165 llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.166
--- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:1.165 Mon Mar 13 15:52:10 2006
+++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Mon Mar 13 17:20:37 2006
@@ -42,8 +42,9 @@
PPCTargetLowering PPCLowering;
unsigned GlobalBaseReg;
public:
- PPCDAGToDAGISel(TargetMachine &TM)
- : SelectionDAGISel(PPCLowering), PPCLowering(TM) {}
+ PPCDAGToDAGISel(PPCTargetMachine &TM)
+ : SelectionDAGISel(PPCLowering),
+ PPCLowering(*TM.getTargetLowering()){}
virtual bool runOnFunction(Function &Fn) {
// Make sure we re-emit a set of the global base reg if necessary
@@ -1140,7 +1141,7 @@
/// createPPCISelDag - This pass converts a legalized DAG into a
/// PowerPC-specific DAG, ready for instruction scheduling.
///
-FunctionPass *llvm::createPPCISelDag(TargetMachine &TM) {
+FunctionPass *llvm::createPPCISelDag(PPCTargetMachine &TM) {
return new PPCDAGToDAGISel(TM);
}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.95 llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.96
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.95 Sat Mar 4 23:08:37 2006
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Mon Mar 13 17:20:37 2006
@@ -14,6 +14,7 @@
#include "PPCISelLowering.h"
#include "PPCTargetMachine.h"
#include "llvm/ADT/VectorExtras.h"
+#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -1174,3 +1175,10 @@
// Handle standard constraint letters.
return TargetLowering::isOperandValidForConstraint(Op, Letter);
}
+
+/// isLegalAddressImmediate - Return true if the integer value can be used
+/// as the offset of the target addressing mode.
+bool PPCTargetLowering::isLegalAddressImmediate(int64_t V) const {
+ // PPC allows a sign-extended 16-bit immediate field.
+ return (V > -(1 << 16) && V < (1 << 16)-1);
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.h
diff -u llvm/lib/Target/PowerPC/PPCISelLowering.h:1.25 llvm/lib/Target/PowerPC/PPCISelLowering.h:1.26
--- llvm/lib/Target/PowerPC/PPCISelLowering.h:1.25 Tue Feb 28 23:50:56 2006
+++ llvm/lib/Target/PowerPC/PPCISelLowering.h Mon Mar 13 17:20:37 2006
@@ -109,6 +109,10 @@
getRegClassForInlineAsmConstraint(const std::string &Constraint,
MVT::ValueType VT) const;
bool isOperandValidForConstraint(SDOperand Op, char ConstraintLetter);
+
+ /// isLegalAddressImmediate - Return true if the integer value can be used
+ /// as the offset of the target addressing mode.
+ virtual bool isLegalAddressImmediate(int64_t V) const;
};
}
Index: llvm/lib/Target/PowerPC/PPCJITInfo.h
diff -u llvm/lib/Target/PowerPC/PPCJITInfo.h:1.8 llvm/lib/Target/PowerPC/PPCJITInfo.h:1.9
--- llvm/lib/Target/PowerPC/PPCJITInfo.h:1.8 Sun Oct 16 00:39:50 2005
+++ llvm/lib/Target/PowerPC/PPCJITInfo.h Mon Mar 13 17:20:37 2006
@@ -17,13 +17,13 @@
#include "llvm/Target/TargetJITInfo.h"
namespace llvm {
- class TargetMachine;
+ class PPCTargetMachine;
class PPCJITInfo : public TargetJITInfo {
protected:
- TargetMachine &TM;
+ PPCTargetMachine &TM;
public:
- PPCJITInfo(TargetMachine &tm) : TM(tm) {useGOT = 0;}
+ PPCJITInfo(PPCTargetMachine &tm) : TM(tm) {useGOT = 0;}
/// addPassesToJITCompile - Add passes to the specified pass manager to
/// implement a fast dynamic compiler for this target. Return true if this
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
diff -u llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.81 llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.82
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.81 Thu Feb 23 16:18:07 2006
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp Mon Mar 13 17:20:37 2006
@@ -62,7 +62,7 @@
const std::string &FS)
: TargetMachine("PowerPC", IL, false, 4, 4, 4, 4, 4, 4, 2, 1, 1),
Subtarget(M, FS), FrameInfo(*this, false), JITInfo(*this),
- InstrItins(Subtarget.getInstrItineraryData()) {
+ TLInfo(*this), InstrItins(Subtarget.getInstrItineraryData()) {
if (TargetDefault == PPCTarget) {
if (Subtarget.isAIX()) PPCTarget = TargetAIX;
if (Subtarget.isDarwin()) PPCTarget = TargetDarwin;
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.h
diff -u llvm/lib/Target/PowerPC/PPCTargetMachine.h:1.16 llvm/lib/Target/PowerPC/PPCTargetMachine.h:1.17
--- llvm/lib/Target/PowerPC/PPCTargetMachine.h:1.16 Mon Nov 7 20:12:47 2005
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.h Mon Mar 13 17:20:37 2006
@@ -18,6 +18,7 @@
#include "PPCSubtarget.h"
#include "PPCJITInfo.h"
#include "PPCInstrInfo.h"
+#include "PPCISelLowering.h"
#include "llvm/Target/TargetMachine.h"
namespace llvm {
@@ -31,6 +32,7 @@
PPCSubtarget Subtarget;
PPCFrameInfo FrameInfo;
PPCJITInfo JITInfo;
+ PPCTargetLowering TLInfo;
InstrItineraryData InstrItins;
public:
PPCTargetMachine(const Module &M, IntrinsicLowering *IL,
@@ -40,6 +42,7 @@
virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
virtual TargetJITInfo *getJITInfo() { return &JITInfo; }
virtual const TargetSubtarget *getSubtargetImpl() const{ return &Subtarget; }
+ virtual PPCTargetLowering *getTargetLowering() { return &TLInfo; }
virtual const MRegisterInfo *getRegisterInfo() const {
return &InstrInfo.getRegisterInfo();
}
From evan.cheng at apple.com Mon Mar 13 17:20:51 2006
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 13 Mar 2006 17:20:51 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86.h X86ATTAsmPrinter.cpp
X86ATTAsmPrinter.h X86AsmPrinter.cpp X86AsmPrinter.h
X86ELFWriter.cpp X86ISelDAGToDAG.cpp X86ISelLowering.h
X86IntelAsmPrinter.cpp X86IntelAsmPrinter.h X86JITInfo.h
X86TargetMachine.cpp X86TargetMachine.h
Message-ID: <200603132320.RAA32343@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/X86:
X86.h updated: 1.44 -> 1.45
X86ATTAsmPrinter.cpp updated: 1.30 -> 1.31
X86ATTAsmPrinter.h updated: 1.9 -> 1.10
X86AsmPrinter.cpp updated: 1.170 -> 1.171
X86AsmPrinter.h updated: 1.13 -> 1.14
X86ELFWriter.cpp updated: 1.2 -> 1.3
X86ISelDAGToDAG.cpp updated: 1.55 -> 1.56
X86ISelLowering.h updated: 1.32 -> 1.33
X86IntelAsmPrinter.cpp updated: 1.23 -> 1.24
X86IntelAsmPrinter.h updated: 1.10 -> 1.11
X86JITInfo.h updated: 1.7 -> 1.8
X86TargetMachine.cpp updated: 1.106 -> 1.107
X86TargetMachine.h updated: 1.31 -> 1.32
---
Log message:
Added getTargetLowering() to TargetMachine. Refactored targets to support this.
---
Diffs of the changes: (+45 -37)
X86.h | 8 ++++----
X86ATTAsmPrinter.cpp | 1 -
X86ATTAsmPrinter.h | 4 +---
X86AsmPrinter.cpp | 10 +++++-----
X86AsmPrinter.h | 5 ++---
X86ELFWriter.cpp | 6 +++---
X86ISelDAGToDAG.cpp | 10 ++++++----
X86ISelLowering.h | 6 ++++++
X86IntelAsmPrinter.cpp | 1 -
X86IntelAsmPrinter.h | 5 +----
X86JITInfo.h | 6 +++---
X86TargetMachine.cpp | 8 ++++++--
X86TargetMachine.h | 12 ++++++++----
13 files changed, 45 insertions(+), 37 deletions(-)
Index: llvm/lib/Target/X86/X86.h
diff -u llvm/lib/Target/X86/X86.h:1.44 llvm/lib/Target/X86/X86.h:1.45
--- llvm/lib/Target/X86/X86.h:1.44 Thu Feb 16 18:03:04 2006
+++ llvm/lib/Target/X86/X86.h Mon Mar 13 17:20:37 2006
@@ -19,7 +19,7 @@
namespace llvm {
-class TargetMachine;
+class X86TargetMachine;
class PassManager;
class FunctionPass;
class IntrinsicLowering;
@@ -28,7 +28,7 @@
/// createX86ISelDag - This pass converts a legalized DAG into a
/// X86-specific DAG, ready for instruction scheduling.
///
-FunctionPass *createX86ISelDag(TargetMachine &TM);
+FunctionPass *createX86ISelDag(X86TargetMachine &TM);
/// createX86FloatingPointStackifierPass - This function returns a pass which
/// converts floating point register references and pseudo instructions into
@@ -40,7 +40,7 @@
/// assembly code for a MachineFunction to the given output stream,
/// using the given target machine description.
///
-FunctionPass *createX86CodePrinterPass(std::ostream &o, TargetMachine &tm);
+FunctionPass *createX86CodePrinterPass(std::ostream &o, X86TargetMachine &tm);
/// createX86CodeEmitterPass - Return a pass that emits the collected X86 code
/// to the specified MCE object.
@@ -50,7 +50,7 @@
/// code as an ELF object file.
///
void addX86ELFObjectWriterPass(PassManager &FPM,
- std::ostream &o, TargetMachine &tm);
+ std::ostream &o, X86TargetMachine &tm);
/// createX86EmitCodeToMemory - Returns a pass that converts a register
/// allocated function into raw machine code in a dynamically
Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.30 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.31
--- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.30 Mon Mar 6 20:23:26 2006
+++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Mon Mar 13 17:20:37 2006
@@ -21,7 +21,6 @@
#include "llvm/Target/TargetOptions.h"
#include
using namespace llvm;
-using namespace x86;
/// runOnMachineFunction - This uses the printMachineInstruction()
/// method to print assembly for each instruction.
Index: llvm/lib/Target/X86/X86ATTAsmPrinter.h
diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.h:1.9 llvm/lib/Target/X86/X86ATTAsmPrinter.h:1.10
--- llvm/lib/Target/X86/X86ATTAsmPrinter.h:1.9 Mon Mar 6 20:02:57 2006
+++ llvm/lib/Target/X86/X86ATTAsmPrinter.h Mon Mar 13 17:20:37 2006
@@ -18,10 +18,9 @@
#include "llvm/CodeGen/ValueTypes.h"
namespace llvm {
-namespace x86 {
struct X86ATTAsmPrinter : public X86SharedAsmPrinter {
- X86ATTAsmPrinter(std::ostream &O, TargetMachine &TM)
+ X86ATTAsmPrinter(std::ostream &O, X86TargetMachine &TM)
: X86SharedAsmPrinter(O, TM) { }
virtual const char *getPassName() const {
@@ -69,7 +68,6 @@
bool runOnMachineFunction(MachineFunction &F);
};
-} // end namespace x86
} // end namespace llvm
#endif
Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.170 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.171
--- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.170 Tue Mar 7 16:00:35 2006
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp Mon Mar 13 17:20:37 2006
@@ -14,10 +14,10 @@
//
//===----------------------------------------------------------------------===//
+#include "X86AsmPrinter.h"
#include "X86ATTAsmPrinter.h"
#include "X86IntelAsmPrinter.h"
#include "X86Subtarget.h"
-#include "X86.h"
#include "llvm/Constants.h"
#include "llvm/Module.h"
#include "llvm/Type.h"
@@ -25,10 +25,9 @@
#include "llvm/Support/Mangler.h"
#include "llvm/Support/CommandLine.h"
using namespace llvm;
-using namespace x86;
-Statistic<> llvm::x86::EmittedInsts("asm-printer",
- "Number of machine instrs printed");
+Statistic<> llvm::EmittedInsts("asm-printer",
+ "Number of machine instrs printed");
enum AsmWriterFlavorTy { att, intel };
cl::opt
@@ -210,7 +209,8 @@
/// for a MachineFunction to the given output stream, using the given target
/// machine description.
///
-FunctionPass *llvm::createX86CodePrinterPass(std::ostream &o,TargetMachine &tm){
+FunctionPass *llvm::createX86CodePrinterPass(std::ostream &o,
+ X86TargetMachine &tm){
switch (AsmWriterFlavor) {
default:
assert(0 && "Unknown asm flavor!");
Index: llvm/lib/Target/X86/X86AsmPrinter.h
diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.13 llvm/lib/Target/X86/X86AsmPrinter.h:1.14
--- llvm/lib/Target/X86/X86AsmPrinter.h:1.13 Mon Mar 6 20:23:26 2006
+++ llvm/lib/Target/X86/X86AsmPrinter.h Mon Mar 13 17:20:37 2006
@@ -17,6 +17,7 @@
#define X86ASMPRINTER_H
#include "X86.h"
+#include "X86TargetMachine.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/DwarfWriter.h"
#include "llvm/CodeGen/MachineDebugInfo.h"
@@ -25,7 +26,6 @@
namespace llvm {
-namespace x86 {
extern Statistic<> EmittedInsts;
@@ -56,7 +56,7 @@
struct X86SharedAsmPrinter : public AsmPrinter {
X86DwarfWriter DW;
- X86SharedAsmPrinter(std::ostream &O, TargetMachine &TM)
+ X86SharedAsmPrinter(std::ostream &O, X86TargetMachine &TM)
: AsmPrinter(O, TM), DW(O, this), forDarwin(false) { }
bool doInitialization(Module &M);
@@ -90,7 +90,6 @@
}
};
-} // end namespace x86
} // end namespace llvm
#endif
Index: llvm/lib/Target/X86/X86ELFWriter.cpp
diff -u llvm/lib/Target/X86/X86ELFWriter.cpp:1.2 llvm/lib/Target/X86/X86ELFWriter.cpp:1.3
--- llvm/lib/Target/X86/X86ELFWriter.cpp:1.2 Mon Jul 11 00:17:48 2005
+++ llvm/lib/Target/X86/X86ELFWriter.cpp Mon Mar 13 17:20:37 2006
@@ -13,15 +13,15 @@
//===----------------------------------------------------------------------===//
#include "X86.h"
+#include "X86TargetMachine.h"
#include "llvm/PassManager.h"
#include "llvm/CodeGen/ELFWriter.h"
-#include "llvm/Target/TargetMachine.h"
using namespace llvm;
namespace {
class X86ELFWriter : public ELFWriter {
public:
- X86ELFWriter(std::ostream &O, TargetMachine &TM) : ELFWriter(O, TM) {
+ X86ELFWriter(std::ostream &O, X86TargetMachine &TM) : ELFWriter(O, TM) {
e_machine = 3; // EM_386
}
};
@@ -31,7 +31,7 @@
/// as an ELF object file.
///
void llvm::addX86ELFObjectWriterPass(PassManager &FPM,
- std::ostream &O, TargetMachine &TM) {
+ std::ostream &O, X86TargetMachine &TM) {
X86ELFWriter *EW = new X86ELFWriter(O, TM);
FPM.add(EW);
FPM.add(createX86CodeEmitterPass(EW->getMachineCodeEmitter()));
Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
diff -u llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.55 llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.56
--- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.55 Tue Feb 28 15:13:57 2006
+++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Mar 13 17:20:37 2006
@@ -15,9 +15,10 @@
#define DEBUG_TYPE "isel"
#include "X86.h"
#include "X86InstrBuilder.h"
+#include "X86ISelLowering.h"
#include "X86RegisterInfo.h"
#include "X86Subtarget.h"
-#include "X86ISelLowering.h"
+#include "X86TargetMachine.h"
#include "llvm/GlobalValue.h"
#include "llvm/Instructions.h"
#include "llvm/Support/CFG.h"
@@ -90,8 +91,9 @@
unsigned GlobalBaseReg;
public:
- X86DAGToDAGISel(TargetMachine &TM)
- : SelectionDAGISel(X86Lowering), X86Lowering(TM) {
+ X86DAGToDAGISel(X86TargetMachine &TM)
+ : SelectionDAGISel(X86Lowering),
+ X86Lowering(*TM.getTargetLowering()) {
Subtarget = &TM.getSubtarget();
}
@@ -842,6 +844,6 @@
/// createX86ISelDag - This pass converts a legalized DAG into a
/// X86-specific DAG, ready for instruction scheduling.
///
-FunctionPass *llvm::createX86ISelDag(TargetMachine &TM) {
+FunctionPass *llvm::createX86ISelDag(X86TargetMachine &TM) {
return new X86DAGToDAGISel(TM);
}
Index: llvm/lib/Target/X86/X86ISelLowering.h
diff -u llvm/lib/Target/X86/X86ISelLowering.h:1.32 llvm/lib/Target/X86/X86ISelLowering.h:1.33
--- llvm/lib/Target/X86/X86ISelLowering.h:1.32 Thu Feb 23 14:41:18 2006
+++ llvm/lib/Target/X86/X86ISelLowering.h Mon Mar 13 17:20:37 2006
@@ -230,6 +230,12 @@
std::vector
getRegClassForInlineAsmConstraint(const std::string &Constraint,
MVT::ValueType VT) const;
+
+ /// isLegalAddressImmediate - Return true if the integer value or
+ /// GlobalValue can be used as the offset of the target addressing mode.
+ virtual bool isLegalAddressImmediate(int64_t V) const;
+ virtual bool isLegalAddressImmediate(GlobalValue *GV) const;
+
private:
// C Calling Convention implementation.
std::vector LowerCCCArguments(Function &F, SelectionDAG &DAG);
Index: llvm/lib/Target/X86/X86IntelAsmPrinter.cpp
diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.23 llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.24
--- llvm/lib/Target/X86/X86IntelAsmPrinter.cpp:1.23 Mon Mar 6 20:23:26 2006
+++ llvm/lib/Target/X86/X86IntelAsmPrinter.cpp Mon Mar 13 17:20:37 2006
@@ -20,7 +20,6 @@
#include "llvm/Support/Mangler.h"
#include "llvm/Target/TargetOptions.h"
using namespace llvm;
-using namespace x86;
/// runOnMachineFunction - This uses the printMachineInstruction()
/// method to print assembly for each instruction.
Index: llvm/lib/Target/X86/X86IntelAsmPrinter.h
diff -u llvm/lib/Target/X86/X86IntelAsmPrinter.h:1.10 llvm/lib/Target/X86/X86IntelAsmPrinter.h:1.11
--- llvm/lib/Target/X86/X86IntelAsmPrinter.h:1.10 Mon Mar 6 20:02:57 2006
+++ llvm/lib/Target/X86/X86IntelAsmPrinter.h Mon Mar 13 17:20:37 2006
@@ -16,14 +16,12 @@
#include "X86AsmPrinter.h"
#include "llvm/CodeGen/ValueTypes.h"
-#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/MRegisterInfo.h"
namespace llvm {
-namespace x86 {
struct X86IntelAsmPrinter : public X86SharedAsmPrinter {
- X86IntelAsmPrinter(std::ostream &O, TargetMachine &TM)
+ X86IntelAsmPrinter(std::ostream &O, X86TargetMachine &TM)
: X86SharedAsmPrinter(O, TM) { }
virtual const char *getPassName() const {
@@ -91,7 +89,6 @@
bool doInitialization(Module &M);
};
-} // end namespace x86
} // end namespace llvm
#endif
Index: llvm/lib/Target/X86/X86JITInfo.h
diff -u llvm/lib/Target/X86/X86JITInfo.h:1.7 llvm/lib/Target/X86/X86JITInfo.h:1.8
--- llvm/lib/Target/X86/X86JITInfo.h:1.7 Fri Jul 29 18:32:02 2005
+++ llvm/lib/Target/X86/X86JITInfo.h Mon Mar 13 17:20:37 2006
@@ -17,13 +17,13 @@
#include "llvm/Target/TargetJITInfo.h"
namespace llvm {
- class TargetMachine;
+ class X86TargetMachine;
class IntrinsicLowering;
class X86JITInfo : public TargetJITInfo {
- TargetMachine &TM;
+ X86TargetMachine &TM;
public:
- X86JITInfo(TargetMachine &tm) : TM(tm) {useGOT = 0;}
+ X86JITInfo(X86TargetMachine &tm) : TM(tm) {useGOT = 0;}
/// addPassesToJITCompile - Add passes to the specified pass manager to
/// implement a fast dynamic compiler for this target. Return true if this
Index: llvm/lib/Target/X86/X86TargetMachine.cpp
diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.106 llvm/lib/Target/X86/X86TargetMachine.cpp:1.107
--- llvm/lib/Target/X86/X86TargetMachine.cpp:1.106 Thu Mar 9 15:51:28 2006
+++ llvm/lib/Target/X86/X86TargetMachine.cpp Mon Mar 13 17:20:37 2006
@@ -79,7 +79,7 @@
Subtarget(M, FS),
FrameInfo(TargetFrameInfo::StackGrowsDown,
Subtarget.getStackAlignment(), -4),
- JITInfo(*this) {
+ JITInfo(*this), TLInfo(*this) {
if (getRelocationModel() == Reloc::Default)
if (Subtarget.isTargetDarwin())
setRelocationModel(Reloc::DynamicNoPIC);
@@ -97,7 +97,7 @@
FileType != TargetMachine::ObjectFile) return true;
// Run loop strength reduction before anything else.
- if (EnableX86LSR) PM.add(createLoopStrengthReducePass());
+ if (EnableX86LSR) PM.add(createLoopStrengthReducePass(1, &TLInfo));
// FIXME: Implement efficient support for garbage collection intrinsics.
PM.add(createLowerGCPass());
@@ -164,6 +164,10 @@
// The JIT should use static relocation model.
TM.setRelocationModel(Reloc::Static);
+ // Run loop strength reduction before anything else.
+ if (EnableX86LSR)
+ PM.add(createLoopStrengthReducePass(1, TM.getTargetLowering()));
+
// FIXME: Implement efficient support for garbage collection intrinsics.
PM.add(createLowerGCPass());
Index: llvm/lib/Target/X86/X86TargetMachine.h
diff -u llvm/lib/Target/X86/X86TargetMachine.h:1.31 llvm/lib/Target/X86/X86TargetMachine.h:1.32
--- llvm/lib/Target/X86/X86TargetMachine.h:1.31 Mon Nov 7 20:11:51 2005
+++ llvm/lib/Target/X86/X86TargetMachine.h Mon Mar 13 17:20:37 2006
@@ -17,18 +17,21 @@
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/PassManager.h"
+#include "X86.h"
#include "X86InstrInfo.h"
#include "X86JITInfo.h"
#include "X86Subtarget.h"
+#include "X86ISelLowering.h"
namespace llvm {
class IntrinsicLowering;
class X86TargetMachine : public TargetMachine {
- X86InstrInfo InstrInfo;
- X86Subtarget Subtarget;
- TargetFrameInfo FrameInfo;
- X86JITInfo JITInfo;
+ X86InstrInfo InstrInfo;
+ X86Subtarget Subtarget;
+ TargetFrameInfo FrameInfo;
+ X86JITInfo JITInfo;
+ X86TargetLowering TLInfo;
public:
X86TargetMachine(const Module &M, IntrinsicLowering *IL,
const std::string &FS);
@@ -37,6 +40,7 @@
virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
virtual TargetJITInfo *getJITInfo() { return &JITInfo; }
virtual const TargetSubtarget *getSubtargetImpl() const{ return &Subtarget; }
+ virtual X86TargetLowering *getTargetLowering() { return &TLInfo; }
virtual const MRegisterInfo *getRegisterInfo() const {
return &InstrInfo.getRegisterInfo();
}
From evan.cheng at apple.com Mon Mar 13 17:20:51 2006
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 13 Mar 2006 17:20:51 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/IA64/IA64.h IA64AsmPrinter.cpp
IA64Bundling.cpp IA64ISelDAGToDAG.cpp IA64TargetMachine.cpp
IA64TargetMachine.h
Message-ID: <200603132320.RAA32323@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/IA64:
IA64.h updated: 1.4 -> 1.5
IA64AsmPrinter.cpp updated: 1.24 -> 1.25
IA64Bundling.cpp updated: 1.2 -> 1.3
IA64ISelDAGToDAG.cpp updated: 1.37 -> 1.38
IA64TargetMachine.cpp updated: 1.11 -> 1.12
IA64TargetMachine.h updated: 1.5 -> 1.6
---
Log message:
Added getTargetLowering() to TargetMachine. Refactored targets to support this.
---
Diffs of the changes: (+22 -16)
IA64.h | 8 ++++----
IA64AsmPrinter.cpp | 3 ++-
IA64Bundling.cpp | 6 +++---
IA64ISelDAGToDAG.cpp | 7 ++++---
IA64TargetMachine.cpp | 3 ++-
IA64TargetMachine.h | 11 +++++++----
6 files changed, 22 insertions(+), 16 deletions(-)
Index: llvm/lib/Target/IA64/IA64.h
diff -u llvm/lib/Target/IA64/IA64.h:1.4 llvm/lib/Target/IA64/IA64.h:1.5
--- llvm/lib/Target/IA64/IA64.h:1.4 Tue Jan 24 20:23:38 2006
+++ llvm/lib/Target/IA64/IA64.h Mon Mar 13 17:20:37 2006
@@ -18,26 +18,26 @@
namespace llvm {
-class TargetMachine;
+class IA64TargetMachine;
class FunctionPass;
class IntrinsicLowering;
/// createIA64DAGToDAGInstructionSelector - This pass converts an LLVM
/// function into IA64 machine code in a sane, DAG->DAG transform.
///
-FunctionPass *createIA64DAGToDAGInstructionSelector(TargetMachine &TM);
+FunctionPass *createIA64DAGToDAGInstructionSelector(IA64TargetMachine &TM);
/// createIA64BundlingPass - This pass adds stop bits and bundles
/// instructions.
///
-FunctionPass *createIA64BundlingPass(TargetMachine &TM);
+FunctionPass *createIA64BundlingPass(IA64TargetMachine &TM);
/// createIA64CodePrinterPass - Returns a pass that prints the IA64
/// assembly code for a MachineFunction to the given output stream,
/// using the given target machine description. This should work
/// regardless of whether the function is in SSA form.
///
-FunctionPass *createIA64CodePrinterPass(std::ostream &o,TargetMachine &tm);
+FunctionPass *createIA64CodePrinterPass(std::ostream &o, IA64TargetMachine &tm);
} // End llvm namespace
Index: llvm/lib/Target/IA64/IA64AsmPrinter.cpp
diff -u llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.24 llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.25
--- llvm/lib/Target/IA64/IA64AsmPrinter.cpp:1.24 Thu Mar 9 00:14:35 2006
+++ llvm/lib/Target/IA64/IA64AsmPrinter.cpp Mon Mar 13 17:20:37 2006
@@ -374,7 +374,8 @@
/// assembly code for a MachineFunction to the given output stream, using
/// the given target machine description.
///
-FunctionPass *llvm::createIA64CodePrinterPass(std::ostream &o,TargetMachine &tm){
+FunctionPass *llvm::createIA64CodePrinterPass(std::ostream &o,
+ IA64TargetMachine &tm) {
return new IA64AsmPrinter(o, tm);
}
Index: llvm/lib/Target/IA64/IA64Bundling.cpp
diff -u llvm/lib/Target/IA64/IA64Bundling.cpp:1.2 llvm/lib/Target/IA64/IA64Bundling.cpp:1.3
--- llvm/lib/Target/IA64/IA64Bundling.cpp:1.2 Thu Jan 26 03:08:31 2006
+++ llvm/lib/Target/IA64/IA64Bundling.cpp Mon Mar 13 17:20:37 2006
@@ -37,9 +37,9 @@
/// Target machine description which we query for reg. names, data
/// layout, etc.
///
- TargetMachine &TM;
+ IA64TargetMachine &TM;
- IA64BundlingPass(TargetMachine &tm) : TM(tm) { }
+ IA64BundlingPass(IA64TargetMachine &tm) : TM(tm) { }
virtual const char *getPassName() const {
return "IA64 (Itanium) Bundling Pass";
@@ -64,7 +64,7 @@
/// createIA64BundlingPass - Returns a pass that adds STOP (;;) instructions
/// and arranges the result into bundles.
///
-FunctionPass *llvm::createIA64BundlingPass(TargetMachine &tm) {
+FunctionPass *llvm::createIA64BundlingPass(IA64TargetMachine &tm) {
return new IA64BundlingPass(tm);
}
Index: llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp
diff -u llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.37 llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.38
--- llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.37 Sat Feb 11 01:33:17 2006
+++ llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp Mon Mar 13 17:20:37 2006
@@ -42,8 +42,8 @@
IA64TargetLowering IA64Lowering;
unsigned GlobalBaseReg;
public:
- IA64DAGToDAGISel(TargetMachine &TM)
- : SelectionDAGISel(IA64Lowering), IA64Lowering(TM) {}
+ IA64DAGToDAGISel(IA64TargetMachine &TM)
+ : SelectionDAGISel(IA64Lowering), IA64Lowering(*TM.getTargetLowering()) {}
virtual bool runOnFunction(Function &Fn) {
// Make sure we re-emit a set of the global base reg if necessary
@@ -621,7 +621,8 @@
/// createIA64DAGToDAGInstructionSelector - This pass converts a legalized DAG
/// into an IA64-specific DAG, ready for instruction scheduling.
///
-FunctionPass *llvm::createIA64DAGToDAGInstructionSelector(TargetMachine &TM) {
+FunctionPass
+*llvm::createIA64DAGToDAGInstructionSelector(IA64TargetMachine &TM) {
return new IA64DAGToDAGISel(TM);
}
Index: llvm/lib/Target/IA64/IA64TargetMachine.cpp
diff -u llvm/lib/Target/IA64/IA64TargetMachine.cpp:1.11 llvm/lib/Target/IA64/IA64TargetMachine.cpp:1.12
--- llvm/lib/Target/IA64/IA64TargetMachine.cpp:1.11 Tue Jan 24 20:23:38 2006
+++ llvm/lib/Target/IA64/IA64TargetMachine.cpp Mon Mar 13 17:20:37 2006
@@ -79,7 +79,8 @@
IA64TargetMachine::IA64TargetMachine(const Module &M, IntrinsicLowering *IL,
const std::string &FS)
: TargetMachine("IA64", IL, true),
- FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0) { // FIXME? check this stuff
+ FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
+ TLInfo(*this) { // FIXME? check this stuff
}
// addPassesToEmitFile - We currently use all of the same passes as the JIT
Index: llvm/lib/Target/IA64/IA64TargetMachine.h
diff -u llvm/lib/Target/IA64/IA64TargetMachine.h:1.5 llvm/lib/Target/IA64/IA64TargetMachine.h:1.6
--- llvm/lib/Target/IA64/IA64TargetMachine.h:1.5 Mon Nov 7 20:11:51 2005
+++ llvm/lib/Target/IA64/IA64TargetMachine.h Mon Mar 13 17:20:37 2006
@@ -18,20 +18,23 @@
#include "llvm/Target/TargetFrameInfo.h"
#include "llvm/PassManager.h"
#include "IA64InstrInfo.h"
+#include "IA64ISelLowering.h"
namespace llvm {
class IntrinsicLowering;
class IA64TargetMachine : public TargetMachine {
- IA64InstrInfo InstrInfo;
- TargetFrameInfo FrameInfo;
+ IA64InstrInfo InstrInfo;
+ TargetFrameInfo FrameInfo;
//IA64JITInfo JITInfo;
+ IA64TargetLowering TLInfo;
public:
IA64TargetMachine(const Module &M, IntrinsicLowering *IL,
const std::string &FS);
- virtual const IA64InstrInfo *getInstrInfo() const { return &InstrInfo; }
- virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
+ virtual const IA64InstrInfo *getInstrInfo() const { return &InstrInfo; }
+ virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
+ virtual IA64TargetLowering *getTargetLowering() { return &TLInfo; }
virtual const MRegisterInfo *getRegisterInfo() const {
return &InstrInfo.getRegisterInfo();
}
From evan.cheng at apple.com Mon Mar 13 17:57:03 2006
From: evan.cheng at apple.com (Evan Cheng)
Date: Mon, 13 Mar 2006 17:57:03 -0600
Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
Message-ID: <200603132357.RAA32683@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/PowerPC:
PPCTargetMachine.cpp updated: 1.82 -> 1.83
---
Log message:
PPC LSR pass should use target lowering hooks.
---
Diffs of the changes: (+2 -2)
PPCTargetMachine.cpp | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
diff -u llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.82 llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.83
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.82 Mon Mar 13 17:20:37 2006
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp Mon Mar 13 17:56:51 2006
@@ -84,7 +84,7 @@
if (FileType != TargetMachine::AssemblyFile) return true;
// Run loop strength reduction before anything else.
- if (!Fast) PM.add(createLoopStrengthReducePass());
+ if (!Fast) PM.add(createLoopStrengthReducePass(1, &TLInfo));
// FIXME: Implement efficient support for garbage collection intrinsics.
PM.add(createLowerGCPass());
@@ -138,7 +138,7 @@
TM.setRelocationModel(Reloc::DynamicNoPIC);
// Run loop strength reduction before anything else.
- PM.add(createLoopStrengthReducePass());
+ PM.add(createLoopStrengthReducePass(1, TM.getTargetLowering()));
// FIXME: Implement efficient support for garbage collection intrinsics.
PM.add(createLowerGCPass());
From jlaskey at apple.com Mon Mar 13 19:53:22 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 13 Mar 2006 19:53:22 -0600
Subject: [llvm-commits]
CVS: llvm/test/Regression/CodeGen/Generic/DebugStuff.ll
Message-ID: <200603140153.TAA01172@zion.cs.uiuc.edu>
Changes in directory llvm/test/Regression/CodeGen/Generic:
DebugStuff.ll updated: 1.4 -> 1.5
---
Log message:
Remove the use of llvm.dbg.declare.
---
Diffs of the changes: (+3 -6)
DebugStuff.ll | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
Index: llvm/test/Regression/CodeGen/Generic/DebugStuff.ll
diff -u llvm/test/Regression/CodeGen/Generic/DebugStuff.ll:1.4 llvm/test/Regression/CodeGen/Generic/DebugStuff.ll:1.5
--- llvm/test/Regression/CodeGen/Generic/DebugStuff.ll:1.4 Wed Feb 15 11:20:59 2006
+++ llvm/test/Regression/CodeGen/Generic/DebugStuff.ll Mon Mar 13 19:53:11 2006
@@ -12,7 +12,6 @@
declare {}* %llvm.dbg.func.start(%lldb.global*)
declare {}* %llvm.dbg.region.start({}*)
declare {}* %llvm.dbg.region.end({}*)
-declare {}* %llvm.dbg.declare({}*, ...)
;; Global object anchors
%llvm.dbg.translation_units = linkonce global {} {}
@@ -90,16 +89,14 @@
%t = alloca int
%.1 = call {}* %llvm.dbg.func.start(%lldb.global* %d.foo)
%.2 = call {}* %llvm.dbg.stoppoint({}* %.1, uint 5, uint 2, %lldb.compile_unit* %d.compile_unit)
-
- %.3 = call {}*({}*, ...)* %llvm.dbg.declare({}* %.2, %lldb.local* %d.t, int* %t)
%tmp.0 = load int* %q
store int %tmp.0, int* %t
- %.4 = call {}* %llvm.dbg.stoppoint({}* %.3, uint 6, uint 2, %lldb.compile_unit* %d.compile_unit)
+ %.3 = call {}* %llvm.dbg.stoppoint({}* %.2, uint 6, uint 2, %lldb.compile_unit* %d.compile_unit)
%tmp.01 = load int* %t
%tmp.1 = add int %tmp.01, 1
store int %tmp.1, int* %q
- %.5 = call {}* %llvm.dbg.stoppoint({}* %.4, uint 7, uint 1, %lldb.compile_unit* %d.compile_unit)
- call {}* %llvm.dbg.region.end({}* %.5)
+ %.4 = call {}* %llvm.dbg.stoppoint({}* %.3, uint 7, uint 1, %lldb.compile_unit* %d.compile_unit)
+ call {}* %llvm.dbg.region.end({}* %.4)
ret void
}
From jlaskey at apple.com Mon Mar 13 20:00:47 2006
From: jlaskey at apple.com (Jim Laskey)
Date: Mon, 13 Mar 2006 20:00:47 -0600
Subject: [llvm-commits] CVS: llvm/lib/VMCore/AutoUpgrade.cpp
Message-ID: <200603140200.UAA01246@zion.cs.uiuc.edu>
Changes in directory llvm/lib/VMCore:
AutoUpgrade.cpp updated: 1.12 -> 1.13
---
Log message:
1. Handle removal of all arguments for a morphed intrinsic.
2. Remove the declaration of llvm.dbg.declare.
---
Diffs of the changes: (+4 -1)
AutoUpgrade.cpp | 5 ++++-
1 files changed, 4 insertions(+), 1 deletion(-)
Index: llvm/lib/VMCore/AutoUpgrade.cpp
diff -u llvm/lib/VMCore/AutoUpgrade.cpp:1.12 llvm/lib/VMCore/AutoUpgrade.cpp:1.13
--- llvm/lib/VMCore/AutoUpgrade.cpp:1.12 Mon Mar 13 07:07:37 2006
+++ llvm/lib/VMCore/AutoUpgrade.cpp Mon Mar 13 20:00:35 2006
@@ -97,6 +97,9 @@
if (F->getReturnType() != Type::VoidTy) {
return M->getOrInsertFunction(Name, Type::VoidTy, NULL);
}
+ } else if (Name == "llvm.dbg.declare") {
+ F->setName("");
+ return NULL;
}
break;
case 'i':
@@ -230,7 +233,7 @@
} else
Oprnds.push_back(UndefValue::get(NewFnTy->getParamType(i)));
}
- } else {
+ } else if (N) {
assert(N == (CI->getNumOperands() - 1) &&
"Upgraded function needs permutation");
for (unsigned i = 0; i != N; ++i) {
From reid at x10sys.com Mon Mar 13 23:39:51 2006
From: reid at x10sys.com (Reid Spencer)
Date: Mon, 13 Mar 2006 23:39:51 -0600
Subject: [llvm-commits] CVS: llvm/docs/AliasAnalysis.html Bugpoint.html
BytecodeFormat.html CFEBuildInstrs.html CodeGenerator.html
CodingStandards.html CommandLine.html CompilerDriver.html
CompilerWriterInfo.html ExtendingLLVM.html FAQ.html
GarbageCollection.html GettingStarted.html
GettingStartedVS.html HowToSubmitABug.html
LLVMVsTheWorld.html LangRef.html Lexicon.html
MakefileGuide.html ProgrammersManual.html Projects.html
SourceLevelDebugging.html Stacker.html SystemLibrary.html
TableGenFundamentals.html TestingGuide.html
UsingLibraries.html WritingAnLLVMBackend.html
WritingAnLLVMPass.html index.html
Message-ID: <200603140539.XAA02536@zion.cs.uiuc.edu>
Changes in directory llvm/docs:
AliasAnalysis.html updated: 1.26 -> 1.27
Bugpoint.html updated: 1.5 -> 1.6
BytecodeFormat.html updated: 1.50 -> 1.51
CFEBuildInstrs.html updated: 1.55 -> 1.56
CodeGenerator.html updated: 1.28 -> 1.29
CodingStandards.html updated: 1.26 -> 1.27
CommandLine.html updated: 1.39 -> 1.40
CompilerDriver.html updated: 1.11 -> 1.12
CompilerWriterInfo.html updated: 1.8 -> 1.9
ExtendingLLVM.html updated: 1.25 -> 1.26
FAQ.html updated: 1.30 -> 1.31
GarbageCollection.html updated: 1.7 -> 1.8
GettingStarted.html updated: 1.125 -> 1.126
GettingStartedVS.html updated: 1.5 -> 1.6
HowToSubmitABug.html updated: 1.25 -> 1.26
LLVMVsTheWorld.html updated: 1.8 -> 1.9
LangRef.html updated: 1.138 -> 1.139
Lexicon.html updated: 1.13 -> 1.14
MakefileGuide.html updated: 1.27 -> 1.28
ProgrammersManual.html updated: 1.89 -> 1.90
Projects.html updated: 1.19 -> 1.20
SourceLevelDebugging.html updated: 1.11 -> 1.12
Stacker.html updated: 1.19 -> 1.20
SystemLibrary.html updated: 1.9 -> 1.10
TableGenFundamentals.html updated: 1.14 -> 1.15
TestingGuide.html updated: 1.27 -> 1.28
UsingLibraries.html updated: 1.18 -> 1.19
WritingAnLLVMBackend.html updated: 1.9 -> 1.10
WritingAnLLVMPass.html updated: 1.43 -> 1.44
index.html updated: 1.50 -> 1.51
---
Log message:
Changes docs for llvm.cs.uiuc.edu -> llvm.org
---
Diffs of the changes: (+124 -124)
AliasAnalysis.html | 8 ++---
Bugpoint.html | 4 +-
BytecodeFormat.html | 8 ++---
CFEBuildInstrs.html | 7 ++--
CodeGenerator.html | 4 +-
CodingStandards.html | 4 +-
CommandLine.html | 4 +-
CompilerDriver.html | 4 +-
CompilerWriterInfo.html | 4 +-
ExtendingLLVM.html | 4 +-
FAQ.html | 8 ++---
GarbageCollection.html | 4 +-
GettingStarted.html | 14 ++++-----
GettingStartedVS.html | 10 +++---
HowToSubmitABug.html | 6 +--
LLVMVsTheWorld.html | 6 +--
LangRef.html | 4 +-
Lexicon.html | 6 +--
MakefileGuide.html | 4 +-
ProgrammersManual.html | 6 +--
Projects.html | 4 +-
SourceLevelDebugging.html | 4 +-
Stacker.html | 4 +-
SystemLibrary.html | 6 +--
TableGenFundamentals.html | 4 +-
TestingGuide.html | 10 +++---
UsingLibraries.html | 4 +-
WritingAnLLVMBackend.html | 4 +-
WritingAnLLVMPass.html | 70 +++++++++++++++++++++++-----------------------
index.html | 18 +++++------
30 files changed, 124 insertions(+), 123 deletions(-)
Index: llvm/docs/AliasAnalysis.html
diff -u llvm/docs/AliasAnalysis.html:1.26 llvm/docs/AliasAnalysis.html:1.27
--- llvm/docs/AliasAnalysis.html:1.26 Tue Jan 3 00:04:48 2006
+++ llvm/docs/AliasAnalysis.html Mon Mar 13 23:39:39 2006
@@ -75,7 +75,7 @@
same object, or are known to never point to the same object.
The LLVM AliasAnalysis
+href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html">AliasAnalysis
class is the primary interface used by clients and implementations of alias
analyses in the LLVM system. This class is the common interface between clients
of alias analysis information and the implementations providing it, and is
@@ -102,7 +102,7 @@
The AliasAnalysis
+href="http://llvm.org/doxygen/classllvm_1_1AliasAnalysis.html">AliasAnalysis
class defines the interface that the various alias analysis implementations
should support. This class exports two important enums: AliasResult
and ModRefResult which represent the result of an alias query or a
@@ -951,8 +951,8 @@
src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!">
Chris Lattner
- LLVM Compiler Infrastructure
- Last modified: $Date: 2006/01/03 06:04:48 $
+ LLVM Compiler Infrastructure
+ Last modified: $Date: 2006/03/14 05:39:39 $