commit c0db8eafdfe5b49191451104d207f8cf61e1c52a
parent 66a8044fcc4c6863570170b04e91947af7311044
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Thu, 11 Feb 2016 20:14:08 -0500
patch minic for new comparisons
This solved one pending bug: comparisons of long
variables are now compiled properly. A bug for
comparisons < and <= of pointers remain, it is
related to signedness, not width. This can be
easily fixed by the reader!
Diffstat:
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/minic/minic.y b/minic/minic.y
@@ -312,13 +312,14 @@ expr(Node *n)
['/'] = "div",
['%'] = "rem",
['&'] = "and",
- ['<'] = "cslt", /* meeeeh, careful with pointers/long */
+ ['<'] = "cslt", /* meeeeh, wrong for pointers! */
['l'] = "csle",
['e'] = "ceq",
['n'] = "cne",
};
Symb sr, s0, s1, sl;
int o, l;
+ char ty[2];
sr.t = Tmp;
sr.u.n = tmp++;
@@ -411,12 +412,15 @@ expr(Node *n)
o = n->op;
Binop:
sr.ctyp = prom(o, &s0, &s1);
- if (strchr("ne<l", n->op))
+ if (strchr("ne<l", n->op)) {
+ sprintf(ty, "%c", irtyp(sr.ctyp));
sr.ctyp = INT;
+ } else
+ strcpy(ty, "");
fprintf(of, "\t");
psymb(sr);
fprintf(of, " =%c", irtyp(sr.ctyp));
- fprintf(of, " %s ", otoa[o]);
+ fprintf(of, " %s%s ", otoa[o], ty);
Args:
psymb(s0);
fprintf(of, ", ");