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

2006-01-13 Thread Nate Begeman


Changes in directory llvm/lib/Target/PowerPC:

PPCISelLowering.cpp updated: 1.65 -> 1.66
---
Log message:

bswap implementation


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

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


Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.65 
llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.66
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.65Fri Jan 13 11:52:03 2006
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Fri Jan 13 21:14:10 2006
@@ -64,7 +64,8 @@
 setOperationAction(ISD::FSQRT, MVT::f32, Expand);
   }
   
-  // PowerPC does not have CTPOP or CTTZ
+  // PowerPC does not have BSWAP, CTPOP or CTTZ
+  setOperationAction(ISD::BSWAP, MVT::i32  , Expand);
   setOperationAction(ISD::CTPOP, MVT::i32  , Expand);
   setOperationAction(ISD::CTTZ , MVT::i32  , Expand);
   



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


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

2006-01-13 Thread Nate Begeman


Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAGISel.cpp updated: 1.124 -> 1.125
---
Log message:

Remove some duplicated code


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

 SelectionDAGISel.cpp |8 
 1 files changed, 8 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.124 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.125
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.124Fri Jan 13 
21:14:10 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp  Fri Jan 13 21:18:27 2006
@@ -990,15 +990,7 @@
 return 0;
   }
   case Intrinsic::bswap_i16:
-setValue(&I, DAG.getNode(ISD::BSWAP,
- getValue(I.getOperand(1)).getValueType(),
- getValue(I.getOperand(1;
-return 0;
   case Intrinsic::bswap_i32:
-setValue(&I, DAG.getNode(ISD::BSWAP,
- getValue(I.getOperand(1)).getValueType(),
- getValue(I.getOperand(1;
-return 0;
   case Intrinsic::bswap_i64:
 setValue(&I, DAG.getNode(ISD::BSWAP,
  getValue(I.getOperand(1)).getValueType(),



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


[llvm-commits] CVS: llvm/lib/Target/IA64/IA64ISelLowering.cpp IA64ISelPattern.cpp

2006-01-13 Thread Nate Begeman


Changes in directory llvm/lib/Target/IA64:

IA64ISelLowering.cpp updated: 1.19 -> 1.20
IA64ISelPattern.cpp updated: 1.75 -> 1.76
---
Log message:

bswap implementation


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

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


Index: llvm/lib/Target/IA64/IA64ISelLowering.cpp
diff -u llvm/lib/Target/IA64/IA64ISelLowering.cpp:1.19 
llvm/lib/Target/IA64/IA64ISelLowering.cpp:1.20
--- llvm/lib/Target/IA64/IA64ISelLowering.cpp:1.19  Thu Jan 12 20:40:58 2006
+++ llvm/lib/Target/IA64/IA64ISelLowering.cpp   Fri Jan 13 21:14:10 2006
@@ -82,6 +82,7 @@
   setOperationAction(ISD::CTLZ , MVT::i64  , Expand);
   setOperationAction(ISD::ROTL , MVT::i64  , Expand);
   setOperationAction(ISD::ROTR , MVT::i64  , Expand);
+  setOperationAction(ISD::BSWAP, MVT::i64  , Expand);  // mux @rev
 
   // Not implemented yet.
   setOperationAction(ISD::STACKSAVE, MVT::Other, Expand);


Index: llvm/lib/Target/IA64/IA64ISelPattern.cpp
diff -u llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.75 
llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.76
--- llvm/lib/Target/IA64/IA64ISelPattern.cpp:1.75   Thu Jan 12 20:40:58 2006
+++ llvm/lib/Target/IA64/IA64ISelPattern.cppFri Jan 13 21:14:10 2006
@@ -98,6 +98,7 @@
   setOperationAction(ISD::CTLZ , MVT::i64  , Expand);
   setOperationAction(ISD::ROTL , MVT::i64  , Expand);
   setOperationAction(ISD::ROTR , MVT::i64  , Expand);
+  setOperationAction(ISD::BSWAP, MVT::i64  , Expand);  // mux @rev
   // FIXME: implement mulhs (xma.h) and mulhu (xma.hu)
   setOperationAction(ISD::MULHS , MVT::i64  , Expand);
   setOperationAction(ISD::MULHU , MVT::i64  , Expand);



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


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

2006-01-13 Thread Nate Begeman


Changes in directory llvm/lib/Target/Alpha:

AlphaISelLowering.cpp updated: 1.20 -> 1.21
---
Log message:

bswap implementation


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

 AlphaISelLowering.cpp |1 +
 1 files changed, 1 insertion(+)


Index: llvm/lib/Target/Alpha/AlphaISelLowering.cpp
diff -u llvm/lib/Target/Alpha/AlphaISelLowering.cpp:1.20 
llvm/lib/Target/Alpha/AlphaISelLowering.cpp:1.21
--- llvm/lib/Target/Alpha/AlphaISelLowering.cpp:1.20Thu Jan 12 20:42:53 2006
+++ llvm/lib/Target/Alpha/AlphaISelLowering.cpp Fri Jan 13 21:14:10 2006
@@ -81,6 +81,7 @@
 setOperationAction(ISD::CTTZ , MVT::i64  , Expand);
 setOperationAction(ISD::CTLZ , MVT::i64  , Expand);
   }
+  setOperationAction(ISD::BSWAP, MVT::i64, Expand);
   setOperationAction(ISD::ROTL , MVT::i64, Expand);
   setOperationAction(ISD::ROTR , MVT::i64, Expand);
   



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


[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp SelectionDAGISel.cpp

2006-01-13 Thread Nate Begeman


Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.262 -> 1.263
SelectionDAGISel.cpp updated: 1.123 -> 1.124
---
Log message:

bswap implementation


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

 LegalizeDAG.cpp  |   68 +++
 SelectionDAGISel.cpp |   15 +++
 2 files changed, 83 insertions(+)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.262 
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.263
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.262 Fri Jan 13 11:48:44 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp   Fri Jan 13 21:14:10 2006
@@ -2217,6 +2217,58 @@
 }
 break;
 
+  case ISD::BSWAP:
+Tmp1 = LegalizeOp(Node->getOperand(0));   // Op
+switch (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0))) {
+  case TargetLowering::Legal:
+if (Tmp1 != Node->getOperand(0))
+  Result = DAG.getNode(Node->getOpcode(), Node->getValueType(0), Tmp1);
+break;
+  case TargetLowering::Promote: {
+MVT::ValueType OVT = Tmp1.getValueType();
+MVT::ValueType NVT = TLI.getTypeToPromoteTo(Node->getOpcode(), OVT);
+unsigned DiffBits = getSizeInBits(NVT) - getSizeInBits(OVT);
+
+Tmp1 = DAG.getNode(ISD::ZERO_EXTEND, NVT, Tmp1);
+Tmp1 = DAG.getNode(ISD::BSWAP, NVT, Tmp1);
+Result = DAG.getNode(ISD::SRL, NVT, Tmp1,
+ DAG.getConstant(DiffBits, 
TLI.getShiftAmountTy()));
+break;
+  }
+  case TargetLowering::Custom:
+assert(0 && "Cannot custom legalize this yet!");
+  case TargetLowering::Expand: {
+MVT::ValueType VT = Tmp1.getValueType();
+switch (VT) {
+default: assert(0 && "Unhandled Expand type in BSWAP!"); abort();
+case MVT::i16:
+  Tmp2 = DAG.getNode(ISD::SHL, VT, Tmp1, 
+ DAG.getConstant(8, TLI.getShiftAmountTy()));
+  Tmp1 = DAG.getNode(ISD::SRL, VT, Tmp1,
+ DAG.getConstant(8, TLI.getShiftAmountTy()));
+  Result = DAG.getNode(ISD::OR, VT, Tmp1, Tmp2);
+  break;
+case MVT::i32:
+  Tmp4 = DAG.getNode(ISD::SHL, VT, Tmp1, 
+ DAG.getConstant(24, TLI.getShiftAmountTy()));
+  Tmp3 = DAG.getNode(ISD::SHL, VT, Tmp1, 
+ DAG.getConstant(8, TLI.getShiftAmountTy()));
+  Tmp2 = DAG.getNode(ISD::SRL, VT, Tmp1, 
+ DAG.getConstant(8, TLI.getShiftAmountTy()));
+  Tmp1 = DAG.getNode(ISD::SRL, VT, Tmp1, 
+ DAG.getConstant(24, TLI.getShiftAmountTy()));
+  Tmp3 = DAG.getNode(ISD::AND, VT, Tmp3, DAG.getConstant(0xFF, 
VT));
+  Tmp2 = DAG.getNode(ISD::AND, VT, Tmp2, DAG.getConstant(0xFF00, VT));
+  Tmp4 = DAG.getNode(ISD::OR, VT, Tmp4, Tmp3);
+  Tmp2 = DAG.getNode(ISD::OR, VT, Tmp2, Tmp1);
+  Result = DAG.getNode(ISD::OR, VT, Tmp4, Tmp2);
+  break;
+}
+break;
+  }
+}
+break;
+
   case ISD::CTPOP:
   case ISD::CTTZ:
   case ISD::CTLZ:
@@ -3027,6 +3079,14 @@
 AddLegalizedOperand(Op.getValue(1), Result.getValue(1));
 break;
   }
+  case ISD::BSWAP:
+Tmp1 = Node->getOperand(0);
+Tmp1 = DAG.getNode(ISD::ZERO_EXTEND, NVT, Tmp1);
+Tmp1 = DAG.getNode(ISD::BSWAP, NVT, Tmp1);
+Result = DAG.getNode(ISD::SRL, NVT, Tmp1,
+ DAG.getConstant(getSizeInBits(NVT) - 
getSizeInBits(VT),
+ TLI.getShiftAmountTy()));
+break;
   case ISD::CTPOP:
   case ISD::CTTZ:
   case ISD::CTLZ:
@@ -3636,6 +3696,14 @@
 Lo = DAG.getNode(ISD::SIGN_EXTEND_INREG, NVT, Lo, Node->getOperand(1));
 break;
 
+  case ISD::BSWAP: {
+ExpandOp(Node->getOperand(0), Lo, Hi);
+SDOperand TempLo = DAG.getNode(ISD::BSWAP, NVT, Hi);
+Hi = DAG.getNode(ISD::BSWAP, NVT, Lo);
+Lo = TempLo;
+break;
+  }
+
   case ISD::CTPOP:
 ExpandOp(Node->getOperand(0), Lo, Hi);
 Lo = DAG.getNode(ISD::ADD, NVT,  // ctpop(HL) -> ctpop(H)+ctpop(L)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.123 
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.124
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.123Thu Jan 12 
20:50:02 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp  Fri Jan 13 21:14:10 2006
@@ -989,6 +989,21 @@
 DAG.setRoot(Tmp.getValue(1));
 return 0;
   }
+  case Intrinsic::bswap_i16:
+setValue(&I, DAG.getNode(ISD::BSWAP,
+ getValue(I.getOperand(1)).getValueType(),
+ getValue(I.getOperand(1;
+return 0;
+  case Intrinsic::bswap_i32:
+setValue(&I, DAG.getNode(ISD::BSWAP,
+ getValue(I.getOperand(1)).getValueTy

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

2006-01-13 Thread Nate Begeman


Changes in directory llvm/lib/Target:

TargetSelectionDAG.td updated: 1.43 -> 1.44
---
Log message:

bswap implementation


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

 TargetSelectionDAG.td |1 +
 1 files changed, 1 insertion(+)


Index: llvm/lib/Target/TargetSelectionDAG.td
diff -u llvm/lib/Target/TargetSelectionDAG.td:1.43 
llvm/lib/Target/TargetSelectionDAG.td:1.44
--- llvm/lib/Target/TargetSelectionDAG.td:1.43  Wed Jan 11 15:21:00 2006
+++ llvm/lib/Target/TargetSelectionDAG.td   Fri Jan 13 21:14:10 2006
@@ -240,6 +240,7 @@
 [SDNPCommutative, SDNPAssociative]>;
 
 def sext_inreg : SDNode<"ISD::SIGN_EXTEND_INREG", SDTExtInreg>;
+def bswap  : SDNode<"ISD::BSWAP"  , SDTIntUnaryOp>;
 def ctlz   : SDNode<"ISD::CTLZ"   , SDTIntUnaryOp>;
 def cttz   : SDNode<"ISD::CTTZ"   , SDTIntUnaryOp>;
 def ctpop  : SDNode<"ISD::CTPOP"  , SDTIntUnaryOp>;



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


[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp X86InstrInfo.td

2006-01-13 Thread Nate Begeman


Changes in directory llvm/lib/Target/X86:

X86ISelLowering.cpp updated: 1.40 -> 1.41
X86InstrInfo.td updated: 1.204 -> 1.205
---
Log message:

bswap implementation


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

 X86ISelLowering.cpp |2 ++
 X86InstrInfo.td |4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)


Index: llvm/lib/Target/X86/X86ISelLowering.cpp
diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.40 
llvm/lib/Target/X86/X86ISelLowering.cpp:1.41
--- llvm/lib/Target/X86/X86ISelLowering.cpp:1.40Fri Jan 13 13:51:46 2006
+++ llvm/lib/Target/X86/X86ISelLowering.cpp Fri Jan 13 21:14:10 2006
@@ -109,6 +109,7 @@
   setOperationAction(ISD::READCYCLECOUNTER , MVT::i64  , Custom);
 
   if (!X86DAGIsel) {
+setOperationAction(ISD::BSWAP  , MVT::i32  , Expand);
 setOperationAction(ISD::ROTL   , MVT::i8   , Expand);
 setOperationAction(ISD::ROTR   , MVT::i8   , Expand);
 setOperationAction(ISD::ROTL   , MVT::i16  , Expand);
@@ -116,6 +117,7 @@
 setOperationAction(ISD::ROTL   , MVT::i32  , Expand);
 setOperationAction(ISD::ROTR   , MVT::i32  , Expand);
   }
+  setOperationAction(ISD::BSWAP, MVT::i16  , Expand);
 
   setOperationAction(ISD::READIO   , MVT::i1   , Expand);
   setOperationAction(ISD::READIO   , MVT::i8   , Expand);


Index: llvm/lib/Target/X86/X86InstrInfo.td
diff -u llvm/lib/Target/X86/X86InstrInfo.td:1.204 
llvm/lib/Target/X86/X86InstrInfo.td:1.205
--- llvm/lib/Target/X86/X86InstrInfo.td:1.204   Fri Jan 13 19:18:49 2006
+++ llvm/lib/Target/X86/X86InstrInfo.td Fri Jan 13 21:14:10 2006
@@ -518,7 +518,9 @@
 
 let isTwoAddress = 1 in   // R32 = bswap R32
   def BSWAP32r : I<0xC8, AddRegFrm,
-   (ops R32:$dst, R32:$src), "bswap{l} $dst", []>, TB;
+   (ops R32:$dst, R32:$src),
+   "bswap{l} $dst", 
+   [(set R32:$dst, (bswap R32:$src))]>, TB;
 
 def XCHG8rr  : I<0x86, MRMDestReg,// xchg R8, R8
  (ops R8:$src1, R8:$src2),



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


[llvm-commits] CVS: llvm/test/Regression/CodeGen/X86/bswap.ll

2006-01-13 Thread Nate Begeman


Changes in directory llvm/test/Regression/CodeGen/X86:

bswap.ll added (r1.1)
---
Log message:

bswap implementation


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

 bswap.ll |   23 +++
 1 files changed, 23 insertions(+)


Index: llvm/test/Regression/CodeGen/X86/bswap.ll
diff -c /dev/null llvm/test/Regression/CodeGen/X86/bswap.ll:1.1
*** /dev/null   Fri Jan 13 21:14:20 2006
--- llvm/test/Regression/CodeGen/X86/bswap.ll   Fri Jan 13 21:14:10 2006
***
*** 0 
--- 1,23 
+ ; bswap should be constant folded when it is passed a constant argument
+ 
+ ; RUN: llvm-as < %s | llc -march=x86 -enable-x86-dag-isel | grep bswapl | wc 
-l | grep 3 &&
+ ; RUN: llvm-as < %s | llc -march=x86 -enable-x86-dag-isel | grep rolw | wc -l 
| grep 1
+ 
+ declare ushort %llvm.bswap.i16(ushort)
+ declare uint %llvm.bswap.i32(uint)
+ declare ulong %llvm.bswap.i64(ulong)
+ 
+ ushort %W(ushort %A) {
+   %Z = call ushort %llvm.bswap.i16(ushort %A)
+   ret ushort %Z
+ }
+ 
+ uint %X(uint %A) {
+   %Z = call uint %llvm.bswap.i32(uint %A)
+   ret uint %Z
+ }
+ 
+ ulong %Y(ulong %A) {
+   %Z = call ulong %llvm.bswap.i64(ulong %A)
+   ret ulong %Z
+ }



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


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

2006-01-13 Thread Nate Begeman


Changes in directory llvm/lib/Target/SparcV8:

SparcV8ISelDAGToDAG.cpp updated: 1.49 -> 1.50
---
Log message:

bswap implementation


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

 SparcV8ISelDAGToDAG.cpp |1 +
 1 files changed, 1 insertion(+)


Index: llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp
diff -u llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.49 
llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.50
--- llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp:1.49Thu Jan 12 
20:42:53 2006
+++ llvm/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp Fri Jan 13 21:14:10 2006
@@ -150,6 +150,7 @@
   setOperationAction(ISD::CTLZ , MVT::i32, Expand);
   setOperationAction(ISD::ROTL , MVT::i32, Expand);
   setOperationAction(ISD::ROTR , MVT::i32, Expand);
+  setOperationAction(ISD::BSWAP, MVT::i32, Expand);
 
   setOperationAction(ISD::SHL_PARTS, MVT::i32, Expand);
   setOperationAction(ISD::SRA_PARTS, MVT::i32, Expand);



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


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

2006-01-13 Thread Jeff Cohen


Changes in directory llvm/include/llvm/Support:

MathExtras.h updated: 1.28 -> 1.29
---
Log message:

Fix generous source of VC++ truncation warnings.

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

 MathExtras.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/include/llvm/Support/MathExtras.h
diff -u llvm/include/llvm/Support/MathExtras.h:1.28 
llvm/include/llvm/Support/MathExtras.h:1.29
--- llvm/include/llvm/Support/MathExtras.h:1.28 Fri Jan 13 19:25:24 2006
+++ llvm/include/llvm/Support/MathExtras.h  Fri Jan 13 20:17:20 2006
@@ -100,8 +100,8 @@
 // ByteSwap_64 - This function returns a byte-swapped representation of the
 // 64-bit argument, Value.
 inline uint64_t ByteSwap_64(uint64_t Value) {
-  uint64_t Hi = ByteSwap_32(Value);
-  uint64_t Lo = ByteSwap_32(Value >> 32);
+  uint64_t Hi = ByteSwap_32(unsigned(Value));
+  uint64_t Lo = ByteSwap_32(unsigned(Value >> 32));
   return (Hi << 32) | Lo;
 }
 



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


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

2006-01-13 Thread Nate Begeman


Changes in directory llvm/docs:

ExtendingLLVM.html updated: 1.19 -> 1.20
---
Log message:

Fix the instructions for adding an intrinsic.


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

 ExtendingLLVM.html |   12 
 1 files changed, 8 insertions(+), 4 deletions(-)


Index: llvm/docs/ExtendingLLVM.html
diff -u llvm/docs/ExtendingLLVM.html:1.19 llvm/docs/ExtendingLLVM.html:1.20
--- llvm/docs/ExtendingLLVM.html:1.19   Sat Nov 12 20:09:55 2005
+++ llvm/docs/ExtendingLLVM.htmlFri Jan 13 19:27:10 2006
@@ -97,9 +97,13 @@
 not access memory or does not write to memory, add it to the relevant list
 of functions.
 
-llvm/lib/Transforms/Utils/Local.cpp: If it is possible to constant
-fold your intrinsic, add support to it in the canConstantFoldCallTo 
and
-ConstantFoldCall functions.
+llvm/lib/Analysis/ConstantFolding.cpp: If it is possible to 
+constant fold your intrinsic, add support to it in the 
+canConstantFoldCallTo and ConstantFoldCall 
functions.
+
+llvm/lib/Transforms/Utils/Local.cpp: If your intrinsic has no 
side-
+effects, add it to the list of intrinsics in the 
+isInstructionTriviallyDead function.
 
 Test your intrinsic
 
@@ -322,7 +326,7 @@
 
   http://llvm.cs.uiuc.edu";>The LLVM Compiler Infrastructure
   
-  Last modified: $Date: 2005/11/13 02:09:55 $
+  Last modified: $Date: 2006/01/14 01:27:10 $
 
 
 



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


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

2006-01-13 Thread Nate Begeman


Changes in directory llvm/include/llvm/Support:

MathExtras.h updated: 1.27 -> 1.28
---
Log message:

Add bswap intrinsics as documented in the Language Reference


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

 MathExtras.h |   26 ++
 1 files changed, 26 insertions(+)


Index: llvm/include/llvm/Support/MathExtras.h
diff -u llvm/include/llvm/Support/MathExtras.h:1.27 
llvm/include/llvm/Support/MathExtras.h:1.28
--- llvm/include/llvm/Support/MathExtras.h:1.27 Fri Oct  7 00:29:25 2005
+++ llvm/include/llvm/Support/MathExtras.h  Fri Jan 13 19:25:24 2006
@@ -79,6 +79,32 @@
   return Value && !(Value & (Value - 1LL));
 }
 
+// ByteSwap_16 - This function returns a byte-swapped representation of the
+// 16-bit argument, Value.
+inline unsigned short ByteSwap_16(unsigned short Value) {
+  unsigned short Hi = Value << 8;
+  unsigned short Lo = Value >> 8;
+  return Hi | Lo;
+}
+
+// ByteSwap_32 - This function returns a byte-swapped representation of the
+// 32-bit argument, Value.
+inline unsigned ByteSwap_32(unsigned Value) {
+  unsigned Byte0 = Value & 0x00FF;
+  unsigned Byte1 = Value & 0xFF00;
+  unsigned Byte2 = Value & 0x00FF;
+  unsigned Byte3 = Value & 0xFF00;
+  return (Byte0 << 24) | (Byte1 << 8) | (Byte2 >> 8) | (Byte3 >> 24);
+}
+
+// ByteSwap_64 - This function returns a byte-swapped representation of the
+// 64-bit argument, Value.
+inline uint64_t ByteSwap_64(uint64_t Value) {
+  uint64_t Hi = ByteSwap_32(Value);
+  uint64_t Lo = ByteSwap_32(Value >> 32);
+  return (Hi << 32) | Lo;
+}
+
 // CountLeadingZeros_32 - this function performs the platform optimal form of
 // counting the number of zeros from the most significant bit to the first one
 // bit.  Ex. CountLeadingZeros_32(0x00F000FF) == 8.



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


[llvm-commits] CVS: llvm/lib/Target/PowerPC/README.txt

2006-01-13 Thread Nate Begeman


Changes in directory llvm/lib/Target/PowerPC:

README.txt updated: 1.42 -> 1.43
---
Log message:

Remove some redundant stuff out of the readme.


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

 README.txt |   18 --
 1 files changed, 18 deletions(-)


Index: llvm/lib/Target/PowerPC/README.txt
diff -u llvm/lib/Target/PowerPC/README.txt:1.42 
llvm/lib/Target/PowerPC/README.txt:1.43
--- llvm/lib/Target/PowerPC/README.txt:1.42 Fri Dec 23 19:00:15 2005
+++ llvm/lib/Target/PowerPC/README.txt  Fri Jan 13 19:24:22 2006
@@ -219,24 +219,6 @@
 
 ===-===
 
-For this testcase:
-int f1(int a, int b) { return (a&0xF)|(b&0xF0); }
-
-We currently emit:
-_f1:
-rlwinm r2, r4, 0, 24, 27
-rlwimi r2, r3, 0, 28, 31
-or r3, r2, r2
-blr
-
-We could emit:
-_f1:
-rlwinm r4, r4, 0, 24, 27
-rlwimi r3, r4, 0, 0, 27
-blr
-
-===-===
-
 No loads or stores of the constants should be needed:
 
 struct foo { double X, Y; };



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


[llvm-commits] CVS: llvm/lib/Analysis/BasicAliasAnalysis.cpp ConstantFolding.cpp

2006-01-13 Thread Nate Begeman


Changes in directory llvm/lib/Analysis:

BasicAliasAnalysis.cpp updated: 1.75 -> 1.76
ConstantFolding.cpp updated: 1.1 -> 1.2
---
Log message:

Add bswap intrinsics as documented in the Language Reference


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

 BasicAliasAnalysis.cpp |3 ++-
 ConstantFolding.cpp|   15 +++
 2 files changed, 17 insertions(+), 1 deletion(-)


Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.75 
llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.76
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.75   Fri Nov 11 13:02:54 2005
+++ llvm/lib/Analysis/BasicAliasAnalysis.cppFri Jan 13 19:25:24 2006
@@ -708,7 +708,8 @@
 static const char *DoesntAccessMemoryTable[] = {
   // LLVM intrinsics:
   "llvm.frameaddress", "llvm.returnaddress", "llvm.readport",
-  "llvm.isunordered", "llvm.sqrt", "llvm.ctpop", "llvm.ctlz", "llvm.cttz",
+  "llvm.isunordered", "llvm.sqrt", "llvm.bswap.i16", "llvm.bswap.i32",
+  "llvm.bswap.i64", "llvm.ctpop", "llvm.ctlz", "llvm.cttz",
 
   "abs", "labs", "llabs", "imaxabs", "fabs", "fabsf", "fabsl",
   "trunc", "truncf", "truncl", "ldexp",


Index: llvm/lib/Analysis/ConstantFolding.cpp
diff -u llvm/lib/Analysis/ConstantFolding.cpp:1.1 
llvm/lib/Analysis/ConstantFolding.cpp:1.2
--- llvm/lib/Analysis/ConstantFolding.cpp:1.1   Thu Oct 27 11:00:11 2005
+++ llvm/lib/Analysis/ConstantFolding.cpp   Fri Jan 13 19:25:24 2006
@@ -37,6 +37,13 @@
   switch (F->getIntrinsicID()) {
   case Intrinsic::isunordered:
   case Intrinsic::sqrt:
+  case Intrinsic::bswap_i16:
+  case Intrinsic::bswap_i32:
+  case Intrinsic::bswap_i64:
+  // FIXME: these should be constant folded as well
+  //case Intrinsic::ctpop:
+  //case Intrinsic::ctlz:
+  //case Intrinsic::cttz:
 return true;
   default: break;
   }
@@ -142,6 +149,14 @@
 default:
   break;
   }
+} else if (ConstantUInt *Op = dyn_cast(Operands[0])) {
+  uint64_t V = Op->getValue();
+  if (Name == "llvm.bswap.i16")
+return ConstantUInt::get(Ty, ByteSwap_16(V));
+  else if (Name == "llvm.bswap.i32")
+return ConstantUInt::get(Ty, ByteSwap_32(V));
+  else if (Name == "llvm.bswap.i64")
+return ConstantUInt::get(Ty, ByteSwap_64(V));
 }
   } else if (Operands.size() == 2) {
 if (ConstantFP *Op1 = dyn_cast(Operands[0])) {



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


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

2006-01-13 Thread Nate Begeman


Changes in directory llvm/include/llvm:

Intrinsics.h updated: 1.34 -> 1.35
---
Log message:

Add bswap intrinsics as documented in the Language Reference


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

 Intrinsics.h |   18 ++
 1 files changed, 10 insertions(+), 8 deletions(-)


Index: llvm/include/llvm/Intrinsics.h
diff -u llvm/include/llvm/Intrinsics.h:1.34 llvm/include/llvm/Intrinsics.h:1.35
--- llvm/include/llvm/Intrinsics.h:1.34 Thu Jan 12 20:15:02 2006
+++ llvm/include/llvm/Intrinsics.h  Fri Jan 13 19:25:24 2006
@@ -58,19 +58,21 @@
 dbg_func_start,   // Start of a function
 dbg_declare,  // Declare a local object
 
-
-// Standard libc functions.
+// Standard C library intrinsics.
 memcpy, // Copy non-overlapping memory blocks
 memmove,// Copy potentially overlapping memory blocks
 memset, // Fill memory with a byte value
-
-// libm related functions.
 isunordered,// Return true if either argument is a NaN
-ctpop, //count population
-ctlz, //count leading zeros
-cttz, //count trailing zeros
-sqrt, //square root
+sqrt,   // Square root
 
+// Bit manipulation instrinsics.
+bswap_i16,  // Byteswap 16 bits
+bswap_i32,  // Byteswap 32 bits
+bswap_i64,  // Byteswap 64 bits
+ctpop,  // Count population
+ctlz,   // Count leading zeros
+cttz,   // Count trailing zeros
+
 // Input/Output intrinsics.
 readport,
 writeport,



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


[llvm-commits] CVS: llvm/lib/Transforms/Utils/Local.cpp

2006-01-13 Thread Nate Begeman


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.48 -> 1.49
---
Log message:

Add bswap intrinsics as documented in the Language Reference


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

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


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.48 
llvm/lib/Transforms/Utils/Local.cpp:1.49
--- llvm/lib/Transforms/Utils/Local.cpp:1.48Fri Jan 13 15:31:54 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Fri Jan 13 19:25:24 2006
@@ -298,6 +298,9 @@
   case Intrinsic::frameaddress:
   case Intrinsic::stacksave:
   case Intrinsic::isunordered:
+  case Intrinsic::bswap_i16:
+  case Intrinsic::bswap_i32:
+  case Intrinsic::bswap_i64:
   case Intrinsic::ctpop:
   case Intrinsic::ctlz:
   case Intrinsic::cttz:



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


[llvm-commits] CVS: llvm/test/Regression/Transforms/ConstProp/bswap.ll

2006-01-13 Thread Nate Begeman


Changes in directory llvm/test/Regression/Transforms/ConstProp:

bswap.ll added (r1.1)
---
Log message:

Add bswap intrinsics as documented in the Language Reference


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

 bswap.ll |   22 ++
 1 files changed, 22 insertions(+)


Index: llvm/test/Regression/Transforms/ConstProp/bswap.ll
diff -c /dev/null llvm/test/Regression/Transforms/ConstProp/bswap.ll:1.1
*** /dev/null   Fri Jan 13 19:25:34 2006
--- llvm/test/Regression/Transforms/ConstProp/bswap.ll  Fri Jan 13 19:25:24 2006
***
*** 0 
--- 1,22 
+ ; bswap should be constant folded when it is passed a constant argument
+ 
+ ; RUN: llvm-as < %s | opt -constprop | llvm-dis | not grep call
+ 
+ declare ushort %llvm.bswap.i16(ushort)
+ declare uint %llvm.bswap.i32(uint)
+ declare ulong %llvm.bswap.i64(ulong)
+ 
+ ushort %W() {
+   %Z = call ushort %llvm.bswap.i16(ushort 1)
+   ret ushort %Z
+ }
+ 
+ uint %X() {
+   %Z = call uint %llvm.bswap.i32(uint 1)
+   ret uint %Z
+ }
+ 
+ ulong %Y() {
+   %Z = call ulong %llvm.bswap.i64(ulong 1)
+   ret ulong %Z
+ }



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


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

2006-01-13 Thread Nate Begeman


Changes in directory llvm/lib/VMCore:

Function.cpp updated: 1.97 -> 1.98
Verifier.cpp updated: 1.139 -> 1.140
---
Log message:

Add bswap intrinsics as documented in the Language Reference


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

 Function.cpp |5 +
 Verifier.cpp |   30 ++
 2 files changed, 35 insertions(+)


Index: llvm/lib/VMCore/Function.cpp
diff -u llvm/lib/VMCore/Function.cpp:1.97 llvm/lib/VMCore/Function.cpp:1.98
--- llvm/lib/VMCore/Function.cpp:1.97   Thu Jan 12 20:15:39 2006
+++ llvm/lib/VMCore/Function.cppFri Jan 13 19:25:24 2006
@@ -207,6 +207,11 @@
   assert(getName().size() != 5 && "'llvm.' is an invalid intrinsic name!");
 
   switch (getName()[5]) {
+  case 'b':
+if (getName() == "llvm.bswap.i16") return Intrinsic::bswap_i16;
+if (getName() == "llvm.bswap.i32") return Intrinsic::bswap_i32;
+if (getName() == "llvm.bswap.i64") return Intrinsic::bswap_i64;
+break;
   case 'c':
 if (getName() == "llvm.ctpop") return Intrinsic::ctpop;
 if (getName() == "llvm.cttz") return Intrinsic::cttz;


Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.139 llvm/lib/VMCore/Verifier.cpp:1.140
--- llvm/lib/VMCore/Verifier.cpp:1.139  Thu Jan 12 20:15:39 2006
+++ llvm/lib/VMCore/Verifier.cppFri Jan 13 19:25:24 2006
@@ -749,6 +749,36 @@
 NumArgs = 0;
 break;
 
+  case Intrinsic::bswap_i16:
+Assert1(FT->getNumParams() == 1,
+"Illegal # arguments for intrinsic function!", IF);
+Assert1(FT->getReturnType() == FT->getParamType(0),
+"Return type does not match source type", IF);
+Assert1(FT->getReturnType() == Type::UShortTy,
+"Return type is not ushort!", IF);
+NumArgs = 1;
+break;
+
+  case Intrinsic::bswap_i32:
+Assert1(FT->getNumParams() == 1,
+"Illegal # arguments for intrinsic function!", IF);
+Assert1(FT->getReturnType() == FT->getParamType(0),
+"Return type does not match source type", IF);
+Assert1(FT->getReturnType() == Type::UIntTy,
+"Return type is not uint!", IF);
+NumArgs = 1;
+break;
+
+  case Intrinsic::bswap_i64:
+Assert1(FT->getNumParams() == 1,
+"Illegal # arguments for intrinsic function!", IF);
+Assert1(FT->getReturnType() == FT->getParamType(0),
+"Return type does not match source type", IF);
+Assert1(FT->getReturnType() == Type::ULongTy,
+"Return type is not ulong!", IF);
+NumArgs = 1;
+break;
+
   case Intrinsic::ctpop:
   case Intrinsic::ctlz:
   case Intrinsic::cttz:



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


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

2006-01-13 Thread Evan Cheng


Changes in directory llvm/lib/Target/X86:

X86InstrInfo.td updated: 1.203 -> 1.204
---
Log message:

A typo.


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

 X86InstrInfo.td |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Target/X86/X86InstrInfo.td
diff -u llvm/lib/Target/X86/X86InstrInfo.td:1.203 
llvm/lib/Target/X86/X86InstrInfo.td:1.204
--- llvm/lib/Target/X86/X86InstrInfo.td:1.203   Fri Jan 13 15:45:19 2006
+++ llvm/lib/Target/X86/X86InstrInfo.td Fri Jan 13 19:18:49 2006
@@ -1257,7 +1257,7 @@
   def AND32mi8 : Ii8<0x83, MRM4m,
  (ops i32mem:$dst, i32i8imm :$src),
  "and{l} {$src, $dst|$dst, $src}",
-[(store (add (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
+[(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
 }
 
 



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


[llvm-commits] CVS: llvm/test/Regression/CFrontend/2006-01-13-Includes.c

2006-01-13 Thread Jim Laskey


Changes in directory llvm/test/Regression/CFrontend:

2006-01-13-Includes.c added (r1.1)
---
Log message:


testcase for PR676: http://llvm.cs.uiuc.edu/PR676 : 
http://llvm.cs.uiuc.edu/PR676: http://llvm.cs.uiuc.edu/PR676 


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

 2006-01-13-Includes.c |9 +
 1 files changed, 9 insertions(+)


Index: llvm/test/Regression/CFrontend/2006-01-13-Includes.c
diff -c /dev/null llvm/test/Regression/CFrontend/2006-01-13-Includes.c:1.1
*** /dev/null   Fri Jan 13 18:29:58 2006
--- llvm/test/Regression/CFrontend/2006-01-13-Includes.cFri Jan 13 
18:29:48 2006
***
*** 0 
--- 1,9 
+ // RUN: %llvmgcc %s -g -S -o - | gccas | llvm-dis | grep 
"llvm/test/Regression/CFrontend"
+ 
+ // PR676
+ 
+ #include 
+ 
+ void test() {
+   printf("Hello World\n");
+ }



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


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

2006-01-13 Thread Chris Lattner


Changes in directory llvm/include/llvm/Target:

TargetData.h updated: 1.32 -> 1.33
---
Log message:

Add a new InvalidateStructLayoutInfo method and some comments.


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

 TargetData.h |9 +
 1 files changed, 9 insertions(+)


Index: llvm/include/llvm/Target/TargetData.h
diff -u llvm/include/llvm/Target/TargetData.h:1.32 
llvm/include/llvm/Target/TargetData.h:1.33
--- llvm/include/llvm/Target/TargetData.h:1.32  Sat Apr 23 17:35:26 2005
+++ llvm/include/llvm/Target/TargetData.h   Fri Jan 13 18:06:42 2006
@@ -113,7 +113,16 @@
   uint64_t getIndexedOffset(const Type *Ty,
 const std::vector &Indices) const;
 
+  /// getStructLayout - Return a StructLayout object, indicating the alignment
+  /// of the struct, its size, and the offsets of its fields.  Note that this
+  /// information is lazily cached.
   const StructLayout *getStructLayout(const StructType *Ty) const;
+  
+  /// InvalidateStructLayoutInfo - TargetData speculatively caches StructLayout
+  /// objects.  If a TargetData object is alive when types are being refined 
and
+  /// removed, this method must be called whenever a StructType is removed to
+  /// avoid a dangling pointer in this cache.
+  void InvalidateStructLayoutInfo(const StructType *Ty) const;
 };
 
 /// StructLayout - used to lazily calculate structure layout information for a



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


[llvm-commits] CVS: llvm-test/Makefile.programs

2006-01-13 Thread Andrew Lenharth


Changes in directory llvm-test:

Makefile.programs updated: 1.182 -> 1.183
---
Log message:

make beta non-dag

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

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


Index: llvm-test/Makefile.programs
diff -u llvm-test/Makefile.programs:1.182 llvm-test/Makefile.programs:1.183
--- llvm-test/Makefile.programs:1.182   Wed Dec 21 13:35:05 2005
+++ llvm-test/Makefile.programs Fri Jan 13 18:07:42 2006
@@ -190,7 +190,7 @@
 LLCBETAOPTION := -sched=simple
 endif
 ifeq ($(ARCH),Alpha)
-LLCBETAOPTION := -enable-dag-isel-for-alpha
+LLCBETAOPTION := -disable-alpha-dag-isel
 # -enable-alpha-FTOI -enable-alpha-intfpdiv
 endif
 ifeq ($(ARCH),IA64)



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


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

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Target:

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

Implement a new InvalidateStructLayoutInfo method and add some comments


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

 TargetData.cpp |   18 ++
 1 files changed, 18 insertions(+)


Index: llvm/lib/Target/TargetData.cpp
diff -u llvm/lib/Target/TargetData.cpp:1.57 llvm/lib/Target/TargetData.cpp:1.58
--- llvm/lib/Target/TargetData.cpp:1.57 Tue Aug  2 14:25:02 2005
+++ llvm/lib/Target/TargetData.cpp  Fri Jan 13 18:07:34 2006
@@ -131,6 +131,9 @@
   BoolAlignment= 1;
 }
 
+/// Layouts - The lazy cache of structure layout information maintained by
+/// TargetData.
+///
 static std::map,
 StructLayout> *Layouts = 0;
 
@@ -165,6 +168,21 @@
   }
 }
 
+/// InvalidateStructLayoutInfo - TargetData speculatively caches StructLayout
+/// objects.  If a TargetData object is alive when types are being refined and
+/// removed, this method must be called whenever a StructType is removed to
+/// avoid a dangling pointer in this cache.
+void TargetData::InvalidateStructLayoutInfo(const StructType *Ty) const {
+  if (!Layouts) return;  // No cache.
+
+  std::map,
+   StructLayout>::iterator I = Layouts->find(std::make_pair(this, Ty));
+  if (I != Layouts->end())
+Layouts->erase(I);
+}
+
+
+
 static inline void getTypeInfo(const Type *Ty, const TargetData *TD,
uint64_t &Size, unsigned char &Alignment) {
   assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");



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


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

2006-01-13 Thread Chris Lattner


Changes in directory llvm/docs:

LangRef.html updated: 1.124 -> 1.125
---
Log message:

fix some minor errors


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

 LangRef.html |8 
 1 files changed, 4 insertions(+), 4 deletions(-)


Index: llvm/docs/LangRef.html
diff -u llvm/docs/LangRef.html:1.124 llvm/docs/LangRef.html:1.125
--- llvm/docs/LangRef.html:1.124Fri Jan 13 17:02:51 2006
+++ llvm/docs/LangRef.html  Fri Jan 13 17:26:01 2006
@@ -102,7 +102,7 @@
   'select' Instruction
   'extractelement' 
Instruction
   'call'  Instruction
-  'vaarg'  Instruction
+  'va_arg'  Instruction
 
   
 
@@ -2369,7 +2369,7 @@
 
 
 
-  'vaarg' Instruction
+  'va_arg' Instruction
 
 
 
@@ -2451,7 +2451,7 @@
 
 
 Variable argument support is defined in LLVM with the vanext instruction and these three
+ href="#i_va_arg">va_arg instruction and these three
 intrinsic functions.  These functions are related to the similarly
 named macros defined in the  header file.
 
@@ -3639,7 +3639,7 @@
 
   mailto:[EMAIL PROTECTED]">Chris Lattner
   http://llvm.cs.uiuc.edu";>The LLVM Compiler Infrastructure
-  Last modified: $Date: 2006/01/13 23:02:51 $
+  Last modified: $Date: 2006/01/13 23:26:01 $
 
 
 



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


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

2006-01-13 Thread Nate Begeman


Changes in directory llvm/docs:

LangRef.html updated: 1.125 -> 1.126
---
Log message:

Make the bswap documentation more to sabre's liking!


---
Diffs of the changes:  (+40 -94)

 LangRef.html |  134 +--
 1 files changed, 40 insertions(+), 94 deletions(-)


Index: llvm/docs/LangRef.html
diff -u llvm/docs/LangRef.html:1.125 llvm/docs/LangRef.html:1.126
--- llvm/docs/LangRef.html:1.125Fri Jan 13 17:26:01 2006
+++ llvm/docs/LangRef.html  Fri Jan 13 17:26:38 2006
@@ -125,9 +125,6 @@
   
   Code Generator Intrinsics
 
-  'llvm.bswap.i16' 
Intrinsic
-  'llvm.bswap.i32' 
Intrinsic
-  'llvm.bswap.i64' 
Intrinsic
   'llvm.returnaddress' 
Intrinsic
   'llvm.frameaddress'   
Intrinsic
   'llvm.stacksave' 
Intrinsic
@@ -154,8 +151,9 @@
 
 
   
-  Bit counting Intrinsics
+  Bit Manipulation Intrinsics
 
+  'llvm.bswap.*' Intrinsics
   'llvm.ctpop' Intrinsic 
   'llvm.ctlz' Intrinsic 
   'llvm.cttz' Intrinsic 
@@ -2707,93 +2705,6 @@
 
 
 
-  'llvm.bswap.i16' Intrinsic
-
-
-
-
-Syntax:
-
-  declare ushort %llvm.bswap.i16( ushort  )
-
-
-Overview:
-
-
-The 'llvm.bwsap.i16' intrinsic is used to byteswap a 16 bit quantity.
-This is useful for performing operations on data that is not in the target's 
-native byte order.
-
-
-Semantics:
-
-
-This intrinsic returns a ushort value that has the two bytes of the input 
ushort
-swapped.
-
-
-
-
-
-
-  'llvm.bswap.i32' Intrinsic
-
-
-
-
-Syntax:
-
-  declare uint %llvm.bswap.i32( uint  )
-
-
-Overview:
-
-
-The 'llvm.bwsap.i32' intrinsic is used to byteswap a 32 bit quantity.
-This is useful for performing operations on data that is not in the target's 
-native byte order.
-
-
-Semantics:
-
-
-This intrinsic returns a uint value that has the four bytes of the input uint
-swapped, so that if the input bytes are numbered 0, 1, 2, 3 then the returned
-uint will have its bytes in 3, 2, 1, 0 order.
-
-
-
-
-
-
-  'llvm.bswap.i64' Intrinsic
-
-
-
-
-Syntax:
-
-  declare ulong %llvm.bswap.i64( ulong  )
-
-
-Overview:
-
-
-The 'llvm.bwsap.i64' intrinsic is used to byteswap a 64 bit quantity.
-This is useful for performing operations on data that is not in the target's 
-native byte order.
-
-
-Semantics:
-
-
-See the description for llvm.bswap.i32.
-
-
-
-
-
-
   'llvm.returnaddress' Intrinsic
 
 
@@ -3499,12 +3410,12 @@
 
 
 
-  Bit Counting Intrinsics
+  Bit Manipulation Intrinsics
 
 
 
 
-LLVM provides intrinsics for a few important bit counting operations.
+LLVM provides intrinsics for a few important bit manipulation operations.
 These allow efficient code generation for some algorithms.
 
 
@@ -3512,6 +3423,41 @@
 
 
 
+  'llvm.bswap.*' Intrinsics
+
+
+
+
+Syntax:
+
+  declare ushort %llvm.bswap.i16( ushort  )
+  declare uint %llvm.bswap.i32( uint  )
+  declare ulong %llvm.bswap.i64( ulong  )
+
+
+Overview:
+
+
+The 'llvm.bwsap' family of intrinsics is used to byteswap a 16, 32 or
+64 bit quantity.  These are useful for performing operations on data that is 
not
+in the target's  native byte order.
+
+
+Semantics:
+
+
+The llvm.bswap.16 intrinsic returns a ushort value that has the high and low
+byte of the input ushort swapped.  Similarly, the llvm.bswap.i32 intrinsic
+returns a uint value that has the four bytes of the input uint swapped, so 
that 
+if the input bytes are numbered 0, 1, 2, 3 then the returned uint will have its
+bytes in 3, 2, 1, 0 order.  The llvm.bswap.i64 intrinsic extends this concept
+to 64 bits.
+
+
+
+
+
+
   'llvm.ctpop' Intrinsic
 
 
@@ -3639,7 +3585,7 @@
 
   mailto:[EMAIL PROTECTED]">Chris Lattner
   http://llvm.cs.uiuc.edu";>The LLVM Compiler Infrastructure
-  Last modified: $Date: 2006/01/13 23:26:01 $
+  Last modified: $Date: 2006/01/13 23:26:38 $
 
 
 



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


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

2006-01-13 Thread Nate Begeman


Changes in directory llvm/docs:

LangRef.html updated: 1.123 -> 1.124
---
Log message:

Add documentation for the upcoming bswap intrinsics!


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

 LangRef.html |   92 ++-
 1 files changed, 91 insertions(+), 1 deletion(-)


Index: llvm/docs/LangRef.html
diff -u llvm/docs/LangRef.html:1.123 llvm/docs/LangRef.html:1.124
--- llvm/docs/LangRef.html:1.123Thu Jan 12 20:03:13 2006
+++ llvm/docs/LangRef.html  Fri Jan 13 17:02:51 2006
@@ -125,6 +125,9 @@
   
   Code Generator Intrinsics
 
+  'llvm.bswap.i16' 
Intrinsic
+  'llvm.bswap.i32' 
Intrinsic
+  'llvm.bswap.i64' 
Intrinsic
   'llvm.returnaddress' 
Intrinsic
   'llvm.frameaddress'   
Intrinsic
   'llvm.stacksave' 
Intrinsic
@@ -2704,6 +2707,93 @@
 
 
 
+  'llvm.bswap.i16' Intrinsic
+
+
+
+
+Syntax:
+
+  declare ushort %llvm.bswap.i16( ushort  )
+
+
+Overview:
+
+
+The 'llvm.bwsap.i16' intrinsic is used to byteswap a 16 bit quantity.
+This is useful for performing operations on data that is not in the target's 
+native byte order.
+
+
+Semantics:
+
+
+This intrinsic returns a ushort value that has the two bytes of the input 
ushort
+swapped.
+
+
+
+
+
+
+  'llvm.bswap.i32' Intrinsic
+
+
+
+
+Syntax:
+
+  declare uint %llvm.bswap.i32( uint  )
+
+
+Overview:
+
+
+The 'llvm.bwsap.i32' intrinsic is used to byteswap a 32 bit quantity.
+This is useful for performing operations on data that is not in the target's 
+native byte order.
+
+
+Semantics:
+
+
+This intrinsic returns a uint value that has the four bytes of the input uint
+swapped, so that if the input bytes are numbered 0, 1, 2, 3 then the returned
+uint will have its bytes in 3, 2, 1, 0 order.
+
+
+
+
+
+
+  'llvm.bswap.i64' Intrinsic
+
+
+
+
+Syntax:
+
+  declare ulong %llvm.bswap.i64( ulong  )
+
+
+Overview:
+
+
+The 'llvm.bwsap.i64' intrinsic is used to byteswap a 64 bit quantity.
+This is useful for performing operations on data that is not in the target's 
+native byte order.
+
+
+Semantics:
+
+
+See the description for llvm.bswap.i32.
+
+
+
+
+
+
   'llvm.returnaddress' Intrinsic
 
 
@@ -3549,7 +3639,7 @@
 
   mailto:[EMAIL PROTECTED]">Chris Lattner
   http://llvm.cs.uiuc.edu";>The LLVM Compiler Infrastructure
-  Last modified: $Date: 2006/01/13 02:03:13 $
+  Last modified: $Date: 2006/01/13 23:02:51 $
 
 
 



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


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

2006-01-13 Thread Robert L. Bocchino Jr.


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.413 -> 1.414
---
Log message:

Added instcombine support for extractelement.


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

 InstructionCombining.cpp |   55 ++-
 1 files changed, 54 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.413 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.414
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.413   Fri Jan 13 
15:28:09 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Jan 13 16:48:06 2006
@@ -135,6 +135,7 @@
 Instruction *visitStoreInst(StoreInst &SI);
 Instruction *visitBranchInst(BranchInst &BI);
 Instruction *visitSwitchInst(SwitchInst &SI);
+Instruction *visitExtractElementInst(ExtractElementInst &EI);
 
 // visitInstruction - Specify what to return for unhandled instructions...
 Instruction *visitInstruction(Instruction &I) { return 0; }
@@ -5877,6 +5878,58 @@
   return 0;
 }
 
+Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
+  if (ConstantAggregateZero *C = 
+  dyn_cast(EI.getOperand(0))) {
+// If packed val is constant 0, replace extract with scalar 0
+const Type *Ty = cast(C->getType())->getElementType();
+EI.replaceAllUsesWith(Constant::getNullValue(Ty));
+return ReplaceInstUsesWith(EI, Constant::getNullValue(Ty));
+  }
+  if (ConstantPacked *C = dyn_cast(EI.getOperand(0))) {
+// If packed val is constant with uniform operands, replace EI
+// with that operand
+Constant *op0 = cast(C->getOperand(0));
+for (unsigned i = 1; i < C->getNumOperands(); ++i)
+  if (C->getOperand(i) != op0) return 0;
+return ReplaceInstUsesWith(EI, op0);
+  }
+  if (Instruction *I = dyn_cast(EI.getOperand(0)))
+if (I->hasOneUse()) {
+  // Push extractelement into predecessor operation if legal and
+  // profitable to do so
+  if (BinaryOperator *BO = dyn_cast(I)) {
+if (!isa(BO->getOperand(0)) &&
+!isa(BO->getOperand(1)))
+  return 0;
+ExtractElementInst *newEI0 = 
+  new ExtractElementInst(BO->getOperand(0), EI.getOperand(1),
+ EI.getName());
+ExtractElementInst *newEI1 =
+  new ExtractElementInst(BO->getOperand(1), EI.getOperand(1),
+ EI.getName());
+InsertNewInstBefore(newEI0, EI);
+InsertNewInstBefore(newEI1, EI);
+return BinaryOperator::create(BO->getOpcode(), newEI0, newEI1);
+  }
+  switch(I->getOpcode()) {
+  case Instruction::Load: {
+Value *Ptr = InsertCastBefore(I->getOperand(0),
+  PointerType::get(EI.getType()), EI);
+GetElementPtrInst *GEP = 
+  new GetElementPtrInst(Ptr, EI.getOperand(1),
+I->getName() + ".gep");
+InsertNewInstBefore(GEP, EI);
+return new LoadInst(GEP);
+  }
+  default:
+return 0;
+  }
+}
+  return 0;
+}
+
+
 void InstCombiner::removeFromWorkList(Instruction *I) {
   WorkList.erase(std::remove(WorkList.begin(), WorkList.end(), I),
  WorkList.end());
@@ -6075,7 +6128,7 @@
   WorkList.push_back(OpI);
 
   // Instructions may end up in the worklist more than once.  Erase all
-  // occurrances of this instruction.
+  // occurrences of this instruction.
   removeFromWorkList(I);
   I->eraseFromParent();
 } else {



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


[llvm-commits] CVS: llvm/test/Regression/CFrontend/2006-01-13-StackSave.c

2006-01-13 Thread Chris Lattner


Changes in directory llvm/test/Regression/CFrontend:

2006-01-13-StackSave.c added (r1.1)
---
Log message:

testcase for PR691: http://llvm.cs.uiuc.edu/PR691 


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

 2006-01-13-StackSave.c |   12 
 1 files changed, 12 insertions(+)


Index: llvm/test/Regression/CFrontend/2006-01-13-StackSave.c
diff -c /dev/null llvm/test/Regression/CFrontend/2006-01-13-StackSave.c:1.1
*** /dev/null   Fri Jan 13 16:05:46 2006
--- llvm/test/Regression/CFrontend/2006-01-13-StackSave.c   Fri Jan 13 
16:05:36 2006
***
*** 0 
--- 1,12 
+ // RUN: %llvmgcc %s -S -o - | gccas | llvm-dis | grep llvm.stacksave
+ // XFAIL: *
+ 
+ // PR691
+ 
+ void test(int N) {
+   int i;
+   for (i = 0; i < N; ++i) {
+ int VLA[i];
+ external(VLA);
+   }
+ }



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


[llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/stacksaverestore.ll

2006-01-13 Thread Chris Lattner


Changes in directory llvm/test/Regression/Transforms/InstCombine:

stacksaverestore.ll added (r1.1)
---
Log message:

new testcases for the stackrestore instcombine optimizations


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

 stacksaverestore.ll |   20 
 1 files changed, 20 insertions(+)


Index: llvm/test/Regression/Transforms/InstCombine/stacksaverestore.ll
diff -c /dev/null 
llvm/test/Regression/Transforms/InstCombine/stacksaverestore.ll:1.1
*** /dev/null   Fri Jan 13 16:01:57 2006
--- llvm/test/Regression/Transforms/InstCombine/stacksaverestore.ll Fri Jan 
13 16:01:47 2006
***
*** 0 
--- 1,20 
+ ; RUN: llvm-as < %s | opt -instcombine -disable-output &&
+ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep call
+ 
+ ;; Test that llvm.stackrestore is removed when possible.
+ 
+ int* %test1(uint %P) {
+ %tmp = call sbyte* %llvm.stacksave()
+ call void %llvm.stackrestore(sbyte* %tmp) ;; not restoring anything
+   %A = alloca int, uint %P
+ ret int* %A
+ }
+ 
+ void %test2(sbyte* %X) {
+   call void %llvm.stackrestore(sbyte* %X)  ;; no allocas before return.
+   ret void
+ }
+ 
+ declare sbyte* %llvm.stacksave()
+ 
+ declare void %llvm.stackrestore(sbyte*)



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


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

2006-01-13 Thread Evan Cheng


Changes in directory llvm/lib/Target/X86:

X86InstrInfo.td updated: 1.202 -> 1.203
---
Log message:

Add truncstore i1 patterns.


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

 X86InstrInfo.td |5 +
 1 files changed, 5 insertions(+)


Index: llvm/lib/Target/X86/X86InstrInfo.td
diff -u llvm/lib/Target/X86/X86InstrInfo.td:1.202 
llvm/lib/Target/X86/X86InstrInfo.td:1.203
--- llvm/lib/Target/X86/X86InstrInfo.td:1.202   Thu Jan 12 16:54:21 2006
+++ llvm/lib/Target/X86/X86InstrInfo.td Fri Jan 13 15:45:19 2006
@@ -2988,6 +2988,11 @@
 def : Pat<(X86subflag R32:$src1, i32immSExt8:$src2),
   (SUB32ri8 R32:$src1, i32immSExt8:$src2)>;
 
+def : Pat<(truncstore (i8 imm:$src), addr:$dst, i1), 
+  (MOV8mi addr:$dst, imm:$src)>;
+def : Pat<(truncstore R8:$src, addr:$dst, i1), 
+  (MOV8mr addr:$dst, R8:$src)>;
+
 // {s|z}extload bool -> {s|z}extload byte
 def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
 def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;



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


[llvm-commits] CVS: llvm/lib/Transforms/Utils/Local.cpp

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

Local.cpp updated: 1.47 -> 1.48
---
Log message:

it is ok to dce stacksave.


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

 Local.cpp |1 +
 1 files changed, 1 insertion(+)


Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.47 
llvm/lib/Transforms/Utils/Local.cpp:1.48
--- llvm/lib/Transforms/Utils/Local.cpp:1.47Tue Jan 10 13:05:15 2006
+++ llvm/lib/Transforms/Utils/Local.cpp Fri Jan 13 15:31:54 2006
@@ -296,6 +296,7 @@
   default: break;
   case Intrinsic::returnaddress:
   case Intrinsic::frameaddress:
+  case Intrinsic::stacksave:
   case Intrinsic::isunordered:
   case Intrinsic::ctpop:
   case Intrinsic::ctlz:



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


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.412 -> 1.413
---
Log message:

Do a simple instcombine xforms to delete llvm.stackrestore cases.


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

 InstructionCombining.cpp |   33 +
 1 files changed, 33 insertions(+)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.412 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.413
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.412   Fri Jan 13 
14:11:04 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Jan 13 15:28:09 2006
@@ -4671,6 +4671,39 @@
 SPI->replaceAllUsesWith(PrevSPI);
 return EraseInstFromFunction(CI);
   }
+  } else {
+switch (II->getIntrinsicID()) {
+default: break;
+case Intrinsic::stackrestore: {
+  // If the save is right next to the restore, remove the restore.  This 
can
+  // happen when variable allocas are DCE'd.
+  if (IntrinsicInst *SS = dyn_cast(II->getOperand(1))) {
+if (SS->getIntrinsicID() == Intrinsic::stacksave) {
+  BasicBlock::iterator BI = SS;
+  if (&*++BI == II)
+return EraseInstFromFunction(CI);
+}
+  }
+  
+  // If the stack restore is in a return/unwind block and if there are no
+  // allocas or calls between the restore and the return, nuke the restore.
+  TerminatorInst *TI = II->getParent()->getTerminator();
+  if (isa(TI) || isa(TI)) {
+BasicBlock::iterator BI = II;
+bool CannotRemove = false;
+for (++BI; &*BI != TI; ++BI) {
+  if (isa(BI) ||
+  (isa(BI) && !isa(BI))) {
+CannotRemove = true;
+break;
+  }
+}
+if (!CannotRemove)
+  return EraseInstFromFunction(CI);
+  }
+  break;
+}
+}
   }
 
   return visitCallSite(II);



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


[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.411 -> 1.412
---
Log message:

Simplify this a tiny bit by using the new IntrinsicInst functionality.


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

 InstructionCombining.cpp |   19 ---
 1 files changed, 12 insertions(+), 7 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.411 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.412
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.411   Fri Jan  6 
19:32:28 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Jan 13 14:11:04 2006
@@ -4620,12 +4620,17 @@
 }
 
 
-// CallInst simplification
-//
+/// visitCallInst - CallInst simplification.  This mostly only handles folding 
+/// of intrinsic instructions.  For normal calls, it allows visitCallSite to do
+/// the heavy lifting.
+///
 Instruction *InstCombiner::visitCallInst(CallInst &CI) {
+  IntrinsicInst *II = dyn_cast(&CI);
+  if (!II) return visitCallSite(&CI);
+  
   // Intrinsics cannot occur in an invoke, so handle them here instead of in
   // visitCallSite.
-  if (MemIntrinsic *MI = dyn_cast(&CI)) {
+  if (MemIntrinsic *MI = dyn_cast(II)) {
 bool Changed = false;
 
 // memmove/cpy/set of zero bytes is a noop.
@@ -4645,7 +4650,7 @@
 // If we have a memmove and the source operation is a constant global,
 // then the source and dest pointers can't alias, so we can change this
 // into a call to memcpy.
-if (MemMoveInst *MMI = dyn_cast(MI))
+if (MemMoveInst *MMI = dyn_cast(II))
   if (GlobalVariable *GVSrc = dyn_cast(MMI->getSource()))
 if (GVSrc->isConstant()) {
   Module *M = CI.getParent()->getParent()->getParent();
@@ -4655,8 +4660,8 @@
   Changed = true;
 }
 
-if (Changed) return &CI;
-  } else if (DbgStopPointInst *SPI = dyn_cast(&CI)) {
+if (Changed) return II;
+  } else if (DbgStopPointInst *SPI = dyn_cast(II)) {
 // If this stoppoint is at the same source location as the previous
 // stoppoint in the chain, it is not needed.
 if (DbgStopPointInst *PrevSPI =
@@ -4668,7 +4673,7 @@
   }
   }
 
-  return visitCallSite(&CI);
+  return visitCallSite(II);
 }
 
 // InvokeInst simplification



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


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

2006-01-13 Thread Chris Lattner


Changes in directory llvm/include/llvm:

IntrinsicInst.h updated: 1.8 -> 1.9
---
Log message:

Simplify the implementations of classof using the new IntrinsicInst classof.


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

 IntrinsicInst.h |   88 
 1 files changed, 32 insertions(+), 56 deletions(-)


Index: llvm/include/llvm/IntrinsicInst.h
diff -u llvm/include/llvm/IntrinsicInst.h:1.8 
llvm/include/llvm/IntrinsicInst.h:1.9
--- llvm/include/llvm/IntrinsicInst.h:1.8   Fri Jan 13 13:49:02 2006
+++ llvm/include/llvm/IntrinsicInst.h   Fri Jan 13 14:00:51 2006
@@ -70,21 +70,19 @@
 
 // Methods for support type inquiry through isa, cast, and dyn_cast:
 static inline bool classof(const DbgInfoIntrinsic *) { return true; }
-static inline bool classof(const CallInst *I) {
-  if (const Function *CF = I->getCalledFunction())
-switch (CF->getIntrinsicID()) {
-case Intrinsic::dbg_stoppoint:
-case Intrinsic::dbg_region_start:
-case Intrinsic::dbg_region_end:
-case Intrinsic::dbg_func_start:
-case Intrinsic::dbg_declare:
-  return true;
-default: break;
-}
-  return false;
+static inline bool classof(const IntrinsicInst *I) {
+  switch (I->getIntrinsicID()) {
+  case Intrinsic::dbg_stoppoint:
+  case Intrinsic::dbg_region_start:
+  case Intrinsic::dbg_region_end:
+  case Intrinsic::dbg_func_start:
+  case Intrinsic::dbg_declare:
+return true;
+  default: return false;
+  }
 }
 static inline bool classof(const Value *V) {
-  return isa(V) && classof(cast(V));
+  return isa(V) && classof(cast(V));
 }
   };
 
@@ -104,13 +102,11 @@
 
 // Methods for support type inquiry through isa, cast, and dyn_cast:
 static inline bool classof(const DbgStopPointInst *) { return true; }
-static inline bool classof(const CallInst *I) {
-  if (const Function *CF = I->getCalledFunction())
-return CF->getIntrinsicID() == Intrinsic::dbg_stoppoint;
-  return false;
+static inline bool classof(const IntrinsicInst *I) {
+  return I->getIntrinsicID() == Intrinsic::dbg_stoppoint;
 }
 static inline bool classof(const Value *V) {
-  return isa(V) && classof(cast(V));
+  return isa(V) && classof(cast(V));
 }
   };
 
@@ -150,19 +146,17 @@
 
 // Methods for support type inquiry through isa, cast, and dyn_cast:
 static inline bool classof(const MemIntrinsic *) { return true; }
-static inline bool classof(const CallInst *I) {
-  if (const Function *CF = I->getCalledFunction())
-switch (CF->getIntrinsicID()) {
-case Intrinsic::memcpy:
-case Intrinsic::memmove:
-case Intrinsic::memset:
-  return true;
-default: break;
-}
-  return false;
+static inline bool classof(const IntrinsicInst *I) {
+  switch (I->getIntrinsicID()) {
+  case Intrinsic::memcpy:
+  case Intrinsic::memmove:
+  case Intrinsic::memset:
+return true;
+  default: return false;
+  }
 }
 static inline bool classof(const Value *V) {
-  return isa(V) && classof(cast(V));
+  return isa(V) && classof(cast(V));
 }
   };
 
@@ -188,17 +182,11 @@
 
 // Methods for support type inquiry through isa, cast, and dyn_cast:
 static inline bool classof(const MemCpyInst *) { return true; }
-static inline bool classof(const MemIntrinsic *I) {
-  return I->getCalledFunction()->getIntrinsicID() == Intrinsic::memcpy;
-}
-static inline bool classof(const CallInst *I) {
-  if (const Function *CF = I->getCalledFunction())
-if (CF->getIntrinsicID() == Intrinsic::memcpy)
-  return true;
-  return false;
+static inline bool classof(const IntrinsicInst *I) {
+  return I->getIntrinsicID() == Intrinsic::memcpy;
 }
 static inline bool classof(const Value *V) {
-  return isa(V) && classof(cast(V));
+  return isa(V) && classof(cast(V));
 }
   };
 
@@ -222,17 +210,11 @@
 
 // Methods for support type inquiry through isa, cast, and dyn_cast:
 static inline bool classof(const MemMoveInst *) { return true; }
-static inline bool classof(const MemIntrinsic *I) {
-  return I->getCalledFunction()->getIntrinsicID() == Intrinsic::memmove;
-}
-static inline bool classof(const CallInst *I) {
-  if (const Function *CF = I->getCalledFunction())
-if (CF->getIntrinsicID() == Intrinsic::memmove)
-  return true;
-  return false;
+static inline bool classof(const IntrinsicInst *I) {
+  return I->getIntrinsicID() == Intrinsic::memmove;
 }
 static inline bool classof(const Value *V) {
-  return isa(V) && classof(cast(V));
+  return isa(V) && classof(cast(V));
 }
   };
 
@@ -251,17 +233,11 @@
 
 // Methods for support type inquiry through isa, cast, and dyn_cast:
 static inline bool classof(const MemSet

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

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Target/X86:

X86ISelPattern.cpp updated: 1.196 -> 1.197
---
Log message:

Fix a bug in my last X86 checkin, pointed out by cozmic


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

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


Index: llvm/lib/Target/X86/X86ISelPattern.cpp
diff -u llvm/lib/Target/X86/X86ISelPattern.cpp:1.196 
llvm/lib/Target/X86/X86ISelPattern.cpp:1.197
--- llvm/lib/Target/X86/X86ISelPattern.cpp:1.196Fri Jan 13 12:00:54 2006
+++ llvm/lib/Target/X86/X86ISelPattern.cpp  Fri Jan 13 14:19:44 2006
@@ -1229,7 +1229,8 @@
   cast(Node->getOperand(1))->getReg() :
   cast(Node)->getReg();
 // Just use the specified register as our input if we can.
-if (MRegisterInfo::isVirtualRegister(Reg))
+if (Node->getOpcode() == ISD::Register ||
+MRegisterInfo::isVirtualRegister(Reg))
   return Reg;
   } 
 



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


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

2006-01-13 Thread Chris Lattner


Changes in directory llvm/include/llvm:

IntrinsicInst.h updated: 1.7 -> 1.8
---
Log message:

Add some functionality to the IntrinsicInst class and some comments


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

 IntrinsicInst.h |   20 
 1 files changed, 20 insertions(+)


Index: llvm/include/llvm/IntrinsicInst.h
diff -u llvm/include/llvm/IntrinsicInst.h:1.7 
llvm/include/llvm/IntrinsicInst.h:1.8
--- llvm/include/llvm/IntrinsicInst.h:1.7   Thu Apr 21 22:20:18 2005
+++ llvm/include/llvm/IntrinsicInst.h   Fri Jan 13 13:49:02 2006
@@ -30,6 +30,9 @@
 #include "llvm/Intrinsics.h"
 
 namespace llvm {
+  /// IntrinsicInst - A useful wrapper class for inspecting calls to intrinsic
+  /// functions.  This allows the standard isa/dyncast/cast functionality to
+  /// work with calls to intrinsic functions.
   class IntrinsicInst : public CallInst {
 IntrinsicInst();  // DO NOT IMPLEMENT
 IntrinsicInst(const IntrinsicInst&);  // DO NOT IMPLEMENT
@@ -40,6 +43,23 @@
 /// casts from the specified value, returning the original uncasted value.
 /// Note that the returned value is guaranteed to have pointer type.
 static Value *StripPointerCasts(Value *Ptr);
+
+/// getIntrinsicID - Return the intrinsic ID of this intrinsic.
+///
+Intrinsic::ID getIntrinsicID() const {
+  return (Intrinsic::ID)getCalledFunction()->getIntrinsicID();
+}
+
+// Methods for support type inquiry through isa, cast, and dyn_cast:
+static inline bool classof(const IntrinsicInst *) { return true; }
+static inline bool classof(const CallInst *I) {
+  if (const Function *CF = I->getCalledFunction())
+return CF->getIntrinsicID() != 0;
+  return false;
+}
+static inline bool classof(const Value *V) {
+  return isa(V) && classof(cast(V));
+}
   };
 
   /// DbgInfoIntrinsic - This is the common base class for debug info 
intrinsics



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


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

2006-01-13 Thread Evan Cheng


Changes in directory llvm/lib/Target/X86:

X86ISelLowering.cpp updated: 1.39 -> 1.40
---
Log message:

LHS = X86ISD::CMOVcc LHS, RHS  means LHS = RHS if cc. So the operands must be
flipped around.


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

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


Index: llvm/lib/Target/X86/X86ISelLowering.cpp
diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.39 
llvm/lib/Target/X86/X86ISelLowering.cpp:1.40
--- llvm/lib/Target/X86/X86ISelLowering.cpp:1.39Fri Jan 13 12:00:54 2006
+++ llvm/lib/Target/X86/X86ISelLowering.cpp Fri Jan 13 13:51:46 2006
@@ -1606,7 +1606,7 @@
   addTest = true;
 
 if (addTest) {
-  CC = DAG.getConstant(X86ISD::COND_E, MVT::i8);
+  CC = DAG.getConstant(X86ISD::COND_NE, MVT::i8);
   Cond = DAG.getNode(X86ISD::TEST, MVT::Flag, Op0, Op0);
 }
 
@@ -1614,8 +1614,10 @@
 Tys.push_back(Op.getValueType());
 Tys.push_back(MVT::Flag);
 std::vector Ops;
-Ops.push_back(Op.getOperand(1));
+// X86ISD::CMOV means set the result (which is operand 1) to the RHS if
+// condition is true.
 Ops.push_back(Op.getOperand(2));
+Ops.push_back(Op.getOperand(1));
 Ops.push_back(CC);
 Ops.push_back(Cond);
 return DAG.getNode(X86ISD::CMOV, Tys, Ops);



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


[llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

InlineFunction.cpp updated: 1.39 -> 1.40
---
Log message:

If inlining a call to a function that contains dynamic allocas, wrap the
resultant code with llvm.stacksave/llvm.stackrestore intrinsics.


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

 InlineFunction.cpp |   30 ++
 1 files changed, 30 insertions(+)


Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.39 
llvm/lib/Transforms/Utils/InlineFunction.cpp:1.40
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.39   Fri Jan 13 13:18:11 2006
+++ llvm/lib/Transforms/Utils/InlineFunction.cppFri Jan 13 13:34:14 2006
@@ -215,6 +215,36 @@
 }
   }
 
+  // If the inlined code contained dynamic alloca instructions, wrap the 
inlined
+  // code with llvm.stacksave/llvm.stackrestore intrinsics.
+  if (InlinedFunctionInfo.ContainsDynamicAllocas) {
+Module *M = Caller->getParent();
+const Type *SBytePtr = PointerType::get(Type::SByteTy);
+// Get the two intrinsics we care about.
+Function *StackSave, *StackRestore;
+StackSave= M->getOrInsertFunction("llvm.stacksave", SBytePtr, NULL);
+StackRestore = M->getOrInsertFunction("llvm.stackrestore", Type::VoidTy,
+  SBytePtr, NULL);
+
+// Insert the llvm.stacksave.
+Value *SavedPtr = new CallInst(StackSave, "savedstack", 
+   FirstNewBlock->begin());
+
+// Insert a call to llvm.stackrestore before any return instructions in the
+// inlined function.
+for (unsigned i = 0, e = Returns.size(); i != e; ++i)
+  new CallInst(StackRestore, SavedPtr, "", Returns[i]);
+
+// If we are inlining an invoke instruction, insert restores before each
+// unwind.  These unwinds will be rewritten into branches later.
+if (InlinedFunctionInfo.ContainsUnwinds && isa(TheCall)) {
+  for (Function::iterator BB = FirstNewBlock, E = Caller->end();
+   BB != E; ++BB)
+if (UnwindInst *UI = dyn_cast(BB->getTerminator()))
+  new CallInst(StackRestore, SavedPtr, "", UI);
+}
+  }
+
   // If we are inlining tail call instruction through a call site that isn't 
   // marked 'tail', we must remove the tail marker for any calls in the inlined
   // code.



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


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

2006-01-13 Thread Andrew Lenharth


Changes in directory llvm/lib/Target/Alpha:

AlphaTargetMachine.cpp updated: 1.19 -> 1.20
---
Log message:

make DAG isel the default

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

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


Index: llvm/lib/Target/Alpha/AlphaTargetMachine.cpp
diff -u llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.19 
llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.20
--- llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.19   Fri Nov 18 07:57:03 2005
+++ llvm/lib/Target/Alpha/AlphaTargetMachine.cppFri Jan 13 12:49:47 2006
@@ -29,8 +29,8 @@
 }
 
 namespace llvm {
-  cl::opt EnableAlphaDAG("enable-dag-isel-for-alpha",
- cl::desc("Enable DAG ISEL for Alpha (beta 
option!)"),
+  cl::opt DisableAlphaDAG("disable-alpha-dag-isel",
+ cl::desc("Disable DAG ISEL for Alpha"),
  cl::Hidden);
 }
 
@@ -94,7 +94,7 @@
   // Make sure that no unreachable blocks are instruction selected.
   PM.add(createUnreachableBlockEliminationPass());
 
-  if (EnableAlphaDAG)
+  if (!DisableAlphaDAG)
 PM.add(createAlphaISelDag(*this));
   else
 PM.add(createAlphaPatternInstructionSelector(*this));



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


[llvm-commits] CVS: llvm/lib/Transforms/IPO/InlineSimple.cpp

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

InlineSimple.cpp updated: 1.71 -> 1.72
---
Log message:

Permit inlining functions that contain dynamic allocations now that 
InlineFunction handles this case safely.  This implements
Transforms/Inline/dynamic_alloca_test.ll.


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

 InlineSimple.cpp |   31 ---
 1 files changed, 4 insertions(+), 27 deletions(-)


Index: llvm/lib/Transforms/IPO/InlineSimple.cpp
diff -u llvm/lib/Transforms/IPO/InlineSimple.cpp:1.71 
llvm/lib/Transforms/IPO/InlineSimple.cpp:1.72
--- llvm/lib/Transforms/IPO/InlineSimple.cpp:1.71   Tue May 17 23:30:33 2005
+++ llvm/lib/Transforms/IPO/InlineSimple.cppFri Jan 13 13:35:43 2006
@@ -33,16 +33,6 @@
   // FunctionInfo - For each function, calculate the size of it in blocks and
   // instructions.
   struct FunctionInfo {
-// HasAllocas - Keep track of whether or not a function contains an alloca
-// instruction that is not in the entry block of the function.  Inlining
-// this call could cause us to blow out the stack, because the stack memory
-// would never be released.
-//
-// FIXME: LLVM needs a way of dealloca'ing memory, which would make this
-// irrelevant!
-//
-bool HasAllocas;
-
 // NumInsts, NumBlocks - Keep track of how large each function is, which is
 // used to estimate the code size cost of inlining it.
 unsigned NumInsts, NumBlocks;
@@ -53,7 +43,7 @@
 // entry here.
 std::vector ArgumentWeights;
 
-FunctionInfo() : HasAllocas(false), NumInsts(0), NumBlocks(0) {}
+FunctionInfo() : NumInsts(0), NumBlocks(0) {}
 
 /// analyzeFunction - Fill in the current structure with information 
gleaned
 /// from the specified function.
@@ -148,17 +138,9 @@
   // each instruction counts as 10.
   for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
 for (BasicBlock::const_iterator II = BB->begin(), E = BB->end();
- II != E; ++II) {
-  if (!isa(II)) ++NumInsts;
-
-  // If there is an alloca in the body of the function, we cannot currently
-  // inline the function without the risk of exploding the stack.
-  if (isa(II) && BB != F->begin()) {
-HasAllocas = true;
-this->NumBlocks = this->NumInsts = 1;
-return;
-  }
-}
+ II != E; ++II)
+  if (!isa(II)) 
+++NumInsts;
 
 ++NumBlocks;
   }
@@ -218,11 +200,6 @@
   if (CalleeFI.NumBlocks == 0)
 CalleeFI.analyzeFunction(Callee);
 
-  // Don't inline calls to functions with allocas that are not in the entry
-  // block of the function.
-  if (CalleeFI.HasAllocas)
-return 20;
-
   // Add to the inline quality for properties that make the call valuable to
   // inline.  This includes factors that indicate that the result of inlining
   // the function will be optimizable.  Currently this just looks at arguments



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


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

2006-01-13 Thread Chris Lattner


Changes in directory llvm/include/llvm/Transforms/Utils:

Cloning.h updated: 1.16 -> 1.17
---
Log message:

Allow the code cloning interfaces to capture some important info about the
code being cloned if the client wants.


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

 Cloning.h |   45 +++--
 1 files changed, 39 insertions(+), 6 deletions(-)


Index: llvm/include/llvm/Transforms/Utils/Cloning.h
diff -u llvm/include/llvm/Transforms/Utils/Cloning.h:1.16 
llvm/include/llvm/Transforms/Utils/Cloning.h:1.17
--- llvm/include/llvm/Transforms/Utils/Cloning.h:1.16   Thu Apr 21 15:59:05 2005
+++ llvm/include/llvm/Transforms/Utils/Cloning.hFri Jan 13 12:38:08 2006
@@ -37,6 +37,31 @@
 ///
 Module *CloneModule(const Module *M);
 
+/// ClonedCodeInfo - This struct can be used to capture information about code
+/// being cloned, while it is being cloned.
+struct ClonedCodeInfo {
+  /// ContainsCalls - This is set to true if the cloned code contains a normal
+  /// call instruction.
+  bool ContainsCalls;
+  
+  /// ContainsUnwinds - This is set to true if the cloned code contains an
+  /// unwind instruction.
+  bool ContainsUnwinds;
+  
+  /// ContainsDynamicAllocas - This is set to true if the cloned code contains
+  /// a 'dynamic' alloca.  Dynamic allocas are allocas that are either not in
+  /// the entry block or they are in the entry block but are not a constant
+  /// size.
+  bool ContainsDynamicAllocas;
+  
+  ClonedCodeInfo() {
+ContainsCalls = false;
+ContainsUnwinds = false;
+ContainsDynamicAllocas = false;
+  }
+};
+
+
 /// CloneBasicBlock - Return a copy of the specified basic block, but without
 /// embedding the block into a particular function.  The block returned is an
 /// exact copy of the specified basic block, without any remapping having been
@@ -61,9 +86,14 @@
 /// If you would like the basic block to be auto-inserted into the end of a
 /// function, you can specify it as the optional fourth parameter.
 ///
+/// If you would like to collect additional information about the cloned
+/// function, you can specify a ClonedCodeInfo object with the optional fifth
+/// parameter.
+///
 BasicBlock *CloneBasicBlock(const BasicBlock *BB,
 std::map &ValueMap,
-const char *NameSuffix = "", Function *F = 0);
+const char *NameSuffix = "", Function *F = 0,
+ClonedCodeInfo *CodeInfo = 0);
 
 
 /// CloneFunction - Return a copy of the specified function, but without
@@ -72,16 +102,18 @@
 /// original one.  If any of the arguments to the function are in the ValueMap,
 /// the arguments are deleted from the resultant function.  The ValueMap is
 /// updated to include mappings from all of the instructions and basicblocks in
-/// the function from their old to new values.
+/// the function from their old to new values.  The final argument captures
+/// information about the cloned code if non-null.
 ///
 Function *CloneFunction(const Function *F,
-std::map &ValueMap);
+std::map &ValueMap,
+ClonedCodeInfo *CodeInfo = 0);
 
 /// CloneFunction - Version of the function that doesn't need the ValueMap.
 ///
-inline Function *CloneFunction(const Function *F) {
+inline Function *CloneFunction(const Function *F, ClonedCodeInfo *CodeInfo = 
0){
   std::map ValueMap;
-  return CloneFunction(F, ValueMap);
+  return CloneFunction(F, ValueMap, CodeInfo);
 }
 
 /// Clone OldFunc into NewFunc, transforming the old arguments into references
@@ -93,7 +125,8 @@
 void CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
std::map &ValueMap,
std::vector &Returns,
-   const char *NameSuffix = "");
+   const char *NameSuffix = "", 
+   ClonedCodeInfo *CodeInfo = 0);
 
 
 /// CloneTraceInto - Clone T into NewFunc. Original<->clone mapping is



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


[llvm-commits] CVS: llvm/test/Regression/Transforms/Inline/dynamic_alloca_test.ll

2006-01-13 Thread Chris Lattner


Changes in directory llvm/test/Regression/Transforms/Inline:

dynamic_alloca_test.ll added (r1.1)
---
Log message:

New testcase that functions with dynamic allocas can be inlined, and are
inlined correctly.


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

 dynamic_alloca_test.ll |   28 
 1 files changed, 28 insertions(+)


Index: llvm/test/Regression/Transforms/Inline/dynamic_alloca_test.ll
diff -c /dev/null 
llvm/test/Regression/Transforms/Inline/dynamic_alloca_test.ll:1.1
*** /dev/null   Fri Jan 13 13:35:15 2006
--- llvm/test/Regression/Transforms/Inline/dynamic_alloca_test.ll   Fri Jan 
13 13:35:05 2006
***
*** 0 
--- 1,28 
+ ; Test that functions with dynamic allocas get inlined in a case where
+ ; naively inlining it would result in a miscompilation.
+ 
+ ; RUN: llvm-as < %s | opt -inline &&
+ ; RUN: llvm-as < %s | opt -inline | llvm-dis | grep llvm.stacksave &&
+ ; RUN: llvm-as < %s | opt -inline | llvm-dis | not grep callee
+ 
+ declare void %ext(int*)
+ implementation
+ 
+ internal void %callee(uint %N) {
+   %P = alloca int, uint %N ;; dynamic alloca
+   call void %ext(int* %P)
+   ret void
+ }
+ 
+ void %foo(uint %N) {
+   br label %Loop
+ Loop:
+   %count = phi uint [0, %0], [%next, %Loop]
+   %next = add uint %count, 1
+   call void %callee(uint %N)
+   %cond = seteq uint %count, 10
+   br bool %cond, label %out, label %Loop
+ out:
+   ret void
+ }
+ 



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


[llvm-commits] CVS: llvm/lib/Transforms/Utils/CloneFunction.cpp

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

CloneFunction.cpp updated: 1.25 -> 1.26
---
Log message:

Allow the code cloning interfaces to capture some important info about the
code being cloned if the client wants.


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

 CloneFunction.cpp |   46 +++---
 1 files changed, 35 insertions(+), 11 deletions(-)


Index: llvm/lib/Transforms/Utils/CloneFunction.cpp
diff -u llvm/lib/Transforms/Utils/CloneFunction.cpp:1.25 
llvm/lib/Transforms/Utils/CloneFunction.cpp:1.26
--- llvm/lib/Transforms/Utils/CloneFunction.cpp:1.25Thu Apr 21 18:45:33 2005
+++ llvm/lib/Transforms/Utils/CloneFunction.cpp Fri Jan 13 12:39:17 2006
@@ -14,8 +14,9 @@
 
//===--===//
 
 #include "llvm/Transforms/Utils/Cloning.h"
-#include "llvm/Instructions.h"
+#include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
+#include "llvm/Instructions.h"
 #include "llvm/Function.h"
 #include "ValueMapper.h"
 using namespace llvm;
@@ -23,11 +24,14 @@
 // CloneBasicBlock - See comments in Cloning.h
 BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB,
   std::map &ValueMap,
-  const char *NameSuffix, Function *F) {
+  const char *NameSuffix, Function *F,
+  ClonedCodeInfo *CodeInfo) {
   BasicBlock *NewBB = new BasicBlock("", F);
   if (BB->hasName()) NewBB->setName(BB->getName()+NameSuffix);
 
-  // Loop over all instructions copying them over...
+  bool hasCalls = false, hasDynamicAllocas = false, hasStaticAllocas = false;
+  
+  // Loop over all instructions, and copy them over.
   for (BasicBlock::const_iterator II = BB->begin(), IE = BB->end();
II != IE; ++II) {
 Instruction *NewInst = II->clone();
@@ -35,6 +39,22 @@
   NewInst->setName(II->getName()+NameSuffix);
 NewBB->getInstList().push_back(NewInst);
 ValueMap[II] = NewInst;// Add instruction map to value.
+
+hasCalls |= isa(II);
+if (const AllocaInst *AI = dyn_cast(II)) {
+  if (isa(AI->getArraySize()))
+hasStaticAllocas = true;
+  else
+hasDynamicAllocas = true;
+}
+  }
+  
+  if (CodeInfo) {
+CodeInfo->ContainsCalls  |= hasCalls;
+CodeInfo->ContainsUnwinds|= isa(BB->getTerminator());
+CodeInfo->ContainsDynamicAllocas |= hasDynamicAllocas;
+CodeInfo->ContainsDynamicAllocas |= hasStaticAllocas && 
+BB != &BB->getParent()->front();
   }
   return NewBB;
 }
@@ -45,12 +65,12 @@
 void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
  std::map &ValueMap,
  std::vector &Returns,
- const char *NameSuffix) {
+ const char *NameSuffix, ClonedCodeInfo *CodeInfo) 
{
   assert(NameSuffix && "NameSuffix cannot be null!");
 
 #ifndef NDEBUG
-  for (Function::const_arg_iterator I = OldFunc->arg_begin(), E = 
OldFunc->arg_end();
-   I != E; ++I)
+  for (Function::const_arg_iterator I = OldFunc->arg_begin(), 
+   E = OldFunc->arg_end(); I != E; ++I)
 assert(ValueMap.count(I) && "No mapping from source argument specified!");
 #endif
 
@@ -63,7 +83,8 @@
 const BasicBlock &BB = *BI;
 
 // Create a new basic block and copy instructions into it!
-BasicBlock *CBB = CloneBasicBlock(&BB, ValueMap, NameSuffix, NewFunc);
+BasicBlock *CBB = CloneBasicBlock(&BB, ValueMap, NameSuffix, NewFunc,
+  CodeInfo);
 ValueMap[&BB] = CBB;   // Add basic block mapping.
 
 if (ReturnInst *RI = dyn_cast(CBB->getTerminator()))
@@ -89,13 +110,15 @@
 /// the function from their old to new values.
 ///
 Function *llvm::CloneFunction(const Function *F,
-  std::map &ValueMap) {
+  std::map &ValueMap,
+  ClonedCodeInfo *CodeInfo) {
   std::vector ArgTypes;
 
   // The user might be deleting arguments to the function by specifying them in
   // the ValueMap.  If so, we need to not add the arguments to the arg ty 
vector
   //
-  for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end(); I != 
E; ++I)
+  for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();
+   I != E; ++I)
 if (ValueMap.count(I) == 0)  // Haven't mapped the argument to anything 
yet?
   ArgTypes.push_back(I->getType());
 
@@ -108,14 +131,15 @@
 
   // Loop over the arguments, copying the names of the mapped arguments over...
   Function::arg_iterator DestI = NewF->arg_begin();
-  for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end(); I != 
E; ++I)
+  for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end();
+   I != E; ++I)
 if (ValueMap.count(I) == 0) {   // Is this 

[llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

InlineFunction.cpp updated: 1.37 -> 1.38
---
Log message:

Use the ClonedCodeInfo object to avoid scans of the inlined code when
it doesn't contain any calls.  This is a fairly common case for C++ code,
so it will probably speed up the inliner marginally in these cases.


---
Diffs of the changes:  (+67 -62)

 InlineFunction.cpp |  129 +++--
 1 files changed, 67 insertions(+), 62 deletions(-)


Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.37 
llvm/lib/Transforms/Utils/InlineFunction.cpp:1.38
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.37   Fri Jan 13 13:05:59 2006
+++ llvm/lib/Transforms/Utils/InlineFunction.cppFri Jan 13 13:15:15 2006
@@ -51,70 +51,75 @@
   // The inlined code is currently at the end of the function, scan from the
   // start of the inlined code to its end, checking for stuff we need to
   // rewrite.
-  for (Function::iterator BB = FirstNewBlock, E = Caller->end();
-   BB != E; ++BB) {
-for (BasicBlock::iterator BBI = BB->begin(), E = BB->end(); BBI != E; ) {
-  Instruction *I = BBI++;
-  
-  // We only need to check for function calls: inlined invoke instructions
-  // require no special handling.
-  if (!isa(I)) continue;
-  CallInst *CI = cast(I);
-
-  // If this is an intrinsic function call, do not convert it to an invoke.
-  if (CI->getCalledFunction() &&
-  CI->getCalledFunction()->getIntrinsicID())
-continue;
-  
-  // Convert this function call into an invoke instruction.
-  // First, split the basic block.
-  BasicBlock *Split = BB->splitBasicBlock(CI, CI->getName()+".noexc");
-  
-  // Next, create the new invoke instruction, inserting it at the end
-  // of the old basic block.
-  InvokeInst *II =
-new InvokeInst(CI->getCalledValue(), Split, InvokeDest,
-   std::vector(CI->op_begin()+1, CI->op_end()),
-   CI->getName(), BB->getTerminator());
-  II->setCallingConv(CI->getCallingConv());
-  
-  // Make sure that anything using the call now uses the invoke!
-  CI->replaceAllUsesWith(II);
-  
-  // Delete the unconditional branch inserted by splitBasicBlock
-  BB->getInstList().pop_back();
-  Split->getInstList().pop_front();  // Delete the original call
-  
-  // Update any PHI nodes in the exceptional block to indicate that
-  // there is now a new entry in them.
-  unsigned i = 0;
-  for (BasicBlock::iterator I = InvokeDest->begin();
-   isa(I); ++I, ++i) {
-PHINode *PN = cast(I);
-PN->addIncoming(InvokeDestPHIValues[i], BB);
+  if (InlinedCodeInfo.ContainsCalls || InlinedCodeInfo.ContainsUnwinds) {
+for (Function::iterator BB = FirstNewBlock, E = Caller->end();
+ BB != E; ++BB) {
+  if (InlinedCodeInfo.ContainsCalls) {
+for (BasicBlock::iterator BBI = BB->begin(), E = BB->end(); BBI != E; 
){
+  Instruction *I = BBI++;
+  
+  // We only need to check for function calls: inlined invoke
+  // instructions require no special handling.
+  if (!isa(I)) continue;
+  CallInst *CI = cast(I);
+
+  // If this is an intrinsic function call, don't convert it to an
+  // invoke.
+  if (CI->getCalledFunction() &&
+  CI->getCalledFunction()->getIntrinsicID())
+continue;
+  
+  // Convert this function call into an invoke instruction.
+  // First, split the basic block.
+  BasicBlock *Split = BB->splitBasicBlock(CI, CI->getName()+".noexc");
+  
+  // Next, create the new invoke instruction, inserting it at the end
+  // of the old basic block.
+  InvokeInst *II =
+new InvokeInst(CI->getCalledValue(), Split, InvokeDest,
+   std::vector(CI->op_begin()+1, CI->op_end()),
+   CI->getName(), BB->getTerminator());
+  II->setCallingConv(CI->getCallingConv());
+  
+  // Make sure that anything using the call now uses the invoke!
+  CI->replaceAllUsesWith(II);
+  
+  // Delete the unconditional branch inserted by splitBasicBlock
+  BB->getInstList().pop_back();
+  Split->getInstList().pop_front();  // Delete the original call
+  
+  // Update any PHI nodes in the exceptional block to indicate that
+  // there is now a new entry in them.
+  unsigned i = 0;
+  for (BasicBlock::iterator I = InvokeDest->begin();
+   isa(I); ++I, ++i) {
+PHINode *PN = cast(I);
+PN->addIncoming(InvokeDestPHIValues[i], BB);
+  }
+
+  // This basic block is now complete, start scanning the next one.
+  break;
+}
   }
-   

[llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

InlineFunction.cpp updated: 1.36 -> 1.37
---
Log message:

Refactor a bunch of invoke handling stuff out into a new function
"HandleInlinedInvoke".  No functionality change.


---
Diffs of the changes:  (+108 -88)

 InlineFunction.cpp |  196 +
 1 files changed, 108 insertions(+), 88 deletions(-)


Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.36 
llvm/lib/Transforms/Utils/InlineFunction.cpp:1.37
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.36   Fri Jan 13 12:16:48 2006
+++ llvm/lib/Transforms/Utils/InlineFunction.cppFri Jan 13 13:05:59 2006
@@ -24,6 +24,109 @@
 bool llvm::InlineFunction(CallInst *CI) { return InlineFunction(CallSite(CI)); 
}
 bool llvm::InlineFunction(InvokeInst *II) {return 
InlineFunction(CallSite(II));}
 
+/// HandleInlinedInvoke - If we inlined an invoke site, we need to convert 
calls
+/// in the body of the inlined function into invokes and turn unwind
+/// instructions into branches to the invoke unwind dest.
+///
+/// II is the invoke instruction begin inlined.  FirstNewBlock is the first
+/// block of the inlined code (the last block is the end of the function),
+/// and InlineCodeInfo is information about the code that got inlined.
+static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock,
+ClonedCodeInfo &InlinedCodeInfo) {
+  BasicBlock *InvokeDest = II->getUnwindDest();
+  std::vector InvokeDestPHIValues;
+
+  // If there are PHI nodes in the unwind destination block, we need to
+  // keep track of which values came into them from this invoke, then remove
+  // the entry for this block.
+  BasicBlock *InvokeBlock = II->getParent();
+  for (BasicBlock::iterator I = InvokeDest->begin(); isa(I); ++I) {
+PHINode *PN = cast(I);
+// Save the value to use for this edge.
+InvokeDestPHIValues.push_back(PN->getIncomingValueForBlock(InvokeBlock));
+  }
+
+  Function *Caller = FirstNewBlock->getParent();
+  
+  // The inlined code is currently at the end of the function, scan from the
+  // start of the inlined code to its end, checking for stuff we need to
+  // rewrite.
+  for (Function::iterator BB = FirstNewBlock, E = Caller->end();
+   BB != E; ++BB) {
+for (BasicBlock::iterator BBI = BB->begin(), E = BB->end(); BBI != E; ) {
+  Instruction *I = BBI++;
+  
+  // We only need to check for function calls: inlined invoke instructions
+  // require no special handling.
+  if (!isa(I)) continue;
+  CallInst *CI = cast(I);
+
+  // If this is an intrinsic function call, do not convert it to an invoke.
+  if (CI->getCalledFunction() &&
+  CI->getCalledFunction()->getIntrinsicID())
+continue;
+  
+  // Convert this function call into an invoke instruction.
+  // First, split the basic block.
+  BasicBlock *Split = BB->splitBasicBlock(CI, CI->getName()+".noexc");
+  
+  // Next, create the new invoke instruction, inserting it at the end
+  // of the old basic block.
+  InvokeInst *II =
+new InvokeInst(CI->getCalledValue(), Split, InvokeDest,
+   std::vector(CI->op_begin()+1, CI->op_end()),
+   CI->getName(), BB->getTerminator());
+  II->setCallingConv(CI->getCallingConv());
+  
+  // Make sure that anything using the call now uses the invoke!
+  CI->replaceAllUsesWith(II);
+  
+  // Delete the unconditional branch inserted by splitBasicBlock
+  BB->getInstList().pop_back();
+  Split->getInstList().pop_front();  // Delete the original call
+  
+  // Update any PHI nodes in the exceptional block to indicate that
+  // there is now a new entry in them.
+  unsigned i = 0;
+  for (BasicBlock::iterator I = InvokeDest->begin();
+   isa(I); ++I, ++i) {
+PHINode *PN = cast(I);
+PN->addIncoming(InvokeDestPHIValues[i], BB);
+  }
+
+  // This basic block is now complete, start scanning the next one.
+  break;
+}
+
+if (UnwindInst *UI = dyn_cast(BB->getTerminator())) {
+  // An UnwindInst requires special handling when it gets inlined into an
+  // invoke site.  Once this happens, we know that the unwind would cause
+  // a control transfer to the invoke exception destination, so we can
+  // transform it into a direct branch to the exception destination.
+  new BranchInst(InvokeDest, UI);
+  
+  // Delete the unwind instruction!
+  UI->getParent()->getInstList().pop_back();
+  
+  // Update any PHI nodes in the exceptional block to indicate that
+  // there is now a new entry in them.
+  unsigned i = 0;
+  for (BasicBlock::iterator I = InvokeDest->begin();
+   isa(I); ++I, ++i) {
+PHINode *PN = cast(I);
+PN->addIncoming(InvokeDestPHIValues[i], BB);
+  }

[llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

InlineFunction.cpp updated: 1.38 -> 1.39
---
Log message:

Use ClonedCodeInfo to avoid another walk over the inlined code, this this
time in common C cases.


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

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


Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.38 
llvm/lib/Transforms/Utils/InlineFunction.cpp:1.39
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.38   Fri Jan 13 13:15:15 2006
+++ llvm/lib/Transforms/Utils/InlineFunction.cppFri Jan 13 13:18:11 2006
@@ -215,8 +215,10 @@
 }
   }
 
-  // If we are inlining tail call instruction through an invoke or
-  if (MustClearTailCallFlags) {
+  // If we are inlining tail call instruction through a call site that isn't 
+  // marked 'tail', we must remove the tail marker for any calls in the inlined
+  // code.
+  if (MustClearTailCallFlags && InlinedFunctionInfo.ContainsCalls) {
 for (Function::iterator BB = FirstNewBlock, E = Caller->end();
  BB != E; ++BB)
   for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)



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


[llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/Utils:

InlineFunction.cpp updated: 1.35 -> 1.36
---
Log message:

Fix a bug I noticed by inspection: if the first instruction in the inlined
function was not an alloca, we wouldn't check the entry block for any allocas,
leading to increased stack space in some cases.  In practice, allocas are almost
always at the top of the block, so this was never noticed.


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

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


Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.35 
llvm/lib/Transforms/Utils/InlineFunction.cpp:1.36
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.35   Wed Jul 27 01:12:34 2005
+++ llvm/lib/Transforms/Utils/InlineFunction.cppFri Jan 13 12:16:48 2006
@@ -10,9 +10,6 @@
 // This file implements inlining of a function into a call site, resolving
 // parameters and the return value as appropriate.
 //
-// FIXME: This pass should transform alloca instructions in the called function
-// into alloca/dealloca pairs!  Or perhaps it should refuse to inline them!
-//
 
//===--===//
 
 #include "llvm/Transforms/Utils/Cloning.h"
@@ -87,13 +84,14 @@
   // calculate which instruction they should be inserted before.  We insert the
   // instructions at the end of the current alloca list.
   //
-  if (isa(FirstNewBlock->begin())) {
+  {
 BasicBlock::iterator InsertPoint = Caller->begin()->begin();
 for (BasicBlock::iterator I = FirstNewBlock->begin(),
E = FirstNewBlock->end(); I != E; )
   if (AllocaInst *AI = dyn_cast(I++))
 if (isa(AI->getArraySize())) {
-  // Scan for the block of allocas that we can move over.
+  // Scan for the block of allocas that we can move over, and move them
+  // all at once.
   while (isa(I) &&
  isa(cast(I)->getArraySize()))
 ++I;



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


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

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.261 -> 1.262
---
Log message:

If a target specified a stack pointer with setStackPointerRegisterToSaveRestore,
lower STACKSAVE/STACKRESTORE into a copy from/to that register.


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

 LegalizeDAG.cpp |   26 +-
 1 files changed, 21 insertions(+), 5 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.261 
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.262
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.261 Thu Jan 12 20:50:02 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp   Fri Jan 13 11:48:44 2006
@@ -1453,10 +1453,20 @@
   AddLegalizedOperand(SDOperand(Node, 1), Result.getValue(1));
   return Result.getValue(Op.ResNo);
 case TargetLowering::Expand:
-  Tmp1 = DAG.getNode(ISD::UNDEF, Node->getValueType(0));
-  AddLegalizedOperand(SDOperand(Node, 0), Tmp1);
-  AddLegalizedOperand(SDOperand(Node, 1), Node->getOperand(0));
-  return Op.ResNo ? Node->getOperand(0) : Tmp1;
+  // Expand to CopyFromReg if the target set 
+  // StackPointerRegisterToSaveRestore.
+  if (unsigned SP = TLI.getStackPointerRegisterToSaveRestore()) {
+Tmp1 = DAG.getCopyFromReg(Node->getOperand(0), SP, 
+  Node->getValueType(0));
+AddLegalizedOperand(SDOperand(Node, 0), Tmp1);
+AddLegalizedOperand(SDOperand(Node, 1), Tmp1.getValue(1));
+return Tmp1.getValue(Op.ResNo);
+  } else {
+Tmp1 = DAG.getNode(ISD::UNDEF, Node->getValueType(0));
+AddLegalizedOperand(SDOperand(Node, 0), Tmp1);
+AddLegalizedOperand(SDOperand(Node, 1), Node->getOperand(0));
+return Op.ResNo ? Node->getOperand(0) : Tmp1;
+  }
 }
 
   case ISD::STACKRESTORE:
@@ -1478,7 +1488,13 @@
 case TargetLowering::Legal:
   break;
 case TargetLowering::Expand:
-  Result = Tmp1;
+  // Expand to CopyToReg if the target set 
+  // StackPointerRegisterToSaveRestore.
+  if (unsigned SP = TLI.getStackPointerRegisterToSaveRestore()) {
+Result = DAG.getCopyToReg(Tmp1, SP, Tmp2);
+  } else {
+Result = Tmp1;
+  }
   break;
 }
 break;



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


[llvm-commits] CVS: llvm/lib/Transforms/IPO/Inliner.cpp

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Transforms/IPO:

Inliner.cpp updated: 1.24 -> 1.25
---
Log message:

Fix 80 column violations


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

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


Index: llvm/lib/Transforms/IPO/Inliner.cpp
diff -u llvm/lib/Transforms/IPO/Inliner.cpp:1.24 
llvm/lib/Transforms/IPO/Inliner.cpp:1.25
--- llvm/lib/Transforms/IPO/Inliner.cpp:1.24Thu Apr 21 18:39:37 2005
+++ llvm/lib/Transforms/IPO/Inliner.cpp Fri Jan 13 12:06:56 2006
@@ -27,10 +27,11 @@
 
 namespace {
   Statistic<> NumInlined("inline", "Number of functions inlined");
-  Statistic<> NumDeleted("inline", "Number of functions deleted because all 
callers found");
+  Statistic<> NumDeleted("inline",
+   "Number of functions deleted because all callers 
found");
   cl::opt // FIXME: 200 is VERY conservative
   InlineLimit("inline-threshold", cl::Hidden, cl::init(200),
-  cl::desc("Control the amount of inlining to perform (default = 
200)"));
+cl::desc("Control the amount of inlining to perform (default = 200)"));
 }
 
 Inliner::Inliner() : InlineThreshold(InlineLimit) {}



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


[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelLowering.cpp X86ISelPattern.cpp

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Target/X86:

X86ISelLowering.cpp updated: 1.38 -> 1.39
X86ISelPattern.cpp updated: 1.195 -> 1.196
---
Log message:

Enable X86 support for savestack/restorestack


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

 X86ISelLowering.cpp |1 +
 X86ISelPattern.cpp  |2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)


Index: llvm/lib/Target/X86/X86ISelLowering.cpp
diff -u llvm/lib/Target/X86/X86ISelLowering.cpp:1.38 
llvm/lib/Target/X86/X86ISelLowering.cpp:1.39
--- llvm/lib/Target/X86/X86ISelLowering.cpp:1.38Thu Jan 12 20:42:53 2006
+++ llvm/lib/Target/X86/X86ISelLowering.cpp Fri Jan 13 12:00:54 2006
@@ -39,6 +39,7 @@
   setSetCCResultType(MVT::i8);
   setSetCCResultContents(ZeroOrOneSetCCResult);
   setShiftAmountFlavor(Mask);   // shl X, 32 == shl X, 0
+  setStackPointerRegisterToSaveRestore(X86::ESP);
 
   // Set up the register classes.
   addRegisterClass(MVT::i8, X86::R8RegisterClass);


Index: llvm/lib/Target/X86/X86ISelPattern.cpp
diff -u llvm/lib/Target/X86/X86ISelPattern.cpp:1.195 
llvm/lib/Target/X86/X86ISelPattern.cpp:1.196
--- llvm/lib/Target/X86/X86ISelPattern.cpp:1.195Thu Jan 12 16:54:21 2006
+++ llvm/lib/Target/X86/X86ISelPattern.cpp  Fri Jan 13 12:00:54 2006
@@ -1229,7 +1229,7 @@
   cast(Node->getOperand(1))->getReg() :
   cast(Node)->getReg();
 // Just use the specified register as our input if we can.
-if (MRegisterInfo::isVirtualRegister(Reg) || Reg == X86::ESP)
+if (MRegisterInfo::isVirtualRegister(Reg))
   return Reg;
   } 
 



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


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

2006-01-13 Thread Chris Lattner


Changes in directory llvm/lib/Target/PowerPC:

PPCISelLowering.cpp updated: 1.64 -> 1.65
---
Log message:

implement stacksave/stackrestore on PPC


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

 PPCISelLowering.cpp |1 +
 1 files changed, 1 insertion(+)


Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
diff -u llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.64 
llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.65
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp:1.64Thu Jan 12 20:42:53 2006
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp Fri Jan 13 11:52:03 2006
@@ -142,6 +142,7 @@
   }
   
   setSetCCResultContents(ZeroOrOneSetCCResult);
+  setStackPointerRegisterToSaveRestore(PPC::R1);
   
   computeRegisterProperties();
 }



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


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

2006-01-13 Thread Chris Lattner


Changes in directory llvm/include/llvm/Target:

TargetLowering.h updated: 1.33 -> 1.34
---
Log message:

Provide an interface for Targets to specify their stack pointer register
for llvm.stacksave/restore.


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

 TargetLowering.h |   19 +++
 1 files changed, 19 insertions(+)


Index: llvm/include/llvm/Target/TargetLowering.h
diff -u llvm/include/llvm/Target/TargetLowering.h:1.33 
llvm/include/llvm/Target/TargetLowering.h:1.34
--- llvm/include/llvm/Target/TargetLowering.h:1.33  Wed Dec 21 19:46:59 2005
+++ llvm/include/llvm/Target/TargetLowering.h   Fri Jan 13 11:47:52 2006
@@ -234,6 +234,13 @@
   bool usesUnderscoreSetJmpLongJmp() const {
 return UseUnderscoreSetJmpLongJmp;
   }
+  
+  /// getStackPointerRegisterToSaveRestore - If a physical register, this
+  /// specifies the register that llvm.savestack/llvm.restorestack should save
+  /// and restore.
+  unsigned getStackPointerRegisterToSaveRestore() const {
+return StackPointerRegisterToSaveRestore;
+  }
 
   
//======//
   // TargetLowering Configuration Methods - These methods should be invoked by
@@ -267,6 +274,13 @@
 UseUnderscoreSetJmpLongJmp = Val;
   }
   
+  /// setStackPointerRegisterToSaveRestore - If set to a physical register, 
this
+  /// specifies the register that llvm.savestack/llvm.restorestack should save
+  /// and restore.
+  void setStackPointerRegisterToSaveRestore(unsigned R) {
+StackPointerRegisterToSaveRestore = R;
+  }
+  
   /// setSetCCIxExpensive - This is a short term hack for targets that codegen
   /// setcc as a conditional branch.  This encourages the code generator to 
fold
   /// setcc operations into other operations if possible.
@@ -443,6 +457,11 @@
   /// UseUnderscoreSetJmpLongJmp - This target prefers to use _setjmp and
   /// _longjmp to implement llvm.setjmp/llvm.longjmp.  Defaults to false.
   bool UseUnderscoreSetJmpLongJmp;
+  
+  /// StackPointerRegisterToSaveRestore - If set to a physical register, this
+  /// specifies the register that llvm.savestack/llvm.restorestack should save
+  /// and restore.
+  unsigned StackPointerRegisterToSaveRestore;
 
   /// RegClassForVT - This indicates the default register class to use for
   /// each ValueType the target supports natively.



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


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

2006-01-13 Thread Duraid Madina


Changes in directory llvm/lib/Target/IA64:

IA64ISelDAGToDAG.cpp updated: 1.19 -> 1.20
---
Log message:

don't be a doofus - this fixes storing bools



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

 IA64ISelDAGToDAG.cpp |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)


Index: llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp
diff -u llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.19 
llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.20
--- llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp:1.19  Wed Jan 11 13:53:22 2006
+++ llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp   Fri Jan 13 04:28:25 2006
@@ -571,9 +571,12 @@
   default: assert(0 && "unknown type in store");
   case MVT::i1: { // this is a bool
 Opc = IA64::ST1; // we store either 0 or 1 as a byte 
+   // first load zero!
+   SDOperand Initial = CurDAG->getCopyFromReg(Chain, IA64::r0, MVT::i64);
+   Chain = Initial.getValue(1);
+   // then load 1 iff the predicate to store is 1
 SDOperand Tmp = 
-  CurDAG->getTargetNode(IA64::PADDS, MVT::i64,
-CurDAG->getRegister(IA64::r0, MVT::i64),
+  CurDAG->getTargetNode(IA64::PADDS, MVT::i64, Initial,
 CurDAG->getConstant(1, MVT::i64),
 Select(N->getOperand(1)));
 return CurDAG->SelectNodeTo(N, Opc, MVT::Other, Address, Tmp, Chain);



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