|
|
@@ -10,7 +10,7 @@ From the repository root:
|
|
|
```sh
|
|
|
cd compiler
|
|
|
./build.sh # M2.atg -> scanner/parser/driver -> ./M2
|
|
|
-./run_tests.sh # 310/310
|
|
|
+./run_tests.sh # 333/333
|
|
|
```
|
|
|
|
|
|
`M2` reads Modula-2 sources and writes QBE IR to `gen_ssa/`.
|
|
|
@@ -140,7 +140,65 @@ M2make --dialect iso ... main.mod
|
|
|
or add the folders explicitly with `-I lib/iso -I lib/common -I
|
|
|
runtime/syslib`. Do not mix `lib/pim` and `lib/iso` in one session.
|
|
|
|
|
|
-## 6. Useful checks
|
|
|
+## 6. Address arithmetic, absolute variables, long literals
|
|
|
+
|
|
|
+`SYSTEM` provides ISO byte-address arithmetic:
|
|
|
+
|
|
|
+```modula2
|
|
|
+FROM SYSTEM IMPORT ADDRESS, ADR, ADDADR, SUBADR, DIFADR, VAL;
|
|
|
+
|
|
|
+VAR
|
|
|
+ buf : ARRAY [0..15] OF CHAR;
|
|
|
+ p, q : ADDRESS;
|
|
|
+ diff : INTEGER;
|
|
|
+BEGIN
|
|
|
+ p := ADR(buf[0]); (* raw data address, not the descriptor *)
|
|
|
+ q := ADDADR(p, 5);
|
|
|
+ diff := DIFADR(q, p); (* 5 *)
|
|
|
+ IF SUBADR(q, 5) = p THEN ... END
|
|
|
+END
|
|
|
+```
|
|
|
+
|
|
|
+Absolute variables use a constant address and emit no storage:
|
|
|
+
|
|
|
+```modula2
|
|
|
+VAR
|
|
|
+ port [0x1000] : CARDINAL;
|
|
|
+
|
|
|
+PROCEDURE P;
|
|
|
+VAR
|
|
|
+ slot [0x2000] : CARDINAL;
|
|
|
+END P;
|
|
|
+```
|
|
|
+
|
|
|
+`ADR(port)` is `0x1000`; the same syntax works locally. Addresses
|
|
|
+above `0x7FFFFFFF` use the 64-bit path. The tests only check `ADR` for
|
|
|
+arbitrary addresses; dereferencing an unmapped page will fault. There is
|
|
|
+no `VOLATILE` pragma yet.
|
|
|
+
|
|
|
+String literals up to the 4 KiB class now survive parsing and lowering:
|
|
|
+
|
|
|
+```modula2
|
|
|
+CONST Text = "...."; (* up to 4095 characters including quotes *)
|
|
|
+```
|
|
|
+
|
|
|
+The new showcase demonstrates all three features:
|
|
|
+
|
|
|
+```sh
|
|
|
+cd compiler
|
|
|
+./M2 ../lib/common/sysio.def ../lib/common/sysio.mod tests/showcase26.mod
|
|
|
+qbe -o gen_ssa/Showcase26.s gen_ssa/Showcase26.ssa
|
|
|
+cc gen_ssa/Showcase26.s ../runtime/syslib/shim.c -o /tmp/showcase26 -lm
|
|
|
+/tmp/showcase26
|
|
|
+```
|
|
|
+
|
|
|
+Expected output:
|
|
|
+
|
|
|
+```text
|
|
|
+showcase26 arith=ok abs=ok local=ok text=3000
|
|
|
+```
|
|
|
+
|
|
|
+## 7. Useful checks
|
|
|
|
|
|
```sh
|
|
|
cd compiler && ./run_tests.sh
|
|
|
@@ -149,10 +207,11 @@ TMP="$PWD/.scratch/fixpoint-separate" ./bootstrap/fixpoint-separate.sh
|
|
|
tools/v3-corpus/corpus.sh
|
|
|
```
|
|
|
|
|
|
-Current gates: suite **310/310**, fixpoint **OK (3,845,439 bytes)**,
|
|
|
-corpus **521/612 compile-OK, 0 crashes**.
|
|
|
+Current gates: suite **333/333**, one-shot fixpoint **OK
|
|
|
+(3,671,466 bytes)**, per-object fixpoint **OK (11 objects)**, corpus
|
|
|
+**521/612 compile-OK, 0 crashes**.
|
|
|
|
|
|
-## 7. Current limits
|
|
|
+## 8. Current limits
|
|
|
|
|
|
- `M2 -I` transitive interface scanning is implemented.
|
|
|
- `M2make --separate` rebuilds only stale objects, relinks when an object,
|
|
|
@@ -164,6 +223,11 @@ corpus **521/612 compile-OK, 0 crashes**.
|
|
|
- Per-object self-hosting is a green gate via
|
|
|
`bootstrap/fixpoint-separate.sh`; compiler units use
|
|
|
`-legacyopen1d`, while user programs keep pointer views.
|
|
|
+- Address arithmetic has no general `ADDRESS +/-` operator and no
|
|
|
+ `MAKEADR` yet. `DIFADR` narrows to `INTEGER`; there is no 64-bit or
|
|
|
+ range-checked result form.
|
|
|
+- Absolute variables are not `VOLATILE`; memory-mapped I/O needs a
|
|
|
+ pragma and backend support that are still future work.
|
|
|
|
|
|
For details, see `docs/separate-compilation.md` and
|
|
|
`docs/plan-separate-compilation.md`.
|