Skip to content

Commit 60323b6

Browse files
authored
rename some uses of ast to ir where applicable (#35156)
1 parent 1077bc4 commit 60323b6

21 files changed

+87
-83
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,13 @@ function abstract_call_method_with_const_args(@nospecialize(rettype), @nospecial
241241
# decide if it's likely to be worthwhile
242242
if !force_inference
243243
code = inf_for_methodinstance(mi, sv.params.world)
244-
declared_inline = isdefined(method, :source) && ccall(:jl_ast_flag_inlineable, Bool, (Any,), method.source)
244+
declared_inline = isdefined(method, :source) && ccall(:jl_ir_flag_inlineable, Bool, (Any,), method.source)
245245
cache_inlineable = declared_inline
246246
if isdefined(code, :inferred) && !cache_inlineable
247247
cache_inf = code.inferred
248248
if !(cache_inf === nothing)
249-
cache_src_inferred = ccall(:jl_ast_flag_inferred, Bool, (Any,), cache_inf)
250-
cache_src_inlineable = ccall(:jl_ast_flag_inlineable, Bool, (Any,), cache_inf)
249+
cache_src_inferred = ccall(:jl_ir_flag_inferred, Bool, (Any,), cache_inf)
250+
cache_src_inlineable = ccall(:jl_ir_flag_inlineable, Bool, (Any,), cache_inf)
251251
cache_inlineable = cache_src_inferred && cache_src_inlineable
252252
end
253253
end

base/compiler/ssair/inlining.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,8 @@ function analyze_method!(idx::Int, sig::Signature, @nospecialize(metharg), meths
711711
return spec_lambda(atype_unlimited, sv, invoke_data)
712712
end
713713

714-
src_inferred = ccall(:jl_ast_flag_inferred, Bool, (Any,), src)
715-
src_inlineable = ccall(:jl_ast_flag_inlineable, Bool, (Any,), src)
714+
src_inferred = ccall(:jl_ir_flag_inferred, Bool, (Any,), src)
715+
src_inlineable = ccall(:jl_ir_flag_inlineable, Bool, (Any,), src)
716716

717717
if !(src_inferred && src_inlineable)
718718
return spec_lambda(atype_unlimited, sv, invoke_data)
@@ -722,7 +722,7 @@ function analyze_method!(idx::Int, sig::Signature, @nospecialize(metharg), meths
722722
add_backedge!(mi, sv)
723723

724724
if !isa(src, CodeInfo)
725-
src = ccall(:jl_uncompress_ast, Any, (Any, Ptr{Cvoid}, Any), method, C_NULL, src::Vector{UInt8})::CodeInfo
725+
src = ccall(:jl_uncompress_ir, Any, (Any, Ptr{Cvoid}, Any), method, C_NULL, src::Vector{UInt8})::CodeInfo
726726
end
727727

728728
@timeit "inline IR inflation" begin

base/compiler/typeinfer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function cache_result(result::InferenceResult, min_valid::UInt, max_valid::UInt)
119119
nslots = length(inferred_result.slotflags)
120120
resize!(inferred_result.slottypes, nslots)
121121
resize!(inferred_result.slotnames, nslots)
122-
inferred_result = ccall(:jl_compress_ast, Any, (Any, Any), def, inferred_result)
122+
inferred_result = ccall(:jl_compress_ir, Any, (Any, Any), def, inferred_result)
123123
else
124124
inferred_result = nothing
125125
end
@@ -559,7 +559,7 @@ function typeinf_ext(mi::MethodInstance, params::Params)
559559
return inf
560560
elseif isa(inf, Vector{UInt8})
561561
i == 2 && ccall(:jl_typeinf_end, Cvoid, ())
562-
inf = _uncompressed_ast(code, inf)
562+
inf = _uncompressed_ir(code, inf)
563563
return inf
564564
end
565565
end

base/compiler/utilities.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function retrieve_code_info(linfo::MethodInstance)
107107
if c === nothing && isdefined(m, :source)
108108
src = m.source
109109
if isa(src, Array{UInt8,1})
110-
c = ccall(:jl_uncompress_ast, Any, (Any, Ptr{Cvoid}, Any), m, C_NULL, src)
110+
c = ccall(:jl_uncompress_ir, Any, (Any, Ptr{Cvoid}, Any), m, C_NULL, src)
111111
else
112112
c = copy(src::CodeInfo)
113113
end

base/reflection.jl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ function code_lowered(@nospecialize(f), @nospecialize(t=Tuple); generated::Bool=
811811
"not leaf types, but the `generated` argument is `true`.")
812812
end
813813
end
814-
code = uncompressed_ast(m.def::Method)
814+
code = uncompressed_ir(m.def::Method)
815815
debuginfo === :none && remove_linenums!(code)
816816
return code
817817
end
@@ -943,12 +943,15 @@ function length(mt::Core.MethodTable)
943943
end
944944
isempty(mt::Core.MethodTable) = (mt.defs === nothing)
945945

946-
uncompressed_ast(m::Method) = isdefined(m, :source) ? _uncompressed_ast(m, m.source) :
947-
isdefined(m, :generator) ? error("Method is @generated; try `code_lowered` instead.") :
948-
error("Code for this Method is not available.")
949-
_uncompressed_ast(m::Method, s::CodeInfo) = copy(s)
950-
_uncompressed_ast(m::Method, s::Array{UInt8,1}) = ccall(:jl_uncompress_ast, Any, (Any, Ptr{Cvoid}, Any), m, C_NULL, s)::CodeInfo
951-
_uncompressed_ast(ci::Core.CodeInstance, s::Array{UInt8,1}) = ccall(:jl_uncompress_ast, Any, (Any, Any, Any), ci.def.def::Method, ci, s)::CodeInfo
946+
uncompressed_ir(m::Method) = isdefined(m, :source) ? _uncompressed_ir(m, m.source) :
947+
isdefined(m, :generator) ? error("Method is @generated; try `code_lowered` instead.") :
948+
error("Code for this Method is not available.")
949+
_uncompressed_ir(m::Method, s::CodeInfo) = copy(s)
950+
_uncompressed_ir(m::Method, s::Array{UInt8,1}) = ccall(:jl_uncompress_ir, Any, (Any, Ptr{Cvoid}, Any), m, C_NULL, s)::CodeInfo
951+
_uncompressed_ir(ci::Core.CodeInstance, s::Array{UInt8,1}) = ccall(:jl_uncompress_ir, Any, (Any, Any, Any), ci.def.def::Method, ci, s)::CodeInfo
952+
# for backwards compat
953+
const uncompressed_ast = uncompressed_ir
954+
const _uncompressed_ast = _uncompressed_ir
952955

953956
function method_instances(@nospecialize(f), @nospecialize(t), world::UInt = typemax(UInt))
954957
tt = signature_type(f, t)
@@ -993,7 +996,7 @@ struct CodegenParams
993996
end
994997

995998
const SLOT_USED = 0x8
996-
ast_slotflag(@nospecialize(code), i) = ccall(:jl_ast_slotflag, UInt8, (Any, Csize_t), code, i - 1)
999+
ast_slotflag(@nospecialize(code), i) = ccall(:jl_ir_slotflag, UInt8, (Any, Csize_t), code, i - 1)
9971000

9981001
"""
9991002
may_invoke_generator(method, atypes, sparams)
@@ -1031,7 +1034,7 @@ function may_invoke_generator(method::Method, @nospecialize(atypes), sparams::Si
10311034
nsparams = length(sparams)
10321035
isdefined(generator_method, :source) || return false
10331036
code = generator_method.source
1034-
nslots = ccall(:jl_ast_nslots, Int, (Any,), code)
1037+
nslots = ccall(:jl_ir_nslots, Int, (Any,), code)
10351038
at = unwrap_unionall(atypes)
10361039
(nslots >= 1 + length(sparams) + length(at.parameters)) || return false
10371040

src/aotcompile.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ void *jl_create_native(jl_array_t *methods, const jl_cgparams_t cgparams)
286286
if ((jl_value_t*)src == jl_nothing)
287287
src = NULL;
288288
if (src && jl_is_method(def))
289-
src = jl_uncompress_ast(def, codeinst, (jl_array_t*)src);
289+
src = jl_uncompress_ir(def, codeinst, (jl_array_t*)src);
290290
}
291291
if (src == NULL || !jl_is_code_info(src)) {
292292
src = jl_type_infer(mi, params.world, 0);
@@ -792,7 +792,7 @@ void *jl_get_llvmf_defn(jl_method_instance_t *mi, size_t world, char getwrapper,
792792
jl_code_instance_t *codeinst = (jl_code_instance_t*)ci;
793793
src = (jl_code_info_t*)codeinst->inferred;
794794
if ((jl_value_t*)src != jl_nothing && !jl_is_code_info(src) && jl_is_method(mi->def.method))
795-
src = jl_uncompress_ast(mi->def.method, codeinst, (jl_array_t*)src);
795+
src = jl_uncompress_ir(mi->def.method, codeinst, (jl_array_t*)src);
796796
jlrettype = codeinst->rettype;
797797
}
798798
if (!src || (jl_value_t*)src == jl_nothing) {
@@ -802,7 +802,7 @@ void *jl_get_llvmf_defn(jl_method_instance_t *mi, size_t world, char getwrapper,
802802
else if (jl_is_method(mi->def.method)) {
803803
src = mi->def.method->generator ? jl_code_for_staged(mi) : (jl_code_info_t*)mi->def.method->source;
804804
if (src && !jl_is_code_info(src) && jl_is_method(mi->def.method))
805-
src = jl_uncompress_ast(mi->def.method, NULL, (jl_array_t*)src);
805+
src = jl_uncompress_ir(mi->def.method, NULL, (jl_array_t*)src);
806806
}
807807
// TODO: use mi->uninferred
808808
}

src/ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ static jl_value_t *scm_to_julia_(fl_context_t *fl_ctx, value_t e, jl_module_t *m
598598
e = cdr_(e);
599599
}
600600
if (sym == lambda_sym)
601-
ex = (jl_value_t*)jl_new_code_info_from_ast((jl_expr_t*)ex);
601+
ex = (jl_value_t*)jl_new_code_info_from_ir((jl_expr_t*)ex);
602602
JL_GC_POP();
603603
if (sym == list_sym)
604604
return (jl_value_t*)((jl_expr_t*)ex)->args;

src/codegen.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6484,7 +6484,7 @@ jl_compile_result_t jl_emit_codeinst(
64846484
src = (jl_code_info_t*)codeinst->inferred;
64856485
jl_method_t *def = codeinst->def->def.method;
64866486
if (src && (jl_value_t*)src != jl_nothing && jl_is_method(def))
6487-
src = jl_uncompress_ast(def, codeinst, (jl_array_t*)src);
6487+
src = jl_uncompress_ir(def, codeinst, (jl_array_t*)src);
64886488
if (!src || !jl_is_code_info(src)) {
64896489
JL_GC_POP();
64906490
return jl_compile_result_t(); // failed
@@ -6526,17 +6526,17 @@ jl_compile_result_t jl_emit_codeinst(
65266526
// update the stored code
65276527
if (codeinst->inferred != (jl_value_t*)src) {
65286528
if (jl_is_method(def))
6529-
src = (jl_code_info_t*)jl_compress_ast(def, src);
6529+
src = (jl_code_info_t*)jl_compress_ir(def, src);
65306530
codeinst->inferred = (jl_value_t*)src;
65316531
jl_gc_wb(codeinst, src);
65326532
}
65336533
}
65346534
else if (// don't delete toplevel code
65356535
jl_is_method(def) &&
6536-
// and there is something to delete (test this before calling jl_ast_flag_inlineable)
6536+
// and there is something to delete (test this before calling jl_ir_flag_inlineable)
65376537
codeinst->inferred != jl_nothing &&
65386538
// don't delete inlineable code, unless it is constant
6539-
(codeinst->invoke == jl_fptr_const_return || !jl_ast_flag_inlineable((jl_array_t*)codeinst->inferred)) &&
6539+
(codeinst->invoke == jl_fptr_const_return || !jl_ir_flag_inlineable((jl_array_t*)codeinst->inferred)) &&
65406540
// don't delete code when generating a precompile file
65416541
!imaging_mode) {
65426542
// if not inlineable, code won't be needed again

src/dump.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ static void jl_serialize_module(jl_serializer_state *s, jl_module_t *m)
481481
write_int32(s->s, m->nospecialize);
482482
}
483483

484-
static int is_ast_node(jl_value_t *v)
484+
static int is_ir_node(jl_value_t *v)
485485
{
486486
// TODO: this accidentally copies QuoteNode(Expr(...)) and QuoteNode(svec(...))
487487
return jl_is_slot(v) || jl_is_ssavalue(v) ||
@@ -563,7 +563,7 @@ static void jl_serialize_value_(jl_serializer_state *s, jl_value_t *v, int as_li
563563
jl_serialize_value(s, jl_tparam0(v));
564564
return;
565565
}
566-
else if (!as_literal && !is_ast_node(v)) {
566+
else if (!as_literal && !is_ir_node(v)) {
567567
int id = literal_val_id(s, v);
568568
assert(id >= 0);
569569
if (id < 256) {
@@ -2502,7 +2502,7 @@ JL_DLLEXPORT void jl_init_restored_modules(jl_array_t *init_order)
25022502

25032503
// --- entry points ---
25042504

2505-
JL_DLLEXPORT jl_array_t *jl_compress_ast(jl_method_t *m, jl_code_info_t *code)
2505+
JL_DLLEXPORT jl_array_t *jl_compress_ir(jl_method_t *m, jl_code_info_t *code)
25062506
{
25072507
JL_TIMING(AST_COMPRESS);
25082508
JL_LOCK(&m->writelock); // protect the roots array (Might GC)
@@ -2536,7 +2536,7 @@ JL_DLLEXPORT jl_array_t *jl_compress_ast(jl_method_t *m, jl_code_info_t *code)
25362536
ios_write(s.s, (char*)jl_array_data(code->slotflags), nslots);
25372537

25382538
// N.B.: The layout of everything before this point is explicitly referenced
2539-
// by the various jl_ast_ accessors. Make sure to adjust those if you change
2539+
// by the various jl_ir_ accessors. Make sure to adjust those if you change
25402540
// the data layout.
25412541

25422542
for (i = 0; i < 6; i++) {
@@ -2587,7 +2587,7 @@ JL_DLLEXPORT jl_array_t *jl_compress_ast(jl_method_t *m, jl_code_info_t *code)
25872587
return v;
25882588
}
25892589

2590-
JL_DLLEXPORT jl_code_info_t *jl_uncompress_ast(jl_method_t *m, jl_code_instance_t *metadata, jl_array_t *data)
2590+
JL_DLLEXPORT jl_code_info_t *jl_uncompress_ir(jl_method_t *m, jl_code_instance_t *metadata, jl_array_t *data)
25912591
{
25922592
if (jl_is_code_info(data))
25932593
return (jl_code_info_t*)data;
@@ -2663,7 +2663,7 @@ JL_DLLEXPORT jl_code_info_t *jl_uncompress_ast(jl_method_t *m, jl_code_instance_
26632663
return code;
26642664
}
26652665

2666-
JL_DLLEXPORT uint8_t jl_ast_flag_inferred(jl_array_t *data)
2666+
JL_DLLEXPORT uint8_t jl_ir_flag_inferred(jl_array_t *data)
26672667
{
26682668
if (jl_is_code_info(data))
26692669
return ((jl_code_info_t*)data)->inferred;
@@ -2672,7 +2672,7 @@ JL_DLLEXPORT uint8_t jl_ast_flag_inferred(jl_array_t *data)
26722672
return !!(flags & (1 << 3));
26732673
}
26742674

2675-
JL_DLLEXPORT uint8_t jl_ast_flag_inlineable(jl_array_t *data)
2675+
JL_DLLEXPORT uint8_t jl_ir_flag_inlineable(jl_array_t *data)
26762676
{
26772677
if (jl_is_code_info(data))
26782678
return ((jl_code_info_t*)data)->inlineable;
@@ -2681,7 +2681,7 @@ JL_DLLEXPORT uint8_t jl_ast_flag_inlineable(jl_array_t *data)
26812681
return !!(flags & (1 << 2));
26822682
}
26832683

2684-
JL_DLLEXPORT uint8_t jl_ast_flag_pure(jl_array_t *data)
2684+
JL_DLLEXPORT uint8_t jl_ir_flag_pure(jl_array_t *data)
26852685
{
26862686
if (jl_is_code_info(data))
26872687
return ((jl_code_info_t*)data)->pure;
@@ -2716,7 +2716,7 @@ JL_DLLEXPORT jl_value_t *jl_compress_argnames(jl_array_t *syms)
27162716
return str;
27172717
}
27182718

2719-
JL_DLLEXPORT ssize_t jl_ast_nslots(jl_array_t *data)
2719+
JL_DLLEXPORT ssize_t jl_ir_nslots(jl_array_t *data)
27202720
{
27212721
if (jl_is_code_info(data)) {
27222722
jl_code_info_t *func = (jl_code_info_t*)data;
@@ -2729,9 +2729,9 @@ JL_DLLEXPORT ssize_t jl_ast_nslots(jl_array_t *data)
27292729
}
27302730
}
27312731

2732-
JL_DLLEXPORT uint8_t jl_ast_slotflag(jl_array_t *data, size_t i)
2732+
JL_DLLEXPORT uint8_t jl_ir_slotflag(jl_array_t *data, size_t i)
27332733
{
2734-
assert(i < jl_ast_nslots(data));
2734+
assert(i < jl_ir_nslots(data));
27352735
if (jl_is_code_info(data))
27362736
return ((uint8_t*)((jl_code_info_t*)data)->slotflags->data)[i];
27372737
assert(jl_typeis(data, jl_array_uint8_type));

src/gf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ JL_DLLEXPORT jl_value_t *jl_rettype_inferred(jl_method_instance_t *mi, size_t mi
338338
while (codeinst) {
339339
if (codeinst->min_world <= min_world && max_world <= codeinst->max_world) {
340340
jl_value_t *code = codeinst->inferred;
341-
if (code && (code == jl_nothing || jl_ast_flag_inferred((jl_array_t*)code)))
341+
if (code && (code == jl_nothing || jl_ir_flag_inferred((jl_array_t*)code)))
342342
return (jl_value_t*)codeinst;
343343
}
344344
codeinst = codeinst->next;

0 commit comments

Comments
 (0)