diff options
Diffstat (limited to 'contrib/llvm/lib/IR/ConstantsContext.h')
-rw-r--r-- | contrib/llvm/lib/IR/ConstantsContext.h | 108 |
1 files changed, 56 insertions, 52 deletions
diff --git a/contrib/llvm/lib/IR/ConstantsContext.h b/contrib/llvm/lib/IR/ConstantsContext.h index 571dec2..f3ddcd7 100644 --- a/contrib/llvm/lib/IR/ConstantsContext.h +++ b/contrib/llvm/lib/IR/ConstantsContext.h @@ -34,7 +34,7 @@ namespace llvm { /// behind the scenes to implement unary constant exprs. class UnaryConstantExpr : public ConstantExpr { void anchor() override; - void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; + void *operator new(size_t, unsigned) = delete; public: // allocate space for exactly one operand void *operator new(size_t s) { @@ -51,7 +51,7 @@ public: /// behind the scenes to implement binary constant exprs. class BinaryConstantExpr : public ConstantExpr { void anchor() override; - void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; + void *operator new(size_t, unsigned) = delete; public: // allocate space for exactly two operands void *operator new(size_t s) { @@ -72,7 +72,7 @@ public: /// behind the scenes to implement select constant exprs. class SelectConstantExpr : public ConstantExpr { void anchor() override; - void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; + void *operator new(size_t, unsigned) = delete; public: // allocate space for exactly three operands void *operator new(size_t s) { @@ -93,14 +93,14 @@ public: /// extractelement constant exprs. class ExtractElementConstantExpr : public ConstantExpr { void anchor() override; - void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; + void *operator new(size_t, unsigned) = delete; public: // allocate space for exactly two operands void *operator new(size_t s) { 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; @@ -114,14 +114,14 @@ public: /// insertelement constant exprs. class InsertElementConstantExpr : public ConstantExpr { void anchor() override; - void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; + void *operator new(size_t, unsigned) = delete; public: // allocate space for exactly three operands void *operator new(size_t s) { 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; @@ -136,7 +136,7 @@ public: /// shufflevector constant exprs. class ShuffleVectorConstantExpr : public ConstantExpr { void anchor() override; - void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; + void *operator new(size_t, unsigned) = delete; public: // allocate space for exactly three operands void *operator new(size_t s) { @@ -146,7 +146,7 @@ public: : 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; @@ -161,7 +161,7 @@ public: /// extractvalue constant exprs. class ExtractValueConstantExpr : public ConstantExpr { void anchor() override; - void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; + void *operator new(size_t, unsigned) = delete; public: // allocate space for exactly one operand void *operator new(size_t s) { @@ -186,7 +186,7 @@ public: /// insertvalue constant exprs. class InsertValueConstantExpr : public ConstantExpr { void anchor() override; - void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; + void *operator new(size_t, unsigned) = delete; public: // allocate space for exactly one operand void *operator new(size_t s) { @@ -207,23 +207,32 @@ public: DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; - /// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is /// used behind the scenes to implement getelementpr constant exprs. class GetElementPtrConstantExpr : public ConstantExpr { + Type *SrcElementTy; void anchor() override; - GetElementPtrConstantExpr(Constant *C, ArrayRef<Constant*> IdxList, - Type *DestTy); + GetElementPtrConstantExpr(Type *SrcElementTy, Constant *C, + ArrayRef<Constant *> IdxList, Type *DestTy); + public: static GetElementPtrConstantExpr *Create(Constant *C, ArrayRef<Constant*> IdxList, Type *DestTy, unsigned Flags) { - GetElementPtrConstantExpr *Result = - new(IdxList.size() + 1) GetElementPtrConstantExpr(C, IdxList, DestTy); + return Create( + cast<PointerType>(C->getType()->getScalarType())->getElementType(), C, + IdxList, DestTy, Flags); + } + static GetElementPtrConstantExpr *Create(Type *SrcElementTy, Constant *C, + ArrayRef<Constant *> IdxList, + Type *DestTy, unsigned Flags) { + GetElementPtrConstantExpr *Result = new (IdxList.size() + 1) + GetElementPtrConstantExpr(SrcElementTy, C, IdxList, DestTy); Result->SubclassOptionalData = Flags; return Result; } + Type *getSourceElementType() const; /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); }; @@ -233,7 +242,7 @@ public: // needed in order to store the predicate value for these instructions. class CompareConstantExpr : public ConstantExpr { void anchor() override; - void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; + void *operator new(size_t, unsigned) = delete; public: // allocate space for exactly two operands void *operator new(size_t s) { @@ -251,65 +260,54 @@ public: }; 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; @@ -420,13 +418,16 @@ struct ConstantExprKeyType { uint16_t SubclassData; ArrayRef<Constant *> Ops; ArrayRef<unsigned> Indexes; + Type *ExplicitTy; ConstantExprKeyType(unsigned Opcode, ArrayRef<Constant *> Ops, unsigned short SubclassData = 0, unsigned short SubclassOptionalData = 0, - ArrayRef<unsigned> Indexes = None) + ArrayRef<unsigned> Indexes = None, + Type *ExplicitTy = nullptr) : Opcode(Opcode), SubclassOptionalData(SubclassOptionalData), - SubclassData(SubclassData), Ops(Ops), Indexes(Indexes) {} + SubclassData(SubclassData), Ops(Ops), Indexes(Indexes), + ExplicitTy(ExplicitTy) {} ConstantExprKeyType(ArrayRef<Constant *> Operands, const ConstantExpr *CE) : Opcode(CE->getOpcode()), SubclassOptionalData(CE->getRawSubclassOptionalData()), @@ -497,8 +498,11 @@ struct ConstantExprKeyType { case Instruction::ExtractValue: return new ExtractValueConstantExpr(Ops[0], Indexes, Ty); case Instruction::GetElementPtr: - return GetElementPtrConstantExpr::Create(Ops[0], Ops.slice(1), Ty, - SubclassOptionalData); + return GetElementPtrConstantExpr::Create( + ExplicitTy ? ExplicitTy + : cast<PointerType>(Ops[0]->getType()->getScalarType()) + ->getElementType(), + Ops[0], Ops.slice(1), Ty, SubclassOptionalData); case Instruction::ICmp: return new CompareConstantExpr(Ty, Instruction::ICmp, SubclassData, Ops[0], Ops[1]); |