From 82385c9a40de1c81ee0e92891bc59a3e68b03a2f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 25 Jan 2012 01:53:58 +0000 Subject: Introduce a new ConstantVector::getSplat constructor function to simplify a really common case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148901 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Constants.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/llvm/Constants.h') diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index d3fd766ee7..1823f1d49e 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -489,6 +489,10 @@ public: // ConstantVector accessors static Constant *get(ArrayRef V); + /// getSplat - Return a ConstantVector with the specified constant in each + /// element. + static Constant *getSplat(unsigned NumElts, Constant *Elt); + /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); @@ -757,6 +761,11 @@ public: static Constant *get(LLVMContext &Context, ArrayRef Elts); static Constant *get(LLVMContext &Context, ArrayRef Elts); + /// getSplat - Return a ConstantVector with the specified constant in each + /// element. The specified constant has to be a of a compatible type (i8/i16/ + /// i32/i64/float/double) and must be a ConstantFP or ConstantInt. + static Constant *getSplat(unsigned NumElts, Constant *Elt); + /// getType - Specialize the getType() method to always return a VectorType, /// which reduces the amount of casting needed in parts of the compiler. /// -- cgit v1.2.3