Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9f52d79

Browse files
Rename SONType to Type - and all sub types too so that it is easy to merge code from Simple
1 parent 1881b27 commit 9f52d79

File tree

107 files changed

+1020
-1047
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1020
-1047
lines changed

‎seaofnodes/src/main/java/com/compilerprogramming/ezlang/compiler/Compiler.java‎

Lines changed: 69 additions & 69 deletions
Large diffs are not rendered by default.

‎seaofnodes/src/main/java/com/compilerprogramming/ezlang/compiler/Var.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,36 @@ public class Var {
1010

1111
public final String _name; // Declared name
1212
public int _idx; // index in containing scope
13-
private SONType _type; // Declared type
13+
private Type _type; // Declared type
1414
public boolean _final; // Final field
1515
public boolean _fref; // Forward ref
1616

17-
public Var(int idx, String name, SONType type, boolean xfinal) {
17+
public Var(int idx, String name, Type type, boolean xfinal) {
1818
this(idx,name,type,xfinal,false);
1919
}
20-
public Var(int idx, String name, SONType type, boolean xfinal, boolean fref) {
20+
public Var(int idx, String name, Type type, boolean xfinal, boolean fref) {
2121
_idx = idx;
2222
_name = name;
2323
_type = type;
2424
_final = xfinal;
2525
_fref = fref;
2626
}
27-
public SONType type() {
27+
public Type type() {
2828
if( !_type.isFRef() ) return _type;
2929
// Update self to no longer use the forward ref type
30-
SONType def = Compiler.TYPES.get(((SONTypeMemPtr)_type)._obj._name);
30+
Type def = Compiler.TYPES.get(((TypeMemPtr)_type)._obj._name);
3131
return (_type=_type.meet(def));
3232
}
33-
public SONType lazyGLB() {
34-
SONType t = type();
35-
return t instanceof SONTypeMemPtr ? t : t.glb();
33+
public Type lazyGLB() {
34+
Type t = type();
35+
return t instanceof TypeMemPtr ? t : t.glb();
3636
}
3737

3838
// Forward reference variables (not types) must be BOTTOM and
3939
// distinct from inferred variables
4040
public boolean isFRef() { return _fref; }
4141

42-
public void defFRef(SONType type, boolean xfinal) {
42+
public void defFRef(Type type, boolean xfinal) {
4343
assert isFRef() && xfinal;
4444
_type = type;
4545
_final = true;

‎seaofnodes/src/main/java/com/compilerprogramming/ezlang/compiler/codegen/BuildLRG.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.compilerprogramming.ezlang.compiler.codegen;
22

3-
import com.compilerprogramming.ezlang.compiler.Utils;
43
import com.compilerprogramming.ezlang.compiler.nodes.*;
5-
import com.compilerprogramming.ezlang.compiler.sontypes.SONTypeMem;
4+
import com.compilerprogramming.ezlang.compiler.sontypes.TypeMem;
65

76
abstract public class BuildLRG {
87
// Compute live ranges in a single forwards pass. Every def is a new live
@@ -17,7 +16,7 @@ abstract public class BuildLRG {
1716
public static boolean run(int round, RegAlloc alloc) {
1817
for( Node bb : alloc._code._cfg )
1918
for( Node n : bb.outs() ) {
20-
if( n instanceof PhiNode phi && !(phi._type instanceof SONTypeMem) ) {
19+
if( n instanceof PhiNode phi && !(phi._type instanceof TypeMem) ) {
2120
// All Phi inputs end up with the same LRG.
2221
// Pass 1: find any pre-existing LRG, to avoid make-then-Union a LRG
2322
LRG lrg = alloc.lrg(phi);

‎seaofnodes/src/main/java/com/compilerprogramming/ezlang/compiler/codegen/CodeGen.java‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public enum Phase {
3636
// Compilation source code
3737
public final String _src;
3838
// Compile-time known initial argument type
39-
public final SONTypeInteger _arg;
39+
public final TypeInteger _arg;
4040

4141
// ---------------------------
42-
public CodeGen( String src ) { this(src, SONTypeInteger.BOT, 123L ); }
43-
public CodeGen(String src, SONTypeInteger arg, long workListSeed ) {
42+
public CodeGen( String src ) { this(src, TypeInteger.BOT, 123L ); }
43+
public CodeGen(String src, TypeInteger arg, long workListSeed ) {
4444
CODE = this;
4545
_phase = null;
4646
_callingConv = null;
@@ -122,39 +122,39 @@ public int iDepthFrom(int idepth) {
122122

123123
// Compute "function indices": FIDX.
124124
// Each new request at the same signature gets a new FIDX.
125-
private final HashMap<SONTypeTuple,Integer> FIDXS = new HashMap<>();
126-
public SONTypeFunPtr makeFun(SONTypeTuplesig, SONType ret ) {
125+
private final HashMap<TypeTuple,Integer> FIDXS = new HashMap<>();
126+
public TypeFunPtr makeFun(TypeTuplesig, Type ret ) {
127127
Integer i = FIDXS.get(sig);
128128
int fidx = i==null ? 0 : i;
129129
FIDXS.put(sig,fidx+1); // Track count per sig
130130
assert fidx<64; // TODO: need a larger FIDX space
131-
return SONTypeFunPtr.make((byte)2,sig,ret, 1L<<fidx );
131+
return TypeFunPtr.make((byte)2,sig,ret, 1L<<fidx );
132132
}
133-
public SONTypeFunPtr makeFun2(SONTypeTuplesig, SONType ret ) {
133+
public TypeFunPtr makeFun2(TypeTuplesig, Type ret ) {
134134
Integer i = FIDXS.get(sig);
135135
int fidx = i==null ? 0 : i;
136136
FIDXS.put(sig,fidx+1); // Track count per sig
137137
assert fidx<64; // TODO: need a larger FIDX space
138-
return new SONTypeFunPtr((byte)2,sig,ret, 1L<<fidx );
138+
return new TypeFunPtr((byte)2,sig,ret, 1L<<fidx );
139139
}
140140
// Signature for MAIN
141-
public SONTypeFunPtr _main = makeFun(SONTypeTuple.MAIN,SONType.BOTTOM);
141+
public TypeFunPtr _main = makeFun(TypeTuple.MAIN,Type.BOTTOM);
142142
// Reverse from a constant function pointer to the IR function being called
143-
public FunNode link( SONTypeFunPtr tfp ) {
143+
public FunNode link( TypeFunPtr tfp ) {
144144
assert tfp.isConstant();
145-
return _linker.get(tfp.makeFrom(SONType.BOTTOM));
145+
return _linker.get(tfp.makeFrom(Type.BOTTOM));
146146
}
147147

148148
// Insert linker mapping from constant function signature to the function
149149
// being called.
150150
public void link(FunNode fun) {
151-
_linker.put(fun.sig().makeFrom(SONType.BOTTOM),fun);
151+
_linker.put(fun.sig().makeFrom(Type.BOTTOM),fun);
152152
}
153153

154154
// "Linker" mapping from constant TypeFunPtrs to heads of function. These
155155
// TFPs all have exact single fidxs and their return is wiped to BOTTOM (so
156156
// the return is not part of the match).
157-
private final HashMap<SONTypeFunPtr,FunNode> _linker = new HashMap<>();
157+
private final HashMap<TypeFunPtr,FunNode> _linker = new HashMap<>();
158158

159159
// Parser object
160160
public final Compiler P;

‎seaofnodes/src/main/java/com/compilerprogramming/ezlang/compiler/codegen/ElfFile.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.nio.ByteBuffer;
1010
import java.nio.ByteOrder;
1111
import java.util.HashMap;
12-
import java.util.Map;
1312

1413
public class ElfFile {
1514

@@ -213,7 +212,7 @@ private void pushSection(Section s) {
213212
}
214213

215214
/* creates function and stores where it starts*/
216-
private final HashMap<SONTypeFunPtr,Symbol> _funcs = new HashMap<>();
215+
private final HashMap<TypeFunPtr,Symbol> _funcs = new HashMap<>();
217216
private void encodeFunctions(SymbolSection symbols, DataSection text) {
218217
for( int i=0; i<_code._cfg._len; i++ ) {
219218
if( !(_code._cfg.at(i) instanceof FunNode fun) ) continue;

‎seaofnodes/src/main/java/com/compilerprogramming/ezlang/compiler/codegen/Encoding.java‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.compilerprogramming.ezlang.compiler.codegen;
22

33
import com.compilerprogramming.ezlang.compiler.Ary;
4-
import com.compilerprogramming.ezlang.compiler.SB;
54
import com.compilerprogramming.ezlang.compiler.Utils;
65
import com.compilerprogramming.ezlang.compiler.nodes.*;
76
import com.compilerprogramming.ezlang.compiler.sontypes.*;
@@ -47,12 +46,12 @@ public static class BAOS extends ByteArrayOutputStream {
4746
// Big Constant relocation info.
4847
public static class Relo {
4948
public final Node _op;
50-
public final SONType _t; // Constant type
49+
public final Type _t; // Constant type
5150
public final byte _off; // Offset from start of opcode
5251
public final byte _elf; // ELF relocation type, e.g. 2/PC32
5352
public int _target; // Where constant is finally placede
5453
public int _opStart; // Opcode start
55-
Relo(Node op, SONType t, byte off, byte elf ) {
54+
Relo(Node op, Type t, byte off, byte elf ) {
5655
_op=op; _t=t; _off=off; _elf=elf;
5756
}
5857
}
@@ -99,12 +98,12 @@ static void padN(int n, BAOS bits) {
9998
}
10099

101100
// Convenience for writing log-N
102-
static void addN(int log, SONType t, BAOS bits ) {
103-
long x = t instanceof SONTypeInteger ti
101+
static void addN(int log, Type t, BAOS bits ) {
102+
long x = t instanceof TypeInteger ti
104103
? ti.value()
105104
: log==3
106-
? Double.doubleToRawLongBits( ((SONTypeFloat)t).value())
107-
: Float.floatToRawIntBits((float)((SONTypeFloat)t).value());
105+
? Double.doubleToRawLongBits( ((TypeFloat)t).value())
106+
: Float.floatToRawIntBits((float)((TypeFloat)t).value());
108107
addN(log,x,bits);
109108
}
110109
static void addN( int log, long x, BAOS bits ) {
@@ -129,7 +128,7 @@ public Encoding relo( CallNode call ) {
129128
return this;
130129
}
131130
public Encoding relo( ConstantNode con ) {
132-
SONTypeFunPtr tfp = (SONTypeFunPtr)con._con;
131+
TypeFunPtr tfp = (TypeFunPtr)con._con;
133132
_internals.put(con,_code.link(tfp));
134133
return this;
135134
}
@@ -146,7 +145,7 @@ public Encoding external( Node call, String extern ) {
146145

147146
// Store t as a 32/64 bit constant in the code space; generate RIP-relative
148147
// addressing to load it
149-
public void largeConstant(Node relo, SONType t, int off, int elf ) {
148+
public void largeConstant(Node relo, Type t, int off, int elf ) {
150149
assert t.isConstant();
151150
assert (byte)off == off;
152151
assert (byte)elf == elf;
@@ -423,7 +422,7 @@ void patchLocalRelocations() {
423422
void writeConstantPool( BAOS bits, boolean patch ) {
424423
padN(16,bits);
425424

426-
HashMap<SONType,Integer> targets = new HashMap<>();
425+
HashMap<Type,Integer> targets = new HashMap<>();
427426

428427
// By log size
429428
for( int log = 3; log >= 0; log-- ) {
@@ -436,8 +435,8 @@ void writeConstantPool( BAOS bits, boolean patch ) {
436435
if( target==null ) {
437436
targets.put(relo._t,target = bits.size());
438437
// Put constant into code space.
439-
if( relo._t instanceof SONTypeTuple tt ) // Constant tuples put all entries
440-
for( SONType tx : tt._types )
438+
if( relo._t instanceof TypeTuple tt ) // Constant tuples put all entries
439+
for( Type tx : tt._types )
441440
addN(log,tx,bits);
442441
else
443442
addN(log,relo._t,bits);

‎seaofnodes/src/main/java/com/compilerprogramming/ezlang/compiler/codegen/GlobalCodeMotion.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ private static void breadth(Node stop, Node[] ns, CFGNode[] late) {
166166
// New makes new memory, never crushes load memory
167167
!(memuse instanceof NewNode) &&
168168
// Load-use directly defines memory
169-
(memuse._type instanceof SONTypeMem ||
169+
(memuse._type instanceof TypeMem ||
170170
// Load-use directly defines memory
171171
memuse instanceof CallNode ||
172172
// Load-use indirectly defines memory
173-
(memuse._type instanceof SONTypeTuple tt && tt._types[ld._alias] instanceof SONTypeMem)) )
173+
(memuse._type instanceof TypeTuple tt && tt._types[ld._alias] instanceof TypeMem)) )
174174
continue outer;
175175

176176
// All uses done, schedule

‎seaofnodes/src/main/java/com/compilerprogramming/ezlang/compiler/codegen/Machine.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.compilerprogramming.ezlang.compiler.codegen;
22

33
import com.compilerprogramming.ezlang.compiler.nodes.*;
4-
import com.compilerprogramming.ezlang.compiler.sontypes.SONTypeFunPtr;
4+
import com.compilerprogramming.ezlang.compiler.sontypes.TypeFunPtr;
55

66
abstract public class Machine {
77
// Human readable machine name. Something like "x86-64" or "arm" or "risc5"
@@ -21,9 +21,9 @@ abstract public class Machine {
2121
// for the function itself, or for *outgoing* calls, the maximum stack slot
2222
// given to the incoming function arguments (stack slots reserved for
2323
// incoming arguments).
24-
public abstract RegMask callArgMask(SONTypeFunPtr tfp, int arg, int maxArgSlot);
24+
public abstract RegMask callArgMask(TypeFunPtr tfp, int arg, int maxArgSlot);
2525
// Return register mask, based on signature (GPR vs FPR)
26-
public abstract RegMask retMask(SONTypeFunPtr tfp);
26+
public abstract RegMask retMask(TypeFunPtr tfp);
2727
// Return PC register
2828
public abstract int rpc();
2929
// Return a MachNode unconditional branch
@@ -92,6 +92,6 @@ abstract public class Machine {
9292
// Maximum stack slot (or 0) for the args in this TFP. This will include
9393
// shadow slots if defined in the ABI, even if all arguments are passed in
9494
// registers.
95-
public abstract short maxArgSlot(SONTypeFunPtr tfp);
95+
public abstract short maxArgSlot(TypeFunPtr tfp);
9696

9797
}

‎seaofnodes/src/main/java/com/compilerprogramming/ezlang/compiler/nodes/AddFNode.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.compilerprogramming.ezlang.compiler.nodes;
22

3-
import com.compilerprogramming.ezlang.compiler.sontypes.SONType;
4-
import com.compilerprogramming.ezlang.compiler.sontypes.SONTypeFloat;
3+
import com.compilerprogramming.ezlang.compiler.sontypes.Type;
4+
import com.compilerprogramming.ezlang.compiler.sontypes.TypeFloat;
55

66
import java.util.BitSet;
77

@@ -20,22 +20,22 @@ public StringBuilder _print1(StringBuilder sb, BitSet visited) {
2020
}
2121

2222
@Override
23-
public SONType compute() {
24-
if (in(1)._type instanceof SONTypeFloat i0 &&
25-
in(2)._type instanceof SONTypeFloat i1) {
23+
public Type compute() {
24+
if (in(1)._type instanceof TypeFloat i0 &&
25+
in(2)._type instanceof TypeFloat i1) {
2626
if (i0.isConstant() && i1.isConstant())
27-
return SONTypeFloat.constant(i0.value()+i1.value());
27+
return TypeFloat.constant(i0.value()+i1.value());
2828
}
2929
return in(1)._type.meet(in(2)._type);
3030
}
3131

3232
@Override
3333
public Node idealize() {
3434
Node lhs = in(1);
35-
SONType t2 = in(2)._type;
35+
Type t2 = in(2)._type;
3636

3737
// Add of 0.
38-
if ( t2.isConstant() && t2 instanceof SONTypeFloat i && i.value()==0 )
38+
if ( t2.isConstant() && t2 instanceof TypeFloat i && i.value()==0 )
3939
return lhs;
4040

4141
return null;

‎seaofnodes/src/main/java/com/compilerprogramming/ezlang/compiler/nodes/AddNode.java‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.compilerprogramming.ezlang.compiler.nodes;
22

3-
import com.compilerprogramming.ezlang.compiler.Compiler;
43
import com.compilerprogramming.ezlang.compiler.sontypes.*;
54

65
import java.util.BitSet;
@@ -23,20 +22,20 @@ public StringBuilder _print1(StringBuilder sb, BitSet visited) {
2322

2423

2524
@Override
26-
public SONType compute() {
27-
SONType t1 = in(1)._type, t2 = in(2)._type;
25+
public Type compute() {
26+
Type t1 = in(1)._type, t2 = in(2)._type;
2827
if( t1.isHigh() || t2.isHigh() )
29-
return SONTypeInteger.TOP;
30-
if( t1 instanceof SONTypeInteger i1 &&
31-
t2 instanceof SONTypeInteger i2 ) {
28+
return TypeInteger.TOP;
29+
if( t1 instanceof TypeInteger i1 &&
30+
t2 instanceof TypeInteger i2 ) {
3231
if (i1.isConstant() && i2.isConstant())
33-
return SONTypeInteger.constant(i1.value()+i2.value());
32+
return TypeInteger.constant(i1.value()+i2.value());
3433
// Fold ranges like {0-1} + {2-3} into {2-4}.
3534
if( !overflow(i1._min,i2._min) &&
3635
!overflow(i1._max,i2._max) )
37-
return SONTypeInteger.make(i1._min+i2._min,i1._max+i2._max);
36+
return TypeInteger.make(i1._min+i2._min,i1._max+i2._max);
3837
}
39-
return SONTypeInteger.BOT;
38+
return TypeInteger.BOT;
4039
}
4140

4241
static boolean overflow( long x, long y ) {
@@ -49,11 +48,11 @@ public Node idealize () {
4948
Node rhs = in(2);
5049
if( rhs instanceof AddNode add && add.err()!=null )
5150
return null;
52-
SONType t2 = rhs._type;
51+
Type t2 = rhs._type;
5352

5453
// Add of 0. We do not check for (0+x) because this will already
5554
// canonicalize to (x+0)
56-
if( t2 == SONTypeInteger.ZERO )
55+
if( t2 == TypeInteger.ZERO )
5756
return lhs;
5857

5958
// Add of same to a multiply by 2
@@ -122,7 +121,7 @@ public Node idealize () {
122121
static Node phiCon(Node op, boolean rotate) {
123122
Node lhs = op.in(1);
124123
Node rhs = op.in(2);
125-
if( rhs._type== SONTypeInteger.TOP ) return null;
124+
if( rhs._type== TypeInteger.TOP ) return null;
126125
// LHS is either a Phi of constants, or another op with Phi of constants
127126
PhiNode lphi = pcon(lhs,op);
128127
if( rotate && lphi==null && lhs.nIns() > 2 ) {
@@ -175,8 +174,8 @@ static boolean spine_cmp( Node hi, Node lo, Node dep ) {
175174
if( lo._type.isConstant() ) return false;
176175
if( hi._type.isConstant() ) return true ;
177176

178-
if( lo instanceof PhiNode lphi && lphi.region()._type== SONType.XCONTROL ) return false;
179-
if( hi instanceof PhiNode hphi && hphi.region()._type== SONType.XCONTROL ) return false;
177+
if( lo instanceof PhiNode lphi && lphi.region()._type== Type.XCONTROL ) return false;
178+
if( hi instanceof PhiNode hphi && hphi.region()._type== Type.XCONTROL ) return false;
180179

181180
if( lo instanceof PhiNode && lo.allCons(dep) ) return false;
182181
if( hi instanceof PhiNode && hi.allCons(dep) ) return true ;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /