@asmlift/core 0.8.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -31
- package/package.json +1 -1
- package/src/aggregate.ts +397 -0
- package/src/backend/c.ts +6 -2
- package/src/backend/cfamily.ts +370 -56
- package/src/backend/cpp.ts +116 -10
- package/src/backend/pascal.ts +69 -11
- package/src/cdecl/constant.ts +59 -0
- package/src/cdecl/lex.ts +209 -0
- package/src/cdecl/parse.ts +975 -0
- package/src/cdecl/spell.ts +69 -0
- package/src/codegen-flags.ts +38 -6
- package/src/compiler-diagnostics.ts +194 -0
- package/src/contracts.ts +777 -84
- package/src/declare.ts +132 -13
- package/src/frontend/asmdata.ts +26 -6
- package/src/frontend/call-plan.ts +1590 -0
- package/src/frontend/dead-reads.ts +628 -0
- package/src/frontend/device-pins.ts +296 -0
- package/src/frontend/emit.ts +4 -3
- package/src/frontend/errors.ts +5 -0
- package/src/frontend/flags-edge.ts +101 -0
- package/src/frontend/fpu.ts +374 -0
- package/src/frontend/frame-objects.ts +3171 -0
- package/src/frontend/frontend.ts +64 -3
- package/src/frontend/high-half.ts +55 -5
- package/src/frontend/jump-table.ts +530 -0
- package/src/frontend/local-object.ts +616 -0
- package/src/frontend/mips.ts +2392 -208
- package/src/frontend/opaque.ts +97 -18
- package/src/frontend/own-struct-return.ts +500 -0
- package/src/frontend/ppc.ts +3137 -267
- package/src/frontend/register-struct-call.ts +484 -0
- package/src/frontend/reloc-symbol.ts +109 -13
- package/src/frontend/splat.ts +108 -5
- package/src/frontend/ssa.ts +2098 -89
- package/src/frontend/stackargs.ts +172 -42
- package/src/frontend/thumb.ts +4563 -2091
- package/src/ir/alias.ts +71 -0
- package/src/ir/bits.ts +681 -1
- package/src/ir/core.ts +199 -6
- package/src/ir/discipline.ts +313 -0
- package/src/ir/entry.ts +159 -0
- package/src/ir/float-bits.ts +47 -0
- package/src/{structure → ir}/loops.ts +6 -2
- package/src/ir/opcodes.ts +193 -121
- package/src/ir/parse.ts +1 -0
- package/src/ir/types.ts +202 -2
- package/src/ir/verify.ts +219 -3
- package/src/l3/address.ts +5 -0
- package/src/l3/argcopy.ts +38 -6
- package/src/l3/ast.ts +467 -23
- package/src/l3/basecse.ts +33 -5
- package/src/l3/coalesce.ts +21 -13
- package/src/l3/constinit.ts +382 -0
- package/src/l3/dce.ts +34 -12
- package/src/l3/gates.ts +9 -3
- package/src/l3/hoist.ts +8 -7
- package/src/l3/initfirst.ts +68 -19
- package/src/l3/intcell.ts +98 -0
- package/src/l3/mentions.ts +10 -4
- package/src/l3/narrowdecl.ts +259 -0
- package/src/l3/nearbase.ts +10 -5
- package/src/l3/parkfirst.ts +8 -5
- package/src/l3/pollguard.ts +11 -4
- package/src/l3/ptrcell.ts +354 -0
- package/src/l3/ptrfield.ts +123 -8
- package/src/l3/regspell.ts +26 -7
- package/src/l3/reindex.ts +293 -103
- package/src/l3/storage.ts +98 -1
- package/src/l3/symbol-refs.ts +182 -23
- package/src/l3/tailmerge.ts +9 -20
- package/src/l3/typing.ts +237 -32
- package/src/l3/unreduce.ts +10 -9
- package/src/l3/volatileptr.ts +17 -54
- package/src/l3/volstore.ts +96 -7
- package/src/mangle.ts +41 -1
- package/src/pattern/engine.ts +373 -82
- package/src/pipeline.ts +589 -27
- package/src/proto-context.ts +1648 -0
- package/src/proto.ts +1203 -49
- package/src/raise/aggmembers.ts +290 -0
- package/src/raise/arrays.ts +8 -3
- package/src/raise/declared-volatile.ts +307 -0
- package/src/raise/divpow2.ts +2 -2
- package/src/raise/errors.ts +17 -0
- package/src/raise/floathelpers.ts +464 -0
- package/src/raise/globalshape.ts +11 -5
- package/src/raise/gvn.ts +29 -8
- package/src/raise/latch.ts +162 -6
- package/src/raise/memberarrays.ts +10 -4
- package/src/raise/narrow.ts +29 -2
- package/src/raise/narrowlocal.ts +11 -6
- package/src/raise/offsetnames.ts +494 -0
- package/src/raise/pairparams.ts +114 -0
- package/src/raise/paramwidth.ts +203 -6
- package/src/raise/pre-recovery.ts +174 -17
- package/src/raise/pre-structure.ts +54 -0
- package/src/raise/recover.ts +26 -15
- package/src/raise/reroll.ts +694 -0
- package/src/raise/retsink.ts +1 -1
- package/src/raise/shortcircuit.ts +66 -30
- package/src/raise/softdiv.ts +21 -23
- package/src/raise/storesign.ts +153 -0
- package/src/raise/struct-arrays.ts +34 -14
- package/src/raise/structs.ts +674 -98
- package/src/raise/truncload.ts +367 -0
- package/src/raise/unthread.ts +400 -0
- package/src/raise/widehelpers.ts +106 -0
- package/src/rank-declare.ts +143 -12
- package/src/rank-variations.ts +117 -31
- package/src/rank.ts +563 -122
- package/src/runtime-helpers.ts +405 -0
- package/src/stillborn.ts +289 -0
- package/src/structure/analysis.ts +1449 -449
- package/src/structure/arith-ops.ts +23 -0
- package/src/structure/globalaccess.ts +111 -9
- package/src/structure/hazards.ts +641 -114
- package/src/structure/local-statics.ts +517 -0
- package/src/structure/namecoalesce.ts +2 -2
- package/src/structure/pointer-spelling.ts +1106 -0
- package/src/structure/redundant-test.ts +99 -0
- package/src/structure/structure.ts +3478 -975
- package/src/structure/switch-recover.ts +403 -178
- package/src/symbols.ts +44 -3
- package/src/target.ts +1387 -71
- package/src/trace.ts +66 -28
- package/src/variation-definitions.ts +243 -13
- package/src/variation-gates.ts +2 -0
- package/src/variation-tokens.ts +25 -7
package/src/ir/alias.ts
CHANGED
|
@@ -86,6 +86,35 @@ export function globalCellOf(defs: Map<Value, Op>, addr: Value, off: number): Gl
|
|
|
86
86
|
return null;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* The named global an address value is DERIVED FROM, through defs alone — `gaddr`, an `add` where
|
|
91
|
+
* exactly one side reaches a name, and the LEFT side of a `sub`, whose right side is a distance and
|
|
92
|
+
* never a second object. Where {@link globalCellOf} asks which CELL an
|
|
93
|
+
* address denotes and answers null the moment a runtime term enters, this asks only which OBJECT
|
|
94
|
+
* it reaches, which a runtime index does not change: `gVolArr[i]` names no cell and one object.
|
|
95
|
+
*
|
|
96
|
+
* So it answers a DECLARATION question — volatile, const, the qualifiers that hold for every byte
|
|
97
|
+
* of the object — and never an aliasing one: two accesses this gives the same name are not thereby
|
|
98
|
+
* the same cell. Null when nothing reaches a name, and when two sides do (a sum of two `gaddr`s is
|
|
99
|
+
* a base the defs cannot tell apart); null is UNKNOWN rather than "no global", so a caller that
|
|
100
|
+
* refuses on a declared property must read it as "the map cannot say".
|
|
101
|
+
*/
|
|
102
|
+
export function globalBaseOf(defs: Map<Value, Op>, addr: Value): string | null {
|
|
103
|
+
const d = defs.get(addr);
|
|
104
|
+
if (d?.opcode === 'gaddr') {
|
|
105
|
+
return d.attrs.sym as string;
|
|
106
|
+
}
|
|
107
|
+
if (d?.opcode === 'add' && d.operands.length === 2) {
|
|
108
|
+
const a = globalBaseOf(defs, d.operands[0]);
|
|
109
|
+
const b = globalBaseOf(defs, d.operands[1]);
|
|
110
|
+
return a !== null && b !== null ? null : (a ?? b);
|
|
111
|
+
}
|
|
112
|
+
if (d?.opcode === 'sub' && d.operands.length === 2) {
|
|
113
|
+
return globalBaseOf(defs, d.operands[0]);
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
89
118
|
/**
|
|
90
119
|
* The NUMERIC address an access denotes, resolved through defs alone — a literal base, or the sum
|
|
91
120
|
* of two literals — plus the access's own `off`. Null when the address
|
|
@@ -110,6 +139,48 @@ export function constAddressOf(defs: Map<Value, Op>, addr: Value, off: number):
|
|
|
110
139
|
return null;
|
|
111
140
|
}
|
|
112
141
|
|
|
142
|
+
/**
|
|
143
|
+
* A constant DISPLACEMENT off a root, read through defs alone: `add(p, K)`, `add(K, p)`, `sub(p, K)`,
|
|
144
|
+
* or a chain of them, as the root `p`, the summed `K`, and the chain's values from `addr` toward
|
|
145
|
+
* `p`. Null when `addr` is not such a link. `sub` is not commutative, so `K - p` stops the walk; a
|
|
146
|
+
* link whose two operands are both constants stops it too (that is a literal address,
|
|
147
|
+
* {@link constAddressOf}'s question). The one reading of address arithmetic that raise/structs.ts
|
|
148
|
+
* (which accesses share a base) and raise/offsetnames.ts (which named global an address stands on)
|
|
149
|
+
* both ask, so the two cannot disagree about where a chain ends.
|
|
150
|
+
*/
|
|
151
|
+
export function constDisplacementOf(
|
|
152
|
+
defs: Map<Value, Op>,
|
|
153
|
+
addr: Value,
|
|
154
|
+
): { root: Value; k: number; chain: Value[] } | null {
|
|
155
|
+
const constOf = (x: Value): number | null => {
|
|
156
|
+
const d = defs.get(x);
|
|
157
|
+
return d?.opcode === 'const' && typeof d.attrs.value === 'number' ? d.attrs.value : null;
|
|
158
|
+
};
|
|
159
|
+
let k = 0;
|
|
160
|
+
const chain: Value[] = [];
|
|
161
|
+
let cur = addr;
|
|
162
|
+
for (;;) {
|
|
163
|
+
const d = defs.get(cur);
|
|
164
|
+
if (!d || (d.opcode !== 'add' && d.opcode !== 'sub') || d.operands.length !== 2) {
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
const [x, y] = d.operands;
|
|
168
|
+
const ky = constOf(y);
|
|
169
|
+
const kx = d.opcode === 'add' ? constOf(x) : null;
|
|
170
|
+
if (ky !== null && kx === null) {
|
|
171
|
+
k += d.opcode === 'add' ? ky : -ky;
|
|
172
|
+
cur = x;
|
|
173
|
+
} else if (kx !== null && ky === null) {
|
|
174
|
+
k += kx;
|
|
175
|
+
cur = y;
|
|
176
|
+
} else {
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
chain.push(d.results[0]);
|
|
180
|
+
}
|
|
181
|
+
return chain.length === 0 ? null : { root: cur, k, chain };
|
|
182
|
+
}
|
|
183
|
+
|
|
113
184
|
/**
|
|
114
185
|
* Are these two accesses through ONE base provably different byte cells — same base value, both at
|
|
115
186
|
* a constant offset and width, ranges non-overlapping? The everyday struct interleave
|