From 5a01cb8419e38623e3cae98490385571894bf9f4 Mon Sep 17 00:00:00 2001 From: Scarlett Date: Tue, 6 May 2025 22:35:26 -0400 Subject: [PATCH] tests update --- tests/given/README.MD | 1 + tests/sprint1/expected/sp1_include.asc.exp | 3 + tests/sprint1/expected/sp1_include.tok.exp | 6 ++ .../sprint2/expected/sp2_carls_mistake.st.exp | 3 + tests/sprint2/expected/sp2_llnode.st.exp | 3 + tests/sprint2/expected/sp2_llnode_bad.st.exp | 4 ++ .../sprint2/expected/sp2_sp2_arrayargs.st.exp | 8 +++ .../sp2_valid_assignable_and_mem.st.exp | 10 ++- .../test/sp2_valid_assignable_and_mem.alpha | 2 +- .../expected/sp3_and_or_type_check.asc.exp | 12 ++-- .../sprint3/expected/sp3_arr_reserve.asc.exp | 10 +++ .../sp3_boolean_binary_op_typecheck.asc.exp | 4 +- .../expected/sp3_carls_second_mistake.asc.exp | 3 - tests/sprint3/expected/sp3_if_else.asc.exp | 21 +++--- .../expected/sp3_if_else_nested_exp.asc.exp | 25 ++++++++ .../sprint3/expected/sp3_if_else_sse.asc.exp | 31 +++++++++ .../sprint3/expected/sp3_if_else_sse2.asc.exp | 34 ++++++++++ .../expected/sp3_while_nested_bools.asc.exp | 29 +++++++++ tests/sprint3/expected/sp3_while_sse.asc.exp | 27 ++++++++ tests/sprint3/test/sp3_arr_reserve.alpha | 2 +- .../sprint3/test/sp3_if_else_nested_exp.alpha | 1 + tests/sprint3/test/sp3_if_else_sse.alpha | 1 + tests/sprint3/test/sp3_if_else_sse2.alpha | 1 + .../sprint3/test/sp3_while_nested_bools.alpha | 1 + tests/sprint3/test/sp3_while_sse.alpha | 1 + tests/sprint4/expected/sp4_cg_add.asc.exp | 4 +- tests/sprint4/expected/sp4_cg_add.ir.exp | 22 +++---- tests/sprint4/expected/sp4_cg_add.s.exp | 6 +- tests/sprint4/expected/sp4_cg_calls.asc.exp | 40 ++++++------ tests/sprint4/expected/sp4_cg_calls.ir.exp | 64 ++++++++++--------- tests/sprint4/expected/sp4_cg_calls.s.exp | 59 +++++++++-------- tests/sprint4/expected/sp4_cg_div.ir.exp | 22 +++---- tests/sprint4/expected/sp4_cg_div.s.exp | 6 +- tests/sprint4/expected/sp4_cg_equal_to.ir.exp | 21 +++--- tests/sprint4/expected/sp4_cg_equal_to.s.exp | 21 +++--- .../sprint4/expected/sp4_cg_less_than.ir.exp | 21 +++--- tests/sprint4/expected/sp4_cg_less_than.s.exp | 20 +++--- tests/sprint4/expected/sp4_cg_mod.ir.exp | 22 +++---- tests/sprint4/expected/sp4_cg_mod.s.exp | 6 +- tests/sprint4/expected/sp4_cg_mult.ir.exp | 22 +++---- tests/sprint4/expected/sp4_cg_mult.s.exp | 6 +- tests/sprint4/expected/sp4_cg_neg.ir.exp | 17 ++--- tests/sprint4/expected/sp4_cg_neg.s.exp | 5 +- tests/sprint4/expected/sp4_cg_not.ir.exp | 7 +- tests/sprint4/expected/sp4_cg_not.s.exp | 15 ++--- tests/sprint4/expected/sp4_cg_or.ir.exp | 28 ++++---- tests/sprint4/expected/sp4_cg_or.s.exp | 28 ++++---- tests/sprint4/expected/sp4_cg_sub.ir.exp | 22 +++---- tests/sprint4/expected/sp4_cg_sub.s.exp | 6 +- 49 files changed, 442 insertions(+), 291 deletions(-) create mode 100644 tests/given/README.MD create mode 100644 tests/sprint1/expected/sp1_include.asc.exp create mode 100644 tests/sprint1/expected/sp1_include.tok.exp create mode 100644 tests/sprint3/expected/sp3_arr_reserve.asc.exp create mode 100644 tests/sprint3/expected/sp3_if_else_nested_exp.asc.exp create mode 100644 tests/sprint3/expected/sp3_if_else_sse.asc.exp create mode 100644 tests/sprint3/expected/sp3_if_else_sse2.asc.exp create mode 100644 tests/sprint3/expected/sp3_while_nested_bools.asc.exp create mode 100644 tests/sprint3/expected/sp3_while_sse.asc.exp diff --git a/tests/given/README.MD b/tests/given/README.MD new file mode 100644 index 0000000..ad2dae4 --- /dev/null +++ b/tests/given/README.MD @@ -0,0 +1 @@ +NOTE: slightly modified from originals, please execute with care. :) \ No newline at end of file diff --git a/tests/sprint1/expected/sp1_include.asc.exp b/tests/sprint1/expected/sp1_include.asc.exp new file mode 100644 index 0000000..d987cea --- /dev/null +++ b/tests/sprint1/expected/sp1_include.asc.exp @@ -0,0 +1,3 @@ +001: #include "alpha.h" +002: #include "alpha.h" +003: #include "alpha.h" \ No newline at end of file diff --git a/tests/sprint1/expected/sp1_include.tok.exp b/tests/sprint1/expected/sp1_include.tok.exp new file mode 100644 index 0000000..086c1ce --- /dev/null +++ b/tests/sprint1/expected/sp1_include.tok.exp @@ -0,0 +1,6 @@ +1 1 901 "#include" +1 10 304 ""alpha.h"" +2 1 901 "#include" +2 10 304 ""alpha.h"" +3 1 901 "#include" +3 10 304 ""alpha.h"" diff --git a/tests/sprint2/expected/sp2_carls_mistake.st.exp b/tests/sprint2/expected/sp2_carls_mistake.st.exp index 7fe89f6..edcf5c5 100644 --- a/tests/sprint2/expected/sp2_carls_mistake.st.exp +++ b/tests/sprint2/expected/sp2_carls_mistake.st.exp @@ -23,6 +23,9 @@ arg : 025000 : 001001 : string result : 025000 : 001001 : integer : Primitive Instance w : 025000 : 001001 : rec : Record Instance ------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: r : 021000 : 001001 : integer : Primitive Instance s : 021000 : 001001 : integer : Primitive Instance ------------------------------:--------:--------:-----------------------------------:-----------------------------------: diff --git a/tests/sprint2/expected/sp2_llnode.st.exp b/tests/sprint2/expected/sp2_llnode.st.exp index 8b78bd3..abbd641 100644 --- a/tests/sprint2/expected/sp2_llnode.st.exp +++ b/tests/sprint2/expected/sp2_llnode.st.exp @@ -26,6 +26,9 @@ result : 068000 : 001001 : integer w : 068000 : 001001 : rec : Record Instance li : 068000 : 001001 : llnode : Record Instance ------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: r : 053000 : 001001 : integer : Primitive Instance s : 053000 : 001001 : integer : Primitive Instance ------------------------------:--------:--------:-----------------------------------:-----------------------------------: diff --git a/tests/sprint2/expected/sp2_llnode_bad.st.exp b/tests/sprint2/expected/sp2_llnode_bad.st.exp index cebad8b..d6e60a4 100644 --- a/tests/sprint2/expected/sp2_llnode_bad.st.exp +++ b/tests/sprint2/expected/sp2_llnode_bad.st.exp @@ -26,6 +26,10 @@ result : 069000 : 001001 : integer w : 069000 : 001001 : rec : Record Instance li : 069000 : 001001 : llnode : Record Instance ------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: r : 054000 : 001001 : integer : Primitive Instance s : 054000 : 001001 : integer : Primitive Instance ------------------------------:--------:--------:-----------------------------------:-----------------------------------: diff --git a/tests/sprint2/expected/sp2_sp2_arrayargs.st.exp b/tests/sprint2/expected/sp2_sp2_arrayargs.st.exp index b76e609..028f8a4 100644 --- a/tests/sprint2/expected/sp2_sp2_arrayargs.st.exp +++ b/tests/sprint2/expected/sp2_sp2_arrayargs.st.exp @@ -14,3 +14,11 @@ a_of_s : 001001 : : 1 -> string one_name : 006000 : 001001 : string : Array Instance another_name : 006000 : 001001 : string : Array Instance many_names : 006000 : 001001 : a_of_s : Array Instance +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +------------------------------:--------:--------:-----------------------------------:-----------------------------------: diff --git a/tests/sprint2/expected/sp2_valid_assignable_and_mem.st.exp b/tests/sprint2/expected/sp2_valid_assignable_and_mem.st.exp index e755b52..3714bab 100644 --- a/tests/sprint2/expected/sp2_valid_assignable_and_mem.st.exp +++ b/tests/sprint2/expected/sp2_valid_assignable_and_mem.st.exp @@ -9,5 +9,13 @@ reserve type : 001001 : : integer -> address reserve : 001001 : : reserve type : Function not defined before runtime release type : 001001 : : address -> integer : Type of Function release : 001001 : : release type : Function not defined before runtime +main : 001001 : : string -> integer : Type of Function +entry : 001001 : : main : Function Definition that starts at line 7 +rec : 001001 : : Record Type : elements-2 size-8 bytes +T2 : 001001 : : rec -> integer : Type of Function ------------------------------:--------:--------:-----------------------------------:-----------------------------------: - : 000000 : 001001 : : Empty Scope +arg : 007000 : 001001 : string : Array Instance +w : 007000 : 001001 : rec : Record Instance +------------------------------:--------:--------:-----------------------------------:-----------------------------------: +x : 004000 : 001001 : integer : Primitive Instance +y : 004000 : 001001 : integer : Primitive Instance diff --git a/tests/sprint2/test/sp2_valid_assignable_and_mem.alpha b/tests/sprint2/test/sp2_valid_assignable_and_mem.alpha index 9fe5655..3fc875e 100644 --- a/tests/sprint2/test/sp2_valid_assignable_and_mem.alpha +++ b/tests/sprint2/test/sp2_valid_assignable_and_mem.alpha @@ -1,5 +1,5 @@ (* TEST: [-st] *) -ype main: string -> integer +type main: string -> integer function entry: main type rec: [integer: x; integer: y] diff --git a/tests/sprint3/expected/sp3_and_or_type_check.asc.exp b/tests/sprint3/expected/sp3_and_or_type_check.asc.exp index fb7fe0c..304d268 100644 --- a/tests/sprint3/expected/sp3_and_or_type_check.asc.exp +++ b/tests/sprint3/expected/sp3_and_or_type_check.asc.exp @@ -57,26 +57,26 @@ LINE (28:2) ** TYPE ERROR: Undefined variable b 029: b := 1 | b; LINE (29:12) ** TYPE ERROR: Invalid type passed to assignable. - LINE (29:12) ** TYPE ERROR: Object $t9 of type integer and Object undefined of type undefined must both be Boolean + LINE (29:12) ** TYPE ERROR: Object $t11 of type integer and Object undefined of type undefined must both be Boolean LINE (29:11) ** TYPE ERROR: Undefined variable b LINE (29:2) ** TYPE ERROR: Undefined variable b 030: b := b | 1; LINE (30:12) ** TYPE ERROR: Invalid type passed to assignable. - LINE (30:12) ** TYPE ERROR: Object undefined of type undefined and Object $t10 of type integer must both be Boolean + LINE (30:12) ** TYPE ERROR: Object undefined of type undefined and Object $t13 of type integer must both be Boolean LINE (30:7) ** TYPE ERROR: Undefined variable b LINE (30:2) ** TYPE ERROR: Undefined variable b 031: b := b & 1; LINE (31:12) ** TYPE ERROR: Invalid type passed to assignable. - LINE (31:12) ** TYPE ERROR: Object undefined of type undefined and Object $t11 of type integer must both be Boolean + LINE (31:12) ** TYPE ERROR: Object undefined of type undefined and Object $t15 of type integer must both be Boolean LINE (31:7) ** TYPE ERROR: Undefined variable b LINE (31:2) ** TYPE ERROR: Undefined variable b 032: b := 1 & b; LINE (32:12) ** TYPE ERROR: Invalid type passed to assignable. - LINE (32:12) ** TYPE ERROR: Object $t12 of type integer and Object undefined of type undefined must both be Boolean + LINE (32:12) ** TYPE ERROR: Object $t17 of type integer and Object undefined of type undefined must both be Boolean LINE (32:11) ** TYPE ERROR: Undefined variable b LINE (32:2) ** TYPE ERROR: Undefined variable b 033: b := 1 = 1; - LINE (33:12) ** TYPE ERROR: Assignable Assign Expression - Object undefined of type undefined != Object $t15 of type Boolean + LINE (33:12) ** TYPE ERROR: Assignable Assign Expression - Object undefined of type undefined != Object $t21 of type Boolean LINE (33:12) ** TYPE ERROR: Invalid type passed to assignable. LINE (33:2) ** TYPE ERROR: Undefined variable b 034: @@ -84,7 +84,7 @@ 036: 037: b := 1 = b; LINE (37:12) ** TYPE ERROR: Invalid type passed to assignable. - LINE (37:12) ** TYPE ERROR: Object $t16 of type integer and Object undefined of type undefined must both be the same type + LINE (37:12) ** TYPE ERROR: Object $t22 of type integer and Object undefined of type undefined must both be the same type LINE (37:11) ** TYPE ERROR: Undefined variable b LINE (37:2) ** TYPE ERROR: Undefined variable b 038: diff --git a/tests/sprint3/expected/sp3_arr_reserve.asc.exp b/tests/sprint3/expected/sp3_arr_reserve.asc.exp new file mode 100644 index 0000000..cb1d755 --- /dev/null +++ b/tests/sprint3/expected/sp3_arr_reserve.asc.exp @@ -0,0 +1,10 @@ +001: type main: string -> integer +002: function entry: main +003: type t: 3 -> integer +004: +005: +006: entry (arg) := { +007: [ t:a] +008: a := reserve a(1, 3, 4); +009: return 0; +010: } diff --git a/tests/sprint3/expected/sp3_boolean_binary_op_typecheck.asc.exp b/tests/sprint3/expected/sp3_boolean_binary_op_typecheck.asc.exp index b9eabd2..fd029ac 100644 --- a/tests/sprint3/expected/sp3_boolean_binary_op_typecheck.asc.exp +++ b/tests/sprint3/expected/sp3_boolean_binary_op_typecheck.asc.exp @@ -10,8 +10,8 @@ LINE (8:18) ** TYPE ERROR: Object arr of type address and Object $t2 of type integer must both be the same type 009: b1 := 6<7 & arr2=7; LINE (9:23) ** TYPE ERROR: Assignable Assign Expression - Object b1 of type Boolean != Object undefined of type undefined - LINE (9:23) ** TYPE ERROR: Object $t5 of type Boolean and Object undefined of type undefined must both be Boolean - LINE (9:23) ** TYPE ERROR: Object arr2 of type address and Object $t6 of type integer must both be the same type + LINE (9:23) ** TYPE ERROR: Object $t6 of type Boolean and Object undefined of type undefined must both be Boolean + LINE (9:23) ** TYPE ERROR: Object arr2 of type address and Object $t7 of type integer must both be the same type 010: 011: return 0; 012: } diff --git a/tests/sprint3/expected/sp3_carls_second_mistake.asc.exp b/tests/sprint3/expected/sp3_carls_second_mistake.asc.exp index 51a366e..c67a27b 100644 --- a/tests/sprint3/expected/sp3_carls_second_mistake.asc.exp +++ b/tests/sprint3/expected/sp3_carls_second_mistake.asc.exp @@ -11,20 +11,17 @@ 011: 012: one_name := "a string literal"; 013: another_name := reserve another_name(4); (* reserve space for an an array of character, with 4 members *) - LINE (13:44) ** TYPE ERROR: Assignable Assign Expression - Object another_name of type string != Object undefined of type undefined 014: another_name(0) := 'C'; 015: another_name(1) := 'a'; 016: another_name(2) := 'r'; 017: another_name(3) := 'l'; 018: many_names := reserve many_names(3); - LINE (18:40) ** TYPE ERROR: Assignable Assign Expression - Object many_names of type a_of_s != Object undefined of type undefined 019: many_names(0) := one_name; 020: many_names(1) := another_name; 021: many_names(2) := reserve many_names(2)(6); (* reserve space for an item of the same type as a_of_s(2), an array of character, with 6 members *) LINE (21:45) ** SYNTAX ERROR: Incorrect syntax at token ')' LINE (21:44) ** SYNTAX ERROR: Incorrect syntax at token '6' LINE (21:43) ** SYNTAX ERROR: Incorrect syntax at token '(' - LINE (21:43) ** TYPE ERROR: Assignable Assign Expression - Object $t20 of type string != Object undefined of type undefined 022: many_names(2)(0) := 'P'; 023: many_names(2)(1) := 'a'; 024: many_names(2)(2) := 'r'; diff --git a/tests/sprint3/expected/sp3_if_else.asc.exp b/tests/sprint3/expected/sp3_if_else.asc.exp index 9bdc9e7..0bd0f6d 100644 --- a/tests/sprint3/expected/sp3_if_else.asc.exp +++ b/tests/sprint3/expected/sp3_if_else.asc.exp @@ -11,15 +11,12 @@ 011: } 012: 013: entry (arg) := { -014: [ integer: result ; rec: w] -015: if ( result = result ) then { -016: if ( result < w.y ) then { -017: result := 8; -018: } else { -019: result := 9; -020: }(* *) -021: } else { -022: result := bar('c', 7); -023: } -024: return 0; -025: } +014: [ integer: r ; integer: s; Boolean: x] +015: (* x := (r < s) & x; *) +016: if ( ( r < s ) & (s = r) ) then { +017: r := 5; +018: } else { +019: r := 7; +020: } +021: return 0; +022: } diff --git a/tests/sprint3/expected/sp3_if_else_nested_exp.asc.exp b/tests/sprint3/expected/sp3_if_else_nested_exp.asc.exp new file mode 100644 index 0000000..1832760 --- /dev/null +++ b/tests/sprint3/expected/sp3_if_else_nested_exp.asc.exp @@ -0,0 +1,25 @@ +001: type rec: [character: x; integer: y] +002: +003: type T2: rec -> integer +004: +005: type main: string -> integer +006: function entry: main +007: function bar: T2 +008: +009: bar (r,s) := { +010: return 0; +011: } +012: +013: entry (arg) := { +014: [ integer: x ; integer: y; integer: z;integer: t] +015: +016: if ( (x = y) < ( z = t ) ) then { +017: if ( (x < y) = ( z < t ) ) then { +018: x := x; +019: } else { +020: x := 1; (* bar('c', 7); *) +021: } +022: } else { +023: return 0; +024: } +025: } diff --git a/tests/sprint3/expected/sp3_if_else_sse.asc.exp b/tests/sprint3/expected/sp3_if_else_sse.asc.exp new file mode 100644 index 0000000..5cb09f5 --- /dev/null +++ b/tests/sprint3/expected/sp3_if_else_sse.asc.exp @@ -0,0 +1,31 @@ +001: type rec: [character: x; integer: y] +002: +003: type T2: rec -> integer +004: +005: type main: string -> integer +006: function entry: main +007: function bar: T2 +008: +009: (* +010: bar (r,s) := { +011: return 0; +012: } +013: +014: *) +015: entry (arg) := { +016: [ Boolean:x ; Boolean:y ; Boolean:z ; Boolean:t] +017: if ( ( x & y ) ) then { +018: +019: (* +020: if ( x integer +004: +005: type main: string -> integer +006: function entry: main +007: function bar: T2 +008: +009: bar (r,s) := { +010: return 0; +011: } +012: +013: entry (arg) := { +014: [ Boolean:x ; Boolean:y ; Boolean:z ; Boolean:t] +015: (* if ( y & (z | t) ) then { *) +016: if ( ( x = y ) & ( z < t ) ) then { +017: (* y := z < t; *) +018: t:= 0; +019: } else { +020: (* t := z = t; *) +021: z := 1; +022: } +023: (* +024: if ( x & y ) then { +025: t := true; +026: } else { +027: y := true; +028: } +029: *) +030: (* } else { *) +031: (* } *) +032: (* x := x & y; *) +033: return 0; +034: } diff --git a/tests/sprint3/expected/sp3_while_nested_bools.asc.exp b/tests/sprint3/expected/sp3_while_nested_bools.asc.exp new file mode 100644 index 0000000..a3444d6 --- /dev/null +++ b/tests/sprint3/expected/sp3_while_nested_bools.asc.exp @@ -0,0 +1,29 @@ +001: type rec: [character: x; integer: y] +002: +003: type T2: rec -> integer +004: +005: type main: string -> integer +006: function entry: main +007: function bar: T2 +008: +009: bar (r,s) := { +010: return 0; +011: } +012: +013: entry (arg) := { +014: [ Boolean: x ; Boolean: y; Boolean: z;Boolean: t] +015: while ( ((x = y)) < ( z | t ) ) { +016: while ( (x & y) = ( z < t ) ) { +017: y := y; +018: } +019: (* +020: x := x; +021: *) +022: if ( (x = y) = ( z < t ) ) then { +023: x := 1; +024: } else { +025: x := 1; +026: } +027: } +028: return 0; +029: } diff --git a/tests/sprint3/expected/sp3_while_sse.asc.exp b/tests/sprint3/expected/sp3_while_sse.asc.exp new file mode 100644 index 0000000..fe8e2ae --- /dev/null +++ b/tests/sprint3/expected/sp3_while_sse.asc.exp @@ -0,0 +1,27 @@ +001: type rec: [character: x; integer: y] +002: +003: type T2: rec -> integer +004: +005: type main: string -> integer +006: function entry: main +007: function bar: T2 +008: +009: bar (r,s) := { +010: return 0; +011: } +012: +013: entry (arg) := { +014: [ Boolean:x ; Boolean:y ; Boolean:z ; Boolean:t] +015: while ( ( x | y ) (* | ( z | t ) *) ) { +016: (* +017: if ( ( x < y ) & ( z = t ) ) then { +018: y := z < t; +019: } else { +020: t := z = t; +021: } +022: *) +023: y := t < z; (* bar('c', 7); *) +024: } +025: (* x := x & y; *) +026: return 0; +027: } diff --git a/tests/sprint3/test/sp3_arr_reserve.alpha b/tests/sprint3/test/sp3_arr_reserve.alpha index 114da34..e78640f 100644 --- a/tests/sprint3/test/sp3_arr_reserve.alpha +++ b/tests/sprint3/test/sp3_arr_reserve.alpha @@ -1,4 +1,4 @@ - +(* TEST: [-asc -tc] *) type main: string -> integer function entry: main type t: 3 -> integer diff --git a/tests/sprint3/test/sp3_if_else_nested_exp.alpha b/tests/sprint3/test/sp3_if_else_nested_exp.alpha index 08161f2..c89da43 100644 --- a/tests/sprint3/test/sp3_if_else_nested_exp.alpha +++ b/tests/sprint3/test/sp3_if_else_nested_exp.alpha @@ -1,3 +1,4 @@ +(* TEST: [-asc -tc] *) type rec: [character: x; integer: y] type T2: rec -> integer diff --git a/tests/sprint3/test/sp3_if_else_sse.alpha b/tests/sprint3/test/sp3_if_else_sse.alpha index cbbf116..8cb74e3 100644 --- a/tests/sprint3/test/sp3_if_else_sse.alpha +++ b/tests/sprint3/test/sp3_if_else_sse.alpha @@ -1,3 +1,4 @@ +(* TEST: [-asc -tc] *) type rec: [character: x; integer: y] type T2: rec -> integer diff --git a/tests/sprint3/test/sp3_if_else_sse2.alpha b/tests/sprint3/test/sp3_if_else_sse2.alpha index e226dd6..c5a1a33 100644 --- a/tests/sprint3/test/sp3_if_else_sse2.alpha +++ b/tests/sprint3/test/sp3_if_else_sse2.alpha @@ -1,3 +1,4 @@ +(* TEST: [-asc -tc] *) type rec: [character: x; integer: y] type T2: rec -> integer diff --git a/tests/sprint3/test/sp3_while_nested_bools.alpha b/tests/sprint3/test/sp3_while_nested_bools.alpha index 11765c0..e9ac27e 100644 --- a/tests/sprint3/test/sp3_while_nested_bools.alpha +++ b/tests/sprint3/test/sp3_while_nested_bools.alpha @@ -1,3 +1,4 @@ +(* TEST: [-asc -tc] *) type rec: [character: x; integer: y] type T2: rec -> integer diff --git a/tests/sprint3/test/sp3_while_sse.alpha b/tests/sprint3/test/sp3_while_sse.alpha index 61b1731..58d8f6a 100644 --- a/tests/sprint3/test/sp3_while_sse.alpha +++ b/tests/sprint3/test/sp3_while_sse.alpha @@ -1,3 +1,4 @@ +(* TEST: [-asc -tc] *) type rec: [character: x; integer: y] type T2: rec -> integer diff --git a/tests/sprint4/expected/sp4_cg_add.asc.exp b/tests/sprint4/expected/sp4_cg_add.asc.exp index c234273..d4499a0 100644 --- a/tests/sprint4/expected/sp4_cg_add.asc.exp +++ b/tests/sprint4/expected/sp4_cg_add.asc.exp @@ -1,4 +1,4 @@ -001: +001: 002: type string: 1 -> character 003: type BooleanXBoolean: [Boolean: x; Boolean: y] 004: type characterXcharacter: [character: x; character: y] @@ -34,7 +34,7 @@ 034: external function inC: integer2character 035: 036: function entry: string2integer -037: +037: 038: entry (arg) := { 039: [integer:x; integer:y; integer: result] 040: diff --git a/tests/sprint4/expected/sp4_cg_add.ir.exp b/tests/sprint4/expected/sp4_cg_add.ir.exp index 73beb15..80451f3 100644 --- a/tests/sprint4/expected/sp4_cg_add.ir.exp +++ b/tests/sprint4/expected/sp4_cg_add.ir.exp @@ -1,16 +1,12 @@ 1: func_dec : entry 2: func : entry 3: $t0 = 1 - 4: Label : 1 - 5: y = $t0 - 6: $t1 = 3 - 7: Label : 2 - 8: x = $t1 - 9: $t2 = x + y - 10: Label : 3 - 11: y = $t2 - 12: param y - 13: call : printInteger 1 - 14: Label : 4 - 15: result = $t3 - 16: return : y + 4: y = $t0 + 5: $t1 = 3 + 6: x = $t1 + 7: $t2 = x + y + 8: y = $t2 + 9: param y + 10: call : printInteger 1 + 11: result = $t3 + 12: return : y diff --git a/tests/sprint4/expected/sp4_cg_add.s.exp b/tests/sprint4/expected/sp4_cg_add.s.exp index f58dd79..c47a3d4 100644 --- a/tests/sprint4/expected/sp4_cg_add.s.exp +++ b/tests/sprint4/expected/sp4_cg_add.s.exp @@ -2,27 +2,23 @@ entry: pushq %rbp movq %rsp, %rbp - subq $128, %rsp + subq $400, %rsp movl %edi, -8(%rbp) #FunctionStart1param end movl $1, -12(%rbp) #constant assign -.L1: movl -12(%rbp), %eax #assign start movl %eax, -16(%rbp) #assign end movl $3, -20(%rbp) #constant assign -.L2: movl -20(%rbp), %eax #assign start movl %eax, -24(%rbp) #assign end movl -24(%rbp), %eax #addition start addl -16(%rbp), %eax movl %eax, -28(%rbp) #addition end -.L3: movl -28(%rbp), %eax #assign start movl %eax, -16(%rbp) #assign end movl -16(%rbp), %edi #adding param start call printInteger movl %eax, -32(%rbp) #store return from call -.L4: movl -32(%rbp), %eax #assign start movl %eax, -36(%rbp) #assign end movl -16(%rbp), %eax #return y diff --git a/tests/sprint4/expected/sp4_cg_calls.asc.exp b/tests/sprint4/expected/sp4_cg_calls.asc.exp index edc0a7a..831976b 100644 --- a/tests/sprint4/expected/sp4_cg_calls.asc.exp +++ b/tests/sprint4/expected/sp4_cg_calls.asc.exp @@ -35,26 +35,26 @@ 035: 036: function entry: string2integer 037: -038: -039: type rec: [integer: x; integer: y; integer: z; integer: a; integer: b; integer: c; integer: d] -040: type T2: rec -> integer -041: type T: integer -> integer -042: function bar: T2 -043: function ahh: T -044: -045: ahh (a) := { -046: a := printInteger(a); -047: return -1; -048: } -049: -050: bar (a, b, c,d,e,f,g) := { -051: a := printInteger(g); -052: return b; -053: } -054: -055: entry (arg) := { -056: [integer:x; integer:y; integer: result] -057: +038: type rec: [integer: x; integer: y; integer: z; integer: a; integer: b; integer: c; integer: d] +039: type T2: rec -> integer +040: type T: integer -> integer +041: function bar: T2 +042: function ahh: T +043: +044: ahh (a) := { +045: a := printInteger(a); +046: return -1; +047: } +048: +049: bar (a, b, c,d,e,f,g) := { +050: a := printInteger(g); +051: return b; +052: } +053: +054: entry (arg) := { +055: [integer:x; integer:y; integer: result; character: a] +056: a := 'a'; +057: x := printCharacter(a); 058: result := bar(1,2,3,4,5,6,7); 059: return 1; 060: } diff --git a/tests/sprint4/expected/sp4_cg_calls.ir.exp b/tests/sprint4/expected/sp4_cg_calls.ir.exp index 2995985..cbaa89e 100644 --- a/tests/sprint4/expected/sp4_cg_calls.ir.exp +++ b/tests/sprint4/expected/sp4_cg_calls.ir.exp @@ -4,34 +4,36 @@ 4: func : ahh 5: param a 6: call : printInteger 1 - 7: Label : 1 - 8: a = $t0 - 9: $t1 = 1 - 10: $t2 = -$t1 - 11: return : $t2 - 12: func : bar - 13: param g - 14: call : printInteger 1 - 15: Label : 2 - 16: a = $t3 - 17: return : b - 18: func : entry - 19: $t4 = 1 - 20: $t5 = 2 - 21: $t6 = 3 - 22: $t7 = 4 - 23: $t8 = 5 - 24: $t9 = 6 - 25: $t10 = 7 - 26: param $t10 - 27: param $t9 - 28: param $t8 - 29: param $t7 - 30: param $t6 - 31: param $t5 - 32: param $t4 - 33: call : bar 7 - 34: Label : 3 - 35: result = $t11 - 36: $t12 = 1 - 37: return : $t12 + 7: a = $t0 + 8: $t1 = 1 + 9: $t2 = -$t1 + 10: return : $t2 + 11: func : bar + 12: param g + 13: call : printInteger 1 + 14: a = $t3 + 15: return : b + 16: func : entry + 17: $t4 = a + 18: a = $t4 + 19: param a + 20: call : printCharacter 1 + 21: x = $t5 + 22: $t6 = 1 + 23: $t7 = 2 + 24: $t8 = 3 + 25: $t9 = 4 + 26: $t10 = 5 + 27: $t11 = 6 + 28: $t12 = 7 + 29: param $t12 + 30: param $t11 + 31: param $t10 + 32: param $t9 + 33: param $t8 + 34: param $t7 + 35: param $t6 + 36: call : bar 7 + 37: result = $t13 + 38: $t14 = 1 + 39: return : $t14 diff --git a/tests/sprint4/expected/sp4_cg_calls.s.exp b/tests/sprint4/expected/sp4_cg_calls.s.exp index 55b65cb..0d28c99 100644 --- a/tests/sprint4/expected/sp4_cg_calls.s.exp +++ b/tests/sprint4/expected/sp4_cg_calls.s.exp @@ -2,12 +2,11 @@ ahh: pushq %rbp movq %rsp, %rbp - subq $128, %rsp + subq $576, %rsp movl %edi, -4(%rbp) #FunctionStart1param end movl -4(%rbp), %edi #adding param start call printInteger movl %eax, -8(%rbp) #store return from call -.L1: movl -8(%rbp), %eax #assign start movl %eax, -4(%rbp) #assign end movl $1, -12(%rbp) #constant assign @@ -20,7 +19,7 @@ ahh: bar: pushq %rbp movq %rsp, %rbp - subq $128, %rsp + subq $576, %rsp movl 20(%rbp), %eax #FunctionStart1Param start movl %eax, -4(%rbp) #FunctionStart1param end movl %r9d, -12(%rbp) #FunctionStart1param end @@ -32,7 +31,6 @@ bar: movl -32(%rbp), %edi #adding param start call printInteger movl %eax, -36(%rbp) #store return from call -.L2: movl -36(%rbp), %eax #assign start movl %eax, -4(%rbp) #assign end movl -12(%rbp), %eax #return b @@ -41,29 +39,36 @@ bar: entry: pushq %rbp movq %rsp, %rbp - subq $128, %rsp - movl %edi, -8(%rbp) #FunctionStart1param end - movl $1, -12(%rbp) #constant assign - movl $2, -16(%rbp) #constant assign - movl $3, -20(%rbp) #constant assign - movl $4, -24(%rbp) #constant assign - movl $5, -28(%rbp) #constant assign - movl $6, -32(%rbp) #constant assign - movl $7, -36(%rbp) #constant assign - movl -36(%rbp), %edi #adding param start - movl -32(%rbp), %esi #adding param start - movl -28(%rbp), %edx #adding param start - movl -24(%rbp), %ecx #adding param start - movl -20(%rbp), %r8d #adding param start - movl -16(%rbp), %r9d #adding param start - movl -12(%rbp), %eax #adding param start - movl %eax, 88(%rbp) #adding param end + subq $576, %rsp + movl %edi, -12(%rbp) #FunctionStart1param end + movl $97, -13(%rbp) #constant assign + movl -13(%rbp), %eax #assign start + movl %eax, -14(%rbp) #assign end + movl -14(%rbp), %edi #adding param start + call printCharacter + movl %eax, -20(%rbp) #store return from call + movl -20(%rbp), %eax #assign start + movl %eax, -24(%rbp) #assign end + movl $1, -28(%rbp) #constant assign + movl $2, -32(%rbp) #constant assign + movl $3, -36(%rbp) #constant assign + movl $4, -40(%rbp) #constant assign + movl $5, -44(%rbp) #constant assign + movl $6, -48(%rbp) #constant assign + movl $7, -52(%rbp) #constant assign + movl -52(%rbp), %edi #adding param start + movl -48(%rbp), %esi #adding param start + movl -44(%rbp), %edx #adding param start + movl -40(%rbp), %ecx #adding param start + movl -36(%rbp), %r8d #adding param start + movl -32(%rbp), %r9d #adding param start + movl -28(%rbp), %eax #adding param start + movl %eax, 152(%rbp) #adding param end call bar - movl %eax, -44(%rbp) #store return from call -.L3: - movl -44(%rbp), %eax #assign start - movl %eax, -48(%rbp) #assign end - movl $1, -52(%rbp) #constant assign - movl -52(%rbp), %eax #return $t12 + movl %eax, -60(%rbp) #store return from call + movl -60(%rbp), %eax #assign start + movl %eax, -64(%rbp) #assign end + movl $1, -68(%rbp) #constant assign + movl -68(%rbp), %eax #return $t14 leave ret diff --git a/tests/sprint4/expected/sp4_cg_div.ir.exp b/tests/sprint4/expected/sp4_cg_div.ir.exp index f316a19..56f58fd 100644 --- a/tests/sprint4/expected/sp4_cg_div.ir.exp +++ b/tests/sprint4/expected/sp4_cg_div.ir.exp @@ -1,16 +1,12 @@ 1: func_dec : entry 2: func : entry 3: $t0 = 24 - 4: Label : 1 - 5: x = $t0 - 6: $t1 = 3 - 7: Label : 2 - 8: y = $t1 - 9: $t2 = x / y - 10: Label : 3 - 11: y = $t2 - 12: param y - 13: call : printInteger 1 - 14: Label : 4 - 15: result = $t3 - 16: return : y + 4: x = $t0 + 5: $t1 = 3 + 6: y = $t1 + 7: $t2 = x / y + 8: y = $t2 + 9: param y + 10: call : printInteger 1 + 11: result = $t3 + 12: return : y diff --git a/tests/sprint4/expected/sp4_cg_div.s.exp b/tests/sprint4/expected/sp4_cg_div.s.exp index cc51cef..53861da 100644 --- a/tests/sprint4/expected/sp4_cg_div.s.exp +++ b/tests/sprint4/expected/sp4_cg_div.s.exp @@ -2,27 +2,23 @@ entry: pushq %rbp movq %rsp, %rbp - subq $128, %rsp + subq $400, %rsp movl %edi, -8(%rbp) #FunctionStart1param end movl $24, -12(%rbp) #constant assign -.L1: movl -12(%rbp), %eax #assign start movl %eax, -16(%rbp) #assign end movl $3, -20(%rbp) #constant assign -.L2: movl -20(%rbp), %eax #assign start movl %eax, -24(%rbp) #assign end movl -16(%rbp), %eax #division start cltd idivl -24(%rbp) movl %eax, -28(%rbp) #division end -.L3: movl -28(%rbp), %eax #assign start movl %eax, -24(%rbp) #assign end movl -24(%rbp), %edi #adding param start call printInteger movl %eax, -32(%rbp) #store return from call -.L4: movl -32(%rbp), %eax #assign start movl %eax, -36(%rbp) #assign end movl -24(%rbp), %eax #return y diff --git a/tests/sprint4/expected/sp4_cg_equal_to.ir.exp b/tests/sprint4/expected/sp4_cg_equal_to.ir.exp index d0b9e1c..c8ec780 100644 --- a/tests/sprint4/expected/sp4_cg_equal_to.ir.exp +++ b/tests/sprint4/expected/sp4_cg_equal_to.ir.exp @@ -1,17 +1,16 @@ 1: func_dec : entry 2: func : entry 3: $t0 = 1 - 4: Label : 1 - 5: x = $t0 - 6: $t1 = 2 - 7: Label : 2 - 8: y = $t1 - 9: $t2 = x == y - 10: Label : 3 + 4: x = $t0 + 5: $t1 = 2 + 6: y = $t1 + 7: $t2 = x == y + 8: if $t2 True GOTO 1 + 9: GOTO : 1 + 10: Label : 1 11: b = $t2 12: param b 13: call : printBoolean 1 - 14: Label : 4 - 15: result = $t3 - 16: $t4 = 1 - 17: return : $t4 + 14: result = $t3 + 15: $t4 = 1 + 16: return : $t4 diff --git a/tests/sprint4/expected/sp4_cg_equal_to.s.exp b/tests/sprint4/expected/sp4_cg_equal_to.s.exp index 374f095..038d473 100644 --- a/tests/sprint4/expected/sp4_cg_equal_to.s.exp +++ b/tests/sprint4/expected/sp4_cg_equal_to.s.exp @@ -2,30 +2,31 @@ entry: pushq %rbp movq %rsp, %rbp - subq $128, %rsp + subq $416, %rsp movl %edi, -8(%rbp) #FunctionStart1param end movl $1, -12(%rbp) #constant assign -.L1: movl -12(%rbp), %eax #assign start movl %eax, -16(%rbp) #assign end movl $2, -20(%rbp) #constant assign -.L2: movl -20(%rbp), %eax #assign start movl %eax, -24(%rbp) #assign end movl -16(%rbp), %eax #equal to start cmpl -24(%rbp), %eax sete %al + movb $0, -25(%rbp) movb %al, -25(%rbp) #equal to end -.L3: + cmpb $0, -25(%rbp) #if true start + jne .L1 #if true end + jmp .L1 +.L1: movl -25(%rbp), %eax #assign start movl %eax, -26(%rbp) #assign end movl -26(%rbp), %edi #adding param start call printBoolean - movl %eax, -30(%rbp) #store return from call -.L4: - movl -30(%rbp), %eax #assign start - movl %eax, -34(%rbp) #assign end - movl $1, -38(%rbp) #constant assign - movl -38(%rbp), %eax #return $t4 + movl %eax, -32(%rbp) #store return from call + movl -32(%rbp), %eax #assign start + movl %eax, -36(%rbp) #assign end + movl $1, -40(%rbp) #constant assign + movl -40(%rbp), %eax #return $t4 leave ret diff --git a/tests/sprint4/expected/sp4_cg_less_than.ir.exp b/tests/sprint4/expected/sp4_cg_less_than.ir.exp index 169347b..ff83dbc 100644 --- a/tests/sprint4/expected/sp4_cg_less_than.ir.exp +++ b/tests/sprint4/expected/sp4_cg_less_than.ir.exp @@ -1,17 +1,16 @@ 1: func_dec : entry 2: func : entry 3: $t0 = 1 - 4: Label : 1 - 5: x = $t0 - 6: $t1 = 2 - 7: Label : 2 - 8: y = $t1 - 9: $t2 = x < y - 10: Label : 3 + 4: x = $t0 + 5: $t1 = 2 + 6: y = $t1 + 7: $t2 = x < y + 8: if $t2 True GOTO 1 + 9: GOTO : 1 + 10: Label : 1 11: b = $t2 12: param b 13: call : printBoolean 1 - 14: Label : 4 - 15: result = $t3 - 16: $t4 = 1 - 17: return : $t4 + 14: result = $t3 + 15: $t4 = 1 + 16: return : $t4 diff --git a/tests/sprint4/expected/sp4_cg_less_than.s.exp b/tests/sprint4/expected/sp4_cg_less_than.s.exp index 57c2a33..a9235cd 100644 --- a/tests/sprint4/expected/sp4_cg_less_than.s.exp +++ b/tests/sprint4/expected/sp4_cg_less_than.s.exp @@ -2,30 +2,30 @@ entry: pushq %rbp movq %rsp, %rbp - subq $128, %rsp + subq $416, %rsp movl %edi, -8(%rbp) #FunctionStart1param end movl $1, -12(%rbp) #constant assign -.L1: movl -12(%rbp), %eax #assign start movl %eax, -16(%rbp) #assign end movl $2, -20(%rbp) #constant assign -.L2: movl -20(%rbp), %eax #assign start movl %eax, -24(%rbp) #assign end movl -16(%rbp), %eax #less than start cmpl -24(%rbp), %eax setl %al movb %al, -25(%rbp) #less than end -.L3: + cmpb $0, -25(%rbp) #if true start + jne .L1 #if true end + jmp .L1 +.L1: movl -25(%rbp), %eax #assign start movl %eax, -26(%rbp) #assign end movl -26(%rbp), %edi #adding param start call printBoolean - movl %eax, -30(%rbp) #store return from call -.L4: - movl -30(%rbp), %eax #assign start - movl %eax, -34(%rbp) #assign end - movl $1, -38(%rbp) #constant assign - movl -38(%rbp), %eax #return $t4 + movl %eax, -32(%rbp) #store return from call + movl -32(%rbp), %eax #assign start + movl %eax, -36(%rbp) #assign end + movl $1, -40(%rbp) #constant assign + movl -40(%rbp), %eax #return $t4 leave ret diff --git a/tests/sprint4/expected/sp4_cg_mod.ir.exp b/tests/sprint4/expected/sp4_cg_mod.ir.exp index 4c2421e..1148d7e 100644 --- a/tests/sprint4/expected/sp4_cg_mod.ir.exp +++ b/tests/sprint4/expected/sp4_cg_mod.ir.exp @@ -1,16 +1,12 @@ 1: func_dec : entry 2: func : entry 3: $t0 = 4 - 4: Label : 1 - 5: x = $t0 - 6: $t1 = 20 - 7: Label : 2 - 8: y = $t1 - 9: $t2 = y % x - 10: Label : 3 - 11: y = $t2 - 12: param y - 13: call : printInteger 1 - 14: Label : 4 - 15: result = $t3 - 16: return : y + 4: x = $t0 + 5: $t1 = 20 + 6: y = $t1 + 7: $t2 = y % x + 8: y = $t2 + 9: param y + 10: call : printInteger 1 + 11: result = $t3 + 12: return : y diff --git a/tests/sprint4/expected/sp4_cg_mod.s.exp b/tests/sprint4/expected/sp4_cg_mod.s.exp index 85cd9db..c76ec55 100644 --- a/tests/sprint4/expected/sp4_cg_mod.s.exp +++ b/tests/sprint4/expected/sp4_cg_mod.s.exp @@ -2,27 +2,23 @@ entry: pushq %rbp movq %rsp, %rbp - subq $128, %rsp + subq $400, %rsp movl %edi, -8(%rbp) #FunctionStart1param end movl $4, -12(%rbp) #constant assign -.L1: movl -12(%rbp), %eax #assign start movl %eax, -16(%rbp) #assign end movl $20, -20(%rbp) #constant assign -.L2: movl -20(%rbp), %eax #assign start movl %eax, -24(%rbp) #assign end movl -24(%rbp), %eax #mod start cltd idivl -16(%rbp) movl %edx, -28(%rbp) #mod end -.L3: movl -28(%rbp), %eax #assign start movl %eax, -24(%rbp) #assign end movl -24(%rbp), %edi #adding param start call printInteger movl %eax, -32(%rbp) #store return from call -.L4: movl -32(%rbp), %eax #assign start movl %eax, -36(%rbp) #assign end movl -24(%rbp), %eax #return y diff --git a/tests/sprint4/expected/sp4_cg_mult.ir.exp b/tests/sprint4/expected/sp4_cg_mult.ir.exp index 70de136..12ec01d 100644 --- a/tests/sprint4/expected/sp4_cg_mult.ir.exp +++ b/tests/sprint4/expected/sp4_cg_mult.ir.exp @@ -1,16 +1,12 @@ 1: func_dec : entry 2: func : entry 3: $t0 = 3 - 4: Label : 1 - 5: x = $t0 - 6: $t1 = 20 - 7: Label : 2 - 8: y = $t1 - 9: $t2 = x * y - 10: Label : 3 - 11: y = $t2 - 12: param y - 13: call : printInteger 1 - 14: Label : 4 - 15: result = $t3 - 16: return : y + 4: x = $t0 + 5: $t1 = 20 + 6: y = $t1 + 7: $t2 = x * y + 8: y = $t2 + 9: param y + 10: call : printInteger 1 + 11: result = $t3 + 12: return : y diff --git a/tests/sprint4/expected/sp4_cg_mult.s.exp b/tests/sprint4/expected/sp4_cg_mult.s.exp index 567acb3..019a840 100644 --- a/tests/sprint4/expected/sp4_cg_mult.s.exp +++ b/tests/sprint4/expected/sp4_cg_mult.s.exp @@ -2,26 +2,22 @@ entry: pushq %rbp movq %rsp, %rbp - subq $128, %rsp + subq $400, %rsp movl %edi, -8(%rbp) #FunctionStart1param end movl $3, -12(%rbp) #constant assign -.L1: movl -12(%rbp), %eax #assign start movl %eax, -16(%rbp) #assign end movl $20, -20(%rbp) #constant assign -.L2: movl -20(%rbp), %eax #assign start movl %eax, -24(%rbp) #assign end movl -16(%rbp), %eax #multiplication start imull -24(%rbp), %eax movl %eax, -28(%rbp) #multiplication end -.L3: movl -28(%rbp), %eax #assign start movl %eax, -24(%rbp) #assign end movl -24(%rbp), %edi #adding param start call printInteger movl %eax, -32(%rbp) #store return from call -.L4: movl -32(%rbp), %eax #assign start movl %eax, -36(%rbp) #assign end movl -24(%rbp), %eax #return y diff --git a/tests/sprint4/expected/sp4_cg_neg.ir.exp b/tests/sprint4/expected/sp4_cg_neg.ir.exp index 9bc3442..88e0fc4 100644 --- a/tests/sprint4/expected/sp4_cg_neg.ir.exp +++ b/tests/sprint4/expected/sp4_cg_neg.ir.exp @@ -1,13 +1,10 @@ 1: func_dec : entry 2: func : entry 3: $t0 = 3 - 4: Label : 1 - 5: x = $t0 - 6: $t1 = -x - 7: Label : 2 - 8: y = $t1 - 9: param y - 10: call : printInteger 1 - 11: Label : 3 - 12: result = $t2 - 13: return : y + 4: x = $t0 + 5: $t1 = -x + 6: y = $t1 + 7: param y + 8: call : printInteger 1 + 9: result = $t2 + 10: return : y diff --git a/tests/sprint4/expected/sp4_cg_neg.s.exp b/tests/sprint4/expected/sp4_cg_neg.s.exp index ddf2a63..6e92063 100644 --- a/tests/sprint4/expected/sp4_cg_neg.s.exp +++ b/tests/sprint4/expected/sp4_cg_neg.s.exp @@ -2,22 +2,19 @@ entry: pushq %rbp movq %rsp, %rbp - subq $128, %rsp + subq $400, %rsp movl %edi, -8(%rbp) #FunctionStart1param end movl $3, -12(%rbp) #constant assign -.L1: movl -12(%rbp), %eax #assign start movl %eax, -16(%rbp) #assign end movl -16(%rbp), %eax #negation start negl %eax movl %eax, -20(%rbp) #negation end -.L2: movl -20(%rbp), %eax #assign start movl %eax, -24(%rbp) #assign end movl -24(%rbp), %edi #adding param start call printInteger movl %eax, -28(%rbp) #store return from call -.L3: movl -28(%rbp), %eax #assign start movl %eax, -32(%rbp) #assign end movl -24(%rbp), %eax #return y diff --git a/tests/sprint4/expected/sp4_cg_not.ir.exp b/tests/sprint4/expected/sp4_cg_not.ir.exp index 5a9a503..eb3abe9 100644 --- a/tests/sprint4/expected/sp4_cg_not.ir.exp +++ b/tests/sprint4/expected/sp4_cg_not.ir.exp @@ -7,7 +7,6 @@ 7: d = $t1 8: param d 9: call : printBoolean 1 - 10: Label : 3 - 11: result = $t2 - 12: $t3 = 1 - 13: return : $t3 + 10: result = $t2 + 11: $t3 = 1 + 12: return : $t3 diff --git a/tests/sprint4/expected/sp4_cg_not.s.exp b/tests/sprint4/expected/sp4_cg_not.s.exp index 63b18a5..8739ed0 100644 --- a/tests/sprint4/expected/sp4_cg_not.s.exp +++ b/tests/sprint4/expected/sp4_cg_not.s.exp @@ -2,20 +2,19 @@ entry: pushq %rbp movq %rsp, %rbp - subq $128, %rsp + subq $400, %rsp movl %edi, -8(%rbp) #FunctionStart1param end - movl $-1, -9(%rbp) #constant assign + movl $1, -9(%rbp) #constant assign .L1: movl -9(%rbp), %eax #assign start movl %eax, -10(%rbp) #assign end .L2: movl -11(%rbp), %edi #adding param start call printBoolean - movl %eax, -15(%rbp) #store return from call -.L3: - movl -15(%rbp), %eax #assign start - movl %eax, -19(%rbp) #assign end - movl $1, -23(%rbp) #constant assign - movl -23(%rbp), %eax #return $t3 + movl %eax, -18(%rbp) #store return from call + movl -18(%rbp), %eax #assign start + movl %eax, -24(%rbp) #assign end + movl $1, -28(%rbp) #constant assign + movl -28(%rbp), %eax #return $t3 leave ret diff --git a/tests/sprint4/expected/sp4_cg_or.ir.exp b/tests/sprint4/expected/sp4_cg_or.ir.exp index 0319c40..4470879 100644 --- a/tests/sprint4/expected/sp4_cg_or.ir.exp +++ b/tests/sprint4/expected/sp4_cg_or.ir.exp @@ -7,18 +7,16 @@ 7: Label : 2 8: d = $t1 9: $t2 = true - 10: Label : 3 - 11: if c True GOTO 5 - 12: GOTO : 4 - 13: Label : 4 - 14: if d True GOTO 5 - 15: $t2 = false - 16: GOTO : 5 - 17: Label : 5 - 18: d = $t2 - 19: param d - 20: call : printBoolean 1 - 21: Label : 6 - 22: result = $t3 - 23: $t4 = 1 - 24: return : $t4 + 10: if c True GOTO 4 + 11: GOTO : 3 + 12: Label : 3 + 13: if d True GOTO 4 + 14: $t2 = false + 15: GOTO : 4 + 16: Label : 4 + 17: d = $t2 + 18: param d + 19: call : printBoolean 1 + 20: result = $t3 + 21: $t4 = 1 + 22: return : $t4 diff --git a/tests/sprint4/expected/sp4_cg_or.s.exp b/tests/sprint4/expected/sp4_cg_or.s.exp index 0493673..1ca0a6a 100644 --- a/tests/sprint4/expected/sp4_cg_or.s.exp +++ b/tests/sprint4/expected/sp4_cg_or.s.exp @@ -2,30 +2,34 @@ entry: pushq %rbp movq %rsp, %rbp - subq $128, %rsp + subq $416, %rsp movl %edi, -8(%rbp) #FunctionStart1param end - movl $-1, -9(%rbp) #constant assign + movl $1, -9(%rbp) #constant assign .L1: movl -9(%rbp), %eax #assign start movl %eax, -10(%rbp) #assign end - movl $-1, -11(%rbp) #constant assign + movl $0, -11(%rbp) #constant assign .L2: movl -11(%rbp), %eax #assign start movl %eax, -12(%rbp) #assign end - movl $-1, -13(%rbp) #constant assign + movl $1, -13(%rbp) #constant assign + cmpb $0, -10(%rbp) #if true start + jne .L4 #if true end + jmp .L3 .L3: + cmpb $0, -12(%rbp) #if true start + jne .L4 #if true end + movl $0, -13(%rbp) #constant assign + jmp .L4 .L4: - movl $-1, -13(%rbp) #constant assign -.L5: movl -13(%rbp), %eax #assign start movl %eax, -12(%rbp) #assign end movl -12(%rbp), %edi #adding param start call printBoolean - movl %eax, -17(%rbp) #store return from call -.L6: - movl -17(%rbp), %eax #assign start - movl %eax, -21(%rbp) #assign end - movl $1, -25(%rbp) #constant assign - movl -25(%rbp), %eax #return $t4 + movl %eax, -18(%rbp) #store return from call + movl -18(%rbp), %eax #assign start + movl %eax, -24(%rbp) #assign end + movl $1, -28(%rbp) #constant assign + movl -28(%rbp), %eax #return $t4 leave ret diff --git a/tests/sprint4/expected/sp4_cg_sub.ir.exp b/tests/sprint4/expected/sp4_cg_sub.ir.exp index 23e60d4..468b1eb 100644 --- a/tests/sprint4/expected/sp4_cg_sub.ir.exp +++ b/tests/sprint4/expected/sp4_cg_sub.ir.exp @@ -1,16 +1,12 @@ 1: func_dec : entry 2: func : entry 3: $t0 = 1 - 4: Label : 1 - 5: y = $t0 - 6: $t1 = 3 - 7: Label : 2 - 8: x = $t1 - 9: $t2 = x - y - 10: Label : 3 - 11: y = $t2 - 12: param y - 13: call : printInteger 1 - 14: Label : 4 - 15: result = $t3 - 16: return : y + 4: y = $t0 + 5: $t1 = 3 + 6: x = $t1 + 7: $t2 = x - y + 8: y = $t2 + 9: param y + 10: call : printInteger 1 + 11: result = $t3 + 12: return : y diff --git a/tests/sprint4/expected/sp4_cg_sub.s.exp b/tests/sprint4/expected/sp4_cg_sub.s.exp index bc47b9f..8f2c60e 100644 --- a/tests/sprint4/expected/sp4_cg_sub.s.exp +++ b/tests/sprint4/expected/sp4_cg_sub.s.exp @@ -2,26 +2,22 @@ entry: pushq %rbp movq %rsp, %rbp - subq $128, %rsp + subq $400, %rsp movl %edi, -8(%rbp) #FunctionStart1param end movl $1, -12(%rbp) #constant assign -.L1: movl -12(%rbp), %eax #assign start movl %eax, -16(%rbp) #assign end movl $3, -20(%rbp) #constant assign -.L2: movl -20(%rbp), %eax #assign start movl %eax, -24(%rbp) #assign end movl -24(%rbp), %eax #subtraction start subl -16(%rbp), %eax movl %eax, -28(%rbp) #subtraction end -.L3: movl -28(%rbp), %eax #assign start movl %eax, -16(%rbp) #assign end movl -16(%rbp), %edi #adding param start call printInteger movl %eax, -32(%rbp) #store return from call -.L4: movl -32(%rbp), %eax #assign start movl %eax, -36(%rbp) #assign end movl -16(%rbp), %eax #return y