FuncTransforms

Documentation for FuncTransforms.

FuncTransforms.FAType
FA(name::Symbol, slotnumber::Int; gen = true)

A "Function Argument" from the transformed function with old slotnumber renamed to name.

source
FuncTransforms.FuncArgsType
abstract type FuncArgs

An 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.
source
FuncTransforms.FuncInfoType
FuncInfo(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.

source
FuncTransforms.FuncTransformType
FuncTransform(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.

source
FuncTransforms.NAType
NA(name::Symbol; gen = true)

A "New Argument" with name. Used to introduce new position argument.

source
FuncTransforms.VAType
VA(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).

source
FuncTransforms.FuncInfoIterFunction
FuncInfoIter(fi::FuncInfo, start = firstssavalue(fi))

Creates an iterator over the code statements of a function's code block starting from a given SSA value.

source
FuncTransforms.addarg!Function
addarg!(fi::FuncInfo, name::Symbol)

Adds a new argument to FuncInfo with the specified name. Returns the new SlotNumber.

source
FuncTransforms.addparg!Function
addparg!(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!.

source
FuncTransforms.addstmt!Function
addstmt!(fi::FuncInfo, stmt)

Adds a new statement to FuncInfo but not insert into the code block. Returns the new SSAValue.

source
FuncTransforms.addstmtafter!Function
addstmtafter!(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!.

source
FuncTransforms.addstmtbefore!Function
addstmtbefore!(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!.

source
FuncTransforms.addva!Function
addva!(fi::FuncInfo, name::Symbol)

Adds a new argument to FuncInfo and sets it as the vararg. Returns the SlotNumber of the new argument.

source
FuncTransforms.addvar!Function
addvar!(fi::FuncInfo, name::Symbol)

Adds a new variable to FuncInfo with the specified name. Returns the new SlotNumber.

source
FuncTransforms.arg2var!Function
arg2var!(fi::FuncInfo, id::Union{SlotNumber, Int})

Moves an argument identified by id from the argument slots to variable slots in FuncInfo.

source
FuncTransforms.assignva!Function
assignva!(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`.

source
FuncTransforms.deleteparg!Function
deleteparg!(fi::FuncInfo, id::Union{SlotNumber, Int})

Removes the positional argument from FuncInfo identified by id.

source
FuncTransforms.getpargFunction
getparg(fi::FuncInfo, index::Integer)

Retrieves the SlotNumber of the positional argument at the given index in FuncInfo.

source
FuncTransforms.insertafter!Function
insertafter!(fi::FuncInfo, id::Union{SSAValue, Int}, stmtid::Union{SSAValue, Int})

Inserts the statement identified by stmtid after the statement identified by id in FuncInfo.

source
FuncTransforms.insertbefore!Function
insertbefore!(fi::FuncInfo, id::Union{SSAValue, Int}, stmtid::Union{SSAValue, Int})

Inserts the statement identified by stmtid before the statement identified by id in FuncInfo.

source
FuncTransforms.insertparg!Function
insertparg!(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.

source
FuncTransforms.nextssavalueFunction
nextssavalue(fi::FuncInfo, i::Union{SSAValue, Int})

Returns the next SSA value of the given SSA value i in the code block of FuncInfo.

source
FuncTransforms.prevssavalueFunction
prevssavalue(fi::FuncInfo, i::Union{SSAValue, Int})

Returns the previous SSA value of the given SSA Value i in the code block of FuncInfo.

source
FuncTransforms.renamearg!Function
renamearg!(fi::FuncInfo, slot, name::Symbol)

Renames an argument identified by slot in FuncInfo to the new name provided.

source
FuncTransforms.renamevar!Function
renamevar!(fi::FuncInfo, slot, name::Symbol)

Renames a variable identified by slot in FuncInfo to the new name provided.

source
FuncTransforms.repackva!Function
repackva!(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).

source
FuncTransforms.replacestmt!Function
replacestmt!(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.

source
FuncTransforms.setva!Function
setva!(fi::FuncInfo, id::Union{SlotNumber, Int})

Sets the vararg of FuncInfo to the specified id.

source