|
Enzyme main
|
Class representing the underlying types of values as sequences of offsets to a ConcreteType. More...
#include "TypeAnalysis/TypeTree.h"


Public Member Functions | |
| TypeTree () | |
| TypeTree (ConcreteType dat) | |
| const ConcreteTypeMapType & | getMapping () const |
| Utility helper to lookup the mapping. | |
| ConcreteType | operator[] (const std::vector< int > Seq) const |
| Lookup the underlying ConcreteType at a given offset sequence or Unknown if none exists. | |
| bool | IsFullyDetermined () const |
| void | remove (const std::vector< int > Seq) |
| bool | insert (const std::vector< int > Seq, ConcreteType CT, bool PointerIntSame=false) |
| Return if changed. | |
| bool | operator< (const TypeTree &vd) const |
| How this TypeTree compares with another. | |
| bool | isKnown () const |
| Whether this TypeTree contains any information. | |
| bool | isKnownPastPointer () const |
| Whether this TypeTree knows any non-pointer information. | |
| TypeTree | JustInt () const |
| Select only the Integer ConcreteTypes. | |
| TypeTree | Only (int Off, llvm::Instruction *orig) const |
| Prepend an offset to all mappings. | |
| TypeTree | Data0 () const |
| Peel off the outermost index at offset 0. | |
| ConcreteType | Inner0 () const |
| Optimized version of Data0()[{}]. | |
| TypeTree | Clear (size_t start, size_t end, size_t len) const |
| Remove any mappings in the range [start, end) or [len, inf) This function has special handling for -1's. | |
| TypeTree | Lookup (size_t len, const llvm::DataLayout &dl) const |
| Select all submappings whose first index is in range [0, len) and remove the first index. | |
| void | CanonicalizeInPlace (size_t len, const llvm::DataLayout &dl) |
| Given that this tree represents something of at most size len, canonicalize this, creating -1's where possible. | |
| TypeTree | KeepMinusOne (bool &legal) const |
| Keep only pointers (or anything's) to a repeated value (represented by -1) | |
| llvm::Type * | allFloat (llvm::Value *val, const llvm::DataLayout &dl, bool anythingIsFloat=false) const |
| bool | anyFloat (llvm::Value *val, const llvm::DataLayout &dl) const |
| bool | anyPointer (llvm::Value *val, const llvm::DataLayout &dl) const |
| TypeTree | ShiftIndices (const llvm::DataLayout &dl, const int offset, const int maxSize, size_t addOffset=0) const |
| Replace mappings in the range in [offset, offset+maxSize] with those in. | |
| TypeTree | PurgeAnything () const |
Keep only mappings where the type is not an Anything | |
| TypeTree | ReplaceMinus () const |
| Replace -1 with 0. | |
| void | ReplaceIntWithAnything () |
| Replace all integer subtypes with anything. | |
| TypeTree | JustAnything () const |
Keep only mappings where the type is an Anything | |
| bool | operator== (const TypeTree &RHS) const |
| Chceck equality of two TypeTrees. | |
| bool | operator= (const TypeTree &RHS) |
| Set this to another TypeTree, returning if this was changed. | |
| bool | checkedOrIn (const std::vector< int > &Seq, ConcreteType RHS, bool PointerIntSame, bool &LegalOr) |
| bool | orIn (const std::vector< int > &Seq, ConcreteType RHS, bool PointerIntSame=false) |
| bool | checkedOrIn (const TypeTree &RHS, bool PointerIntSame, bool &LegalOr) |
Set this to the logical or of itself and RHS, returning whether this value changed Setting PointerIntSame considers pointers and integers as equivalent If this is an illegal operation, LegalOr will be set to false. | |
| bool | orIn (const TypeTree &RHS, bool PointerIntSame) |
Set this to the logical or of itself and RHS, returning whether this value changed Setting PointerIntSame considers pointers and integers as equivalent This function will error if doing an illegal Operation. | |
| bool | orIn (const std::vector< int > Seq, ConcreteType CT, bool PointerIntSame) |
Set this to the logical or of itself and RHS, returning whether this value changed Setting PointerIntSame considers pointers and integers as equivalent This function will error if doing an illegal Operation. | |
| bool | operator|= (const TypeTree &RHS) |
| Set this to the logical or of itself and RHS, returning whether this value changed This assumes that pointers and integers are distinct This function will error if doing an illegal Operation. | |
| bool | andIn (const TypeTree &RHS) |
| Set this to the logical and of itself and RHS, returning whether this value changed If this and RHS are incompatible at an index, the result will be BaseType::Unknown. | |
| bool | operator&= (const TypeTree &RHS) |
| Set this to the logical and of itself and RHS, returning whether this value changed If this and RHS are incompatible at an index, the result will be BaseType::Unknown. | |
| bool | binopIn (bool &Legal, const TypeTree &RHS, llvm::BinaryOperator::BinaryOps Op) |
Set this to the logical binop of itself and RHS, using the Binop Op, returning true if this was changed. | |
| std::string | str () const |
| Returns a string representation of this TypeTree. | |
| llvm::MDNode * | toMD (llvm::LLVMContext &ctx) |
| void | insertFromMD (llvm::MDNode *md, const std::vector< int > &prev={}) |
Static Public Member Functions | |
| static TypeTree | parse (llvm::StringRef str, llvm::LLVMContext &ctx) |
| static TypeTree | fromMD (llvm::MDNode *md) |
Class representing the underlying types of values as sequences of offsets to a ConcreteType.
Definition at line 72 of file TypeTree.h.
|
inline |
Definition at line 79 of file TypeTree.h.
Referenced by ShiftIndices().
|
inline |
Definition at line 80 of file TypeTree.h.
References Unknown.
|
inline |
Definition at line 816 of file TypeTree.h.
References Anything, ConcreteType::isFloat(), operator[](), and Unknown.
Referenced by AdjointGenerator::createBinaryOperatorAdjoint(), AdjointGenerator::createBinaryOperatorDual(), and TypeAnalyzer::visitBinaryOperation().
|
inline |
Set this to the logical and of itself and RHS, returning whether this value changed If this and RHS are incompatible at an index, the result will be BaseType::Unknown.
Definition at line 1366 of file TypeTree.h.
References Unknown.
Referenced by operator&=().
|
inline |
Definition at line 862 of file TypeTree.h.
References Anything, Integer, ConcreteType::isFloat(), operator[](), Pointer, and Unknown.
|
inline |
Definition at line 885 of file TypeTree.h.
References Anything, Integer, operator[](), Pointer, and Unknown.
|
inline |
Set this to the logical binop of itself and RHS, using the Binop Op, returning true if this was changed.
This function will error on an invalid type combination
Definition at line 1392 of file TypeTree.h.
References ConcreteType::binopIn(), and Unknown.
Referenced by TypeAnalyzer::visitBinaryOperation(), TypeAnalyzer::visitIntrinsicInst(), and TypeAnalyzer::visitPHINode().
|
inline |
Given that this tree represents something of at most size len, canonicalize this, creating -1's where possible.
Definition at line 678 of file TypeTree.h.
References insert(), Pointer, and str().
Referenced by getConstantAnalysis(), and TypeAnalyzer::visitCallBase().
|
inline |
Definition at line 1180 of file TypeTree.h.
References Anything, ConcreteType::checkedOrIn(), insert(), Integer, operator[](), Pointer, and Unknown.
Referenced by checkedOrIn(), orIn(), orIn(), orIn(), TypeAnalyzer::visitAtomicRMWInst(), TypeAnalyzer::visitBinaryOperation(), TypeAnalyzer::visitCallBase(), and TypeAnalyzer::visitMemTransferCommon().
|
inline |
Set this to the logical or of itself and RHS, returning whether this value changed Setting PointerIntSame considers pointers and integers as equivalent If this is an illegal operation, LegalOr will be set to false.
Definition at line 1315 of file TypeTree.h.
References checkedOrIn().
|
inline |
Remove any mappings in the range [start, end) or [len, inf) This function has special handling for -1's.
Definition at line 558 of file TypeTree.h.
References insert(), and orIn().
Referenced by TypeAnalyzer::visitInsertElementInst(), and TypeAnalyzer::visitInsertValueInst().
|
inline |
Peel off the outermost index at offset 0.
Definition at line 515 of file TypeTree.h.
Referenced by analyzeIntelSubscriptIntrinsic(), AdjointGenerator::DifferentiableMemCopyFloats(), TypeResults::firstPointer(), TypeAnalyzer::visitBinaryOperation(), TypeAnalyzer::visitCallBase(), TypeAnalyzer::visitGEPOperator(), TypeAnalyzer::visitIntrinsicInst(), AdjointGenerator::visitMemSetCommon(), AdjointGenerator::visitMemTransferCommon(), TypeAnalyzer::visitMemTransferCommon(), and TypeAnalyzer::visitPHINode().
|
inlinestatic |
Definition at line 1516 of file TypeTree.h.
References insertFromMD().
Referenced by TypeAnalyzer::considerTBAA(), and getConstantAnalysis().
|
inline |
Utility helper to lookup the mapping.
Definition at line 173 of file TypeTree.h.
Referenced by checkEnzymeTypeExtent(), and TypeAnalyzer::getReturnAnalysis().
|
inline |
Optimized version of Data0()[{}].
Definition at line 550 of file TypeTree.h.
References operator[]().
Referenced by analyzeIntelSubscriptIntrinsic(), TypeAnalyzer::visitCallBase(), TypeAnalyzer::visitCmpInst(), TypeAnalyzer::visitGEPOperator(), TypeAnalyzer::visitIPOCall(), TypeAnalyzer::visitPHINode(), TypeAnalyzer::visitSelectInst(), and TypeAnalyzer::visitZExtInst().
|
inline |
Return if changed.
Definition at line 236 of file TypeTree.h.
References Anything, CustomErrorHandler, EnzymeMaxTypeDepth, EnzymeTypeWarning, Integer, MaxTypeOffset, Pointer, ConcreteType::str(), str(), to_string(), and TypeDepthExceeded.
Referenced by AugmentWithJuliaObjectType(), CanonicalizeInPlace(), checkedOrIn(), Clear(), TypeAnalyzer::considerTBAA(), fortranDescriptorTree(), getConstantAnalysis(), TypeAnalyzer::getReturnAnalysis(), JustAnything(), JustInt(), KeepMinusOne(), Lookup(), ReplaceMinus(), TypeAnalyzer::visitAtomicRMWInst(), TypeAnalyzer::visitCallBase(), TypeAnalyzer::visitGEPOperator(), TypeAnalyzer::visitIntrinsicInst(), TypeAnalyzer::visitMemTransferCommon(), and AdjointGenerator::visitOMPCall().
|
inline |
Definition at line 1499 of file TypeTree.h.
Referenced by EnzymeTypeTreeFromMD(), and fromMD().
|
inline |
Definition at line 221 of file TypeTree.h.
References Pointer.
|
inline |
Whether this TypeTree contains any information.
Definition at line 433 of file TypeTree.h.
|
inline |
Whether this TypeTree knows any non-pointer information.
Definition at line 445 of file TypeTree.h.
References Anything, and Pointer.
Referenced by TypeAnalyzer::considerTBAA().
|
inline |
Keep only mappings where the type is an Anything
Definition at line 1155 of file TypeTree.h.
References Anything, and insert().
Referenced by TypeAnalyzer::visitSelectInst().
|
inline |
Select only the Integer ConcreteTypes.
Definition at line 461 of file TypeTree.h.
|
inline |
Keep only pointers (or anything's) to a repeated value (represented by -1)
Definition at line 787 of file TypeTree.h.
|
inline |
Select all submappings whose first index is in range [0, len) and remove the first index.
This is the inverse of the Only operation
Definition at line 595 of file TypeTree.h.
References Anything, insert(), and Pointer.
Referenced by TypeAnalyzer::considerTBAA(), TypeAnalyzer::visitAllocaInst(), TypeAnalyzer::visitAtomicRMWInst(), TypeAnalyzer::visitCallBase(), AdjointGenerator::visitCommonStore(), TypeAnalyzer::visitExtractElementInst(), TypeAnalyzer::visitIntrinsicInst(), TypeAnalyzer::visitLoadInst(), TypeAnalyzer::visitStoreInst(), and writesToMemoryReadBy().
|
inline |
Prepend an offset to all mappings.
Definition at line 473 of file TypeTree.h.
References CustomErrorHandler, EmitWarning(), EnzymeMaxTypeDepth, EnzymeTypeWarning, str(), and TypeDepthExceeded.
Referenced by analyzeIntelSubscriptIntrinsic(), TypeHandler< double * >::analyzeType(), TypeHandler< double >::analyzeType(), TypeHandler< float * >::analyzeType(), TypeHandler< float >::analyzeType(), TypeHandler< int * >::analyzeType(), TypeHandler< int >::analyzeType(), TypeHandler< long double * >::analyzeType(), TypeHandler< long double >::analyzeType(), TypeHandler< long int * >::analyzeType(), TypeHandler< long int >::analyzeType(), TypeHandler< long long int * >::analyzeType(), TypeHandler< long long int >::analyzeType(), TypeHandler< long long unsigned int * >::analyzeType(), TypeHandler< long long unsigned int >::analyzeType(), TypeHandler< long unsigned int * >::analyzeType(), TypeHandler< long unsigned int >::analyzeType(), TypeHandler< unsigned int * >::analyzeType(), TypeHandler< unsigned int >::analyzeType(), TypeHandler< void * >::analyzeType(), TypeAnalyzer::considerTBAA(), defaultTypeTreeForLLVM(), AdjointGenerator::DifferentiableMemCopyFloats(), TypeAnalyzer::getAnalysis(), TypeAnalyzer::getCallInfo(), getConstantAnalysis(), parseTBAA(), parseTBAA(), TypeAnalyzer::runPHIHypotheses(), TypeAnalyzer::visitAtomicRMWInst(), TypeAnalyzer::visitBinaryOperation(), TypeAnalyzer::visitBinaryOperator(), TypeAnalyzer::visitCallBase(), TypeAnalyzer::visitCmpInst(), TypeAnalyzer::visitExtractElementInst(), TypeAnalyzer::visitFPExtInst(), TypeAnalyzer::visitFPToSIInst(), TypeAnalyzer::visitFPToUIInst(), TypeAnalyzer::visitFPTruncInst(), TypeAnalyzer::visitGEPOperator(), TypeAnalyzer::visitIntrinsicInst(), TypeAnalyzer::visitIPOCall(), AdjointGenerator::visitMemSetCommon(), AdjointGenerator::visitMemTransferCommon(), TypeAnalyzer::visitMemTransferCommon(), TypeAnalyzer::visitPHINode(), TypeAnalyzer::visitShuffleVectorInst(), TypeAnalyzer::visitSIToFPInst(), TypeAnalyzer::visitUIToFPInst(), and TypeAnalyzer::visitZExtInst().
|
inline |
Set this to the logical and of itself and RHS, returning whether this value changed If this and RHS are incompatible at an index, the result will be BaseType::Unknown.
Definition at line 1387 of file TypeTree.h.
References andIn().
|
inline |
How this TypeTree compares with another.
Definition at line 430 of file TypeTree.h.
|
inline |
Set this to another TypeTree, returning if this was changed.
Definition at line 1169 of file TypeTree.h.
|
inline |
Chceck equality of two TypeTrees.
Definition at line 1166 of file TypeTree.h.
|
inline |
Lookup the underlying ConcreteType at a given offset sequence or Unknown if none exists.
Definition at line 177 of file TypeTree.h.
References Unknown.
Referenced by allFloat(), anyFloat(), anyPointer(), checkedOrIn(), Inner0(), and ShiftIndices().
|
inline |
Set this to the logical or of itself and RHS, returning whether this value changed This assumes that pointers and integers are distinct This function will error if doing an illegal Operation.
Definition at line 1359 of file TypeTree.h.
References orIn().
|
inline |
Definition at line 1304 of file TypeTree.h.
References checkedOrIn().
Referenced by Clear(), Data0(), operator|=(), TypeAnalyzer::visitBinaryOperation(), and TypeAnalyzer::visitCallBase().
|
inline |
Set this to the logical or of itself and RHS, returning whether this value changed Setting PointerIntSame considers pointers and integers as equivalent This function will error if doing an illegal Operation.
Definition at line 1343 of file TypeTree.h.
References checkedOrIn(), ConcreteType::str(), str(), and to_string().
|
inline |
Set this to the logical or of itself and RHS, returning whether this value changed Setting PointerIntSame considers pointers and integers as equivalent This function will error if doing an illegal Operation.
Definition at line 1328 of file TypeTree.h.
References checkedOrIn(), and str().
|
inlinestatic |
Definition at line 86 of file TypeTree.h.
References str().
Referenced by TypeAnalyzer::considerTBAA(), TypeAnalyzer::getReturnAnalysis(), and AdjointGenerator::visitMemTransferCommon().
|
inline |
Keep only mappings where the type is not an Anything
Definition at line 1113 of file TypeTree.h.
References Anything.
Referenced by TypeAnalyzer::considerTBAA(), TypeAnalyzer::visitAtomicRMWInst(), TypeAnalyzer::visitCallBase(), TypeAnalyzer::visitIntrinsicInst(), TypeAnalyzer::visitLoadInst(), AdjointGenerator::visitMemTransferCommon(), TypeAnalyzer::visitMemTransferCommon(), TypeAnalyzer::visitPHINode(), TypeAnalyzer::visitSelectInst(), and TypeAnalyzer::visitStoreInst().
|
inline |
Definition at line 233 of file TypeTree.h.
Referenced by AugmentWithJuliaObjectType(), and TypeAnalyzer::getReturnAnalysis().
|
inline |
Replace all integer subtypes with anything.
Definition at line 1146 of file TypeTree.h.
|
inline |
Replace -1 with 0.
Definition at line 1131 of file TypeTree.h.
References Anything, and insert().
Referenced by TypeAnalyzer::visitStoreInst().
|
inline |
Replace mappings in the range in [offset, offset+maxSize] with those in.
Definition at line 912 of file TypeTree.h.
References Anything, MaxTypeOffset, operator[](), ConcreteType::orIn(), Pointer, str(), and TypeTree().
Referenced by analyzeIntelSubscriptIntrinsic(), TypeAnalyzer::considerTBAA(), defaultTypeTreeForLLVM(), AdjointGenerator::DifferentiableMemCopyFloats(), getConstantAnalysis(), parseTBAA(), parseTBAA(), TypeAnalyzer::visitAtomicRMWInst(), TypeAnalyzer::visitCallBase(), TypeAnalyzer::visitExtractElementInst(), TypeAnalyzer::visitExtractValueInst(), TypeAnalyzer::visitGEPOperator(), TypeAnalyzer::visitInsertElementInst(), TypeAnalyzer::visitInsertValueInst(), TypeAnalyzer::visitIntrinsicInst(), TypeAnalyzer::visitLoadInst(), AdjointGenerator::visitMemSetCommon(), AdjointGenerator::visitMemTransferCommon(), TypeAnalyzer::visitMemTransferCommon(), TypeAnalyzer::visitShuffleVectorInst(), TypeAnalyzer::visitStoreInst(), and TypeAnalyzer::visitTruncInst().
|
inline |
Returns a string representation of this TypeTree.
Definition at line 1455 of file TypeTree.h.
Referenced by TypeAnalysis::analyzeFunction(), CanonicalizeInPlace(), checkEnzymeTypeExtent(), TypeAnalyzer::considerTBAA(), AdjointGenerator::createBinaryOperatorAdjoint(), AdjointGenerator::createBinaryOperatorDual(), Data0(), insert(), Only(), orIn(), orIn(), parse(), ShiftIndices(), TypeAnalyzer::visitAtomicRMWInst(), TypeAnalyzer::visitBinaryOperation(), TypeAnalyzer::visitIntrinsicInst(), TypeAnalyzer::visitMemTransferCommon(), TypeAnalyzer::visitPHINode(), and TypeAnalyzer::visitSelectInst().
|
inline |
Definition at line 1475 of file TypeTree.h.
References ConcreteType::str(), and Unknown.
Referenced by getConstantAnalysis().