diff --git a/cc_core.c b/cc_core.c index 3a1d835..84c033f 100644 --- a/cc_core.c +++ b/cc_core.c @@ -1173,9 +1173,11 @@ void process_if() else if(X86 == Architecture) emit_out("TEST\nJUMP_EQ %ELSE_"); else if(AMD64 == Architecture) emit_out("TEST\nJUMP_EQ %ELSE_"); else if(ARMV7L == Architecture) emit_out("!0 CMPI8 R0 IMM_ALWAYS\n^~ELSE_"); + else if(AARCH64 == Architecture) emit_out("CBNZ_X0_PAST_BR\nLOAD_W16_AHEAD\nSKIP_32_DATA\n&ELSE_"); uniqueID_out(function->s, number_string); if(ARMV7L == Architecture) emit_out(" JUMP_EQUAL\n"); + else if(AARCH64 == Architecture) emit_out("\nBR_X16\n"); require_match("ERROR in process_if\nMISSING )\n", ")"); statement(); @@ -1185,9 +1187,11 @@ void process_if() else if(X86 == Architecture) emit_out("JUMP %_END_IF_"); else if(AMD64 == Architecture) emit_out("JUMP %_END_IF_"); else if(ARMV7L == Architecture) emit_out("^~_END_IF_"); + else if(AARCH64 == Architecture) emit_out("LOAD_W16_AHEAD\nSKIP_32_DATA\n&_END_IF_"); uniqueID_out(function->s, number_string); if(ARMV7L == Architecture) emit_out(" JUMP_ALWAYS\n"); + else if(AARCH64 == Architecture) emit_out("\nBR_X16\n"); emit_out(":ELSE_"); uniqueID_out(function->s, number_string); @@ -1239,15 +1243,19 @@ void process_for() else if(X86 == Architecture) emit_out("TEST\nJUMP_EQ %FOR_END_"); else if(AMD64 == Architecture) emit_out("TEST\nJUMP_EQ %FOR_END_"); else if(ARMV7L == Architecture) emit_out("!0 CMPI8 R0 IMM_ALWAYS\n^~FOR_END_"); + else if(AARCH64 == Architecture) emit_out("CBNZ_X0_PAST_BR\nLOAD_W16_AHEAD\nSKIP_32_DATA\n&FOR_END_"); uniqueID_out(function->s, number_string); if(ARMV7L == Architecture) emit_out(" JUMP_EQUAL\n"); + else if(AARCH64 == Architecture) emit_out("\nBR_X16\n"); if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("JUMP @FOR_THEN_"); else if(X86 == Architecture) emit_out("JUMP %FOR_THEN_"); else if(AMD64 == Architecture) emit_out("JUMP %FOR_THEN_"); else if(ARMV7L == Architecture) emit_out("^~FOR_THEN_"); + else if(AARCH64 == Architecture) emit_out("LOAD_W16_AHEAD\nSKIP_32_DATA\n&FOR_THEN_"); uniqueID_out(function->s, number_string); if(ARMV7L == Architecture) emit_out(" JUMP_ALWAYS\n"); + else if(AARCH64 == Architecture) emit_out("\nBR_X16\n"); emit_out(":FOR_ITER_"); uniqueID_out(function->s, number_string); @@ -1259,8 +1267,10 @@ void process_for() else if(X86 == Architecture) emit_out("JUMP %FOR_"); else if(AMD64 == Architecture) emit_out("JUMP %FOR_"); else if(ARMV7L == Architecture) emit_out("^~FOR_"); + else if(AARCH64 == Architecture) emit_out("LOAD_W16_AHEAD\nSKIP_32_DATA\n&FOR_"); uniqueID_out(function->s, number_string); if(ARMV7L == Architecture) emit_out(" JUMP_ALWAYS\n"); + else if(AARCH64 == Architecture) emit_out("\nBR_X16\n"); emit_out(":FOR_THEN_"); uniqueID_out(function->s, number_string); @@ -1273,8 +1283,10 @@ void process_for() else if(X86 == Architecture) emit_out("JUMP %FOR_ITER_"); else if(AMD64 == Architecture) emit_out("JUMP %FOR_ITER_"); else if(ARMV7L == Architecture) emit_out("^~FOR_ITER_"); + else if(AARCH64 == Architecture) emit_out("LOAD_W16_AHEAD\nSKIP_32_DATA\n&FOR_ITER_"); uniqueID_out(function->s, number_string); if(ARMV7L == Architecture) emit_out(" JUMP_ALWAYS\n"); + else if(AARCH64 == Architecture) emit_out("\nBR_X16\n"); emit_out(":FOR_END_"); uniqueID_out(function->s, number_string); @@ -1335,8 +1347,10 @@ void process_do() else if(X86 == Architecture) emit_out("TEST\nJUMP_NE %DO_"); else if(AMD64 == Architecture) emit_out("TEST\nJUMP_NE %DO_"); else if(ARMV7L == Architecture) emit_out("!0 CMPI8 R0 IMM_ALWAYS\n^~DO_"); + else if(AARCH64 == Architecture) emit_out("CBZ_X0_PAST_BR\nLOAD_W16_AHEAD\nSKIP_32_DATA\n&DO_"); uniqueID_out(function->s, number_string); if(ARMV7L == Architecture) emit_out(" JUMP_NE\n"); + else if(AARCH64 == Architecture) emit_out("\nBR_X16\n"); emit_out(":DO_END_"); uniqueID_out(function->s, number_string); @@ -1375,8 +1389,10 @@ void process_while() else if(X86 == Architecture) emit_out("TEST\nJUMP_EQ %END_WHILE_"); else if(AMD64 == Architecture) emit_out("TEST\nJUMP_EQ %END_WHILE_"); else if(ARMV7L == Architecture) emit_out("!0 CMPI8 R0 IMM_ALWAYS\n^~END_WHILE_"); + else if(AARCH64 == Architecture) emit_out("CBNZ_X0_PAST_BR\nLOAD_W16_AHEAD\nSKIP_32_DATA\n&END_WHILE_"); uniqueID_out(function->s, number_string); if(ARMV7L == Architecture) emit_out(" JUMP_EQUAL\t"); + else if(AARCH64 == Architecture) emit_out("\nBR_X16\n"); emit_out("# THEN_while_"); uniqueID_out(function->s, number_string); @@ -1388,8 +1404,10 @@ void process_while() else if(X86 == Architecture) emit_out("JUMP %WHILE_"); else if(AMD64 == Architecture) emit_out("JUMP %WHILE_"); else if(ARMV7L == Architecture) emit_out("^~WHILE_"); + else if(AARCH64 == Architecture) emit_out("LOAD_W16_AHEAD\nSKIP_32_DATA\n&WHILE_"); uniqueID_out(function->s, number_string); if(ARMV7L == Architecture) emit_out(" JUMP_ALWAYS\n"); + else if(AARCH64 == Architecture) emit_out("\nBR_X16\n"); emit_out(":END_WHILE_"); uniqueID_out(function->s, number_string); @@ -1441,6 +1459,7 @@ void process_break() else if(X86 == Architecture) emit_out("POP_ebx\t# break_cleanup_locals\n"); else if(AMD64 == Architecture) emit_out("POP_RBX\t# break_cleanup_locals\n"); else if(ARMV7L == Architecture) emit_out("{R1} POP_ALWAYS\t# break_cleanup_locals\n"); + else if(AARCH64 == Architecture) emit_out("POP_X1\t# break_cleanup_locals\n"); i = i->next; } global_token = global_token->next; @@ -1449,12 +1468,14 @@ void process_break() else if(X86 == Architecture) emit_out("JUMP %"); else if(AMD64 == Architecture) emit_out("JUMP %"); else if(ARMV7L == Architecture) emit_out("^~"); + else if(AARCH64 == Architecture) emit_out("LOAD_W16_AHEAD\nSKIP_32_DATA\n&"); emit_out(break_target_head); emit_out(break_target_func); emit_out("_"); emit_out(break_target_num); if(ARMV7L == Architecture) emit_out(" JUMP_ALWAYS"); + else if(AARCH64 == Architecture) emit_out("\nBR_X16"); emit_out("\n"); require_match("ERROR in break statement\nMissing ;\n", ";"); } diff --git a/test/test.answers b/test/test.answers index 813f1c5..004aa13 100644 --- a/test/test.answers +++ b/test/test.answers @@ -53,10 +53,10 @@ a0ae067746e7a2b01d33950da1cf640e12c3a70a045ab331ea2025af59dec9af test/results/t e01b615db5df31392bd1054c45141dcff936b11dfb1cad270edc0aa67653f5a1 test/results/test10-knight-native-binary c1b5a2a3cd46c5e95e5540e871c2a916e028684ca80f51c001ef489342e27625 test/results/test10-knight-posix-binary b3e13d54aab689137628fb9c4487bfd8288f9bd18bef8fe756577c8d2dce1f1f test/results/test10-x86-binary -ff8929fd6abd6218b107131f67128012140e73b8bc5e5123c4fa2e8881a307a7 test/results/test100-amd64-binary -e82b46f81f652fc05d3ed5962435a678ba8dde42d152692776308acd2c6bb365 test/results/test100-armv7l-binary -482ce619f387db8d47738d944f70409a272c2e8d887283e94dbfc21cf26672c2 test/results/test100-knight-posix-binary -90b25175db7d780f8a8e3b05e3e564417ccbf8fc46e7970afd18eddd1fbc6993 test/results/test100-x86-binary +2f7f18f92107bb81a49f307945396e891d8b1de6bf33a8dfdd80f9654938194d test/results/test100-amd64-binary +d351523cf26d8fc66ceefb1de1640208ec4e5f2453e519ef7f6cfc40944108fb test/results/test100-armv7l-binary +e89d2dc96af7e893706494c7f28f00b775e3ecc11616738f382e5e7e817c9073 test/results/test100-knight-posix-binary +0e7c8948a5d87e3ebfd5015c6baf97aac9832e32b5c3e0664d6b8b9753ce06b7 test/results/test100-x86-binary 34e6d535e30ef8826a4ad1a4d08b76cfa370c54595599ad3be784b64c9cd8ec5 test/results/test11-amd64-binary 893695e6f300a0fe055fad935a56abd549bba70d1d39c535a680f41bbb73f117 test/results/test11-armv7l-binary 7115c4a552eb4b2c1a868ac3dca43be7d040c8e89b7b66851d0522d298429af9 test/results/test11-knight-native-binary diff --git a/test/test100/proof.answer b/test/test100/proof.answer index 9fedf2f..a76725c 100644 --- a/test/test100/proof.answer +++ b/test/test100/proof.answer @@ -1 +1 @@ -f53c30c629a4da8ed2dccff81dccce99ef3e240fa66cf3e70608abbb09242384 test/test100/proof +31ffe9a685d2023ea786914efd498906f51a7fd7a494fb8c7424a90ec39e9b08 test/test100/proof