-//===-- ConstantHandling.h - Stuff for manipulating constants ----*- C++ -*--=//
+//===-- ConstantHandling.h - Stuff for manipulating constants ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
//
// This file contains the declarations of some cool operators that allow you
// to do natural things with constant pool values.
#include "llvm/Constants.h"
#include "llvm/Type.h"
+
+namespace llvm {
+
class PointerType;
//===----------------------------------------------------------------------===//
case Type::LongTyID: return castToLong(V);
case Type::FloatTyID: return castToFloat(V);
case Type::DoubleTyID: return castToDouble(V);
- case Type::PointerTyID:return castToPointer(V, (PointerType*)Ty);
+ case Type::PointerTyID:
+ return castToPointer(V, reinterpret_cast<const PointerType*>(Ty));
default: return 0;
}
}
static inline ConstRules *get(const Constant &V1, const Constant &V2) {
if (isa<ConstantExpr>(V1) || isa<ConstantExpr>(V2))
return getConstantExprRules();
- return (ConstRules*)V1.getType()->getOrCreateAnnotation(AID);
+ return static_cast<ConstRules*>(V1.getType()->getOrCreateAnnotation(AID));
}
private:
static ConstRules *getConstantExprRules();
// Unary operators...
inline Constant *operator~(const Constant &V) {
- assert(V.getType()->isIntegral() && "Cannot invert non-intergral constant!");
+ assert(V.getType()->isIntegral() && "Cannot invert non-integral constant!");
return ConstRules::get(V, V)->op_xor(&V,
ConstantInt::getAllOnesValue(V.getType()));
}
+inline Constant *operator-(const Constant &V) {
+ return ConstRules::get(V, V)->sub(Constant::getNullValue(V.getType()), &V);
+}
+
// Standard binary operators...
inline Constant *operator+(const Constant &V1, const Constant &V2) {
assert(V1.getType() == V2.getType() && "Constant types must be identical!");
const Constant *V2);
Constant *ConstantFoldGetElementPtr(const Constant *C,
const std::vector<Constant*> &IdxList);
+
+} // End llvm namespace
+
#endif