FuncTransforms
Documentation for FuncTransforms.
FuncTransforms.FAFuncTransforms.FuncArgsFuncTransforms.FuncInfoFuncTransforms.FuncTransformFuncTransforms.NAFuncTransforms.VAFuncTransforms.FuncInfoIterFuncTransforms.addarg!FuncTransforms.addparg!FuncTransforms.addstmt!FuncTransforms.addstmtafter!FuncTransforms.addstmtbefore!FuncTransforms.addva!FuncTransforms.addvar!FuncTransforms.arg2var!FuncTransforms.assignva!FuncTransforms.deletearg!FuncTransforms.deleteparg!FuncTransforms.deletevar!FuncTransforms.firstssavalueFuncTransforms.getpargFuncTransforms.getvaFuncTransforms.insertafter!FuncTransforms.insertbefore!FuncTransforms.insertparg!FuncTransforms.lastssavalueFuncTransforms.nextssavalueFuncTransforms.prevssavalueFuncTransforms.renamearg!FuncTransforms.renamevar!FuncTransforms.repackva!FuncTransforms.replacestmt!FuncTransforms.setva!FuncTransforms.toCodeInfo
FuncTransforms.FA — TypeFA(name::Symbol, slotnumber::Int; gen = true)A "Function Argument" from the transformed function with old slotnumber renamed to name.
FuncTransforms.FuncArgs — Typeabstract type FuncArgsAn abstract type for representing function arguments in a function transformation context for constructing FuncTransform.
Subtypes of FuncArgs include:
NA: Represents a new argument to be added to the function.FA: Represents an existing function argument, possibly with modifications.VA: Specifically denotes a Vararg.
FuncTransforms.FuncInfo — TypeFuncInfo(sig, world; method_tables::Union{Nothing, MethodTable} = nothing)Lookup to Core.CodeInfo of a function signature sig with specific world age and convert the Core.CodeInfo into FuncInfo.
FuncTransforms.FuncTransform — TypeFuncTransform(sig, world, fargs::Union{Vector{FuncArgs}, Nothing} = nothing;
caller::Union{MethodInstance, Nothing} = nothing,
method_tables::Union{Nothing, MethodTable} = nothing)Constructs a FuncTransform object used to perform transformations on function sig of world age world. fargs is used to specific the new function arguments of the new function. If fargs is nothing, the origin arguments would be used. If caller is provided, it also set the backedge accordingly. The transformations should be applied to FuncTransform(...).fi::FuncInfo and use toCodeInfo to get the result.
FuncTransforms.NA — TypeNA(name::Symbol; gen = true)A "New Argument" with name. Used to introduce new position argument.
FuncTransforms.VA — TypeVA(name::Symbol, drop::Int; gen = true)A "VarArg". With VA, we can assign the values in this argument to the arguments of the transformed function. drop would drop the given number of arguments of the transformed function (var"#self#" also counts).
FuncTransforms.FuncInfoIter — FunctionFuncInfoIter(fi::FuncInfo, start = firstssavalue(fi))Creates an iterator over the code statements of a function's code block starting from a given SSA value.
FuncTransforms.addarg! — Functionaddarg!(fi::FuncInfo, name::Symbol)Adds a new argument to FuncInfo with the specified name. Returns the new SlotNumber.
FuncTransforms.addparg! — Functionaddparg!(fi::FuncInfo, name::Symbol [, index::Integer])Adds a new argument to FuncInfo with the specified name, and insert it to the position arguments. If index is not provided, insert it to the last non-vararg position. Returns the new SlotNumber. Equivalent to addarg! + insertparg!.
FuncTransforms.addstmt! — Functionaddstmt!(fi::FuncInfo, stmt)Adds a new statement to FuncInfo but not insert into the code block. Returns the new SSAValue.
FuncTransforms.addstmtafter! — Functionaddstmtafter!(fi::FuncInfo, id::Union{SSAValue, Int}, stmt)Inserts a new statement after the statement identified by id in FuncInfo. Returns the new SSAValue for the inserted statement. Equivalent to addstmt! + insertafter!.
FuncTransforms.addstmtbefore! — Functionaddstmtbefore!(fi::FuncInfo, id::Union{SSAValue, Int}, stmt)Inserts a new statement before the statement identified by id in FuncInfo. Returns the new SSAValue for the inserted statement. Equivalent to addstmt! + insertbefore!.
FuncTransforms.addva! — Functionaddva!(fi::FuncInfo, name::Symbol)Adds a new argument to FuncInfo and sets it as the vararg. Returns the SlotNumber of the new argument.
FuncTransforms.addvar! — Functionaddvar!(fi::FuncInfo, name::Symbol)Adds a new variable to FuncInfo with the specified name. Returns the new SlotNumber.
FuncTransforms.arg2var! — Functionarg2var!(fi::FuncInfo, id::Union{SlotNumber, Int})Moves an argument identified by id from the argument slots to variable slots in FuncInfo.
FuncTransforms.assignva! — Functionassignva!(fi::FuncInfo, varid::Union{SlotNumber, Int}, vaid::Union{SlotNumber, Int}, index::Integer)Add the code at the beginning of code block that: given the new vararg (vaid), extract the element at index and assign to the old argumentvarid`.
FuncTransforms.deletearg! — Functiondeletearg!(fi::FuncInfo, id::Union{SlotNumber, Int})Deletes an argument from FuncInfo identified by id.
FuncTransforms.deleteparg! — Functiondeleteparg!(fi::FuncInfo, id::Union{SlotNumber, Int})Removes the positional argument from FuncInfo identified by id.
FuncTransforms.deletevar! — Functiondeletevar!(fi::FuncInfo, id::Union{SlotNumber, Int})Deletes a variable from FuncInfo identified by id.
FuncTransforms.firstssavalue — Functionfirstssavalue(fi::FuncInfo)Returns the first SSA value in the code block of FuncInfo.
FuncTransforms.getparg — Functiongetparg(fi::FuncInfo, index::Integer)Retrieves the SlotNumber of the positional argument at the given index in FuncInfo.
FuncTransforms.getva — Functiongetva(fi::FuncInfo)Returns the SlotNumber of the vararg in FuncInfo.
FuncTransforms.insertafter! — Functioninsertafter!(fi::FuncInfo, id::Union{SSAValue, Int}, stmtid::Union{SSAValue, Int})Inserts the statement identified by stmtid after the statement identified by id in FuncInfo.
FuncTransforms.insertbefore! — Functioninsertbefore!(fi::FuncInfo, id::Union{SSAValue, Int}, stmtid::Union{SSAValue, Int})Inserts the statement identified by stmtid before the statement identified by id in FuncInfo.
FuncTransforms.insertparg! — Functioninsertparg!(fi::FuncInfo, id::Union{SlotNumber, Int}, index::Integer)Inserts an existing argument identified by id into the positional arguments of FuncInfo at the specified index.
FuncTransforms.lastssavalue — Functionlastssavalue(fi::FuncInfo)Returns the last SSA value in the code block of FuncInfo.
FuncTransforms.nextssavalue — Functionnextssavalue(fi::FuncInfo, i::Union{SSAValue, Int})Returns the next SSA value of the given SSA value i in the code block of FuncInfo.
FuncTransforms.prevssavalue — Functionprevssavalue(fi::FuncInfo, i::Union{SSAValue, Int})Returns the previous SSA value of the given SSA Value i in the code block of FuncInfo.
FuncTransforms.renamearg! — Functionrenamearg!(fi::FuncInfo, slot, name::Symbol)Renames an argument identified by slot in FuncInfo to the new name provided.
FuncTransforms.renamevar! — Functionrenamevar!(fi::FuncInfo, slot, name::Symbol)Renames a variable identified by slot in FuncInfo to the new name provided.
FuncTransforms.repackva! — Functionrepackva!(fi::FuncInfo, varid::Union{SlotNumber, Int}, vaid::Union{SlotNumber, Int}, indices::Vector{Integer})Add the code at the beginning of code block that: given the new vararg (vaid), extract the element at indices, pack them as a tuple and assign to the old vararg (varid).
FuncTransforms.replacestmt! — Functionreplacestmt!(fi::FuncInfo, id::Union{SSAValue, Int}, stmt)Replaces the statement at the given SSA Value id in FuncInfo's code block with a new statement.
FuncTransforms.setva! — Functionsetva!(fi::FuncInfo, id::Union{SlotNumber, Int})Sets the vararg of FuncInfo to the specified id.
FuncTransforms.toCodeInfo — FunctiontoCodeInfo(fi::Union{FuncInfo, FuncTransform})Converts a FuncInfo or FuncTransform into a Core.CodeInfo.