commit 98effae319f860ea2684b5a0709d2da923145f38
parent db3fcecc66333bd273a847cad7a78e87a3628260
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
Date: Mon, 9 May 2016 17:41:24 +0200
[cc1] Add end of switch label to end of switch op
We need the end of switch because if we convert the switch into
a switch table in some point we need to check that any of the
cases matched against the expression and then we have to jump out
of the switch statement.
Diffstat:
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/cc1/code.c b/cc1/code.c
@@ -61,7 +61,7 @@ char *optxt[] = {
[OLABEL] = "L%d\n",
[ODEFAULT] = "\tf\tL%d\n",
[OBSWITCH] = "\ts",
- [OESWITCH] = "\tk\n",
+ [OESWITCH] = "\tk\tL%d\n",
[OCASE] = "\tv\tL%d",
[OJUMP] = "\tj\tL%d\n",
[OBRANCH] = "\ty\tL%d",
@@ -129,7 +129,7 @@ void (*opcode[])(unsigned, void *) = {
[ORET] = emittext,
[ODECL] = emitdcl,
[OBSWITCH] = emittext,
- [OESWITCH] = emittext,
+ [OESWITCH] = emitsymid,
[OPAR] = emitbin,
[OCALL] = emitbin,
[OINIT] = emitinit
diff --git a/cc1/stmt.c b/cc1/stmt.c
@@ -223,7 +223,7 @@ Swtch(Symbol *obr, Symbol *lcont, Switch *osw)
emit(OBSWITCH, NULL);
emit(OEXPR, cond);
stmt(lbreak, lcont, &sw);
- emit(OESWITCH, NULL);
+ emit(OESWITCH, lbreak);
emit(OLABEL, lbreak);
}
diff --git a/cc1/tests/test012.c b/cc1/tests/test012.c
@@ -12,7 +12,7 @@ A3 I "x
s A3
v L5 #I0
L5
- k
+ k L4
L4
s A3
v L7 #I0
@@ -24,9 +24,9 @@ L9
f L11
L11
h #I1
- k
+ k L8
L8
- k
+ k L6
L6
h #I2
L10
@@ -34,7 +34,7 @@ L10
v L13 #I1
L13
h #I3
- k
+ k L12
L12
s A3
A3 #I2 :I
@@ -42,7 +42,7 @@ L15
v L16 #I1
L16
h #I4
- k
+ k L14
L14
s A3
v L18 #I0
@@ -54,7 +54,7 @@ L19
f L20
L20
h #I1
- k
+ k L17
L17
}
*/
diff --git a/cc1/tests/test036.c b/cc1/tests/test036.c
@@ -43,7 +43,7 @@ L18
y L10 R7 #I1 :-I #I0 >I
b
L11
- k
+ k L8
L8
}
*/