Go to the documentation of this file. 1 package com.cliffc.aa.node;
8 import org.jetbrains.annotations.
NotNull;
109 private static String
name(
int fidx,
boolean debug) {
111 return fun==
null ?
name(
null,
null,
fidx,-1,
false,debug) : fun.
name(debug);
115 public String
name(
boolean debug) {
138 for( Integer ii : fidxs ) {
147 if( s==
null ) s=
name;
155 if( prim ) sb.
p(
'{').
p(s).
p(
'}');
else sb.
p(s);
160 for( Integer ii : fidxs ) {
161 if( ++cnt == 5 )
break;
162 sb.
p(ii).
p(fidxs.above_center() ?
'+' :
',');
164 if( cnt >= 5 ) sb.
p(
"...");
172 public void bind( String tok ) {
174 if( !
_name.equals(tok) )
179 public boolean noinline() {
return in(0)==
null &&
name(
false).startsWith(
"noinline"); }
182 @Override @NotNull
public Node copy(
boolean copy_edges) {
throw unimpl(); }
199 if( rez !=
null )
return rez;
215 for(
int i=1; i<
parms.length; i++ )
219 if( progress !=
_sig ) {
241 if( rpc_parm ==
null )
return null;
243 if(
_defs._len <= 2 )
return null;
248 if( !(c.
in(0) instanceof
CallNode) )
return null;
251 if( cepi==
null )
return null;
266 if( formals ==
null ) {
271 if( path == -1 )
return null;
278 if( path == -1 &&
FUNS.find(fun -> fun !=
null && !fun.is_dead() &&
279 fun._sig._formals==fformals && fun._sig._ret ==
_sig.
_ret &&
280 fun.in(1)==
in(1)) != -1 )
286 assert !check_progress;
292 assert
Env.
START.more_flow(
true)==0;
298 if( !(ctl instanceof
ConNode) ) {
318 if(
ret!=
null &&
ret!=use )
return false;
342 if( !ti.
isa(t0) )
continue;
343 if( ti != t0 )
return i;
363 sig[DSP_IDX] =
parms[DSP_IDX]==
null
366 for(
int i=ARG_IDX; i<
parms.length; i++ )
372 boolean progress =
false;
377 if( tmem instanceof
TypeMem ) {
378 for(
int i=DSP_IDX; i<
parms.length; i++ ) {
383 if( i==DSP_IDX )
continue;
400 if( progress )
return sig;
452 default:
throw unimpl();
469 if( sig ==
null )
return null;
495 if( op ==
OP_FUN && n !=
this )
continue;
496 if( op ==
OP_PARM && n.
in(0) !=
this )
continue;
503 if( freached.
tset(n.
_uid) )
continue;
504 if( op ==
OP_RET )
continue;
518 if( n==
null )
continue;
519 if( !freached.get (n.
_uid) )
continue;
520 if( breached.
tset(n.
_uid) )
continue;
537 if(
_defs._len <= 1 )
return -1;
538 boolean self_recursive=
false;
543 int call_indirect=0, call_thunk=0;
544 int[] cnts =
new int[
OP_MAX];
545 for(
Node n : body ) {
585 int m=-1, mncons = -1;
588 if( !(call instanceof
CallNode) )
continue;
594 if( self_recursive && body.find(call)!=-1 )
continue;
597 for(
int j=MEM_IDX; j<
parms.length; j++ ) {
603 { ncon = -2;
break; }
604 if( actual.
is_con() ) ncon++;
608 { mncons = ncon; m = i; }
613 if( cnts[
OP_IF] > 1+mncons)
621 int oldfidx =
fidx();
630 FUNS.setX(newfidx,
this);
667 while(
_defs._len > zlen ) {
681 HashMap<Node,Node> map =
new HashMap<>();
683 BitSet aliases =
new BitSet();
686 for(
Node n : body ) {
687 if( n==
this )
continue;
691 if( old_alias != -1 )
692 aliases.set(old_alias);
702 for(
Node n : map.keySet() ) {
704 assert c.
_defs._len==0;
706 Node newdef = map.get(def);
707 c.
add_def(newdef==
null ? def : newdef);
724 Node old_funptr = use;
725 Node new_funptr = map.get(old_funptr);
726 new_funptr.
insert(old_funptr);
729 old_funptr.
insert(new_unr);
735 Node new_funptr = map.get(old_funptr);
736 new_funptr.
insert(old_funptr);
748 for( Map.Entry<
Node,
Node> e : map.entrySet() )
750 ((
MemSplitNode)e.getKey()).split_alias(e.getValue(),aliases);
775 boolean split_alias=
false;
776 for( Map.Entry<
Node,
Node> e : map.entrySet() ) {
777 Node oo = e.getKey();
778 Node nn = e.getValue();
818 assert call_fidxs.
test_recur(
fidx()) ; cepi.wire1(call,
this,oldret);
819 if( call_fidxs.
test_recur(fun.
fidx()) ) cepi.wire1(call, fun,newret);
830 if( call==path_call ) cepi.wire1(call, fun,newret);
831 else cepi.wire1(call,
this,oldret);
832 if( cepi2!=
null && cepi2.
call()!=path_call ) {
838 cepi2.
wire1(call2,
this,oldret);
848 for(
Node nn : map.values() ) {
851 for(
int i=0; i<ncepi.
nwired(); i++ ) {
853 if( xxxret != newret && xxxret != oldret ) {
875 for(
int i=1; i<
_defs._len; i++ ) {
883 @Override
public boolean unify(
boolean test ) {
return false; }
910 if(
ret==
null )
return null;
917 @Override
public boolean equals(Object o) {
return this==o; }
FunNode(String name, TypeFunSig sig, int op_prec, boolean thunk_rhs, int fidx)
static final BitsFun EMPTY
static final TypeMem DEAD
void wire0(CallNode call, Node fun)
E push(E e)
Add element in amortized constant time.
static TypeTuple make_args(Type[] ts)
static BitsFun make0(int bit)
Type[] find_type_split(Node[] parms)
Memory type; the state of all of memory; memory edges order memory ops.
static boolean eq(String s0, String s1)
FunNode make_new_fun(RetNode ret, TypeTuple new_formals)
public< N extends Node > N add_mono(N n)
Type value(GVNGCM.Mode opt_mode)
void add_flow_uses(Node n)
TypeTuple type_special(Node[] parms)
Ary< E > addAll(Collection<? extends E > c)
int split_size(Ary< Node > body, Node[] parms)
boolean has_unknown_callers()
static final TypeRPC ALL_CALL
static final TypeFunPtr GENERIC_FUNPTR
an implementation of language AA
static SB names(BitsFun fidxs, SB sb, boolean debug)
static TypeFunSig make(String[] args, TypeTuple formals, TypeTuple ret)
public< N extends Node > N keep()
static final byte OP_FRESH
A memory-based collection of optionally named fields.
boolean test_recur(int i)
static boolean test(long[] bits, int i)
static final byte OP_CALL
SB str(SB sb, VBitSet dups, TypeMem mem, boolean debug)
int find_type_split_index(Node[] parms)
static String name(int fidx, boolean debug)
public< N extends Node > N unkeep()
Ary< E > add(E e)
Add element in amortized constant time.
static boolean is_parent(int idx)
static final byte OP_CAST
abstract Type value(GVNGCM.Mode opt_mode)
static final byte OP_DEFMEM
static final TypeTuple RET
void add_reduce_uses(Node n)
static final TypeObj UNUSED
static FunNode find_fidx(int fidx)
static void retype_mem(BitSet aliases, Node mem, Node exit, boolean skip_calls)
static final byte OP_SCOPE
void set_nongens(TV2[] nongens)
void wire1(CallNode call, Node fun, Node ret)
static final byte OP_LOAD
static TypeFunPtr make(BitsFun fidxs, int nargs, Type disp)
static final byte OP_NEWOBJ
static int parent(int kid)
FunNode(NewNode.NewPrimNode prim)
TypeFunSig make_from_arg(int idx, Type arg)
Node insert(int idx, Node n)
Tight/tiny StringBuilder wrapper.
String name(boolean debug)
static final byte OP_NEWSTR
an implementation of language AA
static final byte OP_STORE
Type value(GVNGCM.Mode opt_mode)
FunNode(String name, TypeFunSig sig, int op_prec, boolean thunk_rhs)
static String name(String name, String bal, int fidx, int op_prec, boolean fref, boolean debug)
Node copy(boolean copy_edges)
static final byte OP_PRIM
static TypeFunPtr ttfp(Type tcall)
Node ideal_inline(boolean check_progress)
Node set_def(int idx, Node n)
public< N extends Node > N add_reduce(N n)
static final byte OP_PARM
public< N extends Node > N add_flow(N n)
boolean unify(boolean test)
static TypeTuple set_ttfp(TypeTuple tcall, TypeFunPtr nfptr)
static final byte OP_NAME
static final TypeMemPtr OOP0
Node copy(boolean copy_edges)
FunNode(String[] flds, Type[] ts)
static int new_fidx(int par)
static final TypeTuple NO_ARGS
static Ary< FunNode > FUNS
abstract FunPtrNode funptr()
static final byte OP_REGION
static boolean bad_mem_use(Node n, TypeObj to)
Ary< Node > find_body(RetNode ret)
static TypeMemPtr make(BitsAlias aliases, TypeObj obj)
void split_callers(RetNode oldret, FunNode fun, Ary< Node > body, int path)