Sort a few more #include lines in tools/... unittests/... and utils/...
[oota-llvm.git] / include / llvm / IRBuilder.h
index 6fe98c70ed255ec7f01075a847270b7e0e1718df..c4c2fb928215360b44974d27b5f256aecdcee29e 100644 (file)
@@ -239,7 +239,7 @@ public:
     return Type::getInt16Ty(Context);
   }
 
-  /// getInt32Ty - Fetch the type resepresenting a 32-bit integer.
+  /// getInt32Ty - Fetch the type representing a 32-bit integer.
   IntegerType *getInt32Ty() {
     return Type::getInt32Ty(Context);
   }
@@ -1332,7 +1332,7 @@ public:
 
   LandingPadInst *CreateLandingPad(Type *Ty, Value *PersFn, unsigned NumClauses,
                                    const Twine &Name = "") {
-    return Insert(LandingPadInst::Create(Ty, PersFn, NumClauses, Name));
+    return Insert(LandingPadInst::Create(Ty, PersFn, NumClauses), Name);
   }
 
   //===--------------------------------------------------------------------===//
@@ -1367,6 +1367,22 @@ public:
                            ConstantExpr::getSizeOf(ArgType->getElementType()),
                            Name);
   }
+
+  /// CreateVectorSplat - Return a vector value that contains \arg V broadcasted
+  /// to \p NumElts elements.
+  Value *CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name = "") {
+    assert(NumElts > 0 && "Cannot splat to an empty vector!");
+
+    // First insert it into an undef vector so we can shuffle it.
+    Type *I32Ty = getInt32Ty();
+    Value *Undef = UndefValue::get(VectorType::get(V->getType(), NumElts));
+    V = CreateInsertElement(Undef, V, ConstantInt::get(I32Ty, 0),
+                            Name + ".splatinsert");
+
+    // Shuffle the value across the desired number of elements.
+    Value *Zeros = ConstantAggregateZero::get(VectorType::get(I32Ty, NumElts));
+    return CreateShuffleVector(V, Undef, Zeros, Name + ".splat");
+  }
 };
 
 }