CompilerPluginTools
CompilerPluginTools.JuliaLikeInterpreter
Base.parent
CompilerPluginTools.anymap
CompilerPluginTools.code_ircode
CompilerPluginTools.code_ircode_by_mi
CompilerPluginTools.code_ircode_by_mi
CompilerPluginTools.code_ircode_by_signature
CompilerPluginTools.const_invoke!
CompilerPluginTools.default_julia_pass
CompilerPluginTools.inline_const!
CompilerPluginTools.method_instance
CompilerPluginTools.no_pass
CompilerPluginTools.optimize
CompilerPluginTools.permute_stmts!
CompilerPluginTools.typeinf_lock
CompilerPluginTools.@make_codeinfo
CompilerPluginTools.@make_ircode
CompilerPluginTools.JuliaLikeInterpreter
— TypeJuliaLikeInterpreter <: AbstractInterpreter
Abstract type for julia-like interpreter. The subtype of it usually modifies the native julia interpreter a little bit by overloading certain abstract interpretation interface, but forward most of the interfaces to the native interpreter.
Base.parent
— Methodparent(interp::JuliaLikeInterpreter)
Return the native interpreter of Julia.
CompilerPluginTools.anymap
— Methodanymap(f, xs)
Like map
, but force to create Vector{Any}
.
CompilerPluginTools.code_ircode
— Methodcode_ircode([pass, ]f, types; world=get_world_counter(), interp=NativeInterpreter(world))
Get IRCode
by given function f
and its argument types types
. An option argument pass
can be specified as a transform function on IRCode during type inference.
CompilerPluginTools.code_ircode_by_mi
— Methodcode_ircode_by_mi(f, mi::MethodInstance; world=get_world_counter(), interp=NativeInterpreter(world))
Return the IRCode
object along with inferred return type.
Arguments
f(ir::IRCode, sv::OptimizationState) -> IRCode
: optimization passes to run.mi::MethodInstance
: method instance.
Kwargs
world::Int
: world number, default is callingCore.Compiler.get_world_counter
.interp::AbstractInterpreter
: the interpreter to use for inference.
CompilerPluginTools.code_ircode_by_mi
— Methodcode_ircode_by_mi(mi::MethodInstance; world=get_world_counter(), interp=NativeInterpreter(world))
The default code_ircode_by_mi
that uses the default Julia compiler optimization passes. See also code_ircode_by_mi
.
CompilerPluginTools.code_ircode_by_signature
— Methodcode_ircode_by_signature([pass, ]sig; world=get_world_counter(), interp=NativeInterpreter(world))
Get IRCode
by given signature, one can use the first argument to transform the IRCode
during interpretation.
CompilerPluginTools.const_invoke!
— Methodconst_invoke!(f, ir::IRCode, ref::GlobalRef)
Replace the function invoke Expr(:invoke, _, ref, args...)
with f(args...)
if its arguments args
are all constant.
CompilerPluginTools.default_julia_pass
— Methoddefault_julia_pass(ir::IRCode, sv::OptimizationState)
The default julia optimization pass.
CompilerPluginTools.inline_const!
— Methodinline_const!(ir::IRCode)
This performs constant propagation on IRCode
so after the constant propagation during abstract interpretation, we can force inline constant values in IRCode
.
CompilerPluginTools.method_instance
— Functionmethod_instance(f, tt, world=Base.get_world_counter())
Return the MethodInstance
, unlike Base.method_instances
, tt
must be specified type.
CompilerPluginTools.no_pass
— Methodno_pass(ir::IRCode, ::OptimizationState)
No pass.
CompilerPluginTools.optimize
— Functionoptimize(interp::JuliaLikeInterpreter[, state::OptimizationState], ir::IRCode)
This method is for overloading, it will be executed after running Julia optimizers. If you wish to customize the default Julia optimization passes, consider overloading Core.Compiler.optimize(interp, opt, params, result)
.
CompilerPluginTools.permute_stmts!
— Methodpermute_stmts!(ir::IRCode, perm::Vector{Int})
Permute statements according to perm
.
CompilerPluginTools.typeinf_lock
— Methodtypeinf_lock(f)
Type inference lock. This prevents you from recursing into type inference when you don't want. equivalent to the following code, which you may see in Julia compiler implementation.
ccall(:jl_typeinf_begin, Cvoid, ())
ret = f()
ccall(:jl_typeinf_end, Cvoid, ())
return ret
CompilerPluginTools.@make_codeinfo
— Macro@make_codeinfo begin
<stmt>::<type>
end
Create a typed CodeInfo
object, if field <type>
is not specified, it will use Any
.
CompilerPluginTools.@make_ircode
— Macro@make_ircode begin
<stmt>::<type>
end
Create a typed IRCode
object, if field <type>
is not specified, it will use Any
. See also make_codeinfo
.