summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2001-07-20 21:11:07 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2001-07-20 21:11:07 +0000
commit230365abf7cf242fcc0bdca4e81f33de1fe136c3 (patch)
tree9d810af0eeaf873020161a0c6afb0f1c18f553d8 /include
parentd01d99b2a09b83c35a67e43efd4ab3da155488b1 (diff)
downloadllvm-230365abf7cf242fcc0bdca4e81f33de1fe136c3.tar.gz
llvm-230365abf7cf242fcc0bdca4e81f33de1fe136c3.tar.bz2
llvm-230365abf7cf242fcc0bdca4e81f33de1fe136c3.tar.xz
Provide simpler ways to extract the value of an integer constant.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ConstPoolVals.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/include/llvm/ConstPoolVals.h b/include/llvm/ConstPoolVals.h
index aa2e2ff480..c45c317e3c 100644
--- a/include/llvm/ConstPoolVals.h
+++ b/include/llvm/ConstPoolVals.h
@@ -110,11 +110,11 @@ public:
return Val.Unsigned == V;
}
- // isIntegral - Equilivent to isSigned() || isUnsigned, but with only a single
+ // isIntegral - Equivalent to isSigned() || isUnsigned, but with only a single
// virtual function invocation.
//
virtual bool isIntegral() const { return 1; }
-
+
// ConstPoolInt::get static method: return a constant pool int with the
// specified value. as above, we work only with very small values here.
//
@@ -224,4 +224,24 @@ public:
inline const vector<Use> &getValues() const { return Operands; }
};
+//===---------------------------------------------------------------------------
+// External functions
+//
+
+// Convenience functions to get the value of an integer constant, for an
+// appropriate integer or non-integer type that can be held in an integer.
+// The type of the argument must be the following:
+// GetSignedIntConstantValue: signed integer or bool
+// GetUnsignedIntConstantValue: unsigned integer, bool, or pointer
+// GetConstantValueAsSignedInt: any of the above, but the value
+// must fit into a int64_t.
+//
+// isValidConstant is set to true if a valid constant was found.
+//
+int64_t GetSignedIntConstantValue (const Value* val, bool& isValidConst);
+uint64_t GetUnsignedIntConstantValue (const Value* val, bool& isValidConst);
+int64_t GetConstantValueAsSignedInt (const Value* val, bool& isValidConst);
+
+//===---------------------------------------------------------------------------
+
#endif