/// getAlignment - Return the alignment of the memory that is being allocated
/// by the instruction.
///
- unsigned getAlignment() const { return (1u << SubclassData) >> 1; }
+ unsigned getAlignment() const {
+ return (1u << getSubclassDataFromInstruction()) >> 1;
+ }
void setAlignment(unsigned Align);
/// isStaticAlloca - Return true if this alloca is in the entry block of the
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
+private:
+ // Shadow Instruction::setInstructionSubclassData with a private forwarding
+ // method so that subclasses cannot accidentally use it.
+ void setInstructionSubclassData(unsigned short D) {
+ Instruction::setInstructionSubclassData(D);
+ }
};
/// isVolatile - Return true if this is a load from a volatile memory
/// location.
///
- bool isVolatile() const { return SubclassData & 1; }
+ bool isVolatile() const { return getSubclassDataFromInstruction() & 1; }
/// setVolatile - Specify whether this is a volatile load or not.
///
void setVolatile(bool V) {
- SubclassData = (SubclassData & ~1) | (V ? 1 : 0);
+ setInstructionSubclassData((getSubclassDataFromInstruction() & ~1) |
+ (V ? 1 : 0));
}
/// getAlignment - Return the alignment of the access that is being performed
///
unsigned getAlignment() const {
- return (1 << (SubclassData>>1)) >> 1;
+ return (1 << (getSubclassDataFromInstruction() >> 1)) >> 1;
}
void setAlignment(unsigned Align);
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
+private:
+ // Shadow Instruction::setInstructionSubclassData with a private forwarding
+ // method so that subclasses cannot accidentally use it.
+ void setInstructionSubclassData(unsigned short D) {
+ Instruction::setInstructionSubclassData(D);
+ }
};
/// isVolatile - Return true if this is a load from a volatile memory
/// location.
///
- bool isVolatile() const { return SubclassData & 1; }
+ bool isVolatile() const { return getSubclassDataFromInstruction() & 1; }
/// setVolatile - Specify whether this is a volatile load or not.
///
void setVolatile(bool V) {
- SubclassData = (SubclassData & ~1) | (V ? 1 : 0);
+ setInstructionSubclassData((getSubclassDataFromInstruction() & ~1) |
+ (V ? 1 : 0));
}
/// Transparently provide more efficient getOperand methods.
/// getAlignment - Return the alignment of the access that is being performed
///
unsigned getAlignment() const {
- return (1 << (SubclassData>>1)) >> 1;
+ return (1 << (getSubclassDataFromInstruction() >> 1)) >> 1;
}
void setAlignment(unsigned Align);
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
+private:
+ // Shadow Instruction::setInstructionSubclassData with a private forwarding
+ // method so that subclasses cannot accidentally use it.
+ void setInstructionSubclassData(unsigned short D) {
+ Instruction::setInstructionSubclassData(D);
+ }
};
template <>
/// (e.g. ult).
/// @brief Swap operands and adjust predicate.
void swapOperands() {
- SubclassData = getSwappedPredicate();
+ setPredicate(getSwappedPredicate());
Op<0>().swap(Op<1>());
}
/// @returns true if the predicate of this instruction is EQ or NE.
/// @brief Determine if this is an equality predicate.
bool isEquality() const {
- return SubclassData == FCMP_OEQ || SubclassData == FCMP_ONE ||
- SubclassData == FCMP_UEQ || SubclassData == FCMP_UNE;
+ return getPredicate() == FCMP_OEQ || getPredicate() == FCMP_ONE ||
+ getPredicate() == FCMP_UEQ || getPredicate() == FCMP_UNE;
}
/// @returns true if the predicate of this instruction is commutative.
/// @brief Determine if this is a commutative predicate.
bool isCommutative() const {
return isEquality() ||
- SubclassData == FCMP_FALSE ||
- SubclassData == FCMP_TRUE ||
- SubclassData == FCMP_ORD ||
- SubclassData == FCMP_UNO;
+ getPredicate() == FCMP_FALSE ||
+ getPredicate() == FCMP_TRUE ||
+ getPredicate() == FCMP_ORD ||
+ getPredicate() == FCMP_UNO;
}
/// @returns true if the predicate is relational (not EQ or NE).
/// (e.g. ult).
/// @brief Swap operands and adjust predicate.
void swapOperands() {
- SubclassData = getSwappedPredicate();
+ setPredicate(getSwappedPredicate());
Op<0>().swap(Op<1>());
}
}
};
-//===----------------------------------------------------------------------===//
-// CallInst Class
//===----------------------------------------------------------------------===//
/// CallInst - This class represents a function call, abstracting a target
/// machine's calling convention. This class uses low bit of the SubClassData
/// field to indicate whether or not this is a tail call. The rest of the bits
/// hold the calling convention of the call.
///
-
class CallInst : public Instruction {
AttrListPtr AttributeList; ///< parameter attributes for call
CallInst(const CallInst &CI);
/// 3. Bitcast the result of the malloc call to the specified type.
static Instruction *CreateMalloc(Instruction *InsertBefore,
const Type *IntPtrTy, const Type *AllocTy,
- Value *ArraySize = 0,
+ Value *AllocSize, Value *ArraySize = 0,
const Twine &Name = "");
static Instruction *CreateMalloc(BasicBlock *InsertAtEnd,
const Type *IntPtrTy, const Type *AllocTy,
- Value *ArraySize = 0, Function* MallocF = 0,
+ Value *AllocSize, Value *ArraySize = 0,
+ Function* MallocF = 0,
const Twine &Name = "");
/// CreateFree - Generate the IR for a call to the builtin free function.
static void CreateFree(Value* Source, Instruction *InsertBefore);
~CallInst();
- bool isTailCall() const { return SubclassData & 1; }
+ bool isTailCall() const { return getSubclassDataFromInstruction() & 1; }
void setTailCall(bool isTC = true) {
- SubclassData = (SubclassData & ~1) | unsigned(isTC);
+ setInstructionSubclassData((getSubclassDataFromInstruction() & ~1) |
+ unsigned(isTC));
}
/// Provide fast operand accessors
/// getCallingConv/setCallingConv - Get or set the calling convention of this
/// function call.
CallingConv::ID getCallingConv() const {
- return static_cast<CallingConv::ID>(SubclassData >> 1);
+ return static_cast<CallingConv::ID>(getSubclassDataFromInstruction() >> 1);
}
void setCallingConv(CallingConv::ID CC) {
- SubclassData = (SubclassData & 1) | (static_cast<unsigned>(CC) << 1);
+ setInstructionSubclassData((getSubclassDataFromInstruction() & 1) |
+ (static_cast<unsigned>(CC) << 1));
}
/// getAttributes - Return the parameter attributes for this call.
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
+private:
+ // Shadow Instruction::setInstructionSubclassData with a private forwarding
+ // method so that subclasses cannot accidentally use it.
+ void setInstructionSubclassData(unsigned short D) {
+ Instruction::setInstructionSubclassData(D);
+ }
};
template <>
/// getCallingConv/setCallingConv - Get or set the calling convention of this
/// function call.
CallingConv::ID getCallingConv() const {
- return static_cast<CallingConv::ID>(SubclassData);
+ return static_cast<CallingConv::ID>(getSubclassDataFromInstruction());
}
void setCallingConv(CallingConv::ID CC) {
- SubclassData = static_cast<unsigned>(CC);
+ setInstructionSubclassData(static_cast<unsigned>(CC));
}
/// getAttributes - Return the parameter attributes for this invoke.
virtual BasicBlock *getSuccessorV(unsigned idx) const;
virtual unsigned getNumSuccessorsV() const;
virtual void setSuccessorV(unsigned idx, BasicBlock *B);
+
+ // Shadow Instruction::setInstructionSubclassData with a private forwarding
+ // method so that subclasses cannot accidentally use it.
+ void setInstructionSubclassData(unsigned short D) {
+ Instruction::setInstructionSubclassData(D);
+ }
};
template <>