summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--8/insns.def2
-rw-r--r--8/isel.c15
-rw-r--r--util/muse.c30
3 files changed, 27 insertions, 20 deletions
diff --git a/8/insns.def b/8/insns.def
index 6ec6907..a75d56f 100644
--- a/8/insns.def
+++ b/8/insns.def
@@ -47,7 +47,7 @@ Insn(Ipop, "\tpop%t %r\n", Use(.l={1}),
/* branch instructions */
Insn(Isetz, "\tsetz %v\n", Use(), Def(.l={1}))
Insn(Isetnz, "\tsetnz %v\n", Use(), Def(.l={1}))
-Insn(Isetlt, "\tsetlt %v\n", Use(), Def(.l={1}))
+Insn(Isetl, "\tsetl %v\n", Use(), Def(.l={1}))
Insn(Isetle, "\tsetle %v\n", Use(), Def(.l={1}))
Insn(Isetgt, "\tsetgt %v\n", Use(), Def(.l={1}))
Insn(Isetge, "\tsetge %v\n", Use(), Def(.l={1}))
diff --git a/8/isel.c b/8/isel.c
index f4989e9..f74fcd5 100644
--- a/8/isel.c
+++ b/8/isel.c
@@ -44,7 +44,7 @@ struct {
[One] = {Icmp, Ijnz, Isetnz},
[Ogt] = {Icmp, Ijg, Isetgt},
[Oge] = {Icmp, Ijge, Isetge},
- [Olt] = {Icmp, Ijl, Isetlt},
+ [Olt] = {Icmp, Ijl, Isetl},
[Ole] = {Icmp, Ijle, Isetle}
};
@@ -158,6 +158,15 @@ static void g(Isel *s, AsmOp op, ...)
lappend(&s->curbb->il, &s->curbb->ni, i);
}
+static void movz(Isel *s, Loc *src, Loc *dst)
+{
+ if (src->mode == dst->mode)
+ g(s, Imov, src, dst, NULL);
+ else
+ g(s, Imovz, src, dst, NULL);
+}
+
+
static void load(Isel *s, Loc *a, Loc *b)
{
Loc *l;
@@ -511,7 +520,7 @@ Loc *selexpr(Isel *s, Node *n)
r = locreg(mode(n));
g(s, reloptab[exprop(n)].test, a, a, NULL);
g(s, reloptab[exprop(n)].getflag, b, NULL);
- g(s, Imovz, b, r, NULL);
+ movz(s, b, r);
break;
case Oeq: case One: case Ogt: case Oge: case Olt: case Ole:
@@ -522,7 +531,7 @@ Loc *selexpr(Isel *s, Node *n)
r = locreg(mode(n));
g(s, reloptab[exprop(n)].test, a, b, NULL);
g(s, reloptab[exprop(n)].getflag, c, NULL);
- g(s, Imovz, c, r, NULL);
+ movz(s, c, r);
return r;
case Oasn: /* relabel */
diff --git a/util/muse.c b/util/muse.c
index 6262410..b3f203e 100644
--- a/util/muse.c
+++ b/util/muse.c
@@ -26,6 +26,7 @@ static void usage(char *prog)
printf("\t-I path\tAdd 'path' to use search path\n");
printf("\t-d\tPrint debug dumps\n");
printf("\t-o\tOutput to outfile\n");
+ printf("\t-s\tShow the contents of usefiles `inputs`\n");
}
@@ -34,8 +35,6 @@ int main(int argc, char **argv)
int opt;
int i;
Stab *globls;
- Node *rdback;
- FILE *tmp;
FILE *f;
while ((opt = getopt(argc, argv, "d::ho:I:")) != -1) {
@@ -44,6 +43,9 @@ int main(int argc, char **argv)
outfile = optarg;
break;
case 'h':
+ usage(argv[0]);
+ exit(0);
+ break;
case 'd':
debug = 1;
while (optarg && *optarg)
@@ -59,6 +61,16 @@ int main(int argc, char **argv)
}
}
+ if (debugopt['s']) {
+ for (i = optind; i < argc; i++) {
+ globls = mkstab();
+ f = fopen(argv[i], "r");
+ readuse(file, globls);
+ dumpstab(globls, stdout);
+ }
+ exit(0);
+ }
+
for (i = optind; i < argc; i++) {
globls = mkstab();
tyinit(globls);
@@ -69,20 +81,6 @@ int main(int argc, char **argv)
yyparse();
infer(file);
- /* before we do anything to the parse */
- if (debugopt['p']) {
- /* test storing tree to file */
- tmp = fopen("a.pkl", "w");
- pickle(file, tmp);
- fclose(tmp);
-
- /* and reading it back */
- tmp = fopen("a.pkl", "r");
- rdback = unpickle(tmp);
- dump(rdback, stdout);
- fclose(tmp);
- dump(file, stdout);
- }
if (!outfile)
die("need output file name right now. FIX THIS.");
f = fopen(outfile, "w");