aa
ThunkNode.java
Go to the documentation of this file.
1 package com.cliffc.aa.node;
2 
3 import com.cliffc.aa.GVNGCM;
4 import com.cliffc.aa.type.Type;
5 import com.cliffc.aa.type.TypeMem;
6 
7 import java.util.function.Predicate;
8 
9 // Thunk: a limited function.
10 // See Thret (Return).
11 
12 // Expected 1 caller only, determined after Parse.expr(), so the single input
13 // is just a constant hook: StartNode.
14 // No arguments, not even a display (uses the existing display, no scope implied).
15 // Produces a Control & Memory.
16 public class ThunkNode extends Node {
17  public ThunkNode( Node mem ) { super(OP_THUNK,null,mem); }
18  @Override public Node ideal_reduce() { return null; }
19  @Override public Type value(GVNGCM.Mode opt_mode) {
20  if( _keep==0 && // If keep, then during construction and no Thret built yet (but coming)
21  is_copy(0)==null && // If copy, then alive and collapsing as a copy
22  thret()==null ) // If not-copy & not-keep AND no Thret, then dead from below
23  return Type.XCTRL;
24  return Type.CTRL;
25  }
26  @Override public TypeMem live_use(GVNGCM.Mode opt_mode, Node def ) {
27  return def==in(1) ? TypeMem.ALLMEM : TypeMem.ALIVE; // Basic aliveness, except for memory
28  }
29  @Override public TypeMem all_live() { return TypeMem.ALIVE; }
30 
31  //@Override public TV2 new_tvar(String alloc_site) { return TV2.make_base(this,Type.CTRL,alloc_site); }
32 
33  @Override public Node is_copy(int idx) {
34  if( _defs._len==2 ) return null;
35  if( idx==0 ) return in(2); // Wired thunk added a def
36  if( idx==1 ) return in(1);
37  throw com.cliffc.aa.AA.unimpl();
38  }
39  @Override Node walk_dom_last(Predicate<Node> P) { return in(0)==null ? null : super.walk_dom_last(P); }
40  // Never equal, since will be editted during parsing & then removed.
41  @Override public boolean equals(Object o) { return this==o; } //
43  for( Node use : _uses )
44  if( use instanceof ThretNode && ((ThretNode)use).thunk()==this )
45  return (ThretNode)use;
46  return null;
47  }
48 }
com.cliffc.aa.node.ThunkNode.equals
boolean equals(Object o)
Definition: ThunkNode.java:41
com.cliffc.aa.node.ThunkNode.walk_dom_last
Node walk_dom_last(Predicate< Node > P)
Definition: ThunkNode.java:39
com.cliffc.aa.node.ThunkNode.thret
ThretNode thret()
Definition: ThunkNode.java:42
com.cliffc.aa.node.ThretNode
Definition: ThretNode.java:14
com.cliffc.aa.node.Node.walk_dom_last
Node walk_dom_last(Predicate< Node > P)
Definition: Node.java:863
com.cliffc.aa.node.ThunkNode.is_copy
Node is_copy(int idx)
Definition: ThunkNode.java:33
com.cliffc.aa.type.TypeMem
Memory type; the state of all of memory; memory edges order memory ops.
Definition: TypeMem.java:53
com.cliffc
com.cliffc.aa.node.Node
Definition: Node.java:16
com.cliffc.aa.type.Type
an implementation of language AA
Definition: Type.java:94
com.cliffc.aa.node.ThunkNode.all_live
TypeMem all_live()
Definition: ThunkNode.java:29
com.cliffc.aa.node.Node.OP_THUNK
static final byte OP_THUNK
Definition: Node.java:49
com.cliffc.aa.node.ThunkNode.ideal_reduce
Node ideal_reduce()
Definition: ThunkNode.java:18
com.cliffc.aa.type.TypeMem.ALLMEM
static final TypeMem ALLMEM
Definition: TypeMem.java:228
com.cliffc.aa.AA.unimpl
static RuntimeException unimpl()
Definition: AA.java:10
com.cliffc.aa.node.Node._keep
byte _keep
Definition: Node.java:86
com.cliffc.aa.type.Type.CTRL
static final Type CTRL
Definition: Type.java:326
com.cliffc.aa.node.Node.in
Node in(int i)
Definition: Node.java:126
com.cliffc.aa.type.TypeMem.ALIVE
static final TypeMem ALIVE
Definition: TypeMem.java:226
com.cliffc.aa.type.Type.XCTRL
static final Type XCTRL
Definition: Type.java:327
com.cliffc.aa.GVNGCM
Definition: GVNGCM.java:12
com.cliffc.aa.node.Node._uses
Ary< Node > _uses
Definition: Node.java:245
com.cliffc.aa.AA
an implementation of language AA
Definition: AA.java:9
com.cliffc.aa
Definition: AA.java:1
com.cliffc.aa.node.ThunkNode.live_use
TypeMem live_use(GVNGCM.Mode opt_mode, Node def)
Definition: ThunkNode.java:26
com.cliffc.aa.node.ThunkNode
Definition: ThunkNode.java:16
com.cliffc.aa.node.ThunkNode.ThunkNode
ThunkNode(Node mem)
Definition: ThunkNode.java:17
com
com.cliffc.aa.type
Definition: Bits.java:1
com.cliffc.aa.node.Node._defs
Ary< Node > _defs
Definition: Node.java:124
com.cliffc.aa.node.ThunkNode.value
Type value(GVNGCM.Mode opt_mode)
Definition: ThunkNode.java:19
com.cliffc.aa.GVNGCM.Mode
Definition: GVNGCM.java:14