Просмотр исходного кода

lower L7: retire the -lower flag and the degenerate byte-compare tests

Lower is the only emitter, so -lower no longer changed what was emitted
— only the image name for run_tests.sh's legacy-vs-lower compare, which
compared Lower against itself.  Remove IsLowerParam/lowerTest from the
driver, make Lower.EndSession take no testSuffix, and drop the 23
lower_ok/lower_ok_files cases (the suite is now 181 tests; the covered
programs are already exercised by the expect_run/session cases).

Suite 181/181; FIXPOINT OK (3,370,862 bytes).
Eric Streit 3 дней назад
Родитель
Сommit
bcb93a5053
4 измененных файлов с 5 добавлено и 96 удалено
  1. 0 66
      compiler/run_tests.sh
  2. 1 1
      compiler/src/Lower.def
  3. 1 11
      compiler/src/Lower.mod
  4. 3 18
      compiler/src/compiler.frm

+ 0 - 66
compiler/run_tests.sh

@@ -448,72 +448,6 @@ expect_fail_files() {
 expect_fail_files d_badimp_prog "undeclared identifier" d_basic.def d_basic.mod d_badimp_prog.mod
 expect_fail_files d_badimp_prog "undeclared identifier" d_basic.def d_basic.mod d_badimp_prog.mod
 expect_fail_files sig "implementation does not match definition" sig.def sig.mod sig_prog.mod
 expect_fail_files sig "implementation does not match definition" sig.def sig.mod sig_prog.mod
 
 
-# --- two-phase Lower: re-emit from the AST and byte-compare (docs/plan-lower.md).
-#     -lower is opt-in and only lowers units in Lower.CanLower's subset. ---
-lower_ok() {
-  # $1 = test file
-  name="$1"; mod=$(modof "$name")
-  rm -f "gen_ssa/${mod}L.ssa"
-  if ./M2 -lower "tests/$name" 2>&1 | grep -q "Parsed correctly"; then :; else
-    fail=$((fail+1)); echo "FAIL(lower): $name rejected"; return
-  fi
-  if [ ! -f "gen_ssa/${mod}L.ssa" ]; then
-    fail=$((fail+1)); echo "FAIL(lower): $name no gen_ssa/${mod}L.ssa"; return
-  fi
-  if cmp -s "gen_ssa/$mod.ssa" "gen_ssa/${mod}L.ssa"; then
-    pass=$((pass+1)); echo "PASS(lower): $name"
-  else
-    fail=$((fail+1)); echo "FAIL(lower): $name .ssa mismatch"
-  fi
-}
-lower_ok_files() {
-  # $1 = program module name, then the session source files (program last)
-  prog="$1"; shift
-  files=""
-  for f in "$@"; do
-    case "$f" in */*) files="$files $f";; *) files="$files tests/$f";; esac
-  done
-  rm -f "gen_ssa/$prog.ssa" "gen_ssa/${prog}L.ssa"
-  # generate the legacy image first (self-contained)
-  if ./M2 $files 2>&1 | grep -q "Parsed correctly"; then :; else
-    fail=$((fail+1)); echo "FAIL(lower): $prog legacy rejected"; return
-  fi
-  if ./M2 -lower $files 2>&1 | grep -q "Parsed correctly"; then :; else
-    fail=$((fail+1)); echo "FAIL(lower): $prog rejected"; return
-  fi
-  if [ ! -f "gen_ssa/${prog}L.ssa" ]; then
-    fail=$((fail+1)); echo "FAIL(lower): $prog no gen_ssa/${prog}L.ssa"; return
-  fi
-  if cmp -s "gen_ssa/$prog.ssa" "gen_ssa/${prog}L.ssa"; then
-    pass=$((pass+1)); echo "PASS(lower): $prog"
-  else
-    fail=$((fail+1)); echo "FAIL(lower): $prog .ssa mismatch"
-  fi
-}
-lower_ok t_exit.mod
-lower_ok t_arith.mod
-lower_ok t_lower1.mod
-lower_ok t_lower2.mod
-lower_ok t_lower3.mod
-lower_ok t_nestedmod.mod
-lower_ok t_classmethod.mod
-lower_ok t_classinherit.mod
-lower_ok t_classsibling.mod
-lower_ok t_class.mod
-lower_ok t_classinit.mod
-lower_ok t_virtual.mod
-lower_ok_files DBasicProg d_basic.def d_basic.mod d_basic_prog.mod
-lower_ok_files DQualProg d_basic.def d_basic.mod d_qual_prog.mod
-lower_ok_files TQual d_libc.def t_qual.mod
-lower_ok_files TQualP d_qualp.def t_qualp.mod
-lower_ok t_lower4.mod
-lower_ok t_lower4case.mod
-lower_ok t_lower4with.mod
-lower_ok t_lower5.mod
-lower_ok t_lower5arr.mod
-lower_ok t_lower5lit.mod
-lower_ok t_lower5set.mod
-
 # --- step 7 gate: compiler sources free of gm2-only imports.
 # --- step 7 gate: compiler sources free of gm2-only imports.
 #     FileIO is the last module to port (see docs/summary_step7.md);
 #     FileIO is the last module to port (see docs/summary_step7.md);
 #     it is excluded here so the gate guards everything else. ---
 #     it is excluded here so the gate guards everything else. ---

+ 1 - 1
compiler/src/Lower.def

@@ -16,7 +16,7 @@ IMPORT AST, SymTab, QbeGen;
 PROCEDURE BeginSession (progName: ARRAY OF CHAR);
 PROCEDURE BeginSession (progName: ARRAY OF CHAR);
 PROCEDURE BeginUnit;
 PROCEDURE BeginUnit;
 PROCEDURE LowerUnitNow (unit: AST.Node; isProg: BOOLEAN);
 PROCEDURE LowerUnitNow (unit: AST.Node; isProg: BOOLEAN);
-PROCEDURE EndSession (testSuffix: BOOLEAN);
+PROCEDURE EndSession;
 
 
 (* The expression/statement/declaration walkers are mutually recursive.
 (* The expression/statement/declaration walkers are mutually recursive.
    gm2's link pass rejects FORWARD and V3 has no whole-module pass, so
    gm2's link pass rejects FORWARD and V3 has no whole-module pass, so

+ 1 - 11
compiler/src/Lower.mod

@@ -2193,19 +2193,9 @@ PROCEDURE LowerUnitNow (unit: AST.Node; isProg: BOOLEAN);
     QbeGen.SetNoEmit(TRUE)
     QbeGen.SetNoEmit(TRUE)
   END LowerUnitNow;
   END LowerUnitNow;
 
 
-PROCEDURE EndSession (testSuffix: BOOLEAN);
-  VAR out: ARRAY [0 .. 255] OF CHAR; j: CARDINAL;
+PROCEDURE EndSession;
   BEGIN
   BEGIN
     QbeGen.SetNoEmit(FALSE);
     QbeGen.SetNoEmit(FALSE);
-    IF testSuffix THEN
-      (* test-only: write "<mod>L.ssa" for the legacy/Lower compare *)
-      j := 0;
-      WHILE (j <= 254) AND (curUnitName[j] # CHR(0)) DO
-        out[j] := curUnitName[j]; INC(j)
-      END;
-      out[j] := "L"; INC(j); out[j] := CHR(0);
-      QbeGen.SetOutName(out)
-    END;
     QbeGen.EndModule(curUnitName)
     QbeGen.EndModule(curUnitName)
   END EndSession;
   END EndSession;
 
 

+ 3 - 18
compiler/src/compiler.frm

@@ -274,36 +274,21 @@ MODULE -->Grammar;
       name[i] := CHR(0)
       name[i] := CHR(0)
     END BaseName;
     END BaseName;
 
 
-  PROCEDURE IsLowerParam (s: ARRAY OF CHAR): BOOLEAN;
-  (* "-lower": test-only flag.  Lower is now the only emitter, so this
-     merely names the image "<mod>L.ssa" for the byte-compare harness
-     (it does not change what is emitted). *)
-  BEGIN
-    RETURN (s[0] = "-") AND (s[1] = "l") AND (s[2] = "o") AND (s[3] = "w")
-        AND (s[4] = "e") AND (s[5] = "r") AND (s[6] = CHR(0))
-  END IsLowerParam;
-
   VAR
   VAR
     sourceName, listName, progName: ARRAY [0 .. 255] OF CHAR;
     sourceName, listName, progName: ARRAY [0 .. 255] OF CHAR;
     files: ARRAY [0 .. 127] OF ARRAY [0 .. 255] OF CHAR;
     files: ARRAY [0 .. 127] OF ARRAY [0 .. 255] OF CHAR;
     nFiles: CARDINAL;
     nFiles: CARDINAL;
     f: CARDINAL;
     f: CARDINAL;
     bad: BOOLEAN;
     bad: BOOLEAN;
-    lowerTest: BOOLEAN;
 
 
   BEGIN
   BEGIN
     (* collect the session's source files (program module last) *)
     (* collect the session's source files (program module last) *)
     nFiles := 0;
     nFiles := 0;
-    lowerTest := FALSE;
     LOOP
     LOOP
       FileIO.NextParameter(sourceName);
       FileIO.NextParameter(sourceName);
       IF (sourceName[0] = CHR(0)) OR (nFiles > HIGH(files)) THEN EXIT END;
       IF (sourceName[0] = CHR(0)) OR (nFiles > HIGH(files)) THEN EXIT END;
-      IF IsLowerParam(sourceName) THEN
-        lowerTest := TRUE
-      ELSE
-        Strings.Assign(sourceName, files[nFiles]);
-        INC(nFiles)
-      END
+      Strings.Assign(sourceName, files[nFiles]);
+      INC(nFiles)
     END;
     END;
     IF nFiles = 0 THEN
     IF nFiles = 0 THEN
       FileIO.WriteString(FileIO.StdOut, "No input file specified");
       FileIO.WriteString(FileIO.StdOut, "No input file specified");
@@ -352,7 +337,7 @@ MODULE -->Grammar;
       INC(f)
       INC(f)
     END;
     END;
 
 
-    Lower.EndSession(lowerTest);
+    Lower.EndSession;
 
 
     IF bad OR NOT SymTab.HaveProgram()
     IF bad OR NOT SymTab.HaveProgram()
       THEN FileIO.WriteString(FileIO.StdOut, "Incorrect source")
       THEN FileIO.WriteString(FileIO.StdOut, "Incorrect source")