forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 3
Classes and Methods of Interest
Jeff Cho edited this page Jan 21, 2018
·
1 revision
- swift/include/swift/WALASupport/WALAWalker.h
- declarations of utility methods for parsing and performing semantic analysis on modules
- swift/lib/WALASupport/WalaWalker.cpp
- WalaWalker implementation
WalaWalker::print_object(JNIEnv *java_env, jobject object)
-
WalaWalker::foo()
- instances JNIEnv
- calls print_object
-
WalaWalker::print(SILModule &SM)
- exploratory test function for working with SILModule
- swift/include/swift/FrontendTool/FrontendTool.h
- high-level API for interacting with basic frontend tool operation
- swift/lib/FrontendTool/FrontendTool.cpp
- entrypoint for swift -frontend functionality; core compiler functionality along with additional tools for demonstration and testing purposes
- WalaWalker integration lines 705-709
- Called from FrontendTool.cpp to create SIL
- Calls
SILModule::constructSIL
-> implementation in lib/SILGen/SILGen.cpp:1391
- FunctionListType =
llvm::ilist<SILFunction>
- method:
getTypeLowering(SILType t)
-> const Lowering::TypeLowering- look up the TypeLowering for a SILType
- method:
*getSwiftModule()
-> ModuleDecl - method:
&getASTContext()
-> ASTContext - method:
&getSourceManager()
-> SourceManager - method:
getAssociatedContext()
-> DeclContext- gets Swift DeclContext associated with the SIL module
- method:
getFunctions()
-> iterator_range<iterator>- returns
{functions.begin(), functions.end()}
- returns
- method:
getFunctionList()
-> FunctionListType-
begin()
getsfunctions.begin()
-
end()
getsfunctions.end()
-
- method:
dump()
- method:
dump(const char *fileName, bool Verbose = false, bool PrintASTDecls = false)
- method:
print(raw_ostream &OS, bool Verbose = false, ModuleDecl *M = nullptr, bool ShouldSort = false, bool PrintASTDecls = true)
- base class:
llvm::ilist_node<SILFunction>, SILAllocated<SILFunction>
- BlockListType =
llvm::iplist<SILBasicBlock>
- method:
&getModule()
-> SILModule - method:
getLoweredType()
-> SILType - method:
getLoweredFunctionType()
-> CanSILFunctionType - method:
getConventions()
-> SILFunctionConventions - method:
isNoReturnFunction()
-> bool - method:
canBeDeleted()
-> bool - method:
getRefCount()
-> unsigned- number of entities referring to this function other than the SILModule
- method:
isInlined()
-> bool - method:
isZombie()
-> bool - method:
getRepresentation()
-> SILFunctionTypeRepresentation- calling convention used by this entry point
- method:
hasSelfParam()
-> bool - method:
getName()
-> StringRef- gets mangled name
- method:
hasName(const char *Name)
-> bool-
getName()
== Name
-
- method:
isExternalDeclaration()
-> bool - method:
isDefinition()
-> bool - method:
getLinkage()
-> SILLinkage - method:
isAvailableExternally()
-> bool - method:
isPossiblyUsedExternally()
-> bool - method:
isExternallyUsedSymbol()
-> bool - method:
*getDeclContext()
-> DeclContext - method:
getSemanticAttrs()
-> ArrayRef<std::string> - method:
getLocation()
-> SILLocation - method:
isBare()
-> IsBare_t- enum: IsNotBare, IsBare
- method:
isTransparent()
-> IsTransparent_t- enum: IsNotTransparent, IsTransparent
- method:
isSerialized()
-> IsSerialized_t - method:
isThunk()
-> IsThunk_t- enum: IsNotThunk, IsThunk, IsReabstractedThunk
- method:
getSubclassScope()
-> SubclassScope - method:
getEffectsKind()
-> EffectsKind - Block List Access:
- method:
&getBlocks()
-> BlockListType - method:
empty()
-> bool - method:
begin()
-> iterator - method:
end()
-> iterator - method:
size()
-> unsigned - method:
findReturnBB()
-> iterator- find unique BB containing return if exists; else return end
- method:
findThrowBB()
-> iterator- find unique BB containing throw if exists; else return end
- method:
- Misc:
dump(), dump(bool Verbose)
print(raw_ostream &OS, bool Verbose = false)
-
printName(raw_ostream &OS)
- pretty-print SILFunction's name with SIL syntax, '@function_mangled_name'
- using InstListType =
llvm::iplist<SILInstruction>
- method:
*getParent()
-> SILFunction - method: `&getModule() -> SILModule
- using iterator =
InstListType::iterator (const, reverse, const_reverse)
-
begin()
-> iterator -
end()
-> iterator -
rbegin()
-> reverse_iterator -
rend()
-> reverse_iterator -
empty()
-> bool
-
- using arg_iterator =
std::vector<SILArgument *>::iterator
-
args_begin()
-> arg_iterator -
args_end()
-> arg_iterator -
getArguments()
-> ArrayRef<SILArgument *> -
getFunctionArguments()
-> TransformArrayRef<std::function<SILFunctionArgument *(SILArgument *)>> -
getNumArguments()
-> unsigned -
getArgument(unsigned i)
-> SILArgument
-
- method:
isEntry()
-> bool- if BB is entry BB of its parent
- method:
isNoReturn()
-> bool- if BB ends in an unreachable or an apply of a no-return apply or builtin
- method:
isTrampoline()
-> bool- if instruction only contains a branch
- method:
dump()
- pretty-print the SILBasicBlock
- method:
print(llvm::raw_ostream &OS)
- pretty-print to designated stream
- method:
printAsOperand(raw_ostream &OS, bool PrintType = true)
- method:
*getParent()
-> SILBasicBlock - method:
*getFunction()
-> SILFunction - method:
&getModule()
-> SILModule - method:
getLoc()
-> SILLocation- instruction's source location (ASTNode)
- method:
getAllOperands()
-> MutableArrayRef<Operand> - method:
getTypeDependentOperands()
-> MutableArrayRef<Operand> - method:
getNumOperands()
-> unsigned - method:
getNumTypeDependentOperands()
-> unsigned - method:
getOperand(unsigned Num)
-> SILValue - method:
getMemoryBehavior()
-> MemoryBehavior- enum: None, MayRead, MayWrite, MayReadWrite, MayHaveSideEffects
- method:
getReleasingBehavior()
-> ReleasingBehavior- enum: DoesNotRelease, MayRelease
- method:
mayRelease()
-> bool - method:
mayReleaseOrReadRefCount()
-> bool - method:
mayTrap()
-> bool- if instruction can abort program in some manner
- method:
isIdenticalTo(const SILInstruction *RHS)
-> bool - method:
isIdenticalTo(const SILInstruction *RHS, OpCmp opEqual)
-> bool - method:
mayHaveSideEffects()
-> bool - method:
mayWriteToMemory()
-> bool - method:
mayReadFromMemory()
-> bool - method:
mayReadOrWriteMemory()
-> bool - method:
*clone(SILInstruction *InsertPt = nullptr)
- create copy which retains all operands and other info. If insertion point specified, inserted before; otherwise returned with no parent
- method:
destroy(SILInstruction *I)
- calls destructor, does not deallocate
- method:
combineMemoryBehavior(SILInstruction::MemoryBehavior B1, SILInstruction::MemoryBehavior B2)
-> MemoryBehavior - swift/include/swift/SIL/SILInstruction.h defines many many more classes derived from SILInstruction
- struct DebugLoc: unsigned Line, unsigned Column, StringRef Filename
- method:
isNull()
-> bool - method:
isASTNode()
-> bool - method:
isSILFile()
-> bool - method:
isDebugInfoLoc()
-> bool - method:
isInTopLevel()
-> bool - method:
hasDebugLoc()
-> bool - method:
getKind()
-> LocationKind- enum: NoneKind, RegularKind, ReturnKind, ImplicitReturnKind, InlinedKind, MandatoryInlinedKind, CleanupKind, ArtificialUnreachableKind
- method:
getStorageKind()
-> StorageKind- enum: UnknownKind, ASTNodeKind, SILFileKind, DebugInfoKind
- method:
getDebugSourceLoc()
-> SourceLoc - method:
getSourceLoc()
-> SourceLoc - method:
getStartSourceLoc()
-> SourceLoc - method:
getEndSourceLoc()
-> SourceLoc - method:
getSourceRange()
-> SourceRange - method:
decode(SourceLoc loc, const SourceManager &SM)
-> DebugLoc- extract the line, col, and filename
- method:
decodeDebugLoc(const SourceManager &SM)
-> DebugLoc- return the decoded debug location
- method:
dump(const SourceManager &SM)
- method:
print(raw_ostream &OS, const SourceManager &SM)
- Also defines RegularLocation, ReturnLocation, ImplicitReturnLocation, InlinedLocation, MandatoryInlinedLocation, CleanupLocation, ArtificialUnreachableLocation, SILDebugScope
- Manages and owns source buffers
- method:
&getLLVMSourceMgr()
-> llvm::SourceMgr - method:
findBufferContaining(SourceLoc loc)
-> unsigned (buffer ID) - method:
getIdentifierForBuffer(unsigned BufferID)
-> StringRef - method:
getRangeForBuffer(unsigned BufferID)
-> CharSourceRange - method:
getLineAndColumn(SourceLoc loc, unsigned BufferID = 0)
-> std::pair<unsigned, unsigned> - method:
getLineNumber(SourceLoc loc, unsigned BufferID = 0)
-> unsigned - method:
getEntireTextForBuffer(unsigned BufferID)
-> StringRef
- semantic construct that a declaration belongs to, such as the enclosing AbstractClosureExpr or declaration
- method:
getParentModule()
-> ModuleDecl- returns the parent context that contains this context
- method:
getASTContext()
-> ASTContext- gets ASTContext by walking up to the enclosing module and returning its ASTContext
- method:
walkContext(ASTWalker &walker)
-> bool - method:
dumpContext()
- method:
getKind()
-> ASTNodeKind - method:
getChildren()
-> ArrayRef<MarkupASTNode *> - method:
classOf(const MarkupASTNode *N)
-> bool