|
Enzyme main
|
#include "TraceUtils.h"

Public Member Functions | |
| TraceUtils (ProbProgMode mode, const llvm::SmallPtrSetImpl< llvm::Function * > &sampleFunctions, const llvm::SmallPtrSetImpl< llvm::Function * > &observeFunctions, llvm::Function *newFunc, llvm::Argument *trace, llvm::Argument *observations, llvm::Argument *likelihood, TraceInterface *interface) | |
| ~TraceUtils () | |
| TraceInterface * | getTraceInterface () |
| llvm::Value * | getTrace () |
| llvm::Value * | getObservations () |
| llvm::Value * | getLikelihood () |
| llvm::CallInst * | CreateTrace (llvm::IRBuilder<> &Builder, const llvm::Twine &Name="trace") |
| llvm::CallInst * | FreeTrace (llvm::IRBuilder<> &Builder) |
| llvm::CallInst * | InsertChoice (llvm::IRBuilder<> &Builder, llvm::Value *address, llvm::Value *score, llvm::Value *choice) |
| llvm::CallInst * | InsertCall (llvm::IRBuilder<> &Builder, llvm::Value *address, llvm::Value *subtrace) |
| llvm::CallInst * | InsertArgument (llvm::IRBuilder<> &Builder, llvm::Value *name, llvm::Value *argument) |
| llvm::CallInst * | InsertReturn (llvm::IRBuilder<> &Builder, llvm::Value *ret) |
| llvm::CallInst * | InsertFunction (llvm::IRBuilder<> &Builder, llvm::Function *function) |
| llvm::CallInst * | GetTrace (llvm::IRBuilder<> &Builder, llvm::Value *address, const llvm::Twine &Name="") |
| llvm::Instruction * | GetChoice (llvm::IRBuilder<> &Builder, llvm::Value *address, llvm::Type *choiceType, const llvm::Twine &Name="") |
| llvm::Instruction * | HasChoice (llvm::IRBuilder<> &Builder, llvm::Value *address, const llvm::Twine &Name="") |
| llvm::Instruction * | HasCall (llvm::IRBuilder<> &Builder, llvm::Value *address, const llvm::Twine &Name="") |
| llvm::Instruction * | SampleOrCondition (llvm::IRBuilder<> &Builder, llvm::Function *sample_fn, llvm::ArrayRef< llvm::Value * > sample_args, llvm::Value *address, const llvm::Twine &Name="") |
| llvm::CallInst * | CreateOutlinedFunction (llvm::IRBuilder<> &Builder, llvm::function_ref< void(llvm::IRBuilder<> &, TraceUtils *, llvm::ArrayRef< llvm::Value * >)> Outlined, llvm::Type *RetTy, llvm::ArrayRef< llvm::Value * > Arguments, bool needsLikelihood=true, const llvm::Twine &Name="") |
| bool | isSampleCall (llvm::CallInst *call) |
| bool | isObserveCall (llvm::CallInst *call) |
Static Public Member Functions | |
| static TraceUtils * | FromClone (ProbProgMode mode, const llvm::SmallPtrSetImpl< llvm::Function * > &sampleFunctions, const llvm::SmallPtrSetImpl< llvm::Function * > &observeFunctions, TraceInterface *interface, llvm::Function *oldFunc, llvm::ValueMap< const llvm::Value *, llvm::WeakTrackingVH > &originalToNewFn) |
| static llvm::CallInst * | InsertChoiceGradient (llvm::IRBuilder<> &Builder, llvm::FunctionType *interface_type, llvm::Value *interface_function, llvm::Value *address, llvm::Value *choice, llvm::Value *trace) |
| static llvm::CallInst * | InsertArgumentGradient (llvm::IRBuilder<> &Builder, llvm::FunctionType *interface_type, llvm::Value *interface_function, llvm::Value *name, llvm::Value *argument, llvm::Value *trace) |
Public Attributes | |
| TraceInterface * | interface |
| ProbProgMode | mode |
| llvm::Function * | newFunc |
| llvm::SmallPtrSet< llvm::Function *, 4 > | sampleFunctions |
| llvm::SmallPtrSet< llvm::Function *, 4 > | observeFunctions |
Static Public Attributes | |
| static constexpr const char | TraceParameterAttribute [] = "enzyme_trace" |
| static constexpr const char | ObservationsParameterAttribute [] |
| static constexpr const char | LikelihoodParameterAttribute [] |
Definition at line 43 of file TraceUtils.h.
| TraceUtils::TraceUtils | ( | ProbProgMode | mode, |
| const llvm::SmallPtrSetImpl< llvm::Function * > & | sampleFunctions, | ||
| const llvm::SmallPtrSetImpl< llvm::Function * > & | observeFunctions, | ||
| llvm::Function * | newFunc, | ||
| llvm::Argument * | trace, | ||
| llvm::Argument * | observations, | ||
| llvm::Argument * | likelihood, | ||
| TraceInterface * | interface ) |
Definition at line 47 of file TraceUtils.cpp.
Referenced by CreateOutlinedFunction(), and FromClone().
|
default |
| CallInst * TraceUtils::CreateOutlinedFunction | ( | llvm::IRBuilder<> & | Builder, |
| llvm::function_ref< void(llvm::IRBuilder<> &, TraceUtils *, llvm::ArrayRef< llvm::Value * >)> | Outlined, | ||
| llvm::Type * | RetTy, | ||
| llvm::ArrayRef< llvm::Value * > | Arguments, | ||
| bool | needsLikelihood = true, | ||
| const llvm::Twine & | Name = "" ) |
Definition at line 454 of file TraceUtils.cpp.
References Condition, interface, mode, observeFunctions, sampleFunctions, Trace, and TraceUtils().
Referenced by TraceGenerator::handleObserveCall(), TraceGenerator::handleSampleCall(), and TraceGenerator::visitFunction().
| CallInst * TraceUtils::CreateTrace | ( | llvm::IRBuilder<> & | Builder, |
| const llvm::Twine & | Name = "trace" ) |
Definition at line 207 of file TraceUtils.cpp.
References interface, TraceInterface::newTrace(), and TraceInterface::newTraceTy().
Referenced by TraceGenerator::handleArbitraryCall().
| CallInst * TraceUtils::FreeTrace | ( | llvm::IRBuilder<> & | Builder | ) |
Definition at line 222 of file TraceUtils.cpp.
References TraceInterface::freeTrace(), TraceInterface::freeTraceTy(), and interface.
|
static |
Definition at line 59 of file TraceUtils.cpp.
References Condition, TraceInterface::getTraceTy(), getUnqual(), interface, Likelihood, LikelihoodParameterAttribute, mode, newFunc, ObservationsParameterAttribute, observeFunctions, sampleFunctions, Trace, TraceParameterAttribute, traceType(), and TraceUtils().
| Instruction * TraceUtils::GetChoice | ( | llvm::IRBuilder<> & | Builder, |
| llvm::Value * | address, | ||
| llvm::Type * | choiceType, | ||
| const llvm::Twine & | Name = "" ) |
Definition at line 356 of file TraceUtils.cpp.
References addCallSiteNoCapture(), TraceInterface::getChoice(), TraceInterface::getChoiceTy(), getFirstNonPHIOrDbgOrLifetime(), getInt8PtrTy(), and interface.
Referenced by SampleOrCondition().
| Value * TraceUtils::getLikelihood | ( | ) |
Definition at line 171 of file TraceUtils.cpp.
Referenced by TraceGenerator::handleArbitraryCall(), TraceGenerator::handleObserveCall(), and TraceGenerator::handleSampleCall().
| Value * TraceUtils::getObservations | ( | ) |
Definition at line 169 of file TraceUtils.cpp.
| CallInst * TraceUtils::GetTrace | ( | llvm::IRBuilder<> & | Builder, |
| llvm::Value * | address, | ||
| const llvm::Twine & | Name = "" ) |
Definition at line 343 of file TraceUtils.cpp.
References addCallSiteNoCapture(), TraceInterface::getTrace(), TraceInterface::getTraceTy(), and interface.
Referenced by TraceGenerator::handleArbitraryCall().
| Value * TraceUtils::getTrace | ( | ) |
Definition at line 167 of file TraceUtils.cpp.
| TraceInterface * TraceUtils::getTraceInterface | ( | ) |
Definition at line 165 of file TraceUtils.cpp.
References interface.
Referenced by TraceGenerator::handleArbitraryCall().
| Instruction * TraceUtils::HasCall | ( | llvm::IRBuilder<> & | Builder, |
| llvm::Value * | address, | ||
| const llvm::Twine & | Name = "" ) |
Definition at line 398 of file TraceUtils.cpp.
References addCallSiteNoCapture(), TraceInterface::hasCall(), TraceInterface::hasCallTy(), and interface.
Referenced by TraceGenerator::handleArbitraryCall().
| Instruction * TraceUtils::HasChoice | ( | llvm::IRBuilder<> & | Builder, |
| llvm::Value * | address, | ||
| const llvm::Twine & | Name = "" ) |
Definition at line 387 of file TraceUtils.cpp.
References addCallSiteNoCapture(), TraceInterface::hasChoice(), TraceInterface::hasChoiceTy(), and interface.
Referenced by SampleOrCondition().
| CallInst * TraceUtils::InsertArgument | ( | llvm::IRBuilder<> & | Builder, |
| llvm::Value * | name, | ||
| llvm::Value * | argument ) |
Definition at line 272 of file TraceUtils.cpp.
References addCallSiteNoCapture(), TraceInterface::insertArgument(), TraceInterface::insertArgumentTy(), and interface.
|
static |
Definition at line 326 of file TraceUtils.cpp.
References addCallSiteNoCapture().
| CallInst * TraceUtils::InsertCall | ( | llvm::IRBuilder<> & | Builder, |
| llvm::Value * | address, | ||
| llvm::Value * | subtrace ) |
Definition at line 252 of file TraceUtils.cpp.
References addCallSiteNoCapture(), TraceInterface::insertCall(), TraceInterface::insertCallTy(), and interface.
Referenced by TraceGenerator::handleArbitraryCall().
| CallInst * TraceUtils::InsertChoice | ( | llvm::IRBuilder<> & | Builder, |
| llvm::Value * | address, | ||
| llvm::Value * | score, | ||
| llvm::Value * | choice ) |
Definition at line 237 of file TraceUtils.cpp.
References addCallSiteNoCapture(), TraceInterface::insertChoice(), TraceInterface::insertChoiceTy(), and interface.
|
static |
Definition at line 310 of file TraceUtils.cpp.
References addCallSiteNoCapture().
| CallInst * TraceUtils::InsertFunction | ( | llvm::IRBuilder<> & | Builder, |
| llvm::Function * | function ) |
Definition at line 298 of file TraceUtils.cpp.
References getInt8PtrTy(), TraceInterface::insertFunction(), TraceInterface::insertFunctionTy(), and interface.
Referenced by TraceGenerator::visitFunction().
| CallInst * TraceUtils::InsertReturn | ( | llvm::IRBuilder<> & | Builder, |
| llvm::Value * | ret ) |
Definition at line 287 of file TraceUtils.cpp.
References TraceInterface::insertReturn(), TraceInterface::insertReturnTy(), and interface.
Referenced by TraceGenerator::visitReturnInst().
| bool TraceUtils::isObserveCall | ( | llvm::CallInst * | call | ) |
Definition at line 522 of file TraceUtils.cpp.
References getFunctionFromCall(), and observeFunctions.
Referenced by TraceGenerator::visitCallInst().
| bool TraceUtils::isSampleCall | ( | llvm::CallInst * | call | ) |
Definition at line 517 of file TraceUtils.cpp.
References getFunctionFromCall(), and sampleFunctions.
Referenced by TraceGenerator::visitCallInst().
| Instruction * TraceUtils::SampleOrCondition | ( | llvm::IRBuilder<> & | Builder, |
| llvm::Function * | sample_fn, | ||
| llvm::ArrayRef< llvm::Value * > | sample_args, | ||
| llvm::Value * | address, | ||
| const llvm::Twine & | Name = "" ) |
Definition at line 409 of file TraceUtils.cpp.
References Condition, GetChoice(), HasChoice(), Likelihood, mode, and Trace.
| TraceInterface* TraceUtils::interface |
Definition at line 51 of file TraceUtils.h.
Referenced by CreateOutlinedFunction(), CreateTrace(), FreeTrace(), FromClone(), GetChoice(), GetTrace(), getTraceInterface(), TraceGenerator::handleArbitraryCall(), TraceGenerator::handleSampleCall(), HasCall(), HasChoice(), InsertArgument(), InsertCall(), InsertChoice(), InsertFunction(), InsertReturn(), and TraceGenerator::visitFunction().
|
staticconstexpr |
Definition at line 60 of file TraceUtils.h.
Referenced by FromClone(), and TraceGenerator::visitFunction().
| ProbProgMode TraceUtils::mode |
Definition at line 52 of file TraceUtils.h.
Referenced by CreateOutlinedFunction(), FromClone(), and SampleOrCondition().
| llvm::Function* TraceUtils::newFunc |
Definition at line 53 of file TraceUtils.h.
Referenced by FromClone(), and TraceGenerator::visitFunction().
|
staticconstexpr |
Definition at line 58 of file TraceUtils.h.
Referenced by FromClone(), and TraceGenerator::visitFunction().
| llvm::SmallPtrSet<llvm::Function *, 4> TraceUtils::observeFunctions |
Definition at line 55 of file TraceUtils.h.
Referenced by CreateOutlinedFunction(), FromClone(), TraceGenerator::handleArbitraryCall(), and isObserveCall().
| llvm::SmallPtrSet<llvm::Function *, 4> TraceUtils::sampleFunctions |
Definition at line 54 of file TraceUtils.h.
Referenced by CreateOutlinedFunction(), FromClone(), TraceGenerator::handleArbitraryCall(), and isSampleCall().
|
staticconstexpr |
Definition at line 57 of file TraceUtils.h.
Referenced by FromClone(), and TraceGenerator::visitFunction().