|
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 |
| 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 * | IsAllFloat (const size_t size, 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 |
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 1294 of file TypeTree.h.
References Unknown.
Referenced by operator&=().
|
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 1320 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 676 of file TypeTree.h.
References insert(), Pointer, and str().
Referenced by getConstantAnalysis(), and TypeAnalyzer::visitCallBase().
|
inline |
Definition at line 1108 of file TypeTree.h.
References Anything, ConcreteType::checkedOrIn(), insert(), Integer, operator[](), Pointer, and Unknown.
Referenced by checkedOrIn(), orIn(), orIn(), orIn(), TypeAnalyzer::visitAtomicRMWInst(), TypeAnalyzer::visitBinaryOperation(), 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 1243 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 556 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 513 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 1442 of file TypeTree.h.
References insertFromMD().
Referenced by TypeAnalyzer::considerTBAA().
|
inline |
Utility helper to lookup the mapping.
Definition at line 173 of file TypeTree.h.
|
inline |
Optimized version of Data0()[{}].
Definition at line 548 of file TypeTree.h.
References operator[]().
Referenced by analyzeIntelSubscriptIntrinsic(), TypeAnalyzer::visitCmpInst(), TypeAnalyzer::visitGEPOperator(), TypeAnalyzer::visitIPOCall(), TypeAnalyzer::visitPHINode(), TypeAnalyzer::visitSelectInst(), and TypeAnalyzer::visitZExtInst().
|
inline |
Return if changed.
Definition at line 234 of file TypeTree.h.
References Anything, CustomErrorHandler, EnzymeMaxTypeDepth, EnzymeTypeWarning, Integer, MaxTypeOffset, Pointer, ConcreteType::str(), str(), to_string(), and TypeDepthExceeded.
Referenced by CanonicalizeInPlace(), checkedOrIn(), Clear(), TypeAnalyzer::considerTBAA(), getConstantAnalysis(), JustAnything(), JustInt(), KeepMinusOne(), Lookup(), ReplaceMinus(), TypeAnalyzer::visitAtomicRMWInst(), TypeAnalyzer::visitCallBase(), TypeAnalyzer::visitGEPOperator(), TypeAnalyzer::visitIntrinsicInst(), TypeAnalyzer::visitMemTransferCommon(), and AdjointGenerator::visitOMPCall().
|
inline |
Definition at line 1425 of file TypeTree.h.
Referenced by EnzymeTypeTreeFromMD(), and fromMD().
|
inline |
Definition at line 814 of file TypeTree.h.
References operator[]().
Referenced by AdjointGenerator::createBinaryOperatorAdjoint(), AdjointGenerator::createBinaryOperatorDual(), and TypeAnalyzer::visitBinaryOperation().
|
inline |
Definition at line 221 of file TypeTree.h.
References Pointer.
|
inline |
Whether this TypeTree contains any information.
Definition at line 431 of file TypeTree.h.
Referenced by TypeAnalyzer::considerRustDebugInfo().
|
inline |
Whether this TypeTree knows any non-pointer information.
Definition at line 443 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 1083 of file TypeTree.h.
References Anything, and insert().
Referenced by TypeAnalyzer::visitSelectInst().
|
inline |
Select only the Integer ConcreteTypes.
Definition at line 459 of file TypeTree.h.
|
inline |
Keep only pointers (or anything's) to a repeated value (represented by -1)
Definition at line 785 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 593 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 471 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::considerRustDebugInfo(), TypeAnalyzer::considerTBAA(), defaultTypeTreeForLLVM(), AdjointGenerator::DifferentiableMemCopyFloats(), TypeAnalyzer::getAnalysis(), TypeAnalyzer::getCallInfo(), getConstantAnalysis(), parseDIType(), parseDIType(), 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 1315 of file TypeTree.h.
References andIn().
|
inline |
How this TypeTree compares with another.
Definition at line 428 of file TypeTree.h.
|
inline |
Set this to another TypeTree, returning if this was changed.
Definition at line 1097 of file TypeTree.h.
|
inline |
Chceck equality of two TypeTrees.
Definition at line 1094 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 checkedOrIn(), Inner0(), IsAllFloat(), 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 1287 of file TypeTree.h.
References orIn().
|
inline |
Definition at line 1232 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 1271 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 1256 of file TypeTree.h.
References checkedOrIn(), and str().
|
inlinestatic |
Definition at line 86 of file TypeTree.h.
References str().
Referenced by TypeAnalyzer::considerTBAA(), and AdjointGenerator::visitMemTransferCommon().
|
inline |
Keep only mappings where the type is not an Anything
Definition at line 1041 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 |
Replace all integer subtypes with anything.
Definition at line 1074 of file TypeTree.h.
|
inline |
Replace -1 with 0.
Definition at line 1059 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 840 of file TypeTree.h.
References Anything, MaxTypeOffset, operator[](), ConcreteType::orIn(), Pointer, str(), and TypeTree().
Referenced by analyzeIntelSubscriptIntrinsic(), TypeAnalyzer::considerTBAA(), defaultTypeTreeForLLVM(), AdjointGenerator::DifferentiableMemCopyFloats(), getConstantAnalysis(), parseDIType(), parseDIType(), 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 1383 of file TypeTree.h.
Referenced by TypeAnalysis::analyzeFunction(), CanonicalizeInPlace(), 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 1403 of file TypeTree.h.
References ConcreteType::str(), and Unknown.