aa
PrimNode.java
Go to the documentation of this file.
1 package com.cliffc.aa.node;
2 
3 import com.cliffc.aa.*;
4 import com.cliffc.aa.type.*;
5 import com.cliffc.aa.util.Ary;
6 
7 import java.util.ArrayList;
8 import java.util.Collections;
9 import java.util.HashSet;
10 
11 import static com.cliffc.aa.AA.*;
12 
13 // Primitives can be used as an internal operator (their apply() call does the
14 // primitive operation). Primitives are wrapped as functions when returned
15 // from Env lookup, although the immediate lookup+apply is optimized to just
16 // make a new primitive. See FunNode for function Node structure.
17 //
18 // Fun/Parm-per-arg/Prim/Ret
19 //
20 public abstract class PrimNode extends Node {
21  public final String _name; // Unique name (and program bits)
22  final TypeFunSig _sig; // Argument types; 0 is display, 1 is 1st real arg
23  Parse[] _badargs; // Filled in when inlined in CallNode
24  byte _op_prec; // Operator precedence, computed from table. Generally 1-9.
25  public boolean _thunk_rhs; // Thunk (delay) right-hand-argument.
26  PrimNode( String name, TypeTuple formals, Type ret ) { this(name,null,formals,ret); }
27  PrimNode( String name, String[] args, TypeTuple formals, Type ret ) {
28  super(OP_PRIM);
29  _name=name;
30  assert formals.at(MEM_IDX)==TypeMem.ALLMEM && formals.at(DSP_IDX)==Type.ALL; // Room for no closure; never memory
31  _sig=TypeFunSig.make(args==null ? TypeFunSig.func_names : args,formals,TypeTuple.make_ret(ret));
32  _badargs=null;
33  _op_prec = -1; // Not set yet
34  _thunk_rhs=false;
35  }
36  private static PrimNode[] PRIMS = null; // All primitives
37  public static PrimNode[][] PRECEDENCE = null; // Just the binary operators, grouped by precedence
38  public static String [][] PREC_TOKS = null; // Just the binary op tokens, grouped by precedence
39  public static String [] PRIM_TOKS = null; // Primitive tokens, longer first for greedy token search
40  public static void reset() { PRIMS=null; }
41 
42  public static PrimNode[] PRIMS() {
43  if( PRIMS!=null ) return PRIMS;
44 
45  // Binary-operator primitives, sorted by precedence
46  PRECEDENCE = new PrimNode[][]{
47 
48  {new MulF64(), new DivF64(), new MulI64(), new DivI64(), new ModI64(), },
49 
50  {new AddF64(), new SubF64(), new AddI64(), new SubI64() },
51 
52  {new LT_F64(), new LE_F64(), new GT_F64(), new GE_F64(),
53  new LT_I64(), new LE_I64(), new GT_I64(), new GE_I64(),},
54 
55  {new EQ_F64(), new NE_F64(), new EQ_I64(), new NE_I64(), new EQ_OOP(), new NE_OOP(), },
56 
57  {new AndI64(), },
58 
59  {new OrI64(), },
60 
61  {new AndThen(), },
62 
63  {new OrElse(), },
64 
65  };
66 
67  // Other primitives, not binary operators
68  PrimNode[] others = new PrimNode[] {
69  // These are called like a function
70  new RandI64(),
71  new Id(TypeMemPtr.ISUSED0), // Pre-split OOP from non-OOP
73  new Id(Type.REAL),
74 
75  new ConvertInt64F64(),
76  new ConvertStrStr(),
77 
78  // These are balanced-ops, called by Parse.term()
79  new MemPrimNode.ReadPrimNode.LValueRead (), // Read an L-Value: (ary,idx) ==> elem
80  new MemPrimNode.ReadPrimNode.LValueWrite (), // Write an L-Value: (ary,idx,elem) ==> elem
81  new MemPrimNode.ReadPrimNode.LValueWriteFinal(), // Final Write an L-Value: (ary,idx,elem) ==> elem
82  };
83 
84  // These are unary ops, precedence determined outside of 'Parse.expr'
85  PrimNode[] uniops = new PrimNode[] {
86  new MemPrimNode.ReadPrimNode.LValueLength(), // The other array ops are "balanced ops" and use term() for precedence
87  new MinusF64(),
88  new MinusI64(),
89  new Not(),
90  };
91 
92  Ary<PrimNode> allprims = new Ary<>(others);
93  for( PrimNode prim : uniops ) allprims.push(prim);
94  for( PrimNode[] prims : PRECEDENCE )
95  for( PrimNode prim : prims )
96  allprims.push(prim);
97  PRIMS = allprims.asAry();
98 
99  // Compute precedence from table
100  int max_prec = PRECEDENCE.length;
101  for( int p=0; p<PRECEDENCE.length; p++ )
102  for( PrimNode n : PRECEDENCE[p] )
103  n._op_prec = (byte)(max_prec-p);
104  // Not used to determine precedence, just a uniop flag
105  for( PrimNode prim : uniops ) prim._op_prec = (byte)max_prec;
106 
107  // Compute greedy primitive names, without regard to precedence.
108  // Example from Java: >,>=,>>,>>=,>>>,>>>= are all valid tokens.
109  HashSet<String> hash = new HashSet<>(); // Remove dups
110  for( PrimNode[] prims : PRECEDENCE )
111  for( PrimNode prim : prims )
112  hash.add(prim._name);
113  ArrayList<String> list = new ArrayList<>(hash);
114  Collections.sort(list); // Longer strings on the right
115  Collections.reverse(list); // Longer strings on the left, match first.
116  PRIM_TOKS = list.toArray(new String[0]);
117 
118  // Compute precedence token groupings for parser
119  PREC_TOKS = new String[max_prec+1][];
120  for( int p=0; p<max_prec; p++ ) {
121  String[] toks = PREC_TOKS[p+1] = new String[PRECEDENCE[max_prec-1-p].length];
122  for( int i=0; i<toks.length; i++ )
123  toks[i] = PRECEDENCE[max_prec-1-p][i]._name;
124  }
125 
126  return PRIMS;
127  }
128 
129  public static PrimNode convertTypeName( Type from, Type to, Parse badargs ) {
130  return new ConvertTypeName(from,to,badargs);
131  }
132 
133  // Apply types are 1-based (same as the incoming node index), and not
134  // zero-based (not same as the _formals and _args fields).
135  public abstract Type apply( Type[] args ); // Execute primitive
136  @Override public String xstr() { return _name+":"+_sig._formals.at(ARG_IDX); }
137  @Override public Type value(GVNGCM.Mode opt_mode) {
138  Type[] ts = new Type[_defs._len]; // 1-based
139  // If all inputs are constants we constant fold. If any input is high, we
140  // return high otherwise we return low.
141  boolean is_con = true, has_high = false;
142  for( int i=1; i<_defs._len; i++ ) { // first is control
143  Type tactual = val(i);
144  Type tformal = _sig.arg(i+ARG_IDX-1); // first is control
145  Type t = tformal.dual().meet(ts[i] = tactual);
146  if( !t.is_con() ) {
147  is_con = false; // Some non-constant
148  if( t.above_center() ) has_high=true;
149  }
150  }
151  Type rez = _sig._ret.at(REZ_IDX); // Ignore control,memory from primitive
152  return is_con ? apply(ts) : (has_high ? rez.dual() : rez);
153  }
154  @Override public ErrMsg err( boolean fast ) {
155  for( int i=1; i<_defs._len; i++ ) { // first is control
156  Type tactual = val(i);
157  Type tformal = _sig.arg(i+ARG_IDX-1).simple_ptr(); // 0 is display, 1 is memory, 2 is first real arg
158  if( !tactual.isa(tformal) )
159  return _badargs==null ? ErrMsg.BADARGS : ErrMsg.typerr(_badargs[i],tactual,null,tformal);
160  }
161  return null;
162  }
163  // Prims are equal for same-name-same-signature (and same inputs).
164  // E.g. float-minus of x and y is NOT the same as int-minus of x and y
165  // despite both names being '-'.
166  @Override public int hashCode() { return super.hashCode()+_name.hashCode()+_sig._hash; }
167  @Override public boolean equals(Object o) {
168  if( this==o ) return true;
169  if( !super.equals(o) ) return false;
170  if( !(o instanceof PrimNode) ) return false;
171  PrimNode p = (PrimNode)o;
172  return _name.equals(p._name) && _sig==p._sig;
173  }
174 
175  // Called during basic Env creation and making of type constructors, this
176  // wraps a PrimNode as a full 1st-class function to be passed about or
177  // assigned to variables.
178  public FunPtrNode as_fun( GVNGCM gvn ) {
179  try(GVNGCM.Build<FunPtrNode> X = gvn.new Build<>()) {
180  assert _defs._len==0 && _uses._len==0;
181  FunNode fun = (FunNode) X.xform(new FunNode(this).add_def(Env.ALL_CTRL)); // Points to ScopeNode only
182  Node rpc = X.xform(new ParmNode(0,"rpc",fun,Env.ALL_CALL,null));
183  add_def(_thunk_rhs ? fun : null); // Control for the primitive in slot 0
184  Node mem = X.xform(new ParmNode(MEM_IDX,_sig._args[MEM_IDX],fun,TypeMem.MEM,Env.DEFMEM,null));
185  if( _thunk_rhs ) add_def(mem); // Memory if thunking
186  for( int i=ARG_IDX; i<_sig.nargs(); i++ ) // First is display, always ignored in primitives
187  add_def(X.xform(new ParmNode(i,_sig._args[i],fun, Env.ALL,null)));
188  Node that = X.xform(this);
189  Node ctl,rez;
190  if( _thunk_rhs ) {
191  ctl = X.xform(new CProjNode(that));
192  mem = X.xform(new MProjNode(that));
193  rez = X.xform(new ProjNode(that,AA.REZ_IDX));
194  Env.GVN.add_grow(that);
195  } else {
196  ctl = fun;
197  rez = that;
198  }
199  // Functions return the set of *modified* memory. Most PrimNodes never
200  // *modify* memory (see Intrinsic*Node for some primitives that *modify*
201  // memory). Thunking (short circuit) prims return both memory and a value.
202  RetNode ret = (RetNode)X.xform(new RetNode(ctl,mem,rez,rpc,fun));
203  // No closures are added to primitives
204  return (X._ret = new FunPtrNode(_name,ret));
205  }
206  }
207 
208 
209  // --------------------
210  // Default name constructor using a single tuple type
211  static class ConvertTypeName extends PrimNode {
212  ConvertTypeName(Type from, Type to, Parse badargs) {
213  super(to._name,TypeTuple.make_args(from),to);
214  _badargs = new Parse[]{badargs};
215  }
216  @Override public Type value(GVNGCM.Mode opt_mode) {
217  Type[] ts = new Type[_defs._len];
218  for( int i=1; i<_defs._len; i++ )
219  ts[i] = _defs.at(i)._val;
220  return apply(ts); // Apply (convert) even if some args are not constant
221  }
222  @Override public Type apply( Type[] args ) {
223  Type actual = args[1];
224  if( actual==Type.ANY || actual==Type.ALL ) return actual;
225  Type formal = _sig.arg(ARG_IDX);
226  // Wrapping function will not inline if args are in-error
227  assert formal.dual().isa(actual) && actual.isa(formal);
228  return actual.set_name(_sig._ret.at(REZ_IDX)._name);
229  }
230  @Override public ErrMsg err( boolean fast ) {
231  Type actual = val(1);
232  Type formal = _sig.arg(ARG_IDX);
233  if( !actual.isa(formal) ) // Actual is not a formal
234  return ErrMsg.typerr(_badargs[0],actual,null,formal);
235  return null;
236  }
237  }
238 
239  static class ConvertInt64F64 extends PrimNode {
241  @Override public Type apply( Type[] args ) { return TypeFlt.con((double)args[1].getl()); }
242  }
243 
244  // TODO: Type-check strptr input args
245  static class ConvertStrStr extends PrimNode {
247  @Override public Node ideal_reduce() { return in(1); }
248  @Override public Type value(GVNGCM.Mode opt_mode) { return val(1); }
249  @Override public TypeInt apply( Type[] args ) { throw AA.unimpl(); }
250  }
251 
252  // 1Ops have uniform input/output types, so take a shortcut on name printing
253  abstract static class Prim1OpF64 extends PrimNode {
254  Prim1OpF64( String name ) { super(name,TypeTuple.FLT64,TypeFlt.FLT64); }
255  public Type apply( Type[] args ) { return TypeFlt.con(op(args[1].getd())); }
256  abstract double op( double d );
257  }
258 
259  static class MinusF64 extends Prim1OpF64 {
260  MinusF64() { super("-"); }
261  @Override double op( double d ) { return -d; }
262  }
263 
264  // 1Ops have uniform input/output types, so take a shortcut on name printing
265  abstract static class Prim1OpI64 extends PrimNode {
266  Prim1OpI64( String name ) { super(name,TypeTuple.INT64,TypeInt.INT64); }
267  @Override public Type apply( Type[] args ) { return TypeInt.con(op(args[1].getl())); }
268  abstract long op( long d );
269  }
270 
271  static class MinusI64 extends Prim1OpI64 {
272  MinusI64() { super("-"); }
273  @Override long op( long x ) { return -x; }
274  }
275 
276  // 2Ops have uniform input/output types, so take a shortcut on name printing
277  abstract static class Prim2OpF64 extends PrimNode {
278  Prim2OpF64( String name ) { super(name,TypeTuple.FLT64_FLT64,TypeFlt.FLT64); }
279  @Override public Type apply( Type[] args ) { return TypeFlt.con(op(args[1].getd(),args[2].getd())); }
280  abstract double op( double x, double y );
281  }
282 
283  static class AddF64 extends Prim2OpF64 {
284  AddF64() { super("+"); }
285  double op( double l, double r ) { return l+r; }
286  }
287 
288  static class SubF64 extends Prim2OpF64 {
289  SubF64() { super("-"); }
290  double op( double l, double r ) { return l-r; }
291  }
292 
293  static class MulF64 extends Prim2OpF64 {
294  MulF64() { super("*"); }
295  @Override double op( double l, double r ) { return l*r; }
296  }
297 
298  static class DivF64 extends Prim2OpF64 {
299  DivF64() { super("/"); }
300  @Override double op( double l, double r ) { return l/r; }
301  }
302 
303  // 2RelOps have uniform input types, and bool output
304  abstract static class Prim2RelOpF64 extends PrimNode {
305  Prim2RelOpF64( String name ) { super(name,TypeTuple.FLT64_FLT64,TypeInt.BOOL); }
306  @Override public Type apply( Type[] args ) { return op(args[1].getd(),args[2].getd())?TypeInt.TRUE:TypeInt.FALSE; }
307  abstract boolean op( double x, double y );
308  }
309 
310  static class LT_F64 extends Prim2RelOpF64 { LT_F64() { super("<" ); } boolean op( double l, double r ) { return l< r; } }
311  static class LE_F64 extends Prim2RelOpF64 { LE_F64() { super("<="); } boolean op( double l, double r ) { return l<=r; } }
312  static class GT_F64 extends Prim2RelOpF64 { GT_F64() { super(">" ); } boolean op( double l, double r ) { return l> r; } }
313  static class GE_F64 extends Prim2RelOpF64 { GE_F64() { super(">="); } boolean op( double l, double r ) { return l>=r; } }
314  static class EQ_F64 extends Prim2RelOpF64 { EQ_F64() { super("=="); } boolean op( double l, double r ) { return l==r; } }
315  static class NE_F64 extends Prim2RelOpF64 { NE_F64() { super("!="); } boolean op( double l, double r ) { return l!=r; } }
316 
317 
318  // 2Ops have uniform input/output types, so take a shortcut on name printing
319  abstract static class Prim2OpI64 extends PrimNode {
320  Prim2OpI64( String name ) { super(name,TypeTuple.INT64_INT64,TypeInt.INT64); }
321  @Override public Type apply( Type[] args ) { return TypeInt.con(op(args[1].getl(),args[2].getl())); }
322  abstract long op( long x, long y );
323  }
324 
325  static class AddI64 extends Prim2OpI64 {
326  AddI64() { super("+"); }
327  @Override long op( long l, long r ) { return l+r; }
328  }
329 
330  static class SubI64 extends Prim2OpI64 {
331  SubI64() { super("-"); }
332  @Override long op( long l, long r ) { return l-r; }
333  }
334 
335  static class MulI64 extends Prim2OpI64 {
336  MulI64() { super("*"); }
337  @Override long op( long l, long r ) { return l*r; }
338  }
339 
340  static class DivI64 extends Prim2OpI64 {
341  DivI64() { super("/"); }
342  @Override long op( long l, long r ) { return l/r; } // Long division
343  }
344 
345  static class ModI64 extends Prim2OpI64 {
346  ModI64() { super("%"); }
347  @Override long op( long l, long r ) { return l%r; }
348  }
349 
350  static class AndI64 extends Prim2OpI64 {
351  AndI64() { super("&"); }
352  // And can preserve bit-width
353  @Override public Type value(GVNGCM.Mode opt_mode) {
354  Type t1 = val(1), t2 = val(2);
355  // 0 AND anything is 0
356  if( t1 == Type. NIL || t2 == Type. NIL ) return Type. NIL;
357  if( t1 == Type.XNIL || t2 == Type.XNIL ) return Type.XNIL;
358  // If either is high - results might fall to something reasonable
359  if( t1.above_center() || t2.above_center() )
360  return TypeInt.INT64.dual();
361  // Both are low-or-constant, and one is not valid - return bottom result
362  if( !t1.isa(TypeInt.INT64) || !t2.isa(TypeInt.INT64) )
363  return TypeInt.INT64;
364  // If both are constant ints, return the constant math.
365  if( t1.is_con() && t2.is_con() )
366  return TypeInt.con(t1.getl() & t2.getl());
367  if( !(t1 instanceof TypeInt) || !(t2 instanceof TypeInt) )
368  return TypeInt.INT64;
369  // Preserve width
370  return ((TypeInt)t1).minsize((TypeInt)t2);
371  }
372  @Override long op( long l, long r ) { return l&r; }
373  }
374 
375  static class OrI64 extends Prim2OpI64 {
376  OrI64() { super("|"); }
377  // And can preserve bit-width
378  @Override public Type value(GVNGCM.Mode opt_mode) {
379  Type t1 = val(1), t2 = val(2);
380  // 0 OR anything is that thing
381  if( t1 == Type.NIL || t1 == Type.XNIL ) return t2;
382  if( t2 == Type.NIL || t2 == Type.XNIL ) return t1;
383  // If either is high - results might fall to something reasonable
384  if( t1.above_center() || t2.above_center() )
385  return TypeInt.INT64.dual();
386  // Both are low-or-constant, and one is not valid - return bottom result
387  if( !t1.isa(TypeInt.INT64) || !t2.isa(TypeInt.INT64) )
388  return TypeInt.INT64;
389  // If both are constant ints, return the constant math.
390  if( t1.is_con() && t2.is_con() )
391  return TypeInt.con(t1.getl() | t2.getl());
392  if( !(t1 instanceof TypeInt) || !(t2 instanceof TypeInt) )
393  return TypeInt.INT64;
394  // Preserve width
395  return ((TypeInt)t1).maxsize((TypeInt)t2);
396  }
397  @Override long op( long l, long r ) { return l&r; }
398  }
399 
400  // 2RelOps have uniform input types, and bool output
401  abstract static class Prim2RelOpI64 extends PrimNode {
402  Prim2RelOpI64( String name ) { super(name,TypeTuple.INT64_INT64,TypeInt.BOOL); }
403  @Override public Type apply( Type[] args ) { return op(args[1].getl(),args[2].getl())?TypeInt.TRUE:TypeInt.FALSE; }
404  abstract boolean op( long x, long y );
405  }
406 
407  static class LT_I64 extends Prim2RelOpI64 { LT_I64() { super("<" ); } boolean op( long l, long r ) { return l< r; } }
408  static class LE_I64 extends Prim2RelOpI64 { LE_I64() { super("<="); } boolean op( long l, long r ) { return l<=r; } }
409  static class GT_I64 extends Prim2RelOpI64 { GT_I64() { super(">" ); } boolean op( long l, long r ) { return l> r; } }
410  static class GE_I64 extends Prim2RelOpI64 { GE_I64() { super(">="); } boolean op( long l, long r ) { return l>=r; } }
411  static class EQ_I64 extends Prim2RelOpI64 { EQ_I64() { super("=="); } boolean op( long l, long r ) { return l==r; } }
412  static class NE_I64 extends Prim2RelOpI64 { NE_I64() { super("!="); } boolean op( long l, long r ) { return l!=r; } }
413 
414 
415  static class EQ_OOP extends PrimNode {
416  EQ_OOP() { super("==",TypeTuple.OOP_OOP,TypeInt.BOOL); }
417  @Override public Type value(GVNGCM.Mode opt_mode) {
418  // Oop-equivalence is based on pointer-equivalence NOT on a "deep equals".
419  // Probably need a java-like "===" vs "==" to mean deep-equals. You are
420  // equals if your inputs are the same node, and you are unequals if your
421  // input is 2 different NewNodes (or casts of NewNodes). Otherwise you
422  // have to do the runtime test.
423  if( in(1)==in(2) ) return TypeInt.TRUE;
424  Node nn1 = in(1).in(0), nn2 = in(2).in(0);
425  if( nn1 instanceof NewNode &&
426  nn2 instanceof NewNode &&
427  nn1 != nn2 ) return TypeInt.FALSE;
428  // Constants can only do nil-vs-not-nil, since e.g. two strings "abc" and
429  // "abc" are equal constants in the type system but can be two different
430  // string pointers.
431  Type t1 = val(1);
432  Type t2 = val(2);
433  if( t1==Type.NIL || t1==Type.XNIL ) return vs_nil(t2,TypeInt.TRUE,TypeInt.FALSE);
434  if( t2==Type.NIL || t2==Type.XNIL ) return vs_nil(t1,TypeInt.TRUE,TypeInt.FALSE);
435  if( t1.above_center() || t2.above_center() ) return TypeInt.BOOL.dual();
436  return TypeInt.BOOL;
437  }
438  @Override public TypeInt apply( Type[] args ) { throw AA.unimpl(); }
439  static Type vs_nil( Type tx, Type t, Type f ) {
440  if( tx==Type.NIL || tx==Type.XNIL ) return t;
441  if( tx.above_center() ) return tx.isa(Type.NIL) ? TypeInt.BOOL.dual() : f;
442  return tx.must_nil() ? TypeInt.BOOL : f;
443  }
444  }
445 
446  static class NE_OOP extends PrimNode {
447  NE_OOP() { super("!=",TypeTuple.OOP_OOP,TypeInt.BOOL); }
448  @Override public Type value(GVNGCM.Mode opt_mode) {
449  // Oop-equivalence is based on pointer-equivalence NOT on a "deep equals".
450  // Probably need a java-like "===" vs "==" to mean deep-equals. You are
451  // equals if your inputs are the same node, and you are unequals if your
452  // input is 2 different NewNodes (or casts of NewNodes). Otherwise you
453  // have to do the runtime test.
454  if( in(1)==in(2) ) return TypeInt.FALSE;
455  Node nn1 = in(1).in(0), nn2 = in(2).in(0);
456  if( nn1 instanceof NewNode &&
457  nn2 instanceof NewNode &&
458  nn1 != nn2 ) return TypeInt.TRUE;
459  // Constants can only do nil-vs-not-nil, since e.g. two strings "abc" and
460  // "abc" are equal constants in the type system but can be two different
461  // string pointers.
462  Type t1 = val(1);
463  Type t2 = val(2);
464  if( t1==Type.NIL || t1==Type.XNIL ) return EQ_OOP.vs_nil(t2,TypeInt.FALSE,TypeInt.TRUE);
465  if( t2==Type.NIL || t2==Type.XNIL ) return EQ_OOP.vs_nil(t1,TypeInt.FALSE,TypeInt.TRUE);
466  if( t1.above_center() || t2.above_center() ) return TypeInt.BOOL.dual();
467  return TypeInt.BOOL;
468  }
469  @Override public TypeInt apply( Type[] args ) { throw AA.unimpl(); }
470  }
471 
472 
473  static class Not extends PrimNode {
474  // Rare function which takes a Scalar (works for both ints and ptrs)
475  Not() { super("!",TypeTuple.SCALAR1,TypeInt.BOOL); }
476  @Override public Type value(GVNGCM.Mode opt_mode) {
477  Type t = val(1);
478  if( t== Type.XNIL ||
479  t== Type. NIL ||
480  t== TypeInt.ZERO )
481  return TypeInt.TRUE;
482  if( t. may_nil() ) return TypeInt.BOOL.dual();
483  if( t.must_nil() ) return TypeInt.BOOL;
484  return Type.XNIL; // Cannot be a nil, so return a nil
485  }
486  @Override public TypeInt apply( Type[] args ) { throw AA.unimpl(); }
487  }
488 
489  static class RandI64 extends PrimNode {
490  RandI64() { super("math_rand",TypeTuple.INT64,TypeInt.INT64); }
491  @Override public Type value(GVNGCM.Mode opt_mode) {
492  Type t = val(1);
493  if( t.above_center() ) return TypeInt.BOOL.dual();
494  if( TypeInt.INT64.dual().isa(t) && t.isa(TypeInt.INT64) )
495  return t.meet(TypeInt.FALSE);
496  return t.oob(TypeInt.INT64);
497  }
498  @Override public TypeInt apply( Type[] args ) { throw AA.unimpl(); }
499  // Rands have hidden internal state; 2 Rands are never equal
500  @Override public boolean equals(Object o) { return this==o; }
501  }
502 
503  static class Id extends PrimNode {
504  Id(Type arg) { super("id",TypeTuple.make_args(arg),arg); }
505  @Override public Type value(GVNGCM.Mode opt_mode) { return val(1); }
506  @Override public TypeInt apply( Type[] args ) { throw AA.unimpl(); }
507  }
508 
509  // Classic '&&' short-circuit. The RHS is a *Thunk* not a value. Inlines
510  // immediate into the operators' wrapper function, which in turn aggressively
511  // inlines during parsing.
512  static class AndThen extends PrimNode {
514  // Takes a value on the LHS, and a THUNK on the RHS.
515  AndThen() { super("&&",new String[]{" ctl"," mem","^","p","thunk"},ANDTHEN,Type.SCALAR); _thunk_rhs=true; }
516  // Expect this to inline everytime
517  @Override public Node ideal_grow() {
518  if( _defs._len != 4 ) return null; // Already did this
519  try(GVNGCM.Build<Node> X = Env.GVN.new Build<>()) {
520  Node ctl = in(0);
521  Node mem = in(1);
522  Node lhs = in(2);
523  Node rhs = in(3);
524  // Expand to if/then/else
525  Node iff = X.xform(new IfNode(ctl,lhs));
526  Node fal = X.xform(new CProjNode(iff,0));
527  Node tru = X.xform(new CProjNode(iff,1));
528  // Call on true branch; if false do not call.
529  Node dsp = X.xform(new FP2DispNode(rhs));
530  Node cal = X.xform(new CallNode(true,_badargs,tru,mem,dsp,rhs));
531  Node cep = X.xform(new CallEpiNode(cal,Env.DEFMEM));
532  Node ccc = X.xform(new CProjNode(cep));
533  Node memc= X.xform(new MProjNode(cep));
534  Node rez = X.xform(new ProjNode(cep,AA.REZ_IDX));
535  // Region merging results
536  Node reg = X.xform(new RegionNode(null,fal,ccc));
537  Node phi = X.xform(new PhiNode(Type.SCALAR,null,reg,Env.XNIL,rez ));
538  Node phim= X.xform(new PhiNode(TypeMem.MEM,null,reg,mem,memc ));
539  // Plug into self & trigger is_copy
540  set_def(0,reg );
541  set_def(1,phim);
542  set_def(2,phi );
543  pop(); // Remove arg2, trigger is_copy
544  X.add(this);
545  for( Node use : _uses ) X.add(use);
546  return null;
547  }
548  }
549  @Override public Type value(GVNGCM.Mode opt_mode) {
550  return TypeTuple.RET;
551  }
552  @Override public TypeMem live_use(GVNGCM.Mode opt_mode, Node def ) {
553  if( def==in(0) ) return TypeMem.ALIVE; // Control
554  if( def==in(1) ) return TypeMem.ALLMEM; // Force maximal liveness, since will inline
555  return TypeMem.LIVE_BOT; // Force maximal liveness, since will inline
556  }
557  @Override public TypeMem all_live() { return TypeMem.ALLMEM; }
558  //@Override public TV2 new_tvar(String alloc_site) { return TV2.make("Thunk",this,alloc_site); }
559  @Override public TypeInt apply( Type[] args ) { throw AA.unimpl(); }
560  @Override public Node is_copy(int idx) {
561  return _defs._len==4 ? null : in(idx);
562  }
563  }
564 
565  // Classic '||' short-circuit. The RHS is a *Thunk* not a value. Inlines
566  // immediate into the operators' wrapper function, which in turn aggressively
567  // inlines during parsing.
568  static class OrElse extends PrimNode {
569  private static final TypeTuple ORELSE =
571  // Takes a value on the LHS, and a THUNK on the RHS.
572  OrElse() { super("||",new String[]{" ctl"," mem","^","p","thunk"},ORELSE,Type.SCALAR); _thunk_rhs=true; }
573  // Expect this to inline everytime
574  @Override public Node ideal_grow() {
575  if( _defs._len != 4 ) return null; // Already did this
576  try(GVNGCM.Build<Node> X = Env.GVN.new Build<>()) {
577  Node ctl = in(0);
578  Node mem = in(1);
579  Node lhs = in(2);
580  Node rhs = in(3);
581  // Expand to if/then/else
582  Node iff = X.xform(new IfNode(ctl,lhs));
583  Node fal = X.xform(new CProjNode(iff,0));
584  Node tru = X.xform(new CProjNode(iff,1));
585  // Call on false branch; if true do not call.
586  Node dsp = X.xform(new FP2DispNode(rhs));
587  Node cal = X.xform(new CallNode(true,_badargs,fal,mem,dsp,rhs));
588  Node cep = X.xform(new CallEpiNode(cal,Env.DEFMEM));
589  Node ccc = X.xform(new CProjNode(cep));
590  Node memc= X.xform(new MProjNode(cep));
591  Node rez = X.xform(new ProjNode(cep,AA.REZ_IDX));
592  // Region merging results
593  Node reg = X.xform(new RegionNode(null,tru,ccc));
594  Node phi = X.xform(new PhiNode(Type.SCALAR,null,reg,lhs,rez ));
595  Node phim= X.xform(new PhiNode(TypeMem.MEM,null,reg,mem,memc ));
596  // Plug into self & trigger is_copy
597  set_def(0,reg );
598  set_def(1,phim);
599  set_def(2,phi );
600  pop(); // Remove arg2, trigger is_copy
601  X.add(this);
602  for( Node use : _uses ) X.add(use);
603  return null;
604  }
605  }
606  @Override public Type value(GVNGCM.Mode opt_mode) {
607  return TypeTuple.RET;
608  }
609  @Override public TypeMem live_use(GVNGCM.Mode opt_mode, Node def ) {
610  if( def==in(0) ) return TypeMem.ALIVE; // Control
611  if( def==in(1) ) return TypeMem.ALLMEM; // Force maximal liveness, since will inline
612  return TypeMem.LIVE_BOT; // Force maximal liveness, since will inline
613  }
614  @Override public TypeMem all_live() { return TypeMem.ALLMEM; }
615  //@Override public TV2 new_tvar(String alloc_site) { return TV2.make("Thunk",this,alloc_site); }
616  @Override public TypeInt apply( Type[] args ) { throw AA.unimpl(); }
617  @Override public Node is_copy(int idx) {
618  return _defs._len==4 ? null : in(idx);
619  }
620  }
621 
622 }
com.cliffc.aa.GVNGCM.add_grow
void add_grow(Node n)
Definition: GVNGCM.java:52
com.cliffc.aa.node.PrimNode.LE_F64.LE_F64
LE_F64()
Definition: PrimNode.java:311
com.cliffc.aa.node.PrimNode.NE_I64.NE_I64
NE_I64()
Definition: PrimNode.java:412
com.cliffc.aa.node.PrimNode.PRIMS
static PrimNode[] PRIMS()
Definition: PrimNode.java:42
com.cliffc.aa.node.PrimNode.OrElse.ideal_grow
Node ideal_grow()
Definition: PrimNode.java:574
com.cliffc.aa.node.PrimNode.reset
static void reset()
Definition: PrimNode.java:40
com.cliffc.aa.node.MemPrimNode
Definition: MemPrimNode.java:10
com.cliffc.aa.type.TypeFunPtr
Definition: TypeFunPtr.java:23
com.cliffc.aa.node.PrimNode.Prim2OpI64.op
abstract long op(long x, long y)
com.cliffc.aa.node.PrimNode.ModI64
Definition: PrimNode.java:345
com.cliffc.aa.node.PrimNode
Definition: PrimNode.java:20
com.cliffc.aa.node.PrimNode.OrElse.apply
TypeInt apply(Type[] args)
Definition: PrimNode.java:616
com.cliffc.aa.util.Ary.push
E push(E e)
Add element in amortized constant time.
Definition: Ary.java:58
com.cliffc.aa.type.TypeTuple.make_args
static TypeTuple make_args(Type[] ts)
Definition: TypeTuple.java:106
com.cliffc.aa.node.PrimNode.err
ErrMsg err(boolean fast)
Definition: PrimNode.java:154
com.cliffc.aa.type.Type.isa
boolean isa(Type t)
Definition: Type.java:623
com.cliffc.aa.node.PrimNode.Prim1OpI64.op
abstract long op(long d)
com.cliffc.aa.node.PrimNode.GE_I64.op
boolean op(long l, long r)
Definition: PrimNode.java:410
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.TypeTuple.make_ret
static TypeTuple make_ret(Type trez)
Definition: TypeTuple.java:120
com.cliffc.aa.node.PrimNode.SubI64.SubI64
SubI64()
Definition: PrimNode.java:331
com.cliffc.aa.node.PrimNode.LT_I64
Definition: PrimNode.java:407
com.cliffc.aa.node.PrimNode.Prim1OpF64
Definition: PrimNode.java:253
com.cliffc.aa.node.PrimNode.apply
abstract Type apply(Type[] args)
com.cliffc.aa.type.TypeMemPtr.OOP
static final TypeMemPtr OOP
Definition: TypeMemPtr.java:94
com.cliffc.aa.node.PrimNode._thunk_rhs
boolean _thunk_rhs
Definition: PrimNode.java:25
com.cliffc.aa.type.Type.SCALAR
static final Type SCALAR
Definition: Type.java:328
com.cliffc
com.cliffc.aa.node.PrimNode.RandI64.value
Type value(GVNGCM.Mode opt_mode)
Definition: PrimNode.java:491
com.cliffc.aa.type.Type._hash
int _hash
Definition: Type.java:97
com.cliffc.aa.Env.ALL_CALL
static ConNode ALL_CALL
Definition: Env.java:26
com.cliffc.aa.node.PrimNode.Id.apply
TypeInt apply(Type[] args)
Definition: PrimNode.java:506
com.cliffc.aa.node.PrimNode.AndThen.value
Type value(GVNGCM.Mode opt_mode)
Definition: PrimNode.java:549
com.cliffc.aa.node.PrimNode.ConvertStrStr.ConvertStrStr
ConvertStrStr()
Definition: PrimNode.java:246
com.cliffc.aa.node.PrimNode.NE_OOP.apply
TypeInt apply(Type[] args)
Definition: PrimNode.java:469
com.cliffc.aa.node.PrimNode.DivF64.op
double op(double l, double r)
Definition: PrimNode.java:300
com.cliffc.aa.node.PrimNode.equals
boolean equals(Object o)
Definition: PrimNode.java:167
com.cliffc.aa.node.IfNode
Definition: IfNode.java:9
com.cliffc.aa.node.PrimNode.GT_F64.op
boolean op(double l, double r)
Definition: PrimNode.java:312
com.cliffc.aa.node.PrimNode.hashCode
int hashCode()
Definition: PrimNode.java:166
com.cliffc.aa.type.TypeMem.LIVE_BOT
static final TypeMem LIVE_BOT
Definition: TypeMem.java:226
com.cliffc.aa.node.PrimNode.Prim2OpI64
Definition: PrimNode.java:319
com.cliffc.aa.node.Node
Definition: Node.java:16
com.cliffc.aa.util
Definition: AbstractEntry.java:1
com.cliffc.aa.node.PrimNode.LT_F64.LT_F64
LT_F64()
Definition: PrimNode.java:310
com.cliffc.aa.node.PrimNode.PrimNode
PrimNode(String name, String[] args, TypeTuple formals, Type ret)
Definition: PrimNode.java:27
com.cliffc.aa.type.TypeInt
Definition: TypeInt.java:9
com.cliffc.aa.node.PrimNode.NE_I64.op
boolean op(long l, long r)
Definition: PrimNode.java:412
com.cliffc.aa.type.TypeFunPtr.GENERIC_FUNPTR
static final TypeFunPtr GENERIC_FUNPTR
Definition: TypeFunPtr.java:80
com.cliffc.aa.node.PrimNode.PrimNode
PrimNode(String name, TypeTuple formals, Type ret)
Definition: PrimNode.java:26
com.cliffc.aa.node.PrimNode.OrI64
Definition: PrimNode.java:375
com.cliffc.aa.node.PrimNode.ConvertInt64F64
Definition: PrimNode.java:239
com.cliffc.aa.node.FP2DispNode
Definition: FP2DispNode.java:7
com.cliffc.aa.type.Type
an implementation of language AA
Definition: Type.java:94
com.cliffc.aa.node.PrimNode.OrElse
Definition: PrimNode.java:568
com.cliffc.aa.type.TypeFunSig.make
static TypeFunSig make(String[] args, TypeTuple formals, TypeTuple ret)
Definition: TypeFunSig.java:71
com.cliffc.aa.node.PrimNode.GT_F64
Definition: PrimNode.java:312
com.cliffc.aa.node.PrimNode.ConvertTypeName.err
ErrMsg err(boolean fast)
Definition: PrimNode.java:230
com.cliffc.aa.type.TypeFlt
Definition: TypeFlt.java:9
com.cliffc.aa.node.PrimNode.DivI64
Definition: PrimNode.java:340
com.cliffc.aa.util.Ary
Definition: Ary.java:11
com.cliffc.aa.node.PhiNode
Definition: PhiNode.java:9
com.cliffc.aa.node.CProjNode
Definition: CProjNode.java:10
com.cliffc.aa.node.PrimNode.OrI64.value
Type value(GVNGCM.Mode opt_mode)
Definition: PrimNode.java:378
com.cliffc.aa.node.PrimNode.RandI64
Definition: PrimNode.java:489
com.cliffc.aa.node.Node.ErrMsg.typerr
static ErrMsg typerr(Parse loc, Type actual, Type t0mem, Type expected)
Definition: Node.java:906
com.cliffc.aa.node.PrimNode.Prim2RelOpF64
Definition: PrimNode.java:304
com.cliffc.aa.node.PrimNode.AndThen.all_live
TypeMem all_live()
Definition: PrimNode.java:557
com.cliffc.aa.node.PrimNode.DivF64.DivF64
DivF64()
Definition: PrimNode.java:299
com.cliffc.aa.type.TypeTuple
Definition: TypeTuple.java:11
com.cliffc.aa.node.PrimNode.NE_F64.NE_F64
NE_F64()
Definition: PrimNode.java:315
com.cliffc.aa.node.PrimNode.value
Type value(GVNGCM.Mode opt_mode)
Definition: PrimNode.java:137
com.cliffc.aa.node.PrimNode.Prim2OpF64.op
abstract double op(double x, double y)
com.cliffc.aa.node.PrimNode.EQ_I64.EQ_I64
EQ_I64()
Definition: PrimNode.java:411
com.cliffc.aa.node.PrimNode.EQ_I64.op
boolean op(long l, long r)
Definition: PrimNode.java:411
com.cliffc.aa.type.TypeInt.con
static TypeInt con(long con)
Definition: TypeInt.java:37
com.cliffc.aa.node.PrimNode.Prim2OpI64.Prim2OpI64
Prim2OpI64(String name)
Definition: PrimNode.java:320
com.cliffc.aa.type.TypeMem.ALLMEM
static final TypeMem ALLMEM
Definition: TypeMem.java:228
com.cliffc.aa.type.TypeFunSig.func_names
static final String[] func_names
Definition: TypeFunSig.java:82
com.cliffc.aa.Env.XNIL
static ConNode XNIL
Definition: Env.java:22
com.cliffc.aa.type.Type.ANY
static final Type ANY
Definition: Type.java:325
com.cliffc.aa.node.PrimNode.NE_F64.op
boolean op(double l, double r)
Definition: PrimNode.java:315
com.cliffc.aa.node.PrimNode.SubI64
Definition: PrimNode.java:330
com.cliffc.aa.node.Node.ErrMsg
Definition: Node.java:888
com.cliffc.aa.node.Node.add_def
Node add_def(Node n)
Definition: Node.java:152
com.cliffc.aa.node.PrimNode.NE_OOP.NE_OOP
NE_OOP()
Definition: PrimNode.java:447
com.cliffc.aa.node.FunPtrNode
Definition: FunPtrNode.java:40
com.cliffc.aa.node.PrimNode.NE_OOP
Definition: PrimNode.java:446
com.cliffc.aa.node.PrimNode.MulF64
Definition: PrimNode.java:293
com.cliffc.aa.type.Type.meet
final Type meet(Type t)
Definition: Type.java:412
com.cliffc.aa.node.RetNode
Definition: RetNode.java:19
com.cliffc.aa.node.PrimNode.NE_F64
Definition: PrimNode.java:315
com.cliffc.aa.node.PrimNode.LT_F64.op
boolean op(double l, double r)
Definition: PrimNode.java:310
com.cliffc.aa.node.CallNode
Definition: CallNode.java:86
com.cliffc.aa.AA.unimpl
static RuntimeException unimpl()
Definition: AA.java:10
com.cliffc.aa.node.PrimNode.EQ_I64
Definition: PrimNode.java:411
com.cliffc.aa.node.PrimNode.Prim2OpF64
Definition: PrimNode.java:277
com.cliffc.aa.node.MProjNode
Definition: MProjNode.java:10
com.cliffc.aa.node.PrimNode._name
final String _name
Definition: PrimNode.java:21
com.cliffc.aa.node.PrimNode.SubF64.op
double op(double l, double r)
Definition: PrimNode.java:290
com.cliffc.aa.node.PrimNode.NE_OOP.value
Type value(GVNGCM.Mode opt_mode)
Definition: PrimNode.java:448
com.cliffc.aa.node.PrimNode.ModI64.op
long op(long l, long r)
Definition: PrimNode.java:347
com.cliffc.aa.node.PrimNode.GT_F64.GT_F64
GT_F64()
Definition: PrimNode.java:312
com.cliffc.aa.type.Type.ALL
static final Type ALL
Definition: Type.java:324
com.cliffc.aa.node.PrimNode.MulI64.MulI64
MulI64()
Definition: PrimNode.java:336
com.cliffc.aa.type.TypeFunSig._ret
TypeTuple _ret
Definition: TypeFunSig.java:16
com.cliffc.aa.Env.ALL
static ConNode ALL
Definition: Env.java:25
com.cliffc.aa.node.PrimNode.LE_I64.op
boolean op(long l, long r)
Definition: PrimNode.java:408
com.cliffc.aa.node.PrimNode.ConvertStrStr.apply
TypeInt apply(Type[] args)
Definition: PrimNode.java:249
com.cliffc.aa.util.Ary.asAry
E[] asAry()
Definition: Ary.java:172
com.cliffc.aa.type.TypeFunSig._args
String[] _args
Definition: TypeFunSig.java:14
com.cliffc.aa.node.PrimNode.AndI64.value
Type value(GVNGCM.Mode opt_mode)
Definition: PrimNode.java:353
com.cliffc.aa.type.TypeTuple.SCALAR1
static final TypeTuple SCALAR1
Definition: TypeTuple.java:142
com.cliffc.aa.type.TypeFunSig.arg
Type arg(int idx)
Definition: TypeFunSig.java:88
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.node.PrimNode.GT_I64
Definition: PrimNode.java:409
com.cliffc.aa.node.PrimNode.ConvertStrStr.value
Type value(GVNGCM.Mode opt_mode)
Definition: PrimNode.java:248
com.cliffc.aa.type.Type.set_name
final T set_name(String name)
Definition: Type.java:551
com.cliffc.aa.node.PrimNode.Prim1OpI64
Definition: PrimNode.java:265
com.cliffc.aa.node.PrimNode.AddF64.op
double op(double l, double r)
Definition: PrimNode.java:285
com.cliffc.aa.type.TypeFunSig.nargs
int nargs()
Definition: TypeFunSig.java:87
com.cliffc.aa.type.TypeFlt.con
static Type con(double con)
Definition: TypeFlt.java:36
com.cliffc.aa.node.PrimNode.EQ_OOP.value
Type value(GVNGCM.Mode opt_mode)
Definition: PrimNode.java:417
com.cliffc.aa.node.PrimNode.AndThen.ANDTHEN
static final TypeTuple ANDTHEN
Definition: PrimNode.java:513
com.cliffc.aa.type.Type.is_con
boolean is_con()
Definition: Type.java:776
com.cliffc.aa.node.PrimNode.OrElse.value
Type value(GVNGCM.Mode opt_mode)
Definition: PrimNode.java:606
com.cliffc.aa.type.Type.above_center
boolean above_center()
Definition: Type.java:741
com.cliffc.aa.node.PrimNode.Prim2OpI64.apply
Type apply(Type[] args)
Definition: PrimNode.java:321
com.cliffc.aa.node.PrimNode.OrElse.ORELSE
static final TypeTuple ORELSE
Definition: PrimNode.java:569
com.cliffc.aa.node.PrimNode.xstr
String xstr()
Definition: PrimNode.java:136
com.cliffc.aa.node.PrimNode.AndThen.is_copy
Node is_copy(int idx)
Definition: PrimNode.java:560
com.cliffc.aa.node.PrimNode._sig
final TypeFunSig _sig
Definition: PrimNode.java:22
com.cliffc.aa.type.TypeTuple.RET
static final TypeTuple RET
Definition: TypeTuple.java:130
com.cliffc.aa.type.TypeInt.maxsize
TypeInt maxsize(TypeInt ti)
Definition: TypeInt.java:201
com.cliffc.aa.node.PrimNode.Not.Not
Not()
Definition: PrimNode.java:475
com.cliffc.aa.node.PrimNode.PRIMS
static PrimNode[] PRIMS
Definition: PrimNode.java:36
com.cliffc.aa.node.PrimNode.MulI64.op
long op(long l, long r)
Definition: PrimNode.java:337
com.cliffc.aa.node.PrimNode.Prim1OpI64.apply
Type apply(Type[] args)
Definition: PrimNode.java:267
com.cliffc.aa.node.PrimNode.AndThen
Definition: PrimNode.java:512
com.cliffc.aa.node.PrimNode.LE_F64
Definition: PrimNode.java:311
com.cliffc.aa.AA.REZ_IDX
static final int REZ_IDX
Definition: AA.java:16
com.cliffc.aa.node.PrimNode.AddF64.AddF64
AddF64()
Definition: PrimNode.java:284
com.cliffc.aa.node.PrimNode.GE_I64.GE_I64
GE_I64()
Definition: PrimNode.java:410
com.cliffc.aa.node.PrimNode.OrElse.all_live
TypeMem all_live()
Definition: PrimNode.java:614
com.cliffc.aa.node.PrimNode.Prim2OpF64.apply
Type apply(Type[] args)
Definition: PrimNode.java:279
com.cliffc.aa.type.TypeTuple.FLT64
static final TypeTuple FLT64
Definition: TypeTuple.java:137
com.cliffc.aa.node.Node.in
Node in(int i)
Definition: Node.java:126
com.cliffc.aa.node.PrimNode.ConvertTypeName.value
Type value(GVNGCM.Mode opt_mode)
Definition: PrimNode.java:216
com.cliffc.aa.node.PrimNode.EQ_F64.EQ_F64
EQ_F64()
Definition: PrimNode.java:314
com.cliffc.aa.node.PrimNode.PREC_TOKS
static String[][] PREC_TOKS
Definition: PrimNode.java:38
com.cliffc.aa.node.PrimNode.AndThen.apply
TypeInt apply(Type[] args)
Definition: PrimNode.java:559
com.cliffc.aa.type.Type.must_nil
boolean must_nil()
Definition: Type.java:845
com.cliffc.aa.node.PrimNode.convertTypeName
static PrimNode convertTypeName(Type from, Type to, Parse badargs)
Definition: PrimNode.java:129
com.cliffc.aa.node.PrimNode.EQ_F64.op
boolean op(double l, double r)
Definition: PrimNode.java:314
com.cliffc.aa.type.TypeMem.ALIVE
static final TypeMem ALIVE
Definition: TypeMem.java:226
com.cliffc.aa.GVNGCM
Definition: GVNGCM.java:12
com.cliffc.aa.node.PrimNode.RandI64.equals
boolean equals(Object o)
Definition: PrimNode.java:500
com.cliffc.aa.node.PrimNode.SubI64.op
long op(long l, long r)
Definition: PrimNode.java:332
com.cliffc.aa.node.PrimNode.OrI64.OrI64
OrI64()
Definition: PrimNode.java:376
com.cliffc.aa.node.PrimNode.ConvertTypeName.apply
Type apply(Type[] args)
Definition: PrimNode.java:222
com.cliffc.aa.node.PrimNode.Prim2RelOpI64.op
abstract boolean op(long x, long y)
com.cliffc.aa.type.Type.simple_ptr
Type simple_ptr()
Definition: Type.java:358
com.cliffc.aa.node.PrimNode.EQ_OOP
Definition: PrimNode.java:415
com.cliffc.aa.node.PrimNode.SubF64
Definition: PrimNode.java:288
com.cliffc.aa.node.PrimNode.MinusI64.op
long op(long x)
Definition: PrimNode.java:273
com.cliffc.aa.node.PrimNode.Prim1OpF64.apply
Type apply(Type[] args)
Definition: PrimNode.java:255
com.cliffc.aa.node.PrimNode.ConvertInt64F64.apply
Type apply(Type[] args)
Definition: PrimNode.java:241
com.cliffc.aa.node.PrimNode.MulF64.op
double op(double l, double r)
Definition: PrimNode.java:295
com.cliffc.aa.node.ProjNode
Definition: ProjNode.java:11
com.cliffc.aa.node.PrimNode.GE_F64
Definition: PrimNode.java:313
com.cliffc.aa.node.PrimNode.ConvertStrStr.ideal_reduce
Node ideal_reduce()
Definition: PrimNode.java:247
com.cliffc.aa.node.PrimNode.OrI64.op
long op(long l, long r)
Definition: PrimNode.java:397
com.cliffc.aa.node.PrimNode.LT_I64.op
boolean op(long l, long r)
Definition: PrimNode.java:407
com.cliffc.aa.node.PrimNode.OrElse.is_copy
Node is_copy(int idx)
Definition: PrimNode.java:617
com.cliffc.aa.node.PrimNode.Id
Definition: PrimNode.java:503
com.cliffc.aa.node.PrimNode.RandI64.RandI64
RandI64()
Definition: PrimNode.java:490
com.cliffc.aa.node.PrimNode.LT_F64
Definition: PrimNode.java:310
com.cliffc.aa.type.Type.NIL
static final Type NIL
Definition: Type.java:332
com.cliffc.aa.node.Node._uses
Ary< Node > _uses
Definition: Node.java:245
com.cliffc.aa.node.PrimNode.PRIM_TOKS
static String[] PRIM_TOKS
Definition: PrimNode.java:39
com.cliffc.aa.node.PrimNode.Prim2OpF64.Prim2OpF64
Prim2OpF64(String name)
Definition: PrimNode.java:278
com.cliffc.aa.node.PrimNode.MulF64.MulF64
MulF64()
Definition: PrimNode.java:294
com.cliffc.aa.node.PrimNode.AndI64.AndI64
AndI64()
Definition: PrimNode.java:351
com.cliffc.aa.AA
an implementation of language AA
Definition: AA.java:9
com.cliffc.aa.node.PrimNode.DivI64.op
long op(long l, long r)
Definition: PrimNode.java:342
com.cliffc.aa.node.PrimNode.ConvertInt64F64.ConvertInt64F64
ConvertInt64F64()
Definition: PrimNode.java:240
com.cliffc.aa.node.Node.val
Type val(int idx)
Definition: Node.java:470
com.cliffc.aa.node.PrimNode.MinusF64.op
double op(double d)
Definition: PrimNode.java:261
com.cliffc.aa
Definition: AA.java:1
com.cliffc.aa.node.PrimNode.Prim2RelOpI64
Definition: PrimNode.java:401
com.cliffc.aa.node.PrimNode.ConvertStrStr
Definition: PrimNode.java:245
com.cliffc.aa.node.PrimNode.Not
Definition: PrimNode.java:473
com.cliffc.aa.node.PrimNode.DivF64
Definition: PrimNode.java:298
com.cliffc.aa.node.NewNode
Definition: NewNode.java:17
com.cliffc.aa.node.PrimNode.Prim2RelOpI64.apply
Type apply(Type[] args)
Definition: PrimNode.java:403
com.cliffc.aa.node.PrimNode.LE_F64.op
boolean op(double l, double r)
Definition: PrimNode.java:311
com.cliffc.aa.type.TypeTuple.STRPTR
static final TypeTuple STRPTR
Definition: TypeTuple.java:138
com.cliffc.aa.type.TypeTuple.INT64_INT64
static final TypeTuple INT64_INT64
Definition: TypeTuple.java:139
com.cliffc.aa.node.PrimNode.NE_I64
Definition: PrimNode.java:412
com.cliffc.aa.node.PrimNode.AddF64
Definition: PrimNode.java:283
com.cliffc.aa.node.PrimNode.AndThen.AndThen
AndThen()
Definition: PrimNode.java:515
com.cliffc.aa.node.PrimNode.EQ_OOP.EQ_OOP
EQ_OOP()
Definition: PrimNode.java:416
com.cliffc.aa.node.PrimNode._op_prec
byte _op_prec
Definition: PrimNode.java:24
com.cliffc.aa.node.Node.OP_PRIM
static final byte OP_PRIM
Definition: Node.java:39
com.cliffc.aa.type.TypeTuple.at
Type at(int idx)
Definition: TypeTuple.java:182
com.cliffc.aa.type.TypeInt.FALSE
static final Type FALSE
Definition: TypeInt.java:45
com.cliffc.aa.node.PrimNode.Prim1OpI64.Prim1OpI64
Prim1OpI64(String name)
Definition: PrimNode.java:266
com.cliffc.aa.node.Node.set_def
Node set_def(int idx, Node n)
Definition: Node.java:154
com.cliffc.aa.node.MemPrimNode.ReadPrimNode
Definition: MemPrimNode.java:48
com.cliffc.aa.type.Type._name
String _name
Definition: Type.java:99
com.cliffc.aa.node.PrimNode.Prim2RelOpF64.Prim2RelOpF64
Prim2RelOpF64(String name)
Definition: PrimNode.java:305
com.cliffc.aa.node.PrimNode.AddI64.AddI64
AddI64()
Definition: PrimNode.java:326
com.cliffc.aa.node.PrimNode.Id.Id
Id(Type arg)
Definition: PrimNode.java:504
com.cliffc.aa.type.TypeFunSig
Definition: TypeFunSig.java:10
com.cliffc.aa.type.TypeTuple.OOP_OOP
static final TypeTuple OOP_OOP
Definition: TypeTuple.java:141
com.cliffc.aa.node.PrimNode.AndI64
Definition: PrimNode.java:350
com.cliffc.aa.node.PrimNode.EQ_OOP.apply
TypeInt apply(Type[] args)
Definition: PrimNode.java:438
com.cliffc.aa.node.PrimNode.ConvertTypeName
Definition: PrimNode.java:211
com.cliffc.aa.node.PrimNode.Prim1OpF64.Prim1OpF64
Prim1OpF64(String name)
Definition: PrimNode.java:254
com.cliffc.aa.node.PrimNode.ConvertTypeName.ConvertTypeName
ConvertTypeName(Type from, Type to, Parse badargs)
Definition: PrimNode.java:212
com.cliffc.aa.type.Type.dual
final T dual()
Definition: Type.java:361
com.cliffc.aa.type.Type.REAL
static final Type REAL
Definition: Type.java:334
com.cliffc.aa.node.CallEpiNode
Definition: CallEpiNode.java:24
com.cliffc.aa.node.PrimNode.Id.value
Type value(GVNGCM.Mode opt_mode)
Definition: PrimNode.java:505
com.cliffc.aa.node.PrimNode.MulI64
Definition: PrimNode.java:335
com.cliffc.aa.node.ParmNode
Definition: ParmNode.java:14
com.cliffc.aa.node.PrimNode.GE_I64
Definition: PrimNode.java:410
com.cliffc.aa.node.PrimNode.MinusI64
Definition: PrimNode.java:271
com.cliffc.aa.node.PrimNode.AndThen.ideal_grow
Node ideal_grow()
Definition: PrimNode.java:517
com.cliffc.aa.node.PrimNode.MinusF64.MinusF64
MinusF64()
Definition: PrimNode.java:260
com.cliffc.aa.node.PrimNode.Prim2RelOpF64.op
abstract boolean op(double x, double y)
com.cliffc.aa.type.Type.oob
Type oob()
Definition: Type.java:635
com.cliffc.aa.node.PrimNode.Prim2RelOpI64.Prim2RelOpI64
Prim2RelOpI64(String name)
Definition: PrimNode.java:402
com.cliffc.aa.type.Type.XNIL
static final Type XNIL
Definition: Type.java:333
com.cliffc.aa.type.TypeInt.ZERO
static final TypeInt ZERO
Definition: TypeInt.java:49
com.cliffc.aa.node.PrimNode.MinusI64.MinusI64
MinusI64()
Definition: PrimNode.java:272
com.cliffc.aa.node.PrimNode._badargs
Parse[] _badargs
Definition: PrimNode.java:23
com.cliffc.aa.node.Node.pop
Node pop()
Definition: Node.java:174
com.cliffc.aa.GVNGCM.Build
Definition: GVNGCM.java:356
com.cliffc.aa.type.TypeTuple.FLT64_FLT64
static final TypeTuple FLT64_FLT64
Definition: TypeTuple.java:140
com.cliffc.aa.node.PrimNode.SubF64.SubF64
SubF64()
Definition: PrimNode.java:289
com.cliffc.aa.type.TypeInt.minsize
TypeInt minsize(TypeInt ti)
Definition: TypeInt.java:200
com.cliffc.aa.node.PrimNode.Prim1OpF64.op
abstract double op(double d)
com.cliffc.aa.node.PrimNode.AddI64
Definition: PrimNode.java:325
com.cliffc.aa.node.PrimNode.Not.value
Type value(GVNGCM.Mode opt_mode)
Definition: PrimNode.java:476
com.cliffc.aa.node.PrimNode.GT_I64.op
boolean op(long l, long r)
Definition: PrimNode.java:409
com.cliffc.aa.node.FunNode
Definition: FunNode.java:58
com.cliffc.aa.type.Type.getl
long getl()
Definition: Type.java:802
com.cliffc.aa.node.PrimNode.as_fun
FunPtrNode as_fun(GVNGCM gvn)
Definition: PrimNode.java:178
com.cliffc.aa.type.TypeInt.TRUE
static final TypeInt TRUE
Definition: TypeInt.java:44
com.cliffc.aa.node.RegionNode
Definition: RegionNode.java:11
com.cliffc.aa.node.PrimNode.Prim2RelOpF64.apply
Type apply(Type[] args)
Definition: PrimNode.java:306
com.cliffc.aa.node.PrimNode.EQ_F64
Definition: PrimNode.java:314
com.cliffc.aa.node.PrimNode.ModI64.ModI64
ModI64()
Definition: PrimNode.java:346
com.cliffc.aa.type.TypeTuple.INT64
static final TypeTuple INT64
Definition: TypeTuple.java:136
com
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.node.Node.ErrMsg.BADARGS
static final ErrMsg BADARGS
Definition: Node.java:894
com.cliffc.aa.node.PrimNode.GE_F64.op
boolean op(double l, double r)
Definition: PrimNode.java:313
com.cliffc.aa.node.PrimNode.LE_I64.LE_I64
LE_I64()
Definition: PrimNode.java:408
com.cliffc.aa.node.PrimNode.LT_I64.LT_I64
LT_I64()
Definition: PrimNode.java:407
com.cliffc.aa.node.PrimNode.GE_F64.GE_F64
GE_F64()
Definition: PrimNode.java:313
com.cliffc.aa.type.TypeInt.BOOL
static final TypeInt BOOL
Definition: TypeInt.java:43
com.cliffc.aa.node.PrimNode.AndI64.op
long op(long l, long r)
Definition: PrimNode.java:372
com.cliffc.aa.type
Definition: Bits.java:1
com.cliffc.aa.node.PrimNode.AddI64.op
long op(long l, long r)
Definition: PrimNode.java:327
com.cliffc.aa.node.PrimNode.RandI64.apply
TypeInt apply(Type[] args)
Definition: PrimNode.java:498
com.cliffc.aa.node.Node._defs
Ary< Node > _defs
Definition: Node.java:124
com.cliffc.aa.node.PrimNode.GT_I64.GT_I64
GT_I64()
Definition: PrimNode.java:409
com.cliffc.aa.node.PrimNode.OrElse.OrElse
OrElse()
Definition: PrimNode.java:572
com.cliffc.aa.type.TypeMemPtr
Definition: TypeMemPtr.java:14
com.cliffc.aa.Parse
an implementation of language AA
Definition: Parse.java:68
com.cliffc.aa.Env.ALL_CTRL
static ConNode ALL_CTRL
Definition: Env.java:20
com.cliffc.aa.node.PrimNode.LE_I64
Definition: PrimNode.java:408
com.cliffc.aa.node.PrimNode.MinusF64
Definition: PrimNode.java:259
com.cliffc.aa.type.TypeFlt.FLT64
static final TypeFlt FLT64
Definition: TypeFlt.java:38
com.cliffc.aa.GVNGCM.Mode
Definition: GVNGCM.java:14
com.cliffc.aa.type.TypeFunSig._formals
TypeTuple _formals
Definition: TypeFunSig.java:15
com.cliffc.aa.node.PrimNode.OrElse.live_use
TypeMem live_use(GVNGCM.Mode opt_mode, Node def)
Definition: PrimNode.java:609
com.cliffc.aa.node.PrimNode.Not.apply
TypeInt apply(Type[] args)
Definition: PrimNode.java:486
com.cliffc.aa.node.PrimNode.DivI64.DivI64
DivI64()
Definition: PrimNode.java:341
com.cliffc.aa.node.PrimNode.AndThen.live_use
TypeMem live_use(GVNGCM.Mode opt_mode, Node def)
Definition: PrimNode.java:552
com.cliffc.aa.node.PrimNode.PRECEDENCE
static PrimNode[][] PRECEDENCE
Definition: PrimNode.java:37
com.cliffc.aa.node.PrimNode.EQ_OOP.vs_nil
static Type vs_nil(Type tx, Type t, Type f)
Definition: PrimNode.java:439
com.cliffc.aa.type.TypeMemPtr.ISUSED0
static final TypeMemPtr ISUSED0
Definition: TypeMemPtr.java:91