Skip to content

Commit 580f51d

Browse files
authored
add docstring for new kwargs in code_typed (#40719)
1 parent 2865d97 commit 580f51d

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

base/reflection.jl

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,13 +1174,39 @@ function func_for_method_checked(m::Method, @nospecialize(types), sparams::Simpl
11741174
end
11751175

11761176
"""
1177-
code_typed(f, types; optimize=true, debuginfo=:default)
1177+
code_typed(f, types; kw...)
11781178
11791179
Returns an array of type-inferred lowered form (IR) for the methods matching the given
1180-
generic function and type signature. The keyword argument `optimize` controls whether
1181-
additional optimizations, such as inlining, are also applied.
1182-
The keyword `debuginfo` controls the amount of code metadata present in the output,
1180+
generic function and type signature.
1181+
1182+
# Keyword Arguments
1183+
1184+
- `optimize=true`: controls whether additional optimizations, such as inlining, are also applied.
1185+
- `debuginfo=:default`: controls the amount of code metadata present in the output,
11831186
possible options are `:source` or `:none`.
1187+
1188+
# Internal Keyword Arguments
1189+
1190+
This section should be considered internal, and is only for who understands Julia compiler
1191+
internals.
1192+
1193+
- `world=Base.get_world_counter()`: optional, controls the world age to use when looking up methods,
1194+
use current world age if not specified.
1195+
- `interp=Core.Compiler.NativeInterpreter(world)`: optional, controls the interpreter to use,
1196+
use the native interpreter Julia uses if not specified.
1197+
1198+
# Example
1199+
1200+
One can put the argument types in a tuple to get the corresponding `code_typed`.
1201+
1202+
```julia
1203+
julia> code_typed(+, (Float64, Float64))
1204+
1-element Vector{Any}:
1205+
CodeInfo(
1206+
1 ─ %1 = Base.add_float(x, y)::Float64
1207+
└── return %1
1208+
) => Float64
1209+
```
11841210
"""
11851211
function code_typed(@nospecialize(f), @nospecialize(types=default_tt(f));
11861212
optimize=true,

0 commit comments

Comments
 (0)