From 72e3958003ee84839797b9219e91d6a4648d78c5 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 15 Jun 2007 06:10:53 +0000 Subject: add a Constant::getAllOnesValue helper function, which works on integers AND vectors. llvm-svn: 37586 --- llvm/lib/VMCore/Constants.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/VMCore/Constants.cpp') diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 55e1539b5c1..e171011159c 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -122,6 +122,11 @@ Constant *Constant::getNullValue(const Type *Ty) { } } +Constant *Constant::getAllOnesValue(const Type *Ty) { + if (const IntegerType* ITy = dyn_cast(Ty)) + return ConstantInt::get(APInt::getAllOnesValue(ITy->getBitWidth())); + return ConstantVector::getAllOnesValue(cast(Ty)); +} // Static constructor to create an integral constant with all bits set ConstantInt *ConstantInt::getAllOnesValue(const Type *Ty) { -- cgit v1.2.3