Implement some helpers
authorChris Lattner <sabre@nondot.org>
Tue, 25 May 2004 05:32:43 +0000 (05:32 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 25 May 2004 05:32:43 +0000 (05:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13738 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Constants.cpp

index 3ed70089c1afbc3945ab410aa482bfa66e4ba09e..a393be98ae3899434f3f245bf92aa13da27e999b 100644 (file)
@@ -372,7 +372,17 @@ Constant *ConstantExpr::getShr(Constant *C1, Constant *C2) {
   return get(Instruction::Shr, C1, C2);
 }
 
+Constant *ConstantExpr::getUShr(Constant *C1, Constant *C2) {
+  if (C1->getType()->isUnsigned()) return getShr(C1, C2);
+  return getCast(getShr(getCast(C1,
+                    C1->getType()->getUnsignedVersion()), C2), C1->getType());
+}
 
+Constant *ConstantExpr::getSShr(Constant *C1, Constant *C2) {
+  if (C1->getType()->isSigned()) return getShr(C1, C2);
+  return getCast(getShr(getCast(C1,
+                        C1->getType()->getSignedVersion()), C2), C1->getType());
+}
 
 
 //===----------------------------------------------------------------------===//