/// Return a ConstantInt with the specified value and an implied Type. The
/// type is the integer type that corresponds to the bit width of the value.
static ConstantInt* get(LLVMContext &Context, const APInt& V);
+
+ /// Return a ConstantInt constructed from the string strStart with the given
+ /// radix.
+ static ConstantInt* get(const IntegerType* Ty, const StringRef& Str,
+ uint8_t radix);
/// If Ty is a vector type, return a Constant with a splat of the given
/// value. Otherwise return a ConstantInt for the given value.
APFloat Val;
void *operator new(size_t, unsigned);// DO NOT IMPLEMENT
ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT
- friend struct LLVMContextImpl;
+ friend class LLVMContextImpl;
protected:
ConstantFP(const Type *Ty, const APFloat& V);
protected:
/// only be used for simple constant values like 2.0/1.0 etc, that are
/// known-valid both as host double and as the target format.
static Constant* get(const Type* Ty, double V);
+ static Constant* get(const Type* Ty, const StringRef& Str);
static ConstantFP* get(LLVMContext &Context, const APFloat& V);
static ConstantFP* getNegativeZero(const Type* Ty);
/// of the array by one (you've been warned). However, in some situations
/// this is not desired so if AddNull==false then the string is copied without
/// null termination.
- static Constant* get(const StringRef &Initializer, bool AddNull = true);
+ static Constant* get(LLVMContext &Context, const StringRef &Initializer,
+ bool AddNull = true);
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
};
template <>
-struct OperandTraits<ConstantArray> : VariadicOperandTraits<> {
+struct OperandTraits<ConstantArray> : public VariadicOperandTraits<> {
};
DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantArray, Constant)
public:
// ConstantStruct accessors
static Constant* get(const StructType* T, const std::vector<Constant*>& V);
- static Constant* get(const std::vector<Constant*>& V, bool Packed = false);
- static Constant* get(Constant* const *Vals, unsigned NumVals,
+ static Constant* get(LLVMContext &Context,
+ const std::vector<Constant*>& V, bool Packed = false);
+ static Constant* get(LLVMContext &Context,
+ Constant* const *Vals, unsigned NumVals,
bool Packed = false);
/// Transparently provide more efficient getOperand methods.
};
template <>
-struct OperandTraits<ConstantStruct> : VariadicOperandTraits<> {
+struct OperandTraits<ConstantStruct> : public VariadicOperandTraits<> {
};
DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantStruct, Constant)
};
template <>
-struct OperandTraits<ConstantVector> : VariadicOperandTraits<> {
+struct OperandTraits<ConstantVector> : public VariadicOperandTraits<> {
};
DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantVector, Constant)
// These private methods are used by the type resolution code to create
// ConstantExprs in intermediate forms.
static Constant *getTy(const Type *Ty, unsigned Opcode,
- Constant *C1, Constant *C2);
+ Constant *C1, Constant *C2,
+ unsigned Flags = 0);
static Constant *getCompareTy(unsigned short pred, Constant *C1,
Constant *C2);
static Constant *getSelectTy(const Type *Ty,
Constant *C1, Constant *C2, Constant *C3);
static Constant *getGetElementPtrTy(const Type *Ty, Constant *C,
Value* const *Idxs, unsigned NumIdxs);
+ static Constant *getInBoundsGetElementPtrTy(const Type *Ty, Constant *C,
+ Value* const *Idxs,
+ unsigned NumIdxs);
static Constant *getExtractElementTy(const Type *Ty, Constant *Val,
Constant *Idx);
static Constant *getInsertElementTy(const Type *Ty, Constant *Val,
/// independent way (Note: the return type is an i64).
///
static Constant* getSizeOf(const Type* Ty);
+
+ /// getOffsetOf constant expr - computes the offset of a field in a target
+ /// independent way (Note: the return type is an i64).
+ ///
+ static Constant* getOffsetOf(const StructType* Ty, unsigned FieldNo);
static Constant* getNeg(Constant* C);
static Constant* getFNeg(Constant* C);
static Constant *getIntToPtr(Constant *C, const Type *Ty);
static Constant *getBitCast (Constant *C, const Type *Ty);
+ static Constant* getNSWAdd(Constant* C1, Constant* C2);
+ static Constant* getExactSDiv(Constant* C1, Constant* C2);
+
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
/// get - Return a binary or shift operator constant expression,
/// folding if possible.
///
- static Constant *get(unsigned Opcode, Constant *C1, Constant *C2);
+ static Constant *get(unsigned Opcode, Constant *C1, Constant *C2,
+ unsigned Flags = 0);
/// @brief Return an ICmp or FCmp comparison operator constant expression.
static Constant *getCompare(unsigned short pred, Constant *C1, Constant *C2);
Constant* const *IdxList, unsigned NumIdx);
static Constant *getGetElementPtr(Constant *C,
Value* const *IdxList, unsigned NumIdx);
-
+
+ /// Create an "inbounds" getelementptr. See the documentation for the
+ /// "inbounds" flag in LangRef.html for details.
+ static Constant *getInBoundsGetElementPtr(Constant *C,
+ Constant* const *IdxList,
+ unsigned NumIdx);
+ static Constant *getInBoundsGetElementPtr(Constant *C,
+ Value* const *IdxList,
+ unsigned NumIdx);
+
static Constant *getExtractElement(Constant *Vec, Constant *Idx);
static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx);
static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant *Mask);
};
template <>
-struct OperandTraits<ConstantExpr> : VariadicOperandTraits<1> {
+struct OperandTraits<ConstantExpr> : public VariadicOperandTraits<1> {
};
DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(ConstantExpr, Constant)