aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-05-25 05:32:43 +0000
committerChris Lattner <sabre@nondot.org>2004-05-25 05:32:43 +0000
commitc971025b015366c4f238c1bd6916c8805f5d8274 (patch)
tree083209f7daeba5a64b622b1ec11760dccf29a9f5 /lib
parent02140b025d821ca8cefe5086f90f4d8e0c52ae5b (diff)
Implement some helpers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13738 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/Constants.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 3ed70089c1..a393be98ae 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -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());
+}
//===----------------------------------------------------------------------===//