[llvm-commits] [llvm] r43498 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

2007-10-30 Thread Duncan Sands
Author: baldrick
Date: Tue Oct 30 07:40:58 2007
New Revision: 43498

URL: http://llvm.org/viewvc/llvm-project?rev=43498&view=rev
Log:
If a call to getTruncStore is for a normal store,
offload to getStore rather than trying to handle
both cases at once (the assertions for example
assume the store really is truncating).

Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=43498&r1=43497&r2=43498&view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Oct 30 07:40:58 
2007
@@ -2460,7 +2460,9 @@
   int SVOffset, MVT::ValueType SVT,
   bool isVolatile, unsigned Alignment) {
   MVT::ValueType VT = Val.getValueType();
-  bool isTrunc = VT != SVT;
+
+  if (VT == SVT)
+return getStore(Chain, Val, Ptr, SV, SVOffset, isVolatile, Alignment);
 
   assert(MVT::getSizeInBits(VT) > MVT::getSizeInBits(SVT) &&
  "Not a truncation?");
@@ -2485,7 +2487,7 @@
   FoldingSetNodeID ID;
   AddNodeIDNode(ID, ISD::STORE, VTs, Ops, 4);
   ID.AddInteger(ISD::UNINDEXED);
-  ID.AddInteger(isTrunc);
+  ID.AddInteger(1);
   ID.AddInteger((unsigned int)SVT);
   ID.AddPointer(SV);
   ID.AddInteger(SVOffset);
@@ -2494,7 +2496,7 @@
   void *IP = 0;
   if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
 return SDOperand(E, 0);
-  SDNode *N = new StoreSDNode(Ops, VTs, ISD::UNINDEXED, isTrunc,
+  SDNode *N = new StoreSDNode(Ops, VTs, ISD::UNINDEXED, true,
   SVT, SV, SVOffset, Alignment, isVolatile);
   CSEMap.InsertNode(N, IP);
   AllNodes.push_back(N);


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


[llvm-commits] [llvm] r43499 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAGTypes.cpp

2007-10-30 Thread Duncan Sands
Author: baldrick
Date: Tue Oct 30 07:50:39 2007
New Revision: 43499

URL: http://llvm.org/viewvc/llvm-project?rev=43499&view=rev
Log:
Add support for expanding trunc stores.  Consider
storing an i170 on a 32 bit machine.  This is first
promoted to a trunc-i170 store of an i256.  On a
little-endian machine this expands to a store of
an i128 and a trunc-i42 store of an i128.  The
trunc-i42 store is further expanded to a trunc-i42
store of an i64, then to a store of an i32 and a
trunc-i10 store of an i32.  At this point the operand
type is legal (i32) and expansion stops (legalization
of the trunc-i10 needs to be handled in LegalizeDAG.cpp).
On big-endian machines the high bits are stored first,
and some bit-fiddling is needed in order to generate
aligned stores.

Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAGTypes.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAGTypes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAGTypes.cpp?rev=43499&r1=43498&r2=43499&view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAGTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAGTypes.cpp Tue Oct 30 
07:50:39 2007
@@ -1936,75 +1936,139 @@
 
 SDOperand DAGTypeLegalizer::ExpandOperand_STORE(StoreSDNode *N, unsigned OpNo) 
{
   assert(OpNo == 1 && "Can only expand the stored value so far");
-  assert(!N->isTruncatingStore() && "Can't expand truncstore!");
 
-  unsigned IncrementSize = 0;
+  MVT::ValueType VT = N->getOperand(1).getValueType();
+  MVT::ValueType NVT = TLI.getTypeToTransformTo(VT);
+  SDOperand Ch  = N->getChain();
+  SDOperand Ptr = N->getBasePtr();
+  int SVOffset = N->getSrcValueOffset();
+  unsigned Alignment = N->getAlignment();
+  bool isVolatile = N->isVolatile();
   SDOperand Lo, Hi;
-  
-  // If this is a vector type, then we have to calculate the increment as
-  // the product of the element size in bytes, and the number of elements
-  // in the high half of the vector.
-  if (MVT::isVector(N->getValue().getValueType())) {
-assert(0 && "Vectors not supported yet");
-#if 0
-SDNode *InVal = ST->getValue().Val;
-unsigned NumElems = MVT::getVectorNumElements(InVal->getValueType(0));
-MVT::ValueType EVT = MVT::getVectorElementType(InVal->getValueType(0));
-
-// Figure out if there is a simple type corresponding to this Vector
-// type.  If so, convert to the vector type.
-MVT::ValueType TVT = MVT::getVectorType(EVT, NumElems);
-if (TLI.isTypeLegal(TVT)) {
-  // Turn this into a normal store of the vector type.
-  Tmp3 = LegalizeOp(Node->getOperand(1));
-  Result = DAG.getStore(Tmp1, Tmp3, Tmp2, ST->getSrcValue(),
-SVOffset, isVolatile, Alignment);
-  Result = LegalizeOp(Result);
-  break;
-} else if (NumElems == 1) {
-  // Turn this into a normal store of the scalar type.
-  Tmp3 = ScalarizeVectorOp(Node->getOperand(1));
-  Result = DAG.getStore(Tmp1, Tmp3, Tmp2, ST->getSrcValue(),
-SVOffset, isVolatile, Alignment);
-  // The scalarized value type may not be legal, e.g. it might require
-  // promotion or expansion.  Relegalize the scalar store.
-  return LegalizeOp(Result);
+
+  assert(!(MVT::getSizeInBits(NVT) & 7) && "Expanded type not byte sized!");
+
+  if (!N->isTruncatingStore()) {
+unsigned IncrementSize = 0;
+
+// If this is a vector type, then we have to calculate the increment as
+// the product of the element size in bytes, and the number of elements
+// in the high half of the vector.
+if (MVT::isVector(N->getValue().getValueType())) {
+  assert(0 && "Vectors not supported yet");
+  #if 0
+  SDNode *InVal = ST->getValue().Val;
+  unsigned NumElems = MVT::getVectorNumElements(InVal->getValueType(0));
+  MVT::ValueType EVT = MVT::getVectorElementType(InVal->getValueType(0));
+
+  // Figure out if there is a simple type corresponding to this Vector
+  // type.  If so, convert to the vector type.
+  MVT::ValueType TVT = MVT::getVectorType(EVT, NumElems);
+  if (TLI.isTypeLegal(TVT)) {
+// Turn this into a normal store of the vector type.
+Tmp3 = LegalizeOp(Node->getOperand(1));
+Result = DAG.getStore(Tmp1, Tmp3, Tmp2, ST->getSrcValue(),
+  SVOffset, isVolatile, Alignment);
+Result = LegalizeOp(Result);
+break;
+  } else if (NumElems == 1) {
+// Turn this into a normal store of the scalar type.
+Tmp3 = ScalarizeVectorOp(Node->getOperand(1));
+Result = DAG.getStore(Tmp1, Tmp3, Tmp2, ST->getSrcValue(),
+  SVOffset, isVolatile, Alignment);
+// The scalarized value type may not be legal, e.g. it might require
+// promotion or expansion.  Relegalize the scalar store.
+return LegalizeOp(Result);
+  

[llvm-commits] [llvm] r43500 - in /llvm/trunk/lib/Target/X86: X86ATTAsmPrinter.h X86IntelAsmPrinter.h

2007-10-30 Thread Duncan Sands
Author: baldrick
Date: Tue Oct 30 08:14:37 2007
New Revision: 43500

URL: http://llvm.org/viewvc/llvm-project?rev=43500&view=rev
Log:
Fix for visibility warnings generated by gcc-4.2.

Modified:
llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.h
llvm/trunk/lib/Target/X86/X86IntelAsmPrinter.h

Modified: llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.h?rev=43500&r1=43499&r2=43500&view=diff

==
--- llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.h (original)
+++ llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.h Tue Oct 30 08:14:37 2007
@@ -19,7 +19,7 @@
 
 namespace llvm {
 
-struct X86ATTAsmPrinter : public X86SharedAsmPrinter {
+struct VISIBILITY_HIDDEN X86ATTAsmPrinter : public X86SharedAsmPrinter {
  X86ATTAsmPrinter(std::ostream &O, X86TargetMachine &TM, const TargetAsmInfo 
*T)
 : X86SharedAsmPrinter(O, TM, T) { }
 

Modified: llvm/trunk/lib/Target/X86/X86IntelAsmPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86IntelAsmPrinter.h?rev=43500&r1=43499&r2=43500&view=diff

==
--- llvm/trunk/lib/Target/X86/X86IntelAsmPrinter.h (original)
+++ llvm/trunk/lib/Target/X86/X86IntelAsmPrinter.h Tue Oct 30 08:14:37 2007
@@ -20,7 +20,7 @@
 
 namespace llvm {
 
-struct X86IntelAsmPrinter : public X86SharedAsmPrinter {
+struct VISIBILITY_HIDDEN X86IntelAsmPrinter : public X86SharedAsmPrinter {
   X86IntelAsmPrinter(std::ostream &O, X86TargetMachine &TM,
  const TargetAsmInfo *T)
   : X86SharedAsmPrinter(O, TM, T) {


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


[llvm-commits] [llvm] r43510 - in /llvm/trunk: lib/VMCore/ConstantFold.cpp test/Transforms/InstCombine/fold-vector-zero.ll

2007-10-30 Thread Dan Gohman
Author: djg
Date: Tue Oct 30 14:00:49 2007
New Revision: 43510

URL: http://llvm.org/viewvc/llvm-project?rev=43510&view=rev
Log:
Add support for folding binary operators with vector zero operands.

Added:
llvm/trunk/test/Transforms/InstCombine/fold-vector-zero.ll
Modified:
llvm/trunk/lib/VMCore/ConstantFold.cpp

Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=43510&r1=43509&r2=43510&view=diff

==
--- llvm/trunk/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/trunk/lib/VMCore/ConstantFold.cpp Tue Oct 30 14:00:49 2007
@@ -450,14 +450,20 @@
 
 /// EvalVectorOp - Given two vector constants and a function pointer, apply the
 /// function pointer to each element pair, producing a new ConstantVector
-/// constant.
+/// constant. Either or both of V1 and V2 may be NULL, meaning a
+/// ConstantAggregateZero operand.
 static Constant *EvalVectorOp(const ConstantVector *V1, 
   const ConstantVector *V2,
+  const VectorType *VTy,
   Constant *(*FP)(Constant*, Constant*)) {
   std::vector Res;
-  for (unsigned i = 0, e = V1->getNumOperands(); i != e; ++i)
-Res.push_back(FP(const_cast(V1->getOperand(i)),
- const_cast(V2->getOperand(i;
+  const Type *EltTy = VTy->getElementType();
+  for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
+const Constant *C1 = V1 ? V1->getOperand(i) : 
Constant::getNullValue(EltTy);
+const Constant *C2 = V2 ? V2->getOperand(i) : 
Constant::getNullValue(EltTy);
+Res.push_back(FP(const_cast(C1),
+ const_cast(C2)));
+  }
   return ConstantVector::get(Res);
 }
 
@@ -707,36 +713,40 @@
 return ConstantFP::get(CFP1->getType(), C3V);
   }
 }
-  } else if (const ConstantVector *CP1 = dyn_cast(C1)) {
-if (const ConstantVector *CP2 = dyn_cast(C2)) {
+  } else if (const VectorType *VTy = dyn_cast(C1->getType())) {
+const ConstantVector *CP1 = dyn_cast(C1);
+const ConstantVector *CP2 = dyn_cast(C2);
+assert((CP1 != NULL || isa(C1)) &&
+   "Unexpected kind of vector constant!");
+assert((CP2 != NULL || isa(C2)) &&
+   "Unexpected kind of vector constant!");
   switch (Opcode) {
 default:
   break;
 case Instruction::Add: 
-  return EvalVectorOp(CP1, CP2, ConstantExpr::getAdd);
+return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getAdd);
 case Instruction::Sub: 
-  return EvalVectorOp(CP1, CP2, ConstantExpr::getSub);
+return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getSub);
 case Instruction::Mul: 
-  return EvalVectorOp(CP1, CP2, ConstantExpr::getMul);
+return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getMul);
 case Instruction::UDiv:
-  return EvalVectorOp(CP1, CP2, ConstantExpr::getUDiv);
+return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getUDiv);
 case Instruction::SDiv:
-  return EvalVectorOp(CP1, CP2, ConstantExpr::getSDiv);
+return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getSDiv);
 case Instruction::FDiv:
-  return EvalVectorOp(CP1, CP2, ConstantExpr::getFDiv);
+return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getFDiv);
 case Instruction::URem:
-  return EvalVectorOp(CP1, CP2, ConstantExpr::getURem);
+return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getURem);
 case Instruction::SRem:
-  return EvalVectorOp(CP1, CP2, ConstantExpr::getSRem);
+return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getSRem);
 case Instruction::FRem:
-  return EvalVectorOp(CP1, CP2, ConstantExpr::getFRem);
+return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getFRem);
 case Instruction::And: 
-  return EvalVectorOp(CP1, CP2, ConstantExpr::getAnd);
+return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getAnd);
 case Instruction::Or:  
-  return EvalVectorOp(CP1, CP2, ConstantExpr::getOr);
+return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getOr);
 case Instruction::Xor: 
-  return EvalVectorOp(CP1, CP2, ConstantExpr::getXor);
-  }
+return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getXor);
 }
   }
 

Added: llvm/trunk/test/Transforms/InstCombine/fold-vector-zero.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fold-vector-zero.ll?rev=43510&view=auto

==
--- llvm/trunk/test/Transforms/InstCombine/fold-vector-zero.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/fold-vector-zero.ll Tue Oct 30 
14:00:49 2007
@@ -0,0 +1,35 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep zeroinitializer
+
+define void @foo(i64 %A, i64 %B) {
+bb8:

[llvm-commits] [llvm] r43511 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-10-30 Thread Evan Cheng
Author: evancheng
Date: Tue Oct 30 15:11:21 2007
New Revision: 43511

URL: http://llvm.org/viewvc/llvm-project?rev=43511&view=rev
Log:
Typo.

Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=43511&r1=43510&r2=43511&view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Oct 30 15:11:21 2007
@@ -2771,7 +2771,7 @@
   if (SOp == Trunc)
 Ops.push_back(ExtLoad);
   else
-Ops.push_back(DAG.getNode(ISD::SIGN_EXTEND, VT, SOp));
+Ops.push_back(DAG.getNode(ISD::ZERO_EXTEND, VT, SOp));
   }
 Ops.push_back(SetCC->getOperand(2));
 CombineTo(SetCC, DAG.getNode(ISD::SETCC, SetCC->getValueType(0),


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


[llvm-commits] [llvm-gcc-4.2] r43521 - /llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp

2007-10-30 Thread Dale Johannesen
Author: johannes
Date: Tue Oct 30 17:10:42 2007
New Revision: 43521

URL: http://llvm.org/viewvc/llvm-project?rev=43521&view=rev
Log:
Add missing vec_set_v4hi builtin.
/

Modified:
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp

Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=43521&r1=43520&r2=43521&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Tue Oct 30 17:10:42 2007
@@ -455,6 +455,7 @@
   case IX86_BUILTIN_VEC_EXT_V8HI:
 Result = Builder.CreateExtractElement(Ops[0], Ops[1], "tmp");
 return true;
+  case IX86_BUILTIN_VEC_SET_V4HI:
   case IX86_BUILTIN_VEC_SET_V8HI:
 // GCC sometimes doesn't produce the right element type.
 Ops[1] = Builder.CreateIntCast(Ops[1], Type::Int16Ty, false, "tmp");


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


[llvm-commits] [llvm] r43523 - in /llvm/trunk: include/llvm/IntrinsicsX86.td lib/Target/X86/X86InstrSSE.td

2007-10-30 Thread Dale Johannesen
Author: johannes
Date: Tue Oct 30 17:15:38 2007
New Revision: 43523

URL: http://llvm.org/viewvc/llvm-project?rev=43523&view=rev
Log:
Add missing SSE builtins:  CVTPD2PI, CVTPS2PI,
CVTTPD2PI, CVTTPS2PI, CVTPI2PD, CVTPI2PS.


Modified:
llvm/trunk/include/llvm/IntrinsicsX86.td
llvm/trunk/lib/Target/X86/X86InstrSSE.td

Modified: llvm/trunk/include/llvm/IntrinsicsX86.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=43523&r1=43522&r2=43523&view=diff

==
--- llvm/trunk/include/llvm/IntrinsicsX86.td (original)
+++ llvm/trunk/include/llvm/IntrinsicsX86.td Tue Oct 30 17:15:38 2007
@@ -124,6 +124,13 @@
   def int_x86_sse_cvtsi642ss : GCCBuiltin<"__builtin_ia32_cvtsi642ss">,
   Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty,
  llvm_i64_ty], [IntrNoMem]>;
+  def int_x86_sse_cvtps2pi : GCCBuiltin<"__builtin_ia32_cvtps2pi">,
+  Intrinsic<[llvm_v2i32_ty, llvm_v4f32_ty], [IntrNoMem]>;
+  def int_x86_sse_cvttps2pi: GCCBuiltin<"__builtin_ia32_cvttps2pi">,
+  Intrinsic<[llvm_v2i32_ty, llvm_v4f32_ty], [IntrNoMem]>;
+  def int_x86_sse_cvtpi2ps : GCCBuiltin<"__builtin_ia32_cvtpi2ps">,
+  Intrinsic<[llvm_v4f32_ty, llvm_v4f32_ty, 
+ llvm_v2i32_ty], [IntrNoMem]>;
 }
 
 // SIMD load ops
@@ -400,6 +407,12 @@
   def int_x86_sse2_cvtss2sd : GCCBuiltin<"__builtin_ia32_cvtss2sd">,
   Intrinsic<[llvm_v2f64_ty, llvm_v2f64_ty,
  llvm_v4f32_ty], [IntrNoMem]>;
+  def int_x86_sse_cvtpd2pi : GCCBuiltin<"__builtin_ia32_cvtpd2pi">,
+  Intrinsic<[llvm_v2i32_ty, llvm_v2f64_ty], [IntrNoMem]>;
+  def int_x86_sse_cvttpd2pi: GCCBuiltin<"__builtin_ia32_cvttpd2pi">,
+  Intrinsic<[llvm_v2i32_ty, llvm_v2f64_ty], [IntrNoMem]>;
+  def int_x86_sse_cvtpi2pd : GCCBuiltin<"__builtin_ia32_cvtpi2pd">,
+  Intrinsic<[llvm_v2f64_ty, llvm_v2i32_ty], [IntrNoMem]>;
 }
 
 // SIMD load ops

Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=43523&r1=43522&r2=43523&view=diff

==
--- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Tue Oct 30 17:15:38 2007
@@ -331,6 +331,34 @@
  [(set GR32:$dst, (int_x86_sse_cvtss2si
(load addr:$src)))]>;
 
+// Match intrinisics which expect MM and XMM operand(s).
+def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
+ "cvtps2pi\t{$src, $dst|$dst, $src}",
+ [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>;
+def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
+ "cvtps2pi\t{$src, $dst|$dst, $src}",
+ [(set VR64:$dst, (int_x86_sse_cvtps2pi 
+   (load addr:$src)))]>;
+def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
+ "cvttps2pi\t{$src, $dst|$dst, $src}",
+ [(set VR64:$dst, (int_x86_sse_cvttps2pi 
VR128:$src))]>;
+def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src),
+ "cvttps2pi\t{$src, $dst|$dst, $src}",
+ [(set VR64:$dst, (int_x86_sse_cvttps2pi 
+   (load addr:$src)))]>;
+let isTwoAddress = 1 in {
+  def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg, 
+   (outs VR128:$dst), (ins VR128:$src1, VR64:$src2),
+"cvtpi2ps\t{$src2, $dst|$dst, $src2}",
+[(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1,
+   VR64:$src2))]>;
+  def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem, 
+   (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2),
+"cvtpi2ps\t{$src2, $dst|$dst, $src2}",
+[(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1, 
+(load addr:$src2)))]>;
+}
+
 // Aliases for intrinsics
 def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src),
   "cvttss2si\t{$src, $dst|$dst, $src}",
@@ -1022,6 +1050,29 @@
  [(set GR32:$dst, (int_x86_sse2_cvtsd2si
(load addr:$src)))]>;
 
+// Match intrinisics which expect MM and XMM operand(s).
+def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src),
+ "cvtpd2pi\t{$src, $dst|$dst, $src}",
+ [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>;
+def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), 

[llvm-commits] [llvm-gcc-4.0] r43522 - /llvm-gcc-4.0/trunk/gcc/config/i386/llvm-i386.cpp

2007-10-30 Thread Dale Johannesen
Author: johannes
Date: Tue Oct 30 17:13:05 2007
New Revision: 43522

URL: http://llvm.org/viewvc/llvm-project?rev=43522&view=rev
Log:
Add missing vec_set_v4hi builtin.


Modified:
llvm-gcc-4.0/trunk/gcc/config/i386/llvm-i386.cpp

Modified: llvm-gcc-4.0/trunk/gcc/config/i386/llvm-i386.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/config/i386/llvm-i386.cpp?rev=43522&r1=43521&r2=43522&view=diff

==
--- llvm-gcc-4.0/trunk/gcc/config/i386/llvm-i386.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/config/i386/llvm-i386.cpp Tue Oct 30 17:13:05 2007
@@ -455,6 +455,7 @@
   case IX86_BUILTIN_VEC_EXT_V8HI:
 Result = Builder.CreateExtractElement(Ops[0], Ops[1], "tmp");
 return true;
+  case IX86_BUILTIN_VEC_SET_V4HI:
   case IX86_BUILTIN_VEC_SET_V8HI:
 // GCC sometimes doesn't produce the right element type.
 Ops[1] = Builder.CreateIntCast(Ops[1], Type::Int16Ty, false, "tmp");


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


[llvm-commits] [llvm] r43524 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/CodeGen/X86/2007-10-30-LSRCrash.ll

2007-10-30 Thread Evan Cheng
Author: evancheng
Date: Tue Oct 30 17:27:26 2007
New Revision: 43524

URL: http://llvm.org/viewvc/llvm-project?rev=43524&view=rev
Log:
It's not safe to tell SplitCriticalEdge to merge identical edges. It may delete 
the phi instruction that's being processed.

Added:
llvm/trunk/test/CodeGen/X86/2007-10-30-LSRCrash.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=43524&r1=43523&r2=43524&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Oct 30 17:27:26 
2007
@@ -127,12 +127,12 @@
 /// StrideOrder - An ordering of the keys in IVUsesByStride that is stable:
 /// We use this to iterate over the IVUsesByStride collection without being
 /// dependent on random ordering of pointers in the process.
-std::vector StrideOrder;
+SmallVector StrideOrder;
 
 /// CastedValues - As we need to cast values to uintptr_t, this keeps track
 /// of the casted version of each value.  This is accessed by
 /// getCastedVersionOf.
-std::map CastedPointers;
+DenseMap CastedPointers;
 
 /// DeadInsts - Keep track of instructions we may have made dead, so that
 /// we can remove them after we are done working.
@@ -393,8 +393,7 @@
   // post-incremented value.
   for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
 if (PN->getIncomingValue(i) == IV) {
-  SplitCriticalEdge(PN->getIncomingBlock(i), PN->getParent(), P,
-true);
+  SplitCriticalEdge(PN->getIncomingBlock(i), PN->getParent(), P, false);
   // Splitting the critical edge can reduce the number of entries in this
   // PHI.
   e = PN->getNumIncomingValues();
@@ -627,7 +626,7 @@
   // have multiple entries for the same predecessor.  We use a map to make sure
   // that a PHI node only has a single Value* for each predecessor (which also
   // prevents us from inserting duplicate code in some blocks).
-  std::map InsertedCode;
+  DenseMap InsertedCode;
   PHINode *PN = cast(Inst);
   for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
 if (PN->getIncomingValue(i) == OperandValToReplace) {
@@ -640,7 +639,7 @@
   (PN->getParent() != L->getHeader() || !L->contains(PHIPred))) {
 
 // First step, split the critical edge.
-SplitCriticalEdge(PHIPred, PN->getParent(), P, true);
+SplitCriticalEdge(PHIPred, PN->getParent(), P, false);
 
 // Next step: move the basic block.  In particular, if the PHI node
 // is outside of the loop, and PredTI is in the loop, we want to
@@ -1286,7 +1285,7 @@
 // Get a base value.
 SCEVHandle Base = UsersToProcess[i].Base;
 
-// Compact everything with this base to be consequetive with this one.
+// Compact everything with this base to be consequtive with this one.
 for (unsigned j = i+1; j != e; ++j) {
   if (UsersToProcess[j].Base == Base) {
 std::swap(UsersToProcess[i+1], UsersToProcess[j]);
@@ -1355,10 +1354,9 @@
   // If we are reusing the iv, then it must be multiplied by a constant
   // factor take advantage of addressing mode scale component.
   if (RewriteFactor != 0) {
-RewriteExpr =
-  SE->getMulExpr(SE->getIntegerSCEV(RewriteFactor,
-  RewriteExpr->getType()),
-   RewriteExpr);
+RewriteExpr = SE->getMulExpr(SE->getIntegerSCEV(RewriteFactor,
+
RewriteExpr->getType()),
+ RewriteExpr);
 
 // The common base is emitted in the loop preheader. But since we
 // are reusing an IV, it has not been used to initialize the PHI node.

Added: llvm/trunk/test/CodeGen/X86/2007-10-30-LSRCrash.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-10-30-LSRCrash.ll?rev=43524&view=auto

==
--- llvm/trunk/test/CodeGen/X86/2007-10-30-LSRCrash.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2007-10-30-LSRCrash.ll Tue Oct 30 17:27:26 2007
@@ -0,0 +1,48 @@
+; RUN: llvm-as < %s | llc -march=x86
+
+define i32 @unique(i8* %full, i32 %p, i32 %len, i32 %mode, i32 %verbos, i32 
%flags) {
+entry:
+   br i1 false, label %cond_true15, label %cond_next107
+
+cond_true15:   ; preds = %entry
+   br i1 false, label %bb98.preheader, label %bb
+
+bb:; preds = %cond_true15
+   ret i32 0
+
+bb98.preheader:; preds = %cond_true15
+   br i1 false, label %bb103, label %bb69.outer
+
+bb76.split:; preds = %bb69.outer.split.split, %bb69.us20

[llvm-commits] [llvm] r43527 - /llvm/trunk/test/CFrontend/2007-10-30-Volatile.c

2007-10-30 Thread Devang Patel
Author: dpatel
Date: Tue Oct 30 18:07:47 2007
New Revision: 43527

URL: http://llvm.org/viewvc/llvm-project?rev=43527&view=rev
Log:
New test.

Added:
llvm/trunk/test/CFrontend/2007-10-30-Volatile.c

Added: llvm/trunk/test/CFrontend/2007-10-30-Volatile.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/2007-10-30-Volatile.c?rev=43527&view=auto

==
--- llvm/trunk/test/CFrontend/2007-10-30-Volatile.c (added)
+++ llvm/trunk/test/CFrontend/2007-10-30-Volatile.c Tue Oct 30 18:07:47 2007
@@ -0,0 +1,6 @@
+// RUN: %llvmgcc -S %s -o /dev/null -Wall -Werror
+void bork() {
+  char * volatile p;
+  volatile int cc;
+  p += cc;
+}


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


[llvm-commits] [llvm-gcc-4.0] r43528 - /llvm-gcc-4.0/trunk/gcc/c-common.c

2007-10-30 Thread Devang Patel
Author: dpatel
Date: Tue Oct 30 18:08:24 2007
New Revision: 43528

URL: http://llvm.org/viewvc/llvm-project?rev=43528&view=rev
Log:
Fix
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071029/055013.html

Modified:
llvm-gcc-4.0/trunk/gcc/c-common.c

Modified: llvm-gcc-4.0/trunk/gcc/c-common.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/c-common.c?rev=43528&r1=43527&r2=43528&view=diff

==
--- llvm-gcc-4.0/trunk/gcc/c-common.c (original)
+++ llvm-gcc-4.0/trunk/gcc/c-common.c Tue Oct 30 18:08:24 2007
@@ -2432,8 +2432,8 @@
   TREE_CONSTANT (folded) = TREE_CONSTANT (ptrop) & TREE_CONSTANT (intop);
 
 /* If the original was void* + int, we converted it to char* + int.  
Convert
-   back to the appropriate void* result.  */
-if (!size_set)
+   back to the appropriate void* result and match type qualifiers. */
+if (!size_set || TYPE_QUALS(result_type) != TYPE_QUALS(TREE_TYPE(folded)))
   folded = convert(result_type, folded);
 return folded;
   }


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


Re: [llvm-commits] [llvm-gcc-4.0] r43528 - /llvm-gcc-4.0/trunk/gcc/c-common.c

2007-10-30 Thread Bill Wendling
On 10/30/07, Devang Patel <[EMAIL PROTECTED]> wrote:
> Fix
> http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071029/055013.html
>
4.2 maybe? :)

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


[llvm-commits] [llvm] r43531 - /llvm/trunk/include/llvm/ADT/FoldingSet.h

2007-10-30 Thread Ted Kremenek
Author: kremenek
Date: Tue Oct 30 18:35:55 2007
New Revision: 43531

URL: http://llvm.org/viewvc/llvm-project?rev=43531&view=rev
Log:
Added member function "size()" to FoldingSet to return the number of
nodes in the FoldingSet.

Modified:
llvm/trunk/include/llvm/ADT/FoldingSet.h

Modified: llvm/trunk/include/llvm/ADT/FoldingSet.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/FoldingSet.h?rev=43531&r1=43530&r2=43531&view=diff

==
--- llvm/trunk/include/llvm/ADT/FoldingSet.h (original)
+++ llvm/trunk/include/llvm/ADT/FoldingSet.h Tue Oct 30 18:35:55 2007
@@ -202,7 +202,10 @@
   /// it is not already in the folding set.  InsertPos must be obtained from 
   /// FindNodeOrInsertPos.
   void InsertNode(Node *N, void *InsertPos);
-
+  
+  /// size - Returns the number of nodes in the folding set.
+  unsigned size() const { return NumNodes; }
+  
 private:
 
   /// GrowHashTable - Double the size of the hash table and rehash everything.


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


[llvm-commits] [llvm-gcc-4.2] r43532 - /llvm-gcc-4.2/trunk/gcc/c-common.c

2007-10-30 Thread Devang Patel
Author: dpatel
Date: Tue Oct 30 18:37:43 2007
New Revision: 43532

URL: http://llvm.org/viewvc/llvm-project?rev=43532&view=rev
Log:
Fix
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071029/055013.html

Modified:
llvm-gcc-4.2/trunk/gcc/c-common.c

Modified: llvm-gcc-4.2/trunk/gcc/c-common.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-common.c?rev=43532&r1=43531&r2=43532&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/c-common.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-common.c Tue Oct 30 18:37:43 2007
@@ -2550,8 +2550,8 @@
   TREE_CONSTANT (folded) = TREE_CONSTANT (ptrop) & TREE_CONSTANT (intop);
 
 /* If the original was void* + int, we converted it to char* + int.  
Convert
-   back to the appropriate void* result.  */
-if (!size_set)
+   back to the appropriate void* result and match type qualifiers. */
+if (!size_set || TYPE_QUALS(result_type) != TYPE_QUALS(TREE_TYPE(folded)))
   folded = convert(result_type, folded);
 return folded;
   }


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


[llvm-commits] [llvm] r43533 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp

2007-10-30 Thread Evan Cheng
Author: evancheng
Date: Tue Oct 30 18:45:15 2007
New Revision: 43533

URL: http://llvm.org/viewvc/llvm-project?rev=43533&view=rev
Log:
At end of LSR, replace uses of now constant (as result of SplitCriticalEdge) 
PHI node with the constant value.

Modified:
llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=43533&r1=43532&r2=43533&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Oct 30 18:45:15 
2007
@@ -228,6 +228,21 @@
   while (!Insts.empty()) {
 Instruction *I = *Insts.begin();
 Insts.erase(I);
+
+if (PHINode *PN = dyn_cast(I)) {
+  // If all incoming values to the Phi are the same, we can replace the Phi
+  // with that value.
+  if (Value *PNV = PN->hasConstantValue()) {
+if (Instruction *U = dyn_cast(PNV))
+  Insts.insert(U);
+PN->replaceAllUsesWith(PNV);
+SE->deleteValueFromRecords(PN);
+PN->eraseFromParent();
+Changed = true;
+continue;
+  }
+}
+
 if (isInstructionTriviallyDead(I)) {
   for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
 if (Instruction *U = dyn_cast(I->getOperand(i)))
@@ -359,7 +374,8 @@
 /// the loop, resulting in reg-reg copies (if we use the pre-inc value when we
 /// should use the post-inc value).
 static bool IVUseShouldUsePostIncValue(Instruction *User, Instruction *IV,
-   Loop *L, DominatorTree *DT, Pass *P) {
+   Loop *L, DominatorTree *DT, Pass *P,
+   SmallPtrSet 
&DeadInsts){
   // If the user is in the loop, use the preinc value.
   if (L->contains(User->getParent())) return false;
   
@@ -399,6 +415,9 @@
   e = PN->getNumIncomingValues();
   if (--NumUses == 0) break;
 }
+
+  // PHI node might have become a constant value after SplitCriticalEdge.
+  DeadInsts.insert(User);
   
   return true;
 }
@@ -461,7 +480,7 @@
   // Okay, we found a user that we cannot reduce.  Analyze the instruction
   // and decide what to do with it.  If we are a use inside of the loop, 
use
   // the value before incrementation, otherwise use it after 
incrementation.
-  if (IVUseShouldUsePostIncValue(User, I, L, DT, this)) {
+  if (IVUseShouldUsePostIncValue(User, I, L, DT, this, DeadInsts)) {
 // The value used will be incremented by the stride more than we are
 // expecting, so subtract this off.
 SCEVHandle NewStart = SE->getMinusSCEV(Start, Stride);
@@ -522,8 +541,8 @@
 // operands of Inst to use the new expression 'NewBase', with 'Imm' added
 // to it.
 void RewriteInstructionToUseNewBase(const SCEVHandle &NewBase,
-SCEVExpander &Rewriter, Loop *L,
-Pass *P);
+   SCEVExpander &Rewriter, Loop *L, Pass 
*P,
+   SmallPtrSet 
&DeadInsts);
 
 Value *InsertCodeForBaseAtPosition(const SCEVHandle &NewBase, 
SCEVExpander &Rewriter,
@@ -584,8 +603,8 @@
 // operands of Inst to use the new expression 'NewBase', with 'Imm' added
 // to it.
 void BasedUser::RewriteInstructionToUseNewBase(const SCEVHandle &NewBase,
-   SCEVExpander &Rewriter,
-   Loop *L, Pass *P) {
+  SCEVExpander &Rewriter, Loop *L, Pass *P,
+  SmallPtrSet &DeadInsts) 
{
   if (!isa(Inst)) {
 // By default, insert code at the user instruction.
 BasicBlock::iterator InsertPt = Inst;
@@ -676,6 +695,10 @@
   Rewriter.clear();
 }
   }
+
+  // PHI node might have become a constant value after SplitCriticalEdge.
+  DeadInsts.insert(Inst);
+
   DOUT << "CHANGED: IMM =" << *Imm << "  Inst = " << *Inst;
 }
 
@@ -1373,7 +1396,8 @@
 // Add BaseV to the PHI value if needed.
 RewriteExpr = SE->getAddExpr(RewriteExpr, SE->getUnknown(BaseV));
 
-  User.RewriteInstructionToUseNewBase(RewriteExpr, Rewriter, L, this);
+  User.RewriteInstructionToUseNewBase(RewriteExpr, Rewriter, L, this,
+  DeadInsts);
 
   // Mark old value we replaced as possibly dead, so that it is elminated
   // if we just replaced the last use of that value.
@@ -1457,7 +1481,7 @@
 /// v1 = v1 + 3
 /// if (v1 < 30) goto loop
 ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond,
-  IVStrideUse* &CondUse,
+ 

[llvm-commits] [llvm] r43535 - in /llvm/trunk/lib: CodeGen/SelectionDAG/LegalizeDAG.cpp Target/X86/X86ISelLowering.cpp

2007-10-30 Thread Dale Johannesen
Author: johannes
Date: Tue Oct 30 19:32:36 2007
New Revision: 43535

URL: http://llvm.org/viewvc/llvm-project?rev=43535&view=rev
Log:
Make i64=expand_vector_elt(v2i64) work in 32-bit mode.


Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=43535&r1=43534&r2=43535&view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Tue Oct 30 19:32:36 2007
@@ -5299,6 +5299,11 @@
 #endif
 assert(0 && "Do not know how to expand this operator!");
 abort();
+  case ISD::EXTRACT_VECTOR_ELT:
+assert(VT==MVT::i64 && "Do not know how to expand this operator!");
+// ExpandEXTRACT_VECTOR_ELT tolerates invalid result types.
+Lo  = ExpandEXTRACT_VECTOR_ELT(Op);
+return ExpandOp(Lo, Lo, Hi);
   case ISD::UNDEF:
 NVT = TLI.getTypeToExpandTo(VT);
 Lo = DAG.getNode(ISD::UNDEF, NVT);

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=43535&r1=43534&r2=43535&view=diff

==
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Oct 30 19:32:36 2007
@@ -608,7 +608,8 @@
 setOperationAction(ISD::VECTOR_SHUFFLE, MVT::v2f64, Custom);
 setOperationAction(ISD::VECTOR_SHUFFLE, MVT::v2i64, Custom);
 setOperationAction(ISD::EXTRACT_VECTOR_ELT, MVT::v2f64, Custom);
-setOperationAction(ISD::EXTRACT_VECTOR_ELT, MVT::v2i64, Custom);
+if (Subtarget->is64Bit())
+  setOperationAction(ISD::EXTRACT_VECTOR_ELT, MVT::v2i64, Custom);
 
 // Promote v16i8, v8i16, v4i32 load, select, and, or, xor to v2i64.
 for (unsigned VT = (unsigned)MVT::v16i8; VT != (unsigned)MVT::v2i64; VT++) 
{


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


[llvm-commits] [llvm-gcc-4.2] r43538 - /llvm-gcc-4.2/trunk/gcc/objc/objc-act.c

2007-10-30 Thread Devang Patel
Author: dpatel
Date: Tue Oct 30 20:05:20 2007
New Revision: 43538

URL: http://llvm.org/viewvc/llvm-project?rev=43538&view=rev
Log:
Set 'used' bit to shut up "defined but not used" warning.


Modified:
llvm-gcc-4.2/trunk/gcc/objc/objc-act.c

Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=43538&r1=43537&r2=43538&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original)
+++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Tue Oct 30 20:05:20 2007
@@ -3876,6 +3876,7 @@
 set_user_assembler_name (var, IDENTIFIER_POINTER (DECL_NAME (var)));
 /* Let optimizer know that this var is not removable.  */
 DECL_PRESERVE_P (var) = 1;
+TREE_USED(var) = 1;
   } 
   else
 /* Fall through. Build using 'name' */


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


[llvm-commits] [llvm-gcc-4.0] r43537 - /llvm-gcc-4.0/trunk/gcc/objc/objc-act.c

2007-10-30 Thread Devang Patel
Author: dpatel
Date: Tue Oct 30 20:03:47 2007
New Revision: 43537

URL: http://llvm.org/viewvc/llvm-project?rev=43537&view=rev
Log:
Set 'used' bit to shut up "defined but not used" warning.

Modified:
llvm-gcc-4.0/trunk/gcc/objc/objc-act.c

Modified: llvm-gcc-4.0/trunk/gcc/objc/objc-act.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/objc/objc-act.c?rev=43537&r1=43536&r2=43537&view=diff

==
--- llvm-gcc-4.0/trunk/gcc/objc/objc-act.c (original)
+++ llvm-gcc-4.0/trunk/gcc/objc/objc-act.c Tue Oct 30 20:03:47 2007
@@ -3868,6 +3868,7 @@
 set_user_assembler_name (var, IDENTIFIER_POINTER (DECL_NAME (var)));
 /* Let optimizer know that this var is not removable.  */
 DECL_PRESERVE_P (var) = 1;
+TREE_USED(var) = 1;
   } 
   else
 /* Fall through. Build using 'name' */


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


[llvm-commits] CVS: llvm-www/Users.html

2007-10-30 Thread John Criswell


Changes in directory llvm-www:

Users.html updated: 1.22 -> 1.23
---
Log message:

Added David Penry's research group.


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

 Users.html |   11 ++-
 1 files changed, 10 insertions(+), 1 deletion(-)


Index: llvm-www/Users.html
diff -u llvm-www/Users.html:1.22 llvm-www/Users.html:1.23
--- llvm-www/Users.html:1.22Wed Oct  3 23:39:57 2007
+++ llvm-www/Users.html Tue Oct 30 21:22:28 2007
@@ -95,6 +95,15 @@
 
   
 
+  
+  
+http://www.byu.edu";>Brigham Young University
+http://www.et.byu.edu/groups/bardd";>David Penry's Research 
Group
+Microarchitectural Simulator Partitioning and Synthesis
+Adaptive Online Parallel Optimization
+  
+
+
   
   
 http://www.ugent.be/";>Ghent University
@@ -263,6 +272,6 @@
   src="http://www.w3.org/Icons/valid-html401"; alt="Valid HTML 4.01!">
 
 mailto:[EMAIL PROTECTED]">LLVM Development List
-  Last modified: $Date: 2007/10/04 04:39:57 $
+  Last modified: $Date: 2007/10/31 02:22:28 $
 
 



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


[llvm-commits] [llvm] r43541 - in /llvm/trunk: include/llvm/Analysis/DominatorInternals.h include/llvm/Analysis/Dominators.h include/llvm/CodeGen/MachineDominators.h lib/CodeGen/MachineDominators.cpp

2007-10-30 Thread Owen Anderson
Author: resistor
Date: Tue Oct 30 22:30:14 2007
New Revision: 43541

URL: http://llvm.org/viewvc/llvm-project?rev=43541&view=rev
Log:
Some fixes to get MachineDomTree working better.

Added:
llvm/trunk/lib/CodeGen/MachineDominators.cpp
Modified:
llvm/trunk/include/llvm/Analysis/DominatorInternals.h
llvm/trunk/include/llvm/Analysis/Dominators.h
llvm/trunk/include/llvm/CodeGen/MachineDominators.h

Modified: llvm/trunk/include/llvm/Analysis/DominatorInternals.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DominatorInternals.h?rev=43541&r1=43540&r2=43541&view=diff

==
--- llvm/trunk/include/llvm/Analysis/DominatorInternals.h (original)
+++ llvm/trunk/include/llvm/Analysis/DominatorInternals.h Tue Oct 30 22:30:14 
2007
@@ -273,21 +273,24 @@
   // which postdominates all real exits if there are multiple exit blocks.
   typename GraphT::NodeType* Root = DT.Roots.size() == 1 ? DT.Roots[0]
  : 0;
-  DT.DomTreeNodes[Root] = DT.RootNode = new DomTreeNode(Root, 0);
+  DT.DomTreeNodes[Root] = DT.RootNode =
+new DomTreeNodeBase(Root, 
0);
   
   // Loop over all of the reachable blocks in the function...
-  for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
+  for (typename FuncT::iterator I = F.begin(), E = F.end(); I != E; ++I)
 if (typename GraphT::NodeType* ImmDom = DT.getIDom(I)) {
   // Reachable block.
-  DomTreeNode *BBNode = DT.DomTreeNodes[I];
+  DomTreeNodeBase *BBNode = DT.DomTreeNodes[I];
   if (BBNode) continue;  // Haven't calculated this node yet?
 
   // Get or calculate the node for the immediate dominator
-  DomTreeNode *IDomNode = DT.getNodeForBlock(ImmDom);
+  DomTreeNodeBase *IDomNode =
+ 
DT.getNodeForBlock(ImmDom);
 
   // Add a new tree node for this BasicBlock, and link it as a child of
   // IDomNode
-  DomTreeNode *C = new DomTreeNode(I, IDomNode);
+  DomTreeNodeBase *C =
+new DomTreeNodeBase(I, 
IDomNode);
   DT.DomTreeNodes[I] = IDomNode->addChild(C);
 }
   

Modified: llvm/trunk/include/llvm/Analysis/Dominators.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Dominators.h?rev=43541&r1=43540&r2=43541&view=diff

==
--- llvm/trunk/include/llvm/Analysis/Dominators.h (original)
+++ llvm/trunk/include/llvm/Analysis/Dominators.h Tue Oct 30 22:30:14 2007
@@ -132,6 +132,7 @@
 };
 
 EXTERN_TEMPLATE_INSTANTIATION(class DomTreeNodeBase);
+EXTERN_TEMPLATE_INSTANTIATION(class DomTreeNodeBase);
 
 template
 static std::ostream &operator<<(std::ostream &o,
@@ -156,7 +157,6 @@
 }
 
 typedef DomTreeNodeBase DomTreeNode;
-typedef DomTreeNodeBase MachineDomTreeNode;
 
 
//===--===//
 /// DominatorTree - Calculate the immediate dominator tree for a function.
@@ -607,6 +607,12 @@
 return I != IDoms.end() ? I->second : 0;
   }
   
+  inline void addRoot(NodeT* BB) {
+// Unreachable block is not a root node.
+if (!isa(&BB->back()))
+  this->Roots.push_back(BB);
+  }
+  
 public:
   /// recalculate - compute a dominator tree for the given function
   template
@@ -615,9 +621,9 @@
   reset();
   
   // Initialize roots
-  this->Roots.push_back(&F.getEntryBlock());
-  this->IDoms[&F.getEntryBlock()] = 0;
-  this->DomTreeNodes[&F.getEntryBlock()] = 0;
+  this->Roots.push_back(&F.front());
+  this->IDoms[&F.front()] = 0;
+  this->DomTreeNodes[&F.front()] = 0;
   this->Vertex.push_back(0);
   
   Calculate(*this, F);
@@ -627,13 +633,10 @@
   reset(); // Reset from the last time we were run...
 
   // Initialize the roots list
-  for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
-TerminatorInst *Insn = I->getTerminator();
-if (Insn->getNumSuccessors() == 0) {
-  // Unreachable block is not a root node.
-  if (!isa(Insn))
-this->Roots.push_back(I);
-}
+  for (typename FT::iterator I = F.begin(), E = F.end(); I != E; ++I) {
+if (std::distance(GraphTraits::child_begin(I),
+  GraphTraits::child_end(I)) == 0)
+  addRoot(I);
 
 // Prepopulate maps so that we don't get iterator invalidation issues 
later.
 this->IDoms[I] = 0;

Modified: llvm/trunk/include/llvm/CodeGen/MachineDominators.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineDominators.h?rev=43541&r1=43540&r2=43541&view=diff

==
--- llvm/trunk/include/llvm/CodeGen/MachineDominators.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineDominators.h 

[llvm-commits] [llvm] r43542 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/StrongPHIElimination.cpp

2007-10-30 Thread Owen Anderson
Author: resistor
Date: Tue Oct 30 22:37:57 2007
New Revision: 43542

URL: http://llvm.org/viewvc/llvm-project?rev=43542&view=rev
Log:
Add the skeleton of a better PHI elimination pass.

Added:
llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
Modified:
llvm/trunk/include/llvm/CodeGen/Passes.h

Modified: llvm/trunk/include/llvm/CodeGen/Passes.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=43542&r1=43541&r2=43542&view=diff

==
--- llvm/trunk/include/llvm/CodeGen/Passes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/Passes.h Tue Oct 30 22:37:57 2007
@@ -44,6 +44,14 @@
   /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
   ///
   extern const PassInfo *PHIEliminationID;
+  
+  /// StrongPHIElimination pass - This pass eliminates machine instruction PHI
+  /// nodes by inserting copy instructions.  This destroys SSA information, but
+  /// is the desired input for some register allocators.  This pass is
+  /// "required" by these register allocator like this:
+  ///AU.addRequiredID(PHIEliminationID);
+  ///  This pass is still in development
+  extern const PassInfo *StrongPHIEliminationID;
 
   /// SimpleRegisterCoalescing pass.  Aggressively coalesces every register
   /// copy it can.

Added: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=43542&view=auto

==
--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (added)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Tue Oct 30 22:37:57 2007
@@ -0,0 +1,112 @@
+//===- StrongPhiElimination.cpp - Eliminate PHI nodes by inserting copies 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Owen Anderson and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This pass eliminates machine instruction PHI nodes by inserting copy
+// instructions, using an intelligent copy-folding technique based on
+// dominator information.  This is technique is derived from:
+// 
+//Budimlic, et al. Fast copy coalescing and live-range identification.
+//In Proceedings of the ACM SIGPLAN 2002 Conference on Programming Language
+//Design and Implementation (Berlin, Germany, June 17 - 19, 2002).
+//PLDI '02. ACM, New York, NY, 25-32.
+//DOI= http://doi.acm.org/10.1145/512529.512534
+//
+//===--===//
+
+#define DEBUG_TYPE "strongphielim"
+#include "llvm/CodeGen/Passes.h"
+#include "llvm/CodeGen/MachineDominators.h"
+#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/Target/TargetInstrInfo.h"
+#include "llvm/Target/TargetMachine.h"
+#include "llvm/ADT/Statistic.h"
+#include "llvm/Support/Compiler.h"
+using namespace llvm;
+
+
+namespace {
+  struct VISIBILITY_HIDDEN StrongPHIElimination : public MachineFunctionPass {
+static char ID; // Pass identification, replacement for typeid
+StrongPHIElimination() : MachineFunctionPass((intptr_t)&ID) {}
+
+bool runOnMachineFunction(MachineFunction &Fn) {
+  computeDFS(Fn);
+  
+  
+  return false;
+}
+
+virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+  AU.addRequired();
+  MachineFunctionPass::getAnalysisUsage(AU);
+}
+
+virtual void releaseMemory() {
+  preorder.clear();
+  maxpreorder.clear();
+}
+
+  private:
+DenseMap preorder;
+DenseMap maxpreorder;
+
+void computeDFS(MachineFunction& MF);
+  };
+
+  char StrongPHIElimination::ID = 0;
+  RegisterPass X("strong-phi-node-elimination",
+  "Eliminate PHI nodes for register allocation, 
intelligently");
+}
+
+const PassInfo *llvm::StrongPHIEliminationID = X.getPassInfo();
+
+/// computeDFS - Computes the DFS-in and DFS-out numbers of the dominator tree
+/// of the given MachineFunction.  These numbers are then used in other parts
+/// of the PHI elimination process.
+void StrongPHIElimination::computeDFS(MachineFunction& MF) {
+  SmallPtrSet frontier;
+  SmallPtrSet visited;
+  
+  unsigned time = 0;
+  
+  MachineDominatorTree& DT = getAnalysis();
+  
+  MachineDomTreeNode* node = DT.getRootNode();
+  
+  std::vector worklist;
+  worklist.push_back(node);
+  
+  while (!worklist.empty()) {
+MachineDomTreeNode* currNode = worklist.back();
+
+if (!frontier.count(currNode)) {
+  frontier.insert(currNode);
+  ++time;
+  preorder.insert(std::make_pair(currNode->getBlock(), time));
+}
+
+bool inserted = false;
+for (MachineDomTreeNode::iterator I = node->begin(), E = node->end();
+ I != E; ++I)
+

Re: [llvm-commits] [llvm] r43535 - in /llvm/trunk/lib: CodeGen/SelectionDAG/LegalizeDAG.cpp Target/X86/X86ISelLowering.cpp

2007-10-30 Thread Chris Lattner
> URL: http://llvm.org/viewvc/llvm-project?rev=43535&view=rev
> Log:
> Make i64=expand_vector_elt(v2i64) work in 32-bit mode.

Testcase please :)

-Chris

>
>
> Modified:
>llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
>llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=43535&r1=43534&r2=43535&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ==
> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Tue Oct 30  
> 19:32:36 2007
> @@ -5299,6 +5299,11 @@
> #endif
> assert(0 && "Do not know how to expand this operator!");
> abort();
> +  case ISD::EXTRACT_VECTOR_ELT:
> +assert(VT==MVT::i64 && "Do not know how to expand this  
> operator!");
> +// ExpandEXTRACT_VECTOR_ELT tolerates invalid result types.
> +Lo  = ExpandEXTRACT_VECTOR_ELT(Op);
> +return ExpandOp(Lo, Lo, Hi);
>   case ISD::UNDEF:
> NVT = TLI.getTypeToExpandTo(VT);
> Lo = DAG.getNode(ISD::UNDEF, NVT);
>
> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=43535&r1=43534&r2=43535&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ==
> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Oct 30  
> 19:32:36 2007
> @@ -608,7 +608,8 @@
> setOperationAction(ISD::VECTOR_SHUFFLE, MVT::v2f64, Custom);
> setOperationAction(ISD::VECTOR_SHUFFLE, MVT::v2i64, Custom);
> setOperationAction(ISD::EXTRACT_VECTOR_ELT, MVT::v2f64, Custom);
> -setOperationAction(ISD::EXTRACT_VECTOR_ELT, MVT::v2i64, Custom);
> +if (Subtarget->is64Bit())
> +  setOperationAction(ISD::EXTRACT_VECTOR_ELT, MVT::v2i64,  
> Custom);
>
> // Promote v16i8, v8i16, v4i32 load, select, and, or, xor to  
> v2i64.
> for (unsigned VT = (unsigned)MVT::v16i8; VT !=  
> (unsigned)MVT::v2i64; VT++) {
>
>
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

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


[llvm-commits] [llvm] r43545 - /llvm/trunk/docs/FAQ.html

2007-10-30 Thread Chris Lattner
Author: lattner
Date: Wed Oct 31 00:53:31 2007
New Revision: 43545

URL: http://llvm.org/viewvc/llvm-project?rev=43545&view=rev
Log:
__main is dead along with llvm-gcc3.


Modified:
llvm/trunk/docs/FAQ.html

Modified: llvm/trunk/docs/FAQ.html
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/FAQ.html?rev=43545&r1=43544&r2=43545&view=diff

==
--- llvm/trunk/docs/FAQ.html (original)
+++ llvm/trunk/docs/FAQ.html Wed Oct 31 00:53:31 2007
@@ -89,8 +89,6 @@
 
   Questions about code generated by the GCC 
front-end
   
- What is this __main() call that gets 
inserted into
- main()?
  What is this llvm.global_ctors and
   _GLOBAL__I__tmp_webcompile... stuff that happens when I
   #include ?
@@ -591,29 +589,6 @@
   Questions about code generated by the GCC front-end
 
 
-
-
-What is this __main() call that gets inserted into main()?
-
-
-
-
-The __main call is inserted by the C/C++ compiler in order to 
guarantee
-that static constructors and destructors are called when the program starts up
-and shuts down.  In C, you can create static constructors and destructors by
-using GCC extensions, and in C++ you can do so by creating a global variable
-whose class has a ctor or dtor.
-
-
-
-The actual implementation of __main lives in the
-llvm/runtime/GCCLibraries/crtend/ directory in the source-base, and is
-linked in automatically when you link the program.
-
-
-
-
-
 
 
  What is this llvm.global_ctors and


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


[llvm-commits] [llvm] r43546 - in /llvm/trunk/docs/tutorial: LangImpl5-cfg.png LangImpl5.html index.html

2007-10-30 Thread Chris Lattner
Author: lattner
Date: Wed Oct 31 01:30:21 2007
New Revision: 43546

URL: http://llvm.org/viewvc/llvm-project?rev=43546&view=rev
Log:
Add the first half of chapter 5: if/then/else.  
To come: for statement.

Added:
llvm/trunk/docs/tutorial/LangImpl5-cfg.png   (with props)
llvm/trunk/docs/tutorial/LangImpl5.html
Modified:
llvm/trunk/docs/tutorial/index.html

Added: llvm/trunk/docs/tutorial/LangImpl5-cfg.png
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl5-cfg.png?rev=43546&view=auto

==
Binary file - no diff available.

Propchange: llvm/trunk/docs/tutorial/LangImpl5-cfg.png

--
svn:mime-type = application/octet-stream

Added: llvm/trunk/docs/tutorial/LangImpl5.html
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl5.html?rev=43546&view=auto

==
--- llvm/trunk/docs/tutorial/LangImpl5.html (added)
+++ llvm/trunk/docs/tutorial/LangImpl5.html Wed Oct 31 01:30:21 2007
@@ -0,0 +1,523 @@
+http://www.w3.org/TR/html4/strict.dtd";>
+
+
+
+  Kaleidoscope: Extending the Language: Control Flow
+  
+  
+  
+
+
+
+
+Kaleidoscope: Extending the Language: Control Flow
+
+
+  Written by mailto:[EMAIL PROTECTED]">Chris Lattner
+
+
+
+Part 5 Introduction
+
+
+
+
+Welcome to Part 5 of the "Implementing a language with
+LLVM" tutorial.  Parts 1-4 described the implementation of the simple
+Kaleidoscope language and included support for generating LLVM IR, following by
+optimizations and a JIT compiler.  Unfortunately, as presented, Kaleidoscope is
+mostly useless: it has no control flow other than call and return.  This means
+that you can't have conditional branches in the code, significantly limiting 
its
+power.  In this episode of "build that compiler", we'll extend Kaleidoscope to
+have an if/then/else expression plus a simple looping construct.
+
+
+
+
+If/Then/Else
+
+
+
+
+
+Extending Kaleidoscope to support if/then/else is quite straight-forward.  It
+basically requires adding lexer support for this "new" concept to the lexer,
+parser, AST, and LLVM code emitter.  This example is nice, because it shows how
+easy it is to "grow" a language over time, incrementally extending it as new
+ideas are discovered.
+
+Before we get going on "how" we do this extension, lets talk about what we
+want.  The basic idea is that we want to be able to write this sort of thing:
+
+
+
+
+def fib(x)
+  if x < 3 then
+1
+  else
+fib(x-1)+fib(x-2);
+
+
+
+In Kaleidoscope, every construct is an expression: there are no statements.
+As such, the if/then/else expression needs to return a value like any other.
+Since we're using a mostly functional form, we'll have it evaluate its
+conditional, then return the 'then' or 'else' value based on how the condition
+was resolved.  This is very similar to the C "?:" expression.
+
+The semantics of the if/then/else expression is that it first evaluates the
+condition to a boolean equality value: 0.0 is false and everything else is 
true.
+If the condition is true, the first subexpression is evaluated and returned, if
+the condition is false, the second subexpression is evaluated and returned.
+Since Kaleidoscope allows side-effects, this behavior is important to nail 
down.
+
+
+Now that we know what we want, lets break this down into its constituent
+pieces.
+
+
+
+
+Lexer Extensions for
+If/Then/Else
+
+
+
+
+
+The lexer extensions are straight-forward.  First we add new enum values
+for the relevant tokens:
+
+
+
+  // control
+  tok_if = -6, tok_then = -7, tok_else = -8,
+
+
+
+Once we have that, we recognize the new keywords in the lexer, pretty simple
+stuff:
+
+
+
+...
+if (IdentifierStr == "def") return tok_def;
+if (IdentifierStr == "extern") return tok_extern;
+if (IdentifierStr == "if") return tok_if;
+if (IdentifierStr == "then") return tok_then;
+if (IdentifierStr == "else") return tok_else;
+return tok_identifier;
+
+
+
+
+
+
+AST Extensions for
+ If/Then/Else 
+
+
+
+
+To represent the new expression we add a new AST node for it:
+
+
+
+/// IfExprAST - Expression class for if/then/else.
+class IfExprAST : public ExprAST {
+  ExprAST *Cond, *Then, *Else;
+public:
+  IfExprAST(ExprAST *cond, ExprAST *then, ExprAST *_else)
+: Cond(cond), Then(then), Else(_else) {}
+  virtual Value *Codegen();
+};
+
+
+
+The AST node just has pointers to the various subexpressions.
+
+
+
+
+Parser Extensions for
+If/Then/Else 
+
+
+
+
+Now that we have the relevant tokens coming from the lexer and we have the
+AST node to build, our parsing logic is relatively straight-forward.  First we
+define a new parsing function:
+
+
+
+/// ifexpr ::= 'if' expression 'then' expression 'else' expression
+static ExprAST *ParseIfExpr() {
+  getNextToken();  // eat the if.
+  
+  // condition.
+

[llvm-commits] [llvm] r43547 - /llvm/trunk/docs/tutorial/LangImpl5.html

2007-10-30 Thread Chris Lattner
Author: lattner
Date: Wed Oct 31 01:47:39 2007
New Revision: 43547

URL: http://llvm.org/viewvc/llvm-project?rev=43547&view=rev
Log:
add the code for expression code that we'll add, though most of the
description is missing.

Modified:
llvm/trunk/docs/tutorial/LangImpl5.html

Modified: llvm/trunk/docs/tutorial/LangImpl5.html
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl5.html?rev=43547&r1=43546&r2=43547&view=diff

==
--- llvm/trunk/docs/tutorial/LangImpl5.html (original)
+++ llvm/trunk/docs/tutorial/LangImpl5.html Wed Oct 31 01:47:39 2007
@@ -473,7 +473,271 @@
 
 
 
-...
+Now that we know how to add basic control flow constructs to the language,
+we have the tools to add more powerful things.  Lets add something more
+aggressive, a 'for' expression:
+
+
+
+ # print 100 '*' (ascii 42) characters
+ extern putchard(char)
+ for x = 1, x < 100, 1.0 in putchard(42);
+
+
+
+This expression defines a new variable ("x" in this case) which iterates 
from
+a starting value, while the condition ("x < 100" in this case) is true, 
+incrementing by an optional step value ("1.0" in this case).  If the step value
+is omitted, it defaults to 1.0.  While the loop is true, it executes its 
+body expression.  Because we don't have anything better to return, we'll just
+define the loop as always returning 0.0.  In the future when we have mutable
+variables, it will get more useful.
+
+As before, lets talk about the changes that we need to Kaleidoscope to
+support this.
+
+
+
+
+Lexer Extensions for
+the 'for' Loop
+
+
+
+
+The lexer extensions are the same sort of thing as for if/then/else:
+
+
+
+  ... in enum Token ...
+  // control
+  tok_if = -6, tok_then = -7, tok_else = -8,
+  tok_for = -9, tok_in = -10
+
+  ... in gettok ...
+  if (IdentifierStr == "def") return tok_def;
+  if (IdentifierStr == "extern") return tok_extern;
+  if (IdentifierStr == "if") return tok_if;
+  if (IdentifierStr == "then") return tok_then;
+  if (IdentifierStr == "else") return tok_else;
+  if (IdentifierStr == "for") return tok_for;
+  if (IdentifierStr == "in") return tok_in;
+  return tok_identifier;
+
+
+
+
+
+
+AST Extensions for
+the 'for' Loop
+
+
+
+
+The AST node is similarly simple.  It basically boils down to capturing
+the variable name and the consituent expressions in the node.
+
+
+
+/// ForExprAST - Expression class for for/in.
+class ForExprAST : public ExprAST {
+  std::string VarName;
+  ExprAST *Start, *End, *Step, *Body;
+public:
+  ForExprAST(const std::string &varname, ExprAST *start, ExprAST *end,
+ ExprAST *step, ExprAST *body)
+: VarName(varname), Start(start), End(end), Step(step), Body(body) {}
+  virtual Value *Codegen();
+};
+
+
+
+
+
+
+Parser Extensions for
+the 'for' Loop
+
+
+
+
+The parser code is also fairly standard.  The only interesting thing here is
+handling of the optional step value.  The parser code handles it by checking to
+see if the second comma is present.  If not, it sets the step value to null in
+the AST node:
+
+
+
+/// forexpr ::= 'for' identifer '=' expr ',' expr (',' expr)? 'in' expression
+static ExprAST *ParseForExpr() {
+  getNextToken();  // eat the for.
+
+  if (CurTok != tok_identifier)
+return Error("expected identifier after for");
+  
+  std::string IdName = IdentifierStr;
+  getNextToken();  // eat identifer.
+  
+  if (CurTok != '=')
+return Error("expected '=' after for");
+  getNextToken();  // eat '='.
+  
+  
+  ExprAST *Start = ParseExpression();
+  if (Start == 0) return 0;
+  if (CurTok != ',')
+return Error("expected ',' after for start value");
+  getNextToken();
+  
+  ExprAST *End = ParseExpression();
+  if (End == 0) return 0;
+  
+  // The step value is optional.
+  ExprAST *Step = 0;
+  if (CurTok == ',') {
+getNextToken();
+Step = ParseExpression();
+if (Step == 0) return 0;
+  }
+  
+  if (CurTok != tok_in)
+return Error("expected 'in' after for");
+  getNextToken();  // eat 'in'.
+  
+  ExprAST *Body = ParseExpression();
+  if (Body == 0) return 0;
+
+  return new ForExprAST(IdName, Start, End, Step, Body);
+}
+
+
+
+
+
+
+LLVM IR for 
+the 'for' Loop
+
+
+
+
+Now we get to the good part: the LLVM IR we want to generate for this thing.
+
+
+
+
+
+
+
+Code Generation for 
+the 'for' Loop
+
+
+
+
+
+
+
+Value *ForExprAST::Codegen() {
+  // Output this as:
+  //   ...
+  //   start = startexpr
+  //   goto loop
+  // loop: 
+  //   variable = phi [start, loopheader], [nextvariable, loopend]
+  //   ...
+  //   bodyexpr
+  //   ...
+  // loopend:
+  //   step = stepexpr
+  //   nextvariable = variable + step
+  //   endcond = endexpr
+  //   br endcond, loop, endloop
+  // outloop:
+  
+  // Emit the start code first, without 'variable' in scope.
+  Value *StartVal = Start->Codegen();
+  if (StartVal == 0) return 0;
+  
+  // Make the new basic block for the loop header, inserting after current
+  // block.
+  Funct

[llvm-commits] [llvm] r43548 - /llvm/trunk/docs/tutorial/LangImpl5.html

2007-10-30 Thread Chris Lattner
Author: lattner
Date: Wed Oct 31 02:29:43 2007
New Revision: 43548

URL: http://llvm.org/viewvc/llvm-project?rev=43548&view=rev
Log:
okay, fine, make me finish this chapter. :)

Feedback appreciated!

Modified:
llvm/trunk/docs/tutorial/LangImpl5.html

Modified: llvm/trunk/docs/tutorial/LangImpl5.html
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl5.html?rev=43548&r1=43547&r2=43548&view=diff

==
--- llvm/trunk/docs/tutorial/LangImpl5.html (original)
+++ llvm/trunk/docs/tutorial/LangImpl5.html Wed Oct 31 02:29:43 2007
@@ -479,14 +479,18 @@
 
 
 
- # print 100 '*' (ascii 42) characters
  extern putchard(char)
- for x = 1, x < 100, 1.0 in putchard(42);
+ def printstar(n)
+   for i = 1, i < n, 1.0 in
+ putchard(42);  # ascii 42 = '*'
+ 
+ # print 100 '*' characters
+ printstar(100);
 
 
 
-This expression defines a new variable ("x" in this case) which iterates 
from
-a starting value, while the condition ("x < 100" in this case) is true, 
+This expression defines a new variable ("i" in this case) which iterates 
from
+a starting value, while the condition ("i < n" in this case) is true, 
 incrementing by an optional step value ("1.0" in this case).  If the step value
 is omitted, it defaults to 1.0.  While the loop is true, it executes its 
 body expression.  Because we don't have anything better to return, we'll just
@@ -623,9 +627,41 @@
 
 
 Now we get to the good part: the LLVM IR we want to generate for this thing.
+With the simple example above, we get this LLVM IR (note that this dump is
+generated with optimizations disabled):
 
 
+
+
+declare double @putchard(double)
+
+define double @printstar(double %n) {
+entry:
+; initial value = 1.0 (inlined into phi)
+   br label %loop
+
+loop:  ; preds = %loop, %entry
+   %i = phi double [ 1.00e+00, %entry ], [ %nextvar, %loop ]
+; body
+   %calltmp = call double @putchard( double 4.20e+01 )
+; increment
+   %nextvar = add double %i, 1.00e+00
+
+; termination test
+   %multmp = fcmp ult double %i, %n
+   %booltmp = uitofp i1 %multmp to double
+   %loopcond = fcmp one double %booltmp, 0.00e+00
+   br i1 %loopcond, label %loop, label %afterloop
+
+afterloop: ; preds = %loop
+; loop always returns 0.0
+   ret double 0.00e+00
+}
+
+
 
+This loop contains all the same constructs we saw before: a phi node, 
several
+expressions, and some basic blocks.  Lets see how this fits together.
 
 
 
@@ -636,30 +672,25 @@
 
 
 
+The first part of codegen is very simple: we just output the start 
expression
+for the loop value:
 
 
 
 Value *ForExprAST::Codegen() {
-  // Output this as:
-  //   ...
-  //   start = startexpr
-  //   goto loop
-  // loop: 
-  //   variable = phi [start, loopheader], [nextvariable, loopend]
-  //   ...
-  //   bodyexpr
-  //   ...
-  // loopend:
-  //   step = stepexpr
-  //   nextvariable = variable + step
-  //   endcond = endexpr
-  //   br endcond, loop, endloop
-  // outloop:
-  
   // Emit the start code first, without 'variable' in scope.
   Value *StartVal = Start->Codegen();
   if (StartVal == 0) return 0;
-  
+
+
+
+With this out of the way, the next step is to set up the LLVM basic block
+for the start of the loop body.  In the case above, the whole loop body is one
+block, but remember that the body code itself could consist of multiple blocks
+(e.g. if it is a if/then/else expression).
+
+
+
   // Make the new basic block for the loop header, inserting after current
   // block.
   Function *TheFunction = Builder.GetInsertBlock()->getParent();
@@ -667,14 +698,35 @@
   BasicBlock *LoopBB = new BasicBlock("loop", TheFunction);
   
   // Insert an explicit fall through from the current block to the LoopBB.
-  // Start insertion in LoopBB.
   Builder.CreateBr(LoopBB);
+
+
+
+This code is similar to what we saw for if/then/else.  Because we will need
+it to create the Phi node, we remember the block that falls through into the
+loop.  Once we have that, we create the actual block that starts the loop and
+create an unconditional branch for the fall-through between the two blocks.
+  
+
+
+  // Start insertion in LoopBB.
   Builder.SetInsertPoint(LoopBB);
   
   // Start the PHI node with an entry for Start.
   PHINode *Variable = Builder.CreatePHI(Type::DoubleTy, VarName.c_str());
   Variable->addIncoming(StartVal, PreheaderBB);
-  
+
+
+
+Now that the "preheader" for the loop is set up, we switch to emitting code
+for the loop body.  To begin with, we move the insertion point and create the
+PHI node for the loop induction variable.  SInce we already know the incoming
+value for the starting value, we add it to the Phi node.  Note that the Phi 
will
+eventually get a second value for the backedge, but we can't set it up yet
+(because it doesn't exist!).
+
+
+
   // Within the loop, the variable is defined equal 

[llvm-commits] [llvm] r43549 - /llvm/trunk/docs/tutorial/LangImpl4.html

2007-10-30 Thread Chris Lattner
Author: lattner
Date: Wed Oct 31 02:30:39 2007
New Revision: 43549

URL: http://llvm.org/viewvc/llvm-project?rev=43549&view=rev
Log:
fix validation

Modified:
llvm/trunk/docs/tutorial/LangImpl4.html

Modified: llvm/trunk/docs/tutorial/LangImpl4.html
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl4.html?rev=43549&r1=43548&r2=43549&view=diff

==
--- llvm/trunk/docs/tutorial/LangImpl4.html (original)
+++ llvm/trunk/docs/tutorial/LangImpl4.html Wed Oct 31 02:30:39 2007
@@ -360,7 +360,7 @@
 
 
 
-ready> def testfunc(x y) x + y*2;  
+ready> def testfunc(x y) x + y*2;  
 Read function definition:
 define double @testfunc(double %x, double %y) {
 entry:


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