[hackers] [scc] remove the type in return statements || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 27 Aug 2015 18:17:48 +0200 (CEST)

commit dfaab330047216d4902aa71dea50c28728698da4
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Aug 27 16:40:58 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Aug 27 16:40:58 2015 +0200

    remove the type in return statements
    
    The type is already in the optional expression,
    so it is not needed and make 'y' more similar to
    'j'.

diff --git a/cc1/code.c b/cc1/code.c
index fac9010..071591f 100644
--- a/cc1/code.c
+++ b/cc1/code.c
_AT_@ -13,7 +13,7 @@ static void emitbin(unsigned, void *), emitswitcht(unsigned, void *),
             emitexp(unsigned, void *),
             emitsymid(unsigned, void *), emittext(unsigned, void *),
             emitfun(unsigned, void *),
- emitret(unsigned, void *), emitdcl(unsigned, void *);
+ emitdcl(unsigned, void *);
 
 char *optxt[] = {
         [OADD] = "+",
_AT_@ -58,9 +58,10 @@ char *optxt[] = {
         [OCASE] = "\tv\tL%d",
         [OJUMP] = "\tj\tL%d\n",
         [OBRANCH] = "\tj\tL%d",
- [OEFUN] = "}",
- [OELOOP] = "\tb",
- [OBLOOP] = "\td",
+ [OEFUN] = "}\n",
+ [OELOOP] = "\tb\n",
+ [OBLOOP] = "\td\n",
+ [ORET] = "\ty",
         [OPAR] = "p",
         [OCALL] = "c",
         [OFIELD] = "."
_AT_@ -118,7 +119,7 @@ void (*opcode[])(unsigned, void *) = {
         [OELOOP] = emittext,
         [OBLOOP] = emittext,
         [OFUN] = emitfun,
- [ORET] = emitret,
+ [ORET] = emittext,
         [ODECL] = emitdcl,
         [OSWITCH] = emitswitch,
         [OSWITCHT] = emitswitcht,
_AT_@ -347,18 +348,9 @@ emitfun(unsigned op, void *arg)
 }
 
 static void
-emitret(unsigned op, void *arg)
-{
- Type *tp = arg;
-
- fputs("\ty", stdout);
- emitletter(tp);
-}
-
-static void
 emittext(unsigned op, void *arg)
 {
- puts(optxt[op]);
+ fputs(optxt[op], stdout);
 }
 
 static void
diff --git a/cc1/ir.md b/cc1/ir.md
index 8cb0ce6..661d98d 100644
--- a/cc1/ir.md
+++ b/cc1/ir.md
_AT_@ -246,7 +246,7 @@ generates:
> }
 
 Another form of jump is the return statement, which uses the
-letter 'y' with a return type and an optional expression.
+letter 'y' with an optional expression.
 For example:
 
> int
_AT_@ -261,7 +261,7 @@ produces:
> G1 F1 main
> {
> -
-> yI #I10
+> y #I10
> }
 
 
diff --git a/cc1/stmt.c b/cc1/stmt.c
index e72dbde..738329a 100644
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
_AT_@ -143,7 +143,7 @@ Return(Symbol *lbreak, Symbol *lcont, Caselist *lswitch)
                 else if ((np = convert(np, tp, 0)) == NULL)
                         error("incorrect type in return");
         }
- emit(ORET, tp);
+ emit(ORET, NULL);
         emit(OEXPR, np);
 }
 
diff --git a/cc1/tests/test001.c b/cc1/tests/test001.c
index 35afef6..00a2064 100644
--- a/cc1/tests/test001.c
+++ b/cc1/tests/test001.c
_AT_@ -9,7 +9,7 @@ G2 F1 main
 {
 -
         X1 "68656C6C6F20776F726C640A 'P pP cI
- yI #I0
+ y #I0
 }
 */
 
diff --git a/cc1/tests/test003.c b/cc1/tests/test003.c
index 9b3d3f2..c7965c4 100644
--- a/cc1/tests/test003.c
+++ b/cc1/tests/test003.c
_AT_@ -6,17 +6,17 @@ F1
 G1 F1 foo
 {
 -
- yI #I2A
+ y #I2A
 }
 G2 F1 bar
 {
 -
- yI #I18
+ y #I18
 }
 G3 F1 main
 {
 -
- yI G1 cI
+ y G1 cI
 }
 */
 
diff --git a/cc1/tests/test004.c b/cc1/tests/test004.c
index cfa8ed3..91e5f80 100644
--- a/cc1/tests/test004.c
+++ b/cc1/tests/test004.c
_AT_@ -23,9 +23,9 @@ A2 I x
         A2 A2 A2 #I1 >I #I1 #I0 ?I +I :I
         A2 A2 A2 #I4 <I #I1 #I0 ?I +I :I
         j L3 A2 #I4 =I
- yI #I1
+ y #I1
 L3
- yI #I0
+ y #I0
 }
 */
 
diff --git a/cc1/tests/test005.c b/cc1/tests/test005.c
index 08f4265..434ab64 100644
--- a/cc1/tests/test005.c
+++ b/cc1/tests/test005.c
_AT_@ -13,9 +13,9 @@ A2 I x
         A2 A2 ~I :I
         A2 A2 _I :I
         j L3 A2 #I2 =I
- yI #I1
+ y #I1
 L3
- yI #I0
+ y #I0
 }
 */
 
diff --git a/cc1/tests/test006.c b/cc1/tests/test006.c
index 93661eb..33f375e 100644
--- a/cc1/tests/test006.c
+++ b/cc1/tests/test006.c
_AT_@ -11,7 +11,7 @@ G2 F1 main
 {
 -
         j L2 #I0
- yI #I1
+ y #I1
         j L3
 L2
         j L4 #I0
_AT_@ -19,18 +19,18 @@ L2
 L4
         j L6 #I1
         j L7 G1 MI #I0 =I
- yI #I1
+ y #I1
         j L8
 L7
- yI #I0
+ y #I0
 L8
         j L9
 L6
- yI #I1
+ y #I1
 L9
 L5
 L3
- yI #I1
+ y #I1
 }
 */
 
diff --git a/cc1/tests/test007.c b/cc1/tests/test007.c
index 2684c86..a6490ae 100644
--- a/cc1/tests/test007.c
+++ b/cc1/tests/test007.c
_AT_@ -16,7 +16,7 @@ L5
         j L3 A2 #I0 !I
         b
 L4
- yI A2
+ y A2
 }
 */
 
diff --git a/cc1/tests/test008.c b/cc1/tests/test008.c
index a69cbe7..3a09426 100644
--- a/cc1/tests/test008.c
+++ b/cc1/tests/test008.c
_AT_@ -20,7 +20,7 @@ L5
         j L5 A2 #I14 <I
         b
 L6
- yI A2 #I14 -I
+ y A2 #I14 -I
 }
 */
 
diff --git a/cc1/tests/test009.c b/cc1/tests/test009.c
index 9fb3421..c85d716 100644
--- a/cc1/tests/test009.c
+++ b/cc1/tests/test009.c
_AT_@ -17,9 +17,9 @@ L5
         b
 L4
         j L6 A2 #IA =I
- yI #I1
+ y #I1
 L6
- yI #I0
+ y #I0
 }
 */
 
diff --git a/cc1/tests/test010.c b/cc1/tests/test010.c
index 0ff2d20..ab7151e 100644
--- a/cc1/tests/test010.c
+++ b/cc1/tests/test010.c
_AT_@ -55,7 +55,7 @@ L16
         j L14 #I1
         b
 L15
- yI A2 #IF -I
+ y A2 #IF -I
 }
 */
 
diff --git a/cc1/tests/test011.c b/cc1/tests/test011.c
index 2347d30..82d0606 100644
--- a/cc1/tests/test011.c
+++ b/cc1/tests/test011.c
_AT_@ -10,13 +10,13 @@ G1 F1 main
 -
 L2
         j L3
- yI #I1
+ y #I1
 L4
- yI #I0
+ y #I0
 L3
 L5
         j L4
- yI #I1
+ y #I1
 }
 */
 
diff --git a/cc1/tests/test012.c b/cc1/tests/test012.c
index f1c9f3e..2c579c5 100644
--- a/cc1/tests/test012.c
+++ b/cc1/tests/test012.c
_AT_@ -22,7 +22,7 @@ L8
 L11
         j L12
 L13
- yI #I1
+ y #I1
         j L9
 L10
         t #2
_AT_@ -34,11 +34,11 @@ L7
         t #1
         v L8 #I0
 L6
- yI #I2
+ y #I2
 L12
         s L15 A2
 L16
- yI #I3
+ y #I3
         j L14
 L15
         t #1
_AT_@ -48,7 +48,7 @@ L14
         A2 #I2 :I
 L19
 L20
- yI #I4
+ y #I4
         j L17
 L18
         t #1
_AT_@ -56,11 +56,11 @@ L18
 L17
         s L22 A2
 L23
- yI A2
+ y A2
 L24
- yI #I1
+ y #I1
 L25
- yI #I1
+ y #I1
         j L21
 L22
         t #3
diff --git a/cc1/tests/test014.c b/cc1/tests/test014.c
index 50d1a0d..4c1b1e9 100644
--- a/cc1/tests/test014.c
+++ b/cc1/tests/test014.c
_AT_@ -29,7 +29,7 @@ T3 M i
 R4 W j
 X5 I k
 T6 Z a
- yI #I0
+ y #I0
 }
 F2 I
 G6 F2 func2
diff --git a/cc1/tests/test015.c b/cc1/tests/test015.c
index f4faf1e..4bfb46a 100644
--- a/cc1/tests/test015.c
+++ b/cc1/tests/test015.c
_AT_@ -24,8 +24,8 @@ G13 F1 main
         j L2
 A3 S2 s
 A4 I s
- yI A4
- yI A3 M11 .S5 M6 .I A3 M11 .S5 M10 .S8 M9 .I +I
+ y A4
+ y A3 M11 .S5 M6 .I A3 M11 .S5 M10 .S8 M9 .I +I
 L2
 ????
 */
diff --git a/cc1/tests/test016.c b/cc1/tests/test016.c
index b83349f..850fae1 100644
--- a/cc1/tests/test016.c
+++ b/cc1/tests/test016.c
_AT_@ -16,14 +16,14 @@ A4 P p
         A4 A2 'P :P
         A4 _AT_I #I0 :I
         j L5 A2 #I0 =I
- yI #I1
+ y #I1
 L5
         A4 G1 'P :P
         A4 _AT_I #I0 :I
         j L6 A4 #I0 IP !I
- yI #I1
+ y #I1
 L6
- yI #I0
+ y #I0
 }
 G3 F1 func2
 {
_AT_@ -38,7 +38,7 @@ A4 P pp
         A4 _AT_P @I #I0 :I
 L5
         A2 #I0 IP :P
- yI A1
+ y A1
 }
 ????
 */
diff --git a/cc1/tests/test017.c b/cc1/tests/test017.c
index 69d1476..a195be9 100644
--- a/cc1/tests/test017.c
+++ b/cc1/tests/test017.c
_AT_@ -21,12 +21,12 @@ A3 S6 v
         A3 M8 .P _AT_S2 M3 .I #I1 :I
         A3 M8 .P _AT_S2 M4 .I #I2 :I
         j L4 A2 M3 .I #I1 =I
- yI #I1
+ y #I1
 L4
         j L5 A2 M4 .I #I2 =I
- yI #I2
+ y #I2
 L5
- yI #I0
+ y #I0
 }
 */
 
diff --git a/cc1/tests/test018.c b/cc1/tests/test018.c
index aa50f08..562540f 100644
--- a/cc1/tests/test018.c
+++ b/cc1/tests/test018.c
_AT_@ -18,18 +18,18 @@ A10 V9 v
         A4 'P #P4 +P #P3 +P _AT_M #M2 :M
         A10 'P _AT_I #I2 :I
         j L12 A4 'P #P4 +P #P3 +P _AT_M MI #I2 =I
- yI #I1
+ y #I1
 L12
         j L13 A6 #P4 +P #P3 +P _AT_M MI #I2 =I
- yI #I1
+ y #I1
 L13
         j L14 A8 _AT_M MI #I2 =I
- yI #I1
+ y #I1
 L14
         j L15 A10 _AT_I #I2 =I
- yI #I1
+ y #I1
 L15
- yI #I0
+ y #I0
 }
 */
 
Received on Thu Aug 27 2015 - 18:17:48 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 27 2015 - 18:24:18 CEST