aa
com.cliffc.aa.node.TestNodeSmall Class Reference
Collaboration diagram for com.cliffc.aa.node.TestNodeSmall:
[legend]

Public Member Functions

void testCallNodeResolve ()
 Validate monotonicity of CallNode.resolve(). More...
 
void testCallNodeResolve2 ()
 
void testMemoryArgs ()
 
void testRecursiveDisplay ()
 
void testUnresolvedAdd ()
 

Static Package Functions

static void perror (String msg, Type t1, Type t2)
 

Private Member Functions

Type[] _testMonotonicChain (Node[] ins, Node n, TypeTuple[] argss)
 

Static Private Member Functions

static Type[] check (GVNGCM gvn, TypeFunSig tsig, TypeMem tmem, Type targ1, Type targ2)
 
static TypeMem tmem (int[] as, TypeObj... ts)
 
static TypeFunPtr v (Node n, GVNGCM gvn)
 

Static Private Attributes

static int ERR =0
 

Detailed Description

Definition at line 17 of file TestNodeSmall.java.

Member Function Documentation

◆ _testMonotonicChain()

Type [] com.cliffc.aa.node.TestNodeSmall._testMonotonicChain ( Node[]  ins,
Node  n,
TypeTuple[]  argss 
)
private

Definition at line 158 of file TestNodeSmall.java.

158  {
159  GVNGCM gvn = Env.GVN;
160 
161  // First validate the test itself. If two tuples are 'isa' then the result
162  // is also 'isa'. To allow the tests in any order, we check a slightly
163  // strong condition: if all tuples are isa IN SOME ORDER, then the result
164  // is also 'isa' IN THAT ORDER.
165  int len = argss.length;
166  int num = argss[0]._ts.length;
167  for( int i=0; i<len; i++ ) {
168  TypeTuple tti = argss[i];
169  int order=0; // no order picked
170  midloop:
171  for( int j=i+1; j<len; j++ ) { // Triangulate
172  TypeTuple ttj = argss[j];
173  for( int k=0; k<num-1; k++ ) { // Check all parts are 'isa', except the answer
174  Type ttik = tti.at(k);
175  Type ttjk = ttj.at(k);
176  if( ttik==ttjk ) continue; // Does not affect outcome
177  if( ttik.isa(ttjk) ) order |= 1;// i isa j
178  else if( ttjk.isa(ttik) ) order |= 2;// j isa i
179  else order |= 3; // Unordered
180  if( order==3 ) continue midloop; // Mixed/unordered
181  }
182  assert order==1 || order==2;
183  Type ttiN = tti.at(num-1); // Then check last answer element is 'isa'
184  Type ttjN = ttj.at(num-1);
185  if( order==1 ) assertTrue("Test is broken: "+tti+" isa "+ttj+", but "+ttiN+" !isa "+ttjN,ttiN.isa(ttjN));
186  else assertTrue("Test is broken: "+ttj+" isa "+tti+", but "+ttjN+" !isa "+ttiN,ttjN.isa(ttiN));
187  }
188  }
189 
190 
191  // Now call Node.value()
192  TypeTuple[] tns= new TypeTuple[argss.length];
193  for( int i=0; i<argss.length; i++ ) {
194  for( int j=0; j<ins.length; j++ )
195  ins[j]._val = argss[i].at(j);
196  tns[i] = (TypeTuple)n.value(gvn._opt_mode);
197  }
198  // Equals check after computing them all
199  for( int i=0; i<argss.length; i++ ) {
200  TypeFunPtr expect = (TypeFunPtr)argss[i].at(ins.length);
201  TypeFunPtr actual = CallNode.ttfp(tns[i]); // Looking at the TFP from the Call, ignore ctrl,memory,args
202  assertEquals("Expect "+expect+", but actual is "+actual+", for ("+argss[i].at(3)+", "+argss[i].at(4)+")",
203  expect.fidxs(),actual.fidxs());
204  }
205  return tns;
206  }

References com.cliffc.aa.GVNGCM._opt_mode, com.cliffc.aa.type.TypeTuple._ts, com.cliffc.aa.type.TypeTuple.at(), com.cliffc.aa.type.TypeFunPtr.fidxs(), com.cliffc.aa.Env.GVN, com.cliffc.aa.type.Type< T extends Type< T >.isa(), com.cliffc.aa.node.CallNode.ttfp(), and com.cliffc.aa.node.Node.value().

Referenced by com.cliffc.aa.node.TestNodeSmall.testCallNodeResolve().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check()

static Type [] com.cliffc.aa.node.TestNodeSmall.check ( GVNGCM  gvn,
TypeFunSig  tsig,
TypeMem  tmem,
Type  targ1,
Type  targ2 
)
staticprivate

Definition at line 681 of file TestNodeSmall.java.

681  {
682  assert targ1.simple_ptr()==targ1;
683  assert targ2.simple_ptr()==targ2;
684  ConNode ctl = gvn.init(new ConNode<>(Type.CTRL));
685  CallNode call = gvn.init(new CallNode(true, null, ctl, null/*mem*/, null/*disp*/, null/*x*/, null/*y*/, null/*fidx*/));
686  CallEpiNode cepi = gvn.init(new CallEpiNode(call, Env.DEFMEM)); // Unwired
687  Node cpj = gvn.xform(new CProjNode(call,0));
688  ConNode mem = (ConNode)gvn.xform(new ConNode<>(tmem ));
689  ConNode arg1= (ConNode)gvn.xform(new ConNode<>(targ1));
690  ConNode arg2= (ConNode)gvn.xform(new ConNode<>(targ2));
691 
692  // Make nodes
693  FunNode fun = new FunNode(null,tsig,-1,false).unkeep();
694  gvn.xform(fun.add_def(cpj));
695 
696  ParmNode parmem= gvn.init(new ParmNode( 0,"mem" ,fun,mem ,null));
697  ParmNode parm1 = gvn.init(new ParmNode( 2,"arg1",fun,arg1,null));
698  ParmNode parm2 = gvn.init(new ParmNode( 3,"arg2",fun,arg2,null));
699 
700  // Types for normal args before memory type
701  Type tp1 = parm1 .xval ();
702  Type tp2 = parm2 .xval ();
703  Type tpm = parmem.value(gvn._opt_mode);
704 
705  // Check the isa(sig) on complex pointer args
706  Type actual1 = tpm.sharptr(tp1);
707  Type formal1 = fun.formal(2);
708  if( !actual1.isa(formal1) && !formal1.isa(actual1) )
709  perror("arg1-vs-formal1",actual1,formal1);
710  Type actual2 = tpm.sharptr(tp2);
711  Type formal2 = fun.formal(3);
712  if( !actual2.isa(formal2) && !formal2.isa(actual2) )
713  perror("arg2-vs-formal2",actual2,formal2);
714 
715  // Record for later monotonic check
716  return new Type[]{tpm,tp1,tp2};
717  }

References com.cliffc.aa.GVNGCM._opt_mode, com.cliffc.aa.node.Node.add_def(), com.cliffc.aa.type.Type< T extends Type< T >.CTRL, com.cliffc.aa.Env.DEFMEM, com.cliffc.aa.node.FunNode.formal(), com.cliffc.aa.GVNGCM.init(), com.cliffc.aa.type.Type< T extends Type< T >.isa(), com.cliffc.aa.node.TestNodeSmall.perror(), com.cliffc.aa.type.Type< T extends Type< T >.sharptr(), com.cliffc.aa.type.Type< T extends Type< T >.simple_ptr(), com.cliffc.aa.node.TestNodeSmall.tmem(), com.cliffc.aa.node.Node.unkeep(), com.cliffc.aa.node.ParmNode.value(), com.cliffc.aa.GVNGCM.xform(), and com.cliffc.aa.node.Node.xval().

Referenced by com.cliffc.aa.node.TestNodeSmall.testMemoryArgs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perror()

static void com.cliffc.aa.node.TestNodeSmall.perror ( String  msg,
Type  t1,
Type  t2 
)
staticpackage

Definition at line 719 of file TestNodeSmall.java.

719  {
720  if( ERR < 10 )
721  System.out.println(msg+", "+t1+" is not "+t2);
722  ERR++;
723  }

References com.cliffc.aa.node.TestNodeSmall.ERR.

Referenced by com.cliffc.aa.node.TestNodeSmall.check(), and com.cliffc.aa.node.TestNodeSmall.testMemoryArgs().

Here is the caller graph for this function:

◆ testCallNodeResolve()

void com.cliffc.aa.node.TestNodeSmall.testCallNodeResolve ( )

Validate monotonicity of CallNode.resolve().

There are only a couple of interesting variants; this test also tests e.g. XCTRL for correctness but its implementation is a simple cutout, same for the display arg "^" being NO_DISP.

=== High mul fptr (e.g. GCP) === arg1 arg2 fptr* resolve ~S ~S [~int+flt] [~int+flt] Choices all around 2 ~S [~int+flt] [~int+flt] Choices all around; arg2 can fall to e.g. 3 or 3.14 2 3 [~int+flt] [~int+flt] Valid to cutout flt or allow (least_cost will resolve) 2 I [~int+flt] [ int ] Only int 2 F [~int+flt] [ flt] Only flt 2 S [~int+flt] [ int,flt] Error state, but arg2 may lift S S [~int+flt] [ int,flt] Error state, but args may lift ~S S [~int+flt] [ int,flt] Error state in GCP, args may lift in ITER ~S str [~int+flt] [ int,flt] Error state - sideways 2 str [~int+flt] [ int,flt] Error state - sideways

=== High add fptr (e.g. GCP) === arg1 arg2 fptr+ resolve ~S ~S [~int+flt+str] [~int+flt+str] Choices all around 2 ~S [~int+flt+str] [~int+XXX ] Cutout str, but int,flt OK 2 3 [~int+flt+str] [~int+XXX ] Valid to cutout flt or allow (least_cost will resolve by lowering) 2 S [~int+flt+str] [ int,flt ] Error state, but arg2 may lift S S [~int+flt+str] [ int,flt,str] Error state, but args may lift 2 str [~int+flt+str] [ int,flt,str] Error state, none of {int,flt,str} work ~S str [~int+flt+str] [ ~str] Choice, since may yet be error str str [~int+flt+str] [ ~str] Choice, since may yet be error

=== Low fptr (GCP, but also ITER depending on implementation choices ) === arg1 arg2 fptr resolve X X [ int,flt] [ SAME ] Same as high fptr 2 ~S [~int+flt] [~int+flt] Error args 2 3 [ int,flt] [ int,XXX] Low, not high, for all good args

Definition at line 248 of file TestNodeSmall.java.

248  {
249  Env top = Env.top_scope();
250  GVNGCM gvn = Env.GVN;
251 
252  // Make a Unknown/CallNode/CallEpi combo.
253  // Unwired. Validate the resolve process and monotonicity.
254  gvn._opt_mode=GVNGCM.Mode.Parse;
255  ConNode ctrl = (ConNode) gvn.xform(new ConNode<>(Type.CTRL));
256  UnresolvedNode fp_mul = (UnresolvedNode)top.lookup("*"); // {int int -> int} and {flt flt -> flt}
257  FunPtrNode mflt = (FunPtrNode)fp_mul.in(0);
258  FunPtrNode mint = (FunPtrNode)fp_mul.in(1);
259  UnresolvedNode fp_add = (UnresolvedNode)top.lookup("+"); // {int int -> int} and {flt flt -> flt} and {str str -> str}
260  FunPtrNode aflt = (FunPtrNode)fp_add.in(0);
261  FunPtrNode aint = (FunPtrNode)fp_add.in(1);
262  FunPtrNode astr = (FunPtrNode)fp_add.in(2);
263  // Make a flt/int combo, drops off string.
264  ConNode mem = gvn.init(new ConNode<>(TypeMem.MEM));
265  ConNode arg1 = gvn.init(new ConNode<>(Type.SCALAR));
266  ConNode arg2 = gvn.init(new ConNode<>(Type.SCALAR));
267  Node dsp = gvn.xform(new ConNode<>(TypeMemPtr.NO_DISP));
268  CallNode call = (CallNode)gvn.xform(new CallNode(true, null, ctrl, mem, dsp, arg1, arg2, fp_mul));
269  CallEpiNode cepi = (CallEpiNode)gvn.xform(new CallEpiNode(call, Env.DEFMEM)); // Unwired
270 
271  call.unelock(); // Will be hacking edges
272  Node[] ins = new Node[]{ctrl,mem,fp_mul,arg1,arg2};
273 
274  // Args to calls
275  Type tctl = Type.CTRL, txctl = Type.XCTRL;
276  Type tscl = Type.SCALAR, txscl = Type.XSCALAR;
277  Type tnil = Type.XNIL;
278  TypeMem tfull = TypeMem.MEM;
279  Type t2 = TypeInt.con(2); // Small ints are ambiguously either ints or floats
280  Type t3 = TypeInt.con(3);
281  Type tint=TypeInt.INT64;
282  Type tflt=TypeFlt.FLT64;
284 
285  // iter(), not gcp(). Types always rise. Very low types might lift to be
286  // valid, but e.g. a 2:int will never lift to a str.
287  gvn._opt_mode=GVNGCM.Mode.PesiNoCG;
288 
289  // The various kinds of results we expect
290  TypeFunPtr tmul1 = v(fp_mul,gvn), tmul1X = tmul1.dual();
291  TypeFunPtr tadd1 = v(fp_add,gvn), tadd1X = tadd1.dual();
292 
293  UnresolvedNode anum = gvn.init(new UnresolvedNode(null,aflt,aint));
294  TypeFunPtr tnum1 = v(anum,gvn), tnum1X = tnum1.dual();
295  TypeFunPtr tflt1 = v(aflt,gvn), tflt1X = tflt1.dual();
296  TypeFunPtr tint1 = v(aint,gvn), tint1X = tint1.dual();
297  TypeFunPtr tstr1 = v(astr,gvn), tstr1X = tstr1.dual();
298  TypeFunPtr tmint = v(mint,gvn), tmintX = tmint.dual();
299  TypeFunPtr tmflt = v(mflt,gvn), tmfltX = tmflt.dual();
300 
301  TypeFunPtr tmul1E = TypeFunPtr.make(BitsFun.EMPTY,0,NO_DISP); // All bad choices
302 
303  assert tadd1X.isa(tnum1X) && tnum1X.isa(tflt1X) && tflt1X.isa(tnum1) && tnum1.isa(tadd1);
304 
305  // Check the fptr {int,flt} meet
306  call.set_fdx(ins[2]=fp_mul);
307  TypeTuple[] argss_mul1 = new TypeTuple[] { // arg1 arg2 resolve
308  TypeTuple.make( tctl, tfull, tmul1, txscl, txscl, tmul1X), // ~S ~S [+int+flt] ; high
309  TypeTuple.make( tctl, tfull, tmul1, t2 , txscl, tmul1X), // 2 ~S [+int+flt] ; good+high
310  TypeTuple.make( tctl, tfull, tmul1, t2 , t3 , tmul1X), // 2 3 [+int+flt] ; good, requires 'least cost' to resolve
311  TypeTuple.make( tctl, tfull, tmul1, t2 , tint , tmintX), // 2 I [+int ] ; good
312  TypeTuple.make( tctl, tfull, tmul1, t2 , tflt , tmfltX), // 2 F [ +flt] ; good
313  TypeTuple.make( tctl, tfull, tmul1, t2 , tscl , tmul1 ), // 2 S [ int,flt] ; low+good
314  TypeTuple.make( tctl, tfull, tmul1, tscl , tscl , tmul1 ), // S S [ int,flt] ; low
315  TypeTuple.make( tctl, tfull, tmul1, txscl, tscl , tmul1 ), // ~S S [ int,flt] ; low +high
316  TypeTuple.make( tctl, tfull, tmul1, txscl, tabc , tmul1X), // ~S str [+int+flt] ; bad high
317  TypeTuple.make( tctl, tfull, tmul1, tabc , tabc , tmul1 ), // str str [ ] ; bad
318  TypeTuple.make( tctl, tfull, tmul1, t2 , tabc , tmul1 ), // 2 str [+int+flt] ; bad+good
319  };
320  _testMonotonicChain(ins,call,argss_mul1);
321 
322  // Check the {int,flt,str} meet.
323  // Rules:
324  // - Some args High & no Low, keep all & join (ignore Good,Bad)
325  // - Some args Low & no High, keep all & meet (ignore Good,Bad)
326  // - Mix High/Low & no Good , keep all & fidx?join:meet
327  // - Some Good, no Low, no High, drop Bad & fidx?join:meet
328  // - All Bad, like Low: keep all & meet
329  call.set_fdx(ins[2]=fp_add);
330  TypeTuple[] argss_add1 = new TypeTuple[] {
331  TypeTuple.make( tctl, tfull, tadd1, txscl, txscl, tadd1X), // ~S ~S [+int+flt+str] (__H,__H,__H) ; All high, keep all, join
332  TypeTuple.make( tctl, tfull, tadd1, txscl, tabc , tadd1X), // ~S str [+int+flt+str] (B_H,B_H,_GH) ; Some high, keep all, join
333  TypeTuple.make( tctl, tfull, tadd1, txscl, tscl , tadd1 ), // ~S S [ int,flt,str] (L_H,L_H,L_H) ; Mix H/L no Good, fidx/meet
334  TypeTuple.make( tctl, tfull, tadd1, tnil , txscl, tadd1X), // 0 ~S [+int+flt+str] (_GH,_GH,_GH) ; Some high, keep all, join
335  TypeTuple.make( tctl, tfull, tadd1, tnil , t3 , tnum1X), // 0 3 [+int+flt ] (_G_,_G_,BG_) ; Some good, drop bad, fidx/meet
336  TypeTuple.make( tctl, tfull, tadd1, tnil , tabc , tstr1X), // 0 str [ +str] (BG_,BG_,_G_) ; Some good, drop bad, fidx/meet
337  TypeTuple.make( tctl, tfull, tadd1, tnil , tint , tint1X), // 0 3 [+int ] (_G_,_G_,_G_) ; All good
338  TypeTuple.make( tctl, tfull, tadd1, tnil , tscl , tadd1 ), // 0 S [ int,flt,str] (LG_,LG_,LG_) ; Some low , keep all, meet
339  TypeTuple.make( tctl, tfull, tadd1, t2 , txscl, tadd1X), // 2 ~S [+int+flt+str] (_GH,_GH,B_H) ; Some high, keep all, join
340  TypeTuple.make( tctl, tfull, tadd1, t2 , t3 , tnum1X), // 2 3 [+int+flt ] (_G_,_G_,B__) ; Some good, drop bad, fidx/meet
341  TypeTuple.make( tctl, tfull, tadd1, t2 , tabc , tadd1 ), // 2 str [ int,flt,str] (BG_,BG_,BG_) ; All bad , keep all, meet
342  TypeTuple.make( tctl, tfull, tadd1, t2 , tscl , tadd1 ), // 2 S [ int,flt,str] (LG_,LG_,B__) ; Some low , keep all, meet
343  TypeTuple.make( tctl, tfull, tadd1, tabc , tabc , tstr1X), // str str [ +str] (B__,B__,_G_) ; Some good, drop bad, fidx/meet
344  TypeTuple.make( tctl, tfull, tadd1, tscl , tscl , tadd1 ), // S S [ int,flt,str] (L__,L__,L__) ; All low , keep all, meet
345  };
346  _testMonotonicChain(ins,call,argss_add1);
347 
348 
349  // gcp(), not iter(). Types always lower. Very high types might lower to be
350  // valid, but e.g. a 2:int will never lower to a str.
351  gvn._opt_mode=GVNGCM.Mode.Opto;
352 
353  // The various kinds of results we expect
354  TypeFunPtr tmul2X = v(fp_mul,gvn), tmul2 = tmul2X.dual();
355  TypeFunPtr tadd2X = v(fp_add,gvn), tadd2 = tadd2X.dual();
356 
357  TypeFunPtr tnum2X = v(anum,gvn), tnum2 = tnum2X.dual();
358  TypeFunPtr tflt2 = v(aflt,gvn), tflt2X= tflt2 .dual();
359  TypeFunPtr tint2 = v(aint,gvn), tint2X= tint2 .dual();
360  TypeFunPtr tstr2 = v(astr,gvn), tstr2X= tstr2 .dual();
361 
362  assert tadd2X.isa(tnum2X) && tnum2X.isa(tflt2X) && tflt2X.isa(tnum2) && tnum2.isa(tadd2);
363 
364 
365  // Check the fptr {+int+flt} choices
366  call.set_fdx(ins[2]=fp_mul);
367  TypeTuple[] argss_mul2 = new TypeTuple[] { // arg2 arg2 resolve
368  TypeTuple.make( tctl, tfull, tmul2X, txscl, txscl, tmul2X), // ~S ~S [+int+flt]
369  TypeTuple.make( tctl, tfull, tmul2X, t2 , txscl, tmul2X), // 2 ~S [+int+flt]
370  TypeTuple.make( tctl, tfull, tmul2X, t2 , t3 , tmul2X), // 2 3 [ int,flt]
371  TypeTuple.make( tctl, tfull, tmul2X, t2 , tscl , tmul2 ), // 2 S [ int,flt]
372  TypeTuple.make( tctl, tfull, tmul2X, tscl , tscl , tmul2 ), // S S [ int,flt]
373  TypeTuple.make( tctl, tfull, tmul2X, txscl, tscl , tmul2X), // ~S S [ int,flt]
374  TypeTuple.make( tctl, tfull, tmul2X, txscl, tabc , tmul2X), // ~S str [ int,flt]
375  TypeTuple.make( tctl, tfull, tmul2X, t2 , tabc , tmul2 ), // 2 str [ int,flt]
376  };
377  _testMonotonicChain(ins,call,argss_mul2);
378 
379  // Check the {+int+flt+str} choices
380  call.set_fdx(ins[2]=fp_add);
381  TypeTuple[] argss_add2 = new TypeTuple[] {
382  TypeTuple.make( tctl, tfull, tadd2X, txscl, txscl, tadd2X), // ~S ~S [+int+flt+str] (__H,__H,__H) ; All high, keep all, join
383  TypeTuple.make( tctl, tfull, tadd2X, txscl, tabc , tadd2X), // ~S str [+int+flt+str] (B_H,B_H,_GH) ; Some high, keep all, join
384  TypeTuple.make( tctl, tfull, tadd2X, txscl, tscl , tadd2X), // ~S S [+int+flt+str] (L_H,L_H,L_H) ; Mix H/L, no good, keep all, fidx/join
385  TypeTuple.make( tctl, tfull, tadd2X, tnil , txscl, tadd2X), // 0 ~S [+int+flt+str] (_GH,_GH,_GH) ; Some high, keep all, join
386  TypeTuple.make( tctl, tfull, tadd2X, tnil , t3 , tnum2X), // 0 3 [+int+flt ] (_G_,_G_,BG_) ; Some good, drop bad, fidx/join
387  TypeTuple.make( tctl, tfull, tadd2X, tnil , tabc , tstr2X), // 0 str [ +str] (BG_,BG_,_G_) ; Some good, drop bad, fidx/join
388  TypeTuple.make( tctl, tfull, tadd2X, tnil , tscl , tadd2 ), // 0 S [ int,flt,str] (LG_,LG_,LG_) ; Some low , keep all, meet
389  TypeTuple.make( tctl, tfull, tadd2X, t2 , txscl, tadd2X), // 2 ~S [+int+flt+str] (_GH,_GH,B_H) ; Some high, keep all, join
390  TypeTuple.make( tctl, tfull, tadd2X, t2 , t3 , tnum2X), // 2 3 [+int+flt ] (_G_,_G_,B__) ; Some good, drop bad, fidx/join
391  TypeTuple.make( tctl, tfull, tadd2X, t2 , tabc , tadd2 ), // 2 str [ int,flt,str] (BG_,BG_,BG_) ; All bad , keep all, meet
392  TypeTuple.make( tctl, tfull, tadd2X, t2 , tscl , tadd2 ), // 2 S [ int,flt,str] (LG_,LG_,B__) ; Some low , keep all, meet
393  TypeTuple.make( tctl, tfull, tadd2X, tabc , tabc , tstr2X), // str str [ +str] (B__,B__,_G_) ; Some good, drop bad, fidx/join
394  TypeTuple.make( tctl, tfull, tadd2X, tscl , tscl , tadd2 ), // S S [ int,flt,str] (L__,L__,L__) ; All low , keep all, meet
395  };
396  _testMonotonicChain(ins,call,argss_add2);
397 
398  cepi.kill();
399  }

References com.cliffc.aa.GVNGCM._opt_mode, com.cliffc.aa.node.TestNodeSmall._testMonotonicChain(), com.cliffc.aa.type.TypeMemPtr.ABCPTR, com.cliffc.aa.type.TypeInt.con(), com.cliffc.aa.type.Type< T extends Type< T >.CTRL, com.cliffc.aa.Env.DEFMEM, com.cliffc.aa.type.Type< T extends Type< T >.dual(), com.cliffc.aa.type.BitsFun.EMPTY, com.cliffc.aa.type.TypeFlt.FLT64, com.cliffc.aa.Env.GVN, com.cliffc.aa.node.Node.in(), com.cliffc.aa.GVNGCM.init(), com.cliffc.aa.type.TypeInt.INT64, com.cliffc.aa.type.Type< T extends Type< T >.isa(), com.cliffc.aa.node.Node.kill(), com.cliffc.aa.Env.lookup(), com.cliffc.aa.type.TypeFunPtr.make(), com.cliffc.aa.type.TypeTuple.make(), com.cliffc.aa.type.TypeMem.MEM, com.cliffc.aa.type.TypeMemPtr.NO_DISP, com.cliffc.aa.GVNGCM.Mode.Opto, com.cliffc.aa.GVNGCM.Mode.Parse, com.cliffc.aa.GVNGCM.Mode.PesiNoCG, com.cliffc.aa.type.Type< T extends Type< T >.SCALAR, com.cliffc.aa.node.CallNode.set_fdx(), com.cliffc.aa.type.TypeMemPtr.simple_ptr(), com.cliffc.aa.Env.top_scope(), com.cliffc.aa.node.Node.unelock(), com.cliffc.aa.node.TestNodeSmall.v(), com.cliffc.aa.type.Type< T extends Type< T >.XCTRL, com.cliffc.aa.GVNGCM.xform(), com.cliffc.aa.type.Type< T extends Type< T >.XNIL, and com.cliffc.aa.type.Type< T extends Type< T >.XSCALAR.

Here is the call graph for this function:

◆ testCallNodeResolve2()

void com.cliffc.aa.node.TestNodeSmall.testCallNodeResolve2 ( )

Definition at line 401 of file TestNodeSmall.java.

401  {
402  Env top = Env.top_scope();
403  GVNGCM gvn = Env.GVN;
404  gvn._opt_mode=GVNGCM.Mode.Parse;
405 
406  UnresolvedNode fp_add = (UnresolvedNode)top.lookup("+"); // {int int -> int} and {flt flt -> flt} and {str str -> str}
407  FunPtrNode aflt = (FunPtrNode)fp_add.in(0);
408  FunPtrNode aint = (FunPtrNode)fp_add.in(1);
409  FunPtrNode astr = (FunPtrNode)fp_add.in(2);
410 
411  // Make a Unknown/CallNode/CallEpi combo. Unwired.
412  ConNode ctrl = (ConNode)gvn.xform(new ConNode<>(Type.CTRL));
413  ConNode mem = (ConNode)gvn.xform(new ConNode<>(TypeMem.MEM));
414  ConNode dsp = (ConNode)gvn.xform(new ConNode<>(TypeMemPtr.NO_DISP));
415  ConNode arg3 = gvn.init(new ConNode<>(Type.SCALAR));
416  ConNode arg4 = gvn.init(new ConNode<>(Type.SCALAR));
417  ConNode fdx = gvn.init(new ConNode<>(fp_add._val));
418  CallNode call = gvn.init(new CallNode(true, null, ctrl, mem, dsp, arg3, arg4, fdx));
419  CallEpiNode cepi = gvn.init(new CallEpiNode(call, Env.DEFMEM)); // Unwired
420 
421  // Types we see on inputs, choosen to walk across the sample space
422  Type i32 = TypeInt.INT32; // Subsets both int64 and flt64
423  Type i64 = TypeInt.INT64;
424  Type f64 = TypeFlt.FLT64;
425  Type scl = Type.SCALAR;
426  Type abc = TypeMemPtr.ABCPTR.simple_ptr(); // Constant string
427  Type tup = TypeMemPtr.STRUCT.simple_ptr(); // Tuple pointer (always wrong
428  // All args, including duals
429  Type[] targs = new Type[]{i64,i64.dual(),
430  f64,f64.dual(),
431  scl,scl.dual(),
432  //abc,abc.dual(),
433  //i32,i32.dual(),
434  //tup,tup.dual(),
435  };
436  // Functions we see, in all combos
437  Type fint = aint._val;
438  Type fflt = aflt._val;
439  Type fstr = astr._val;
440  Type fif_ = fint.meet(fflt);
441  Type f_fs = fstr.meet(fflt);
442  Type fi_s = fstr.meet(fint);
443  Type fifs = fint.meet(fflt).meet(fstr);
444  // All FDXS, including duals
445  Type[] tfdxs = new Type[]{fint,fint.dual(),fflt,fflt.dual(),fstr,fstr.dual(),
446  fif_,fif_.dual(),f_fs,f_fs.dual(),
447  fi_s,fi_s.dual(),fifs,fifs.dual(),};
448 
449  // Pre-compute them all
450  HashMap<TypeTuple,Type> cvals = new HashMap<>();
451  for( Type targ3 : targs ) {
452  arg3._val = targ3;
453  for( Type targ4 : targs ) {
454  arg4._val = targ4;
455  for( Type tfdx : tfdxs ) {
456  fdx._val = tfdx;
457  Type tcall = call.value(GVNGCM.Mode.Parse);
458  TypeTuple args = TypeTuple.make(targ3,targ4,tfdx);
459  cvals.put(args,tcall);
460  }
461  }
462  }
463 
464  // Verify ISA relation
465  Set<TypeTuple> keys = cvals.keySet();
466  for( TypeTuple key0 : keys )
467  for( TypeTuple key1 : keys )
468  if( key0.isa(key1) )
469  assertTrue(cvals.get(key0).isa(cvals.get(key1)));
470 
471 
472 
473  }

References com.cliffc.aa.GVNGCM._opt_mode, com.cliffc.aa.node.Node._val, com.cliffc.aa.type.TypeMemPtr.ABCPTR, com.cliffc.aa.type.Type< T extends Type< T >.CTRL, com.cliffc.aa.Env.DEFMEM, com.cliffc.aa.type.Type< T extends Type< T >.dual(), com.cliffc.aa.type.TypeFlt.FLT64, com.cliffc.aa.Env.GVN, com.cliffc.aa.node.Node.in(), com.cliffc.aa.GVNGCM.init(), com.cliffc.aa.type.TypeInt.INT32, com.cliffc.aa.type.TypeInt.INT64, com.cliffc.aa.Env.lookup(), com.cliffc.aa.type.TypeTuple.make(), com.cliffc.aa.type.Type< T extends Type< T >.meet(), com.cliffc.aa.type.TypeMem.MEM, com.cliffc.aa.type.TypeMemPtr.NO_DISP, com.cliffc.aa.GVNGCM.Mode.Parse, com.cliffc.aa.type.Type< T extends Type< T >.SCALAR, com.cliffc.aa.type.TypeMemPtr.simple_ptr(), com.cliffc.aa.type.TypeMemPtr.STRUCT, com.cliffc.aa.Env.top_scope(), com.cliffc.aa.node.CallNode.value(), and com.cliffc.aa.GVNGCM.xform().

Here is the call graph for this function:

◆ testMemoryArgs()

void com.cliffc.aa.node.TestNodeSmall.testMemoryArgs ( )

Definition at line 590 of file TestNodeSmall.java.

590  {
591  Env top = Env.top_scope();
592  GVNGCM gvn = Env.GVN;
593 
594  // Check Parm.value calls are monotonic, and within Fun.sig bounds -
595  // including memory args.
596 
597  // Build a bunch of aliases.
598  int a1 = BitsAlias.new_alias(BitsAlias.REC);
599  int a2 = BitsAlias.new_alias(BitsAlias.REC);
600  int a3 = BitsAlias.new_alias(BitsAlias.REC);
603  // @{ a:int; b:"abc" }
604  TypeStruct a_int_b_abc = TypeStruct.make(TypeFld.NO_DISP,
605  TypeFld.make("a",TypeInt.INT64,1),
606  TypeFld.make("b",TypeMemPtr.ABCPTR,2));
607 
608  // Build a bunch of function type signatures
609  TypeFunSig[] sigs = new TypeFunSig[] {
610  TypeFunSig.make(TypeTuple.RET,ts_int_flt), // {int flt -> }
611  TypeFunSig.make(TypeTuple.RET,ts_int_abc), // {int "abc" -> }
612  // { flt @{a:int; b:"abc"} -> }
614  };
615 
616  // Build a bunch of memory parm types
617  TypeMem[] mems = new TypeMem[] {
618  tmem(null),
619  tmem(null).dual(),
620  tmem(new int[]{a1},TypeStr.STR),
621  tmem(new int[]{a1},a_int_b_abc),
622  };
623 
624  // Build a bunch of parameter types
625  Type[] args = new Type[] {
626  Type.NIL,
627  Type.XNIL,
628  TypeInt.INT64,
629  TypeInt.INT64.dual(),
630  TypeInt.NINT64,
632  TypeMemPtr.ABCPTR.dual().simple_ptr(),
634  TypeMemPtr.make(a1,TypeObj.OBJ).dual().simple_ptr(),
635  };
636 
637  // One-off jig for testing single combo
638  // Known easy fail: 0,0,0,[6,5]
639  // Known easy fail: 2,1,0,[6,7]
640  // Known easy fail: 1,0,0,[8,5]
641  // Known easy fail: 2,[1,0],0,7
642  Type[] rez1 = check(gvn,sigs[2],mems[1],args[0],args[8]);
643  Type[] rez2 = check(gvn,sigs[2],mems[0],args[0],args[8]);
644  for( int k=0; k<rez1.length; k++ )
645  assertTrue(rez1[k].isa(rez2[k]));
646 
647 
648  // Call for all combos.
649  // Check results are isa-sig.
650  Type[][][][][] rezs = new Type[sigs.length][mems.length][args.length][args.length][];
651  for( int is = 0; is<sigs.length; is++ )
652  for( int im = 0; im<mems.length; im++ )
653  for( int ia0 = 0; ia0<args.length; ia0++ )
654  for( int ia1 = 0; ia1<args.length; ia1++ )
655  rezs[is][im][ia0][ia1] = check(gvn,sigs[is],mems[im],args[ia0],args[ia1]);
656 
657  // Check results are monotonic:
658  for( int is = 0; is<sigs.length; is++ )
659  for( int js = 0; js<sigs.length; js++ )
660  if( sigs[is].isa(sigs[js]) )
661  for( int im = 0; im<mems.length; im++ )
662  for( int jm = 0; jm<mems.length; jm++ )
663  if( mems[im].isa(mems[jm]) )
664  for( int ia0 = 0; ia0<args.length; ia0++ )
665  for( int ja0 = 0; ja0<args.length; ja0++ )
666  if( args[ia0].isa(args[ja0]) )
667  for( int ia1 = 0; ia1<args.length; ia1++ )
668  for( int ja1 = 0; ja1<args.length; ja1++ )
669  if( args[ia1].isa(args[ja1]) ) {
670  Type[] rezi = rezs[is][im][ia0][ia1];
671  Type[] rezj = rezs[js][jm][ja0][ja1];
672  for( int k=0; k<rezi.length; k++ )
673  if( !rezi[k].isa(rezj[k]) )
674  perror("Not monotonic",rezi[k],rezj[k]);
675  }
676  assertEquals(0,ERR);
677  }

References com.cliffc.aa.type.TypeMemPtr.ABCPTR, com.cliffc.aa.node.TestNodeSmall.check(), com.cliffc.aa.type.Type< T extends Type< T >.dual(), com.cliffc.aa.node.TestNodeSmall.ERR, com.cliffc.aa.type.TypeFlt.FLT64, com.cliffc.aa.Env.GVN, com.cliffc.aa.type.TypeInt.INT64, com.cliffc.aa.type.TypeFld.make(), com.cliffc.aa.type.TypeMemPtr.make(), com.cliffc.aa.type.TypeFunSig.make(), com.cliffc.aa.type.TypeStruct.make(), com.cliffc.aa.type.TypeTuple.make_args(), com.cliffc.aa.type.BitsAlias.new_alias(), com.cliffc.aa.type.Type< T extends Type< T >.NIL, com.cliffc.aa.type.TypeInt.NINT64, com.cliffc.aa.type.TypeFld.NO_DISP, com.cliffc.aa.type.TypeObj< O extends TypeObj< O >.OBJ, com.cliffc.aa.node.TestNodeSmall.perror(), com.cliffc.aa.type.BitsAlias.REC, com.cliffc.aa.type.TypeTuple.RET, com.cliffc.aa.type.TypeMemPtr.simple_ptr(), com.cliffc.aa.type.TypeStr.STR, com.cliffc.aa.node.TestNodeSmall.tmem(), com.cliffc.aa.Env.top_scope(), and com.cliffc.aa.type.Type< T extends Type< T >.XNIL.

Here is the call graph for this function:

◆ testRecursiveDisplay()

void com.cliffc.aa.node.TestNodeSmall.testRecursiveDisplay ( )

Definition at line 487 of file TestNodeSmall.java.

487  {
488  Env top = Env.top_scope();
489  GVNGCM gvn = Env.GVN;
490 
491  // Build the graph for the "fact" example:
492  // NewObj (display); inputs are prior display and FunPtr
493  // OProj
494  // DProj
495  // MemMerge; default mem and OProj
496  // Fun (and Fun._tf) - Just default control and some other control
497  // Parm:^ - Default display and DProj
498  // Parm:mem - Default mem and the MemMerge of OProj
499  // Ret - {Fun,Mem,Parm:^} - Not really fact() nor gen_ctr() code but upwards exposed closure
500  // FunPtr - Ret
501  gvn._opt_mode=GVNGCM.Mode.Parse;
502  ConNode ctl = gvn.init(new ConNode<>(Type.CTRL));
503  ctl._val = Type.CTRL;
504  ConNode mem = (ConNode)gvn.xform(new ConNode<>(TypeMem.ANYMEM)).keep();
505  ConNode rpc = (ConNode)gvn.xform(new ConNode<>(TypeRPC.ALL_CALL));
506  ConNode dsp_prims = (ConNode) gvn.xform(new ConNode<>(TypeMemPtr.DISP_SIMPLE));
507  // The file-scope display closing the graph-cycle. Needs the FunPtr, not
508  // yet built.
509  NewObjNode dsp_file = (NewObjNode)gvn.xform(new NewObjNode(true,TypeMemPtr.DISPLAY,dsp_prims));
510  MrgProjNode dsp_file_obj = Env.DEFMEM.make_mem_proj(dsp_file,mem);
511  ProjNode dsp_file_ptr = ( ProjNode)gvn.xform(new ProjNode(DSP_IDX, dsp_file));
512  Env.ALL_DISPLAYS = Env.ALL_DISPLAYS.set(dsp_file._alias);
513  // The Fun and Fun._tf:
515  TypeMem.MEM,
516  dsp_file_ptr._val, // File-scope display as arg0
517  Type.SCALAR)); // Some scalar arg1
518  TypeFunSig sig = TypeFunSig.make(TypeTuple.RET,formals);
519  FunNode fun = new FunNode(null,sig,-1,false);
520  gvn.init(fun.add_def(ctl).add_def(ctl)).unkeep();
521  // Parms for the Fun. Note that the default type is "weak" because the
522  // file-level display can not yet know about "fact".
523  ParmNode parm_mem = new ParmNode(MEM_IDX," mem",fun,mem,null);
524  gvn.xform(parm_mem.add_def(dsp_file_obj));
525  ParmNode parm_dsp = new ParmNode(DSP_IDX,"^" ,fun,Type.SCALAR,Node.con(dsp_file_ptr._val),null);
526  gvn.xform(parm_dsp.add_def(dsp_file_ptr));
527  // Close the function up
528  RetNode ret = gvn.init(new RetNode(fun,parm_mem,parm_dsp,rpc,fun));
529  FunPtrNode fptr = gvn.init(new FunPtrNode(ret,dsp_file_ptr));
530  // Close the cycle
531  dsp_file.create("fact",fptr,Access.Final);
532  dsp_file.no_more_fields();
533  // Return the fptr to keep all alive
534  ScopeNode env = new ScopeNode(null,true);
535  env.set_ctrl(ctl);
536  env.set_ptr (dsp_file_ptr);
537  env.set_mem (dsp_file_obj);
538  env.set_rez (fptr);
539  gvn.init(env);
540 
541  Node[] nodes = new Node[]{ctl,mem,rpc,dsp_prims,dsp_file,dsp_file_obj,dsp_file_ptr,fun,parm_mem,parm_dsp,ret,fptr,env};
542 
543  // Validate graph initial conditions. No optimizations, as this
544  // pile-o-bits is all dead and will vaporize if the optimizer is turned
545  // loose on it. Just check the types flow correctly.
546  gvn._opt_mode=GVNGCM.Mode.PesiNoCG;
547  for( Node n : nodes ) {
548  Type old = n._val;
549  Type nnn = n.value(gvn._opt_mode);
550  assert nnn.isa(old);
551  }
552 
553  // Now run GCP to closure. This is the key call being tested.
554  gvn.gcp(GVNGCM.Mode.Opto,env);
555 
556  // Validate cyclic display/function type
557  TypeFunPtr tfptr0 = (TypeFunPtr) fptr._val;
558  Type tdptr0 = tfptr0._disp;
559  Type tret = ((TypeTuple) ret._val).at(2);
560  assertEquals(tdptr0,tret); // Returning the display
561  // Display contains 'fact' pointing to self
562  TypeMem tmem = (TypeMem) dsp_file_obj._val;
563  TypeStruct tdisp0 = (TypeStruct)tmem.ld((TypeMemPtr)tdptr0);
564  assertEquals(tfptr0,tdisp0.at(tdisp0.fld_find("fact")));
565  }

References com.cliffc.aa.node.NewNode< T extends TypeObj< T >._alias, com.cliffc.aa.type.TypeFunPtr._disp, com.cliffc.aa.GVNGCM._opt_mode, com.cliffc.aa.node.Node._val, com.cliffc.aa.node.Node.add_def(), com.cliffc.aa.type.TypeRPC.ALL_CALL, com.cliffc.aa.Env.ALL_DISPLAYS, com.cliffc.aa.type.TypeMem.ANYMEM, com.cliffc.aa.node.Node.con(), com.cliffc.aa.node.NewObjNode.create(), com.cliffc.aa.type.Type< T extends Type< T >.CTRL, com.cliffc.aa.Env.DEFMEM, com.cliffc.aa.type.TypeMemPtr.DISP_SIMPLE, com.cliffc.aa.type.TypeMemPtr.DISPLAY, com.cliffc.aa.type.TypeFld.Access.Final, com.cliffc.aa.GVNGCM.gcp(), com.cliffc.aa.Env.GVN, com.cliffc.aa.GVNGCM.init(), com.cliffc.aa.type.Type< T extends Type< T >.isa(), com.cliffc.aa.type.TypeMem.ld(), com.cliffc.aa.type.TypeFunSig.make(), com.cliffc.aa.type.TypeTuple.make_args(), com.cliffc.aa.type.TypeMem.MEM, com.cliffc.aa.node.NewObjNode.no_more_fields(), com.cliffc.aa.GVNGCM.Mode.Opto, com.cliffc.aa.GVNGCM.Mode.Parse, com.cliffc.aa.GVNGCM.Mode.PesiNoCG, com.cliffc.aa.type.TypeTuple.RET, com.cliffc.aa.type.Type< T extends Type< T >.SCALAR, com.cliffc.aa.type.Bits< B extends Bits< B >.set(), com.cliffc.aa.node.ScopeNode.set_ctrl(), com.cliffc.aa.node.ScopeNode.set_mem(), com.cliffc.aa.node.ScopeNode.set_ptr(), com.cliffc.aa.node.ScopeNode.set_rez(), com.cliffc.aa.node.TestNodeSmall.tmem(), com.cliffc.aa.Env.top_scope(), com.cliffc.aa.type.Types.ts(), and com.cliffc.aa.GVNGCM.xform().

Here is the call graph for this function:

◆ testUnresolvedAdd()

void com.cliffc.aa.node.TestNodeSmall.testUnresolvedAdd ( )

Definition at line 20 of file TestNodeSmall.java.

20  {
21  Env top = Env.top_scope();
22  GVNGCM gvn = Env.GVN;
23 
24  // Current theory on Unresolved: Call.resolve moves closer to the centerline:
25  // LOW fidxs are all must-calls, and removing one LIFTS . If args are MEET, removing LIFTS.
26  // HIGH fidxs are all may -calls, and removing one LOWERS. If args are JOIN, removing LOWERS.
27 
28  // Phi: always MEET, so highs meet to empty; and lows MEET.
29  // During GCP fidxs are high, then move to low.
30  // Call.resolve: choices get removed which lifts or lowers
31 
32  // WANT: During GCP, high choices fed to Call.resolve. Choices get removed, which LOWERS resolved.
33  // Means Unresolved during GCP produces only HIGH choices.
34  // WANT: During Iter, low choices fed to Call.resolve. Choices get removed, which LIFTS resolved.
35  // Means Unresolved during ITER produces only LOW choices.
36  // WANT: Same behavior during GCP and ITER, but doesn't appear I can have that.
37 
38  // Unresolved: ITER: all is MEET and no FIDX goes HIGH (except for dead/dying).
39 
40  // Unresolved: GCP : if FunPtr above center optional to ignore or JOIN.
41  // if FunPtr below center, flip to high and JOIN. Also high/ignore args kept high, and low args moved high for JOIN.
42  // Kinda sorta looks like: use startype on incoming, and JOIN.
43 
44  gvn._opt_mode=GVNGCM.Mode.Parse;
45  UnresolvedNode uadd = (UnresolvedNode)top.lookup("+"); // {int int -> int} and {flt flt -> flt} and {str str -> str}
46  FunPtrNode aflt = (FunPtrNode)uadd.in(0);
47  FunPtrNode aint = (FunPtrNode)uadd.in(1);
48  FunPtrNode astr = (FunPtrNode)uadd.in(2);
49  // Make a flt/int combo, drops off string.
50  UnresolvedNode anum = (UnresolvedNode)gvn.xform(new UnresolvedNode(null,aflt,aint));
51 
52  // All nodes have this property: START >= {ALL.dual(),value(START)} >= value(ALL.dual()) >= value(ALL) >= ALL
53  // Holds for both ITER and GCP.
54 
55 
56  // Compute Node.all_type() and all_type.startype()
57  Type uaddALL = uadd._val, uaddSTART = Type.ANY;
58  Type anumALL = anum._val, anumSTART = Type.ANY;
59  Type afltALL = aflt._val, afltSTART = Type.ANY;
60  Type aintALL = aint._val, aintSTART = Type.ANY;
61  Type astrALL = astr._val, astrSTART = Type.ANY;
62 
63  // Compute Node.value() where initial GVN is startype()
64  uadd._val = uaddSTART;
65  anum._val = anumSTART;
66  aflt._val = afltSTART;
67  aint._val = aintSTART;
68  astr._val = astrSTART;
69  gvn._opt_mode=GVNGCM.Mode.PesiNoCG;
70  Type uaddVAL1START = uadd.value(gvn._opt_mode);
71  Type anumVAL1START = anum.value(gvn._opt_mode);
72  Type afltVAL1START = aflt.value(gvn._opt_mode);
73  Type aintVAL1START = aint.value(gvn._opt_mode);
74  Type astrVAL1START = astr.value(gvn._opt_mode);
75  gvn._opt_mode=GVNGCM.Mode.Opto;
76  Type uaddVAL2START = uadd.value(gvn._opt_mode);
77  Type anumVAL2START = anum.value(gvn._opt_mode);
78  Type afltVAL2START = aflt.value(gvn._opt_mode);
79  Type aintVAL2START = aint.value(gvn._opt_mode);
80  Type astrVAL2START = astr.value(gvn._opt_mode);
81 
82  // Compute Node.value() where initial GVN is all_type.dual()
83  uadd._val = uaddALL.dual();
84  anum._val = anumALL.dual();
85  aflt._val = afltALL.dual();
86  aint._val = aintALL.dual();
87  astr._val = astrALL.dual();
88  gvn._opt_mode=GVNGCM.Mode.PesiNoCG;
89  Type uaddVAL1XALL = uadd.value(gvn._opt_mode);
90  Type anumVAL1XALL = anum.value(gvn._opt_mode);
91  Type afltVAL1XALL = aflt.value(gvn._opt_mode);
92  Type aintVAL1XALL = aint.value(gvn._opt_mode);
93  Type astrVAL1XALL = astr.value(gvn._opt_mode);
94  gvn._opt_mode=GVNGCM.Mode.Opto;
95  Type uaddVAL2XALL = uadd.value(gvn._opt_mode);
96  Type anumVAL2XALL = anum.value(gvn._opt_mode);
97  Type afltVAL2XALL = aflt.value(gvn._opt_mode);
98  Type aintVAL2XALL = aint.value(gvn._opt_mode);
99  Type astrVAL2XALL = astr.value(gvn._opt_mode);
100 
101  // Compute Node.value() where initial GVN is all_type()
102  uadd._val = uaddALL;
103  anum._val = uaddALL;
104  aflt._val = afltALL;
105  aint._val = aintALL;
106  astr._val = astrALL;
107  gvn._opt_mode=GVNGCM.Mode.PesiNoCG;
108  Type uaddVAL1ALL = uadd.value(gvn._opt_mode);
109  Type anumVAL1ALL = anum.value(gvn._opt_mode);
110  Type afltVAL1ALL = aflt.value(gvn._opt_mode);
111  Type aintVAL1ALL = aint.value(gvn._opt_mode);
112  Type astrVAL1ALL = astr.value(gvn._opt_mode);
113  gvn._opt_mode=GVNGCM.Mode.Opto;
114  Type uaddVAL2ALL = uadd.value(gvn._opt_mode);
115  Type anumVAL2ALL = anum.value(gvn._opt_mode);
116  Type afltVAL2ALL = aflt.value(gvn._opt_mode);
117  Type aintVAL2ALL = aint.value(gvn._opt_mode);
118  Type astrVAL2ALL = astr.value(gvn._opt_mode);
119 
120  Type[] uadds = new Type[]{uaddSTART,uaddALL.dual(),uaddVAL1START,uaddVAL2START,uaddVAL1XALL,uaddVAL2XALL,uaddVAL1ALL,uaddVAL2ALL,uaddALL};
121  Type[] anums = new Type[]{anumSTART,anumALL.dual(),anumVAL1START,anumVAL2START,anumVAL1XALL,anumVAL2XALL,anumVAL1ALL,anumVAL2ALL,anumALL};
122  Type[] aflts = new Type[]{afltSTART,afltALL.dual(),afltVAL1START,afltVAL2START,afltVAL1XALL,afltVAL2XALL,afltVAL1ALL,afltVAL2ALL,afltALL};
123  Type[] aints = new Type[]{aintSTART,aintALL.dual(),aintVAL1START,aintVAL2START,aintVAL1XALL,aintVAL2XALL,aintVAL1ALL,aintVAL2ALL,aintALL};
124  Type[] astrs = new Type[]{astrSTART,astrALL.dual(),astrVAL1START,astrVAL2START,astrVAL1XALL,astrVAL2XALL,astrVAL1ALL,astrVAL2ALL,astrALL};
125  Type[][] tfpss = new Type[][]{aflts,aints,astrs,anums,uadds};
126 
127  // All nodes have these properties:
128  // START >= {ALL.dual(),value1(START)} >= value1(ALL.dual()) >= value1(ALL) >= ALL
129  // START >= {ALL.dual(),value2(START)} >= value2(ALL.dual()) >= value2(ALL) >= ALL
130  for( Type[] tfps : tfpss ) {
131  Type start = tfps[0], xall = tfps[1], val1s = tfps[2], val2s = tfps[3];
132  Type val1x = tfps[4], val2x = tfps[5], val1a = tfps[6], val2a = tfps[7];
133  Type all = tfps[8];
134 
135  assertTrue(start.isa(xall ));
136  assertTrue(start.isa(val1s)); assertTrue(start.isa(val2s));
137  assertTrue(xall .isa(val1x)); assertTrue(xall .isa(val2x));
138  assertTrue(val1s.isa(val1x)); assertTrue(val2s.isa(val2x));
139  assertTrue(val1x.isa(val1a)); assertTrue(val2x.isa(val2a));
140  assertTrue(val1a.isa(all )); assertTrue(val2a.isa(all ));
141  }
142 
143  // Also, for CallNode.resolve we want the properties:
144  // UnresolvedAdd.XAll >= AnumAdd.Xall} >= {Flt,Int,Str}XAdd.All-- Removing a choice during GCP lowers
145  // {Flt,Int,Str}Add.ALL >= AnumAdd.ALL >= UnresolvedAdd.All -- Removing a choice during ITER lifts
146  assertTrue(uaddALL.dual().isa(anumALL.dual()));
147  assertTrue(anumALL.dual().isa(afltALL.dual()));
148  assertTrue(anumALL.dual().isa(aintALL.dual()));
149  assertTrue(uaddALL.dual().isa(astrALL.dual()));
150 
151  assertTrue(astrALL.isa(uaddALL));
152  assertTrue(aintALL.isa(anumALL));
153  assertTrue(afltALL.isa(anumALL));
154  assertTrue(anumALL.isa(uaddALL));
155 
156  }

References com.cliffc.aa.GVNGCM._opt_mode, com.cliffc.aa.node.Node._val, com.cliffc.aa.type.Type< T extends Type< T >.ANY, com.cliffc.aa.type.Type< T extends Type< T >.dual(), com.cliffc.aa.Env.GVN, com.cliffc.aa.node.Node.in(), com.cliffc.aa.type.Type< T extends Type< T >.isa(), com.cliffc.aa.Env.lookup(), com.cliffc.aa.GVNGCM.Mode.Opto, com.cliffc.aa.GVNGCM.Mode.Parse, com.cliffc.aa.GVNGCM.Mode.PesiNoCG, com.cliffc.aa.Env.top_scope(), com.cliffc.aa.node.UnresolvedNode.value(), com.cliffc.aa.node.FunPtrNode.value(), and com.cliffc.aa.GVNGCM.xform().

Here is the call graph for this function:

◆ tmem()

static TypeMem com.cliffc.aa.node.TestNodeSmall.tmem ( int[]  as,
TypeObj...  ts 
)
staticprivate

Definition at line 727 of file TestNodeSmall.java.

727  {
728  int max = BitsAlias.AARY;
729  if( as !=null && as.length> 0 ) max = Math.max(max,as[as.length-1]);
730  TypeObj[] tos = new TypeObj[max+1];
731  tos[BitsAlias.ALL] = TypeObj.OBJ;
733  tos[BitsAlias.ABC] = TypeStr.ABC; //
734  tos[BitsAlias.STR] = TypeStr.STR;
735  tos[BitsAlias.AARY] = TypeAry.ARY;
736  if( as != null )
737  for( int i=0; i<as.length; i++ )
738  tos[as[i]] = ts[i];
739  return TypeMem.make0(tos);
740  }

References com.cliffc.aa.type.BitsAlias.AARY, com.cliffc.aa.type.BitsAlias.ABC, com.cliffc.aa.type.TypeStr.ABC, com.cliffc.aa.type.BitsAlias.ALL, com.cliffc.aa.type.TypeStruct.ALLSTRUCT, com.cliffc.aa.type.TypeAry.ARY, com.cliffc.aa.type.TypeMem.make0(), com.cliffc.aa.type.TypeObj< O extends TypeObj< O >.OBJ, com.cliffc.aa.type.BitsAlias.REC, com.cliffc.aa.type.BitsAlias.STR, and com.cliffc.aa.type.TypeStr.STR.

Referenced by com.cliffc.aa.node.TestNodeSmall.check(), com.cliffc.aa.node.TestNodeSmall.testMemoryArgs(), and com.cliffc.aa.node.TestNodeSmall.testRecursiveDisplay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ v()

static TypeFunPtr com.cliffc.aa.node.TestNodeSmall.v ( Node  n,
GVNGCM  gvn 
)
staticprivate

Definition at line 209 of file TestNodeSmall.java.

209 { return (TypeFunPtr)n.value(gvn._opt_mode); }

References com.cliffc.aa.GVNGCM._opt_mode, and com.cliffc.aa.node.Node.value().

Referenced by com.cliffc.aa.node.TestNodeSmall.testCallNodeResolve().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ ERR

int com.cliffc.aa.node.TestNodeSmall.ERR =0
staticprivate

The documentation for this class was generated from the following file:
com.cliffc.aa.type.TypeFld.Access.Final
Final
Definition: TypeFld.java:112
com.cliffc.aa.type.TypeMemPtr.NO_DISP
static final Type NO_DISP
Definition: TypeMemPtr.java:80
com.cliffc.aa.type.BitsFun.EMPTY
static final BitsFun EMPTY
Definition: BitsFun.java:37
com.cliffc.aa.type.TypeMem.ld
TypeObj ld(TypeMemPtr ptr)
Definition: TypeMem.java:325
com.cliffc.aa.type.TypeFunPtr
Definition: TypeFunPtr.java:23
com.cliffc.aa.node.TestNodeSmall.ERR
static int ERR
Definition: TestNodeSmall.java:589
com.cliffc.aa.node.TestNodeSmall.tmem
static TypeMem tmem(int[] as, TypeObj... ts)
Definition: TestNodeSmall.java:727
com.cliffc.aa.type.TypeTuple.make_args
static TypeTuple make_args(Type[] ts)
Definition: TypeTuple.java:106
com.cliffc.aa.type.Type.isa
boolean isa(Type t)
Definition: Type.java:623
com.cliffc.aa.type.TypeMemPtr.ABCPTR
static final TypeMemPtr ABCPTR
Definition: TypeMemPtr.java:99
com.cliffc.aa.type.TypeMem
Memory type; the state of all of memory; memory edges order memory ops.
Definition: TypeMem.java:53
com.cliffc.aa.type.Type.SCALAR
static final Type SCALAR
Definition: Type.java:328
com.cliffc.aa.Env.top_scope
static Env top_scope()
Definition: Env.java:72
com.cliffc.aa.type.BitsAlias.AARY
static final int AARY
Definition: BitsAlias.java:25
com.cliffc.aa.type.TypeFld
Definition: TypeFld.java:12
com.cliffc.aa.type.Type.XSCALAR
static final Type XSCALAR
Definition: Type.java:329
com.cliffc.aa.type.TypeRPC.ALL_CALL
static final TypeRPC ALL_CALL
Definition: TypeRPC.java:31
com.cliffc.aa.type.TypeInt
Definition: TypeInt.java:9
com.cliffc.aa.type.Type
an implementation of language AA
Definition: Type.java:94
com.cliffc.aa.type.TypeFunSig.make
static TypeFunSig make(String[] args, TypeTuple formals, TypeTuple ret)
Definition: TypeFunSig.java:71
com.cliffc.aa.type.TypeFlt
Definition: TypeFlt.java:9
com.cliffc.aa.type.TypeStruct.ALLSTRUCT
static final TypeStruct ALLSTRUCT
Definition: TypeStruct.java:228
com.cliffc.aa.type.BitsAlias
Definition: BitsAlias.java:8
com.cliffc.aa.type.TypeTuple
Definition: TypeTuple.java:11
com.cliffc.aa.type.TypeFld.NO_DISP
static final TypeFld NO_DISP
Definition: TypeFld.java:170
com.cliffc.aa.type.TypeInt.con
static TypeInt con(long con)
Definition: TypeInt.java:37
com.cliffc.aa.node.Node.unelock
void unelock()
Definition: Node.java:128
com.cliffc.aa.type.TypeFunPtr.fidxs
BitsFun fidxs()
Definition: TypeFunPtr.java:127
com.cliffc.aa.type.Type.ANY
static final Type ANY
Definition: Type.java:325
com.cliffc.aa.type.BitsAlias.new_alias
static int new_alias(int par)
Definition: BitsAlias.java:75
com.cliffc.aa.node.Node.add_def
Node add_def(Node n)
Definition: Node.java:152
com.cliffc.aa.type.TypeAry
Definition: TypeAry.java:7
com.cliffc.aa.type.Type.meet
final Type meet(Type t)
Definition: Type.java:412
com.cliffc.aa.node.FunNode.formal
Type formal(int idx)
Definition: FunNode.java:187
com.cliffc.aa.type.TypeStruct
A memory-based collection of optionally named fields.
Definition: TypeStruct.java:50
com.cliffc.aa.type.TypeFld.make
static TypeFld make(String fld, Type t, int order)
Definition: TypeFld.java:58
com.cliffc.aa.node.TestNodeSmall.v
static TypeFunPtr v(Node n, GVNGCM gvn)
Definition: TestNodeSmall.java:209
com.cliffc.aa.Env.ALL_DISPLAYS
static BitsAlias ALL_DISPLAYS
Definition: Env.java:28
com.cliffc.aa.type.TypeMem.ANYMEM
static final TypeMem ANYMEM
Definition: TypeMem.java:228
com.cliffc.aa.type.Types
Definition: Types.java:9
com.cliffc.aa.Env.lookup
Node lookup(String name)
Definition: Env.java:186
com.cliffc.aa.type.Types.ts
static Type[] ts(Type t0)
Definition: Types.java:90
com.cliffc.aa.type.BitsAlias.REC
static final int REC
Definition: BitsAlias.java:25
com.cliffc.aa.type.TypeMem.make0
static TypeMem make0(TypeObj[] as)
Definition: TypeMem.java:170
com.cliffc.aa.Env.GVN
static final GVNGCM GVN
Definition: Env.java:13
com.cliffc.aa.type.TypeInt.INT64
static final TypeInt INT64
Definition: TypeInt.java:39
com.cliffc.aa.type.TypeObj.OBJ
static final TypeObj OBJ
Definition: TypeObj.java:44
com.cliffc.aa.type.TypeMemPtr.DISP_SIMPLE
static final TypeMemPtr DISP_SIMPLE
Definition: TypeMemPtr.java:105
com.cliffc.aa.type.TypeObj
Definition: TypeObj.java:15
com.cliffc.aa.node.Node.unkeep
public< N extends Node > N unkeep()
Definition: Node.java:232
com.cliffc.aa.type.TypeAry.ARY
static final TypeAry ARY
Definition: TypeAry.java:44
com.cliffc.aa.type.TypeTuple.RET
static final TypeTuple RET
Definition: TypeTuple.java:130
com.cliffc.aa.node.TestNodeSmall._testMonotonicChain
Type[] _testMonotonicChain(Node[] ins, Node n, TypeTuple[] argss)
Definition: TestNodeSmall.java:158
com.cliffc.aa.type.TypeMemPtr.DISPLAY
static final TypeStruct DISPLAY
Definition: TypeMemPtr.java:78
com.cliffc.aa.type.TypeFunPtr._disp
Type _disp
Definition: TypeFunPtr.java:28
com.cliffc.aa.type.TypeStr.ABC
static final TypeStr ABC
Definition: TypeStr.java:47
com.cliffc.aa.type.BitsAlias.ALL
static final int ALL
Definition: BitsAlias.java:25
com.cliffc.aa.type.Type.CTRL
static final Type CTRL
Definition: Type.java:326
com.cliffc.aa.type.TypeInt.INT32
static final TypeInt INT32
Definition: TypeInt.java:40
com.cliffc.aa.type.TypeTuple.make
static TypeTuple make(boolean any, Type[] ts)
Definition: TypeTuple.java:82
com.cliffc.aa.node.TestNodeSmall.perror
static void perror(String msg, Type t1, Type t2)
Definition: TestNodeSmall.java:719
com.cliffc.aa.node.Node.in
Node in(int i)
Definition: Node.java:126
com.cliffc.aa.type.TypeMemPtr.STRUCT
static final TypeMemPtr STRUCT
Definition: TypeMemPtr.java:101
com.cliffc.aa.type.Type.XCTRL
static final Type XCTRL
Definition: Type.java:327
com.cliffc.aa.type.TypeFunPtr.make
static TypeFunPtr make(BitsFun fidxs, int nargs, Type disp)
Definition: TypeFunPtr.java:67
com.cliffc.aa.type.Type.sharptr
Type sharptr(Type ptr)
Definition: Type.java:930
com.cliffc.aa.type.Type.init
T init(byte type, String name)
Definition: Type.java:105
com.cliffc.aa.type.BitsAlias.ABC
static final int ABC
Definition: BitsAlias.java:25
com.cliffc.aa.type.Type.simple_ptr
Type simple_ptr()
Definition: Type.java:358
com.cliffc.aa.type.TypeStr
Definition: TypeStr.java:14
com.cliffc.aa.type.BitsFun
Definition: BitsFun.java:7
com.cliffc.aa.type.Type.NIL
static final Type NIL
Definition: Type.java:332
com.cliffc.aa.GVNGCM.Mode.Mode
Mode(boolean CG)
Definition: GVNGCM.java:20
com.cliffc.aa.type.TypeMemPtr.simple_ptr
Type simple_ptr()
Definition: TypeMemPtr.java:160
com.cliffc.aa.type.TypeInt.NINT64
static final TypeInt NINT64
Definition: TypeInt.java:48
com.cliffc.aa.type.TypeTuple.at
Type at(int idx)
Definition: TypeTuple.java:182
com.cliffc.aa.type.TypeFunSig
Definition: TypeFunSig.java:10
com.cliffc.aa.type.Type.dual
final T dual()
Definition: Type.java:361
com.cliffc.aa.type.TypeStruct.make
static TypeStruct make(String fld_name, Type t)
Definition: TypeStruct.java:190
com.cliffc.aa.node.TestNodeSmall.check
static Type[] check(GVNGCM gvn, TypeFunSig tsig, TypeMem tmem, Type targ1, Type targ2)
Definition: TestNodeSmall.java:681
com.cliffc.aa.type.TypeRPC
Definition: TypeRPC.java:7
com.cliffc.aa.GVNGCM._opt_mode
Mode _opt_mode
Definition: GVNGCM.java:22
com.cliffc.aa.type.Type.XNIL
static final Type XNIL
Definition: Type.java:333
com.cliffc.aa.type.TypeStr.STR
static final TypeStr STR
Definition: TypeStr.java:45
com.cliffc.aa.type.TypeFld.Access
Definition: TypeFld.java:109
com.cliffc.aa.node.FunNode
Definition: FunNode.java:58
com.cliffc.aa.type.Bits.set
B set(int bit)
Definition: Bits.java:264
com.cliffc.aa.type.TypeMem.MEM
static final TypeMem MEM
Definition: TypeMem.java:224
com.cliffc.aa.Env.DEFMEM
static DefMemNode DEFMEM
Definition: Env.java:19
com.cliffc.aa.Env
Definition: Env.java:12
com.cliffc.aa.type.BitsAlias.STR
static final int STR
Definition: BitsAlias.java:25
com.cliffc.aa.type.TypeMemPtr
Definition: TypeMemPtr.java:14
com.cliffc.aa.type.TypeFlt.FLT64
static final TypeFlt FLT64
Definition: TypeFlt.java:38
com.cliffc.aa.type.TypeMemPtr.make
static TypeMemPtr make(BitsAlias aliases, TypeObj obj)
Definition: TypeMemPtr.java:66