return User::operator new(s, 2);
}
ExtractElementConstantExpr(Constant *C1, Constant *C2)
- : ConstantExpr(cast<VectorType>(C1->getType())->getElementType(),
+ : ConstantExpr(cast<VectorType>(C1->getType())->getElementType(),
Instruction::ExtractElement, &Op<0>(), 2) {
Op<0>() = C1;
Op<1>() = C2;
return User::operator new(s, 3);
}
InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3)
- : ConstantExpr(C1->getType(), Instruction::InsertElement,
+ : ConstantExpr(C1->getType(), Instruction::InsertElement,
&Op<0>(), 3) {
Op<0>() = C1;
Op<1>() = C2;
: ConstantExpr(VectorType::get(
cast<VectorType>(C1->getType())->getElementType(),
cast<VectorType>(C3->getType())->getNumElements()),
- Instruction::ShuffleVector,
+ Instruction::ShuffleVector,
&Op<0>(), 3) {
Op<0>() = C1;
Op<1>() = C2;
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ static bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::ExtractValue;
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
};
/// InsertValueConstantExpr - This class is private to
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
-};
+ static bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::InsertValue;
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
+};
/// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is
/// used behind the scenes to implement getelementpr constant exprs.
Type *getSourceElementType() const;
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ static bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::GetElementPtr;
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
};
// CompareConstantExpr - This class is private to Constants.cpp, and is used
}
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ static bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::ICmp ||
+ CE->getOpcode() == Instruction::FCmp;
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
};
template <>
-struct OperandTraits<UnaryConstantExpr> :
- public FixedNumOperandTraits<UnaryConstantExpr, 1> {
-};
+struct OperandTraits<UnaryConstantExpr>
+ : public FixedNumOperandTraits<UnaryConstantExpr, 1> {};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UnaryConstantExpr, Value)
template <>
-struct OperandTraits<BinaryConstantExpr> :
- public FixedNumOperandTraits<BinaryConstantExpr, 2> {
-};
+struct OperandTraits<BinaryConstantExpr>
+ : public FixedNumOperandTraits<BinaryConstantExpr, 2> {};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BinaryConstantExpr, Value)
template <>
-struct OperandTraits<SelectConstantExpr> :
- public FixedNumOperandTraits<SelectConstantExpr, 3> {
-};
+struct OperandTraits<SelectConstantExpr>
+ : public FixedNumOperandTraits<SelectConstantExpr, 3> {};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SelectConstantExpr, Value)
template <>
-struct OperandTraits<ExtractElementConstantExpr> :
- public FixedNumOperandTraits<ExtractElementConstantExpr, 2> {
-};
+struct OperandTraits<ExtractElementConstantExpr>
+ : public FixedNumOperandTraits<ExtractElementConstantExpr, 2> {};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementConstantExpr, Value)
template <>
-struct OperandTraits<InsertElementConstantExpr> :
- public FixedNumOperandTraits<InsertElementConstantExpr, 3> {
-};
+struct OperandTraits<InsertElementConstantExpr>
+ : public FixedNumOperandTraits<InsertElementConstantExpr, 3> {};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertElementConstantExpr, Value)
template <>
-struct OperandTraits<ShuffleVectorConstantExpr> :
- public FixedNumOperandTraits<ShuffleVectorConstantExpr, 3> {
-};
+struct OperandTraits<ShuffleVectorConstantExpr>
+ : public FixedNumOperandTraits<ShuffleVectorConstantExpr, 3> {};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorConstantExpr, Value)
template <>
-struct OperandTraits<ExtractValueConstantExpr> :
- public FixedNumOperandTraits<ExtractValueConstantExpr, 1> {
-};
+struct OperandTraits<ExtractValueConstantExpr>
+ : public FixedNumOperandTraits<ExtractValueConstantExpr, 1> {};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractValueConstantExpr, Value)
template <>
-struct OperandTraits<InsertValueConstantExpr> :
- public FixedNumOperandTraits<InsertValueConstantExpr, 2> {
-};
+struct OperandTraits<InsertValueConstantExpr>
+ : public FixedNumOperandTraits<InsertValueConstantExpr, 2> {};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueConstantExpr, Value)
template <>
-struct OperandTraits<GetElementPtrConstantExpr> :
- public VariadicOperandTraits<GetElementPtrConstantExpr, 1> {
-};
+struct OperandTraits<GetElementPtrConstantExpr>
+ : public VariadicOperandTraits<GetElementPtrConstantExpr, 1> {};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrConstantExpr, Value)
-
template <>
-struct OperandTraits<CompareConstantExpr> :
- public FixedNumOperandTraits<CompareConstantExpr, 2> {
-};
+struct OperandTraits<CompareConstantExpr>
+ : public FixedNumOperandTraits<CompareConstantExpr, 2> {};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CompareConstantExpr, Value)
template <class ConstantClass> struct ConstantAggrKeyType;
struct InlineAsmKeyType {
StringRef AsmString;
StringRef Constraints;
+ FunctionType *FTy;
bool HasSideEffects;
bool IsAlignStack;
InlineAsm::AsmDialect AsmDialect;
InlineAsmKeyType(StringRef AsmString, StringRef Constraints,
- bool HasSideEffects, bool IsAlignStack,
+ FunctionType *FTy, bool HasSideEffects, bool IsAlignStack,
InlineAsm::AsmDialect AsmDialect)
- : AsmString(AsmString), Constraints(Constraints),
+ : AsmString(AsmString), Constraints(Constraints), FTy(FTy),
HasSideEffects(HasSideEffects), IsAlignStack(IsAlignStack),
AsmDialect(AsmDialect) {}
InlineAsmKeyType(const InlineAsm *Asm, SmallVectorImpl<Constant *> &)
: AsmString(Asm->getAsmString()), Constraints(Asm->getConstraintString()),
- HasSideEffects(Asm->hasSideEffects()),
+ FTy(Asm->getFunctionType()), HasSideEffects(Asm->hasSideEffects()),
IsAlignStack(Asm->isAlignStack()), AsmDialect(Asm->getDialect()) {}
bool operator==(const InlineAsmKeyType &X) const {
return HasSideEffects == X.HasSideEffects &&
IsAlignStack == X.IsAlignStack && AsmDialect == X.AsmDialect &&
- AsmString == X.AsmString && Constraints == X.Constraints;
+ AsmString == X.AsmString && Constraints == X.Constraints &&
+ FTy == X.FTy;
}
bool operator==(const InlineAsm *Asm) const {
return HasSideEffects == Asm->hasSideEffects() &&
IsAlignStack == Asm->isAlignStack() &&
AsmDialect == Asm->getDialect() &&
AsmString == Asm->getAsmString() &&
- Constraints == Asm->getConstraintString();
+ Constraints == Asm->getConstraintString() &&
+ FTy == Asm->getFunctionType();
}
unsigned getHash() const {
return hash_combine(AsmString, Constraints, HasSideEffects, IsAlignStack,
- AsmDialect);
+ AsmDialect, FTy);
}
typedef ConstantInfo<InlineAsm>::TypeClass TypeClass;
InlineAsm *create(TypeClass *Ty) const {
- return new InlineAsm(Ty, AsmString, Constraints, HasSideEffects,
+ assert(PointerType::getUnqual(FTy) == Ty);
+ return new InlineAsm(FTy, AsmString, Constraints, HasSideEffects,
IsAlignStack, AsmDialect);
}
};