CompilerPluginTools

CompilerPluginTools.JuliaLikeInterpreterType
JuliaLikeInterpreter <: 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.

source
Base.parentMethod
parent(interp::JuliaLikeInterpreter)

Return the native interpreter of Julia.

source
CompilerPluginTools.code_ircodeMethod
code_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.

source
CompilerPluginTools.code_ircode_by_miMethod
code_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 calling Core.Compiler.get_world_counter.
  • interp::AbstractInterpreter: the interpreter to use for inference.
source
CompilerPluginTools.code_ircode_by_signatureMethod
code_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.

source
CompilerPluginTools.const_invoke!Method
const_invoke!(f, ir::IRCode, ref::GlobalRef)

Replace the function invoke Expr(:invoke, _, ref, args...) with f(args...) if its arguments args are all constant.

source
CompilerPluginTools.inline_const!Method
inline_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.

source
CompilerPluginTools.optimizeFunction
optimize(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).

source
CompilerPluginTools.typeinf_lockMethod
typeinf_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
source