Compare commits
3 Commits
tail
...
c86672e9dc
| Author | SHA1 | Date | |
|---|---|---|---|
| c86672e9dc | |||
| ab0e88ede2 | |||
| 1ed9eba90a |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,5 +6,4 @@ config.h
|
||||
*~
|
||||
.direnv
|
||||
result
|
||||
.cache
|
||||
.fuse_hidden*
|
||||
.cache
|
||||
5
all.h
5
all.h
@@ -159,12 +159,13 @@ enum J {
|
||||
#define JMPS(X) \
|
||||
X(retw) X(retl) X(rets) X(retd) \
|
||||
X(retsb) X(retub) X(retsh) X(retuh) \
|
||||
X(retc) X(ret0) X(jmp) X(jnz) \
|
||||
X(retc) X(ret0) X(jmp) X(jnz) \
|
||||
X(tail) \
|
||||
X(jfieq) X(jfine) X(jfisge) X(jfisgt) \
|
||||
X(jfisle) X(jfislt) X(jfiuge) X(jfiugt) \
|
||||
X(jfiule) X(jfiult) X(jffeq) X(jffge) \
|
||||
X(jffgt) X(jffle) X(jfflt) X(jffne) \
|
||||
X(jffo) X(jffuo) X(hlt) X(tail)
|
||||
X(jffo) X(jffuo) X(hlt)
|
||||
#define X(j) J##j,
|
||||
JMPS(X)
|
||||
#undef X
|
||||
|
||||
@@ -602,8 +602,7 @@ seljmp(Blk *b, Fn *fn)
|
||||
|
||||
if (b->jmp.type == Jret0
|
||||
|| b->jmp.type == Jjmp
|
||||
|| b->jmp.type == Jhlt
|
||||
|| b->jmp.type == Jtail)
|
||||
|| b->jmp.type == Jhlt)
|
||||
return;
|
||||
assert(b->jmp.type == Jjnz);
|
||||
r = b->jmp.arg;
|
||||
|
||||
14
amd64/sysv.c
14
amd64/sysv.c
@@ -167,7 +167,7 @@ argsclass(Ins *i0, Ins *i1, AClass *ac, int op, AClass *aret, Ref *env)
|
||||
nsse = 8;
|
||||
varc = 0;
|
||||
envc = 0;
|
||||
for (i=i0, a=ac; i<i1; i++, a++) {
|
||||
for (i=i0, a=ac; i<i1; i++, a++)
|
||||
switch (i->op - op + Oarg) {
|
||||
case Oarg:
|
||||
if (KBASE(i->cls) == 0)
|
||||
@@ -211,9 +211,8 @@ argsclass(Ins *i0, Ins *i1, AClass *ac, int op, AClass *aret, Ref *env)
|
||||
varc = 1;
|
||||
break;
|
||||
default:
|
||||
die("218 unreachable");
|
||||
die("unreachable");
|
||||
}
|
||||
}
|
||||
|
||||
if (varc && envc)
|
||||
err("sysv abi does not support variadic env calls");
|
||||
@@ -687,7 +686,7 @@ amd64_sysv_abi(Fn *fn)
|
||||
continue;
|
||||
curi = &insb[NIns];
|
||||
selret(b, fn);
|
||||
for (i=&b->ins[b->nins]; i!=b->ins;) {
|
||||
for (i=&b->ins[b->nins]; i!=b->ins;)
|
||||
switch ((--i)->op) {
|
||||
default:
|
||||
emiti(*i);
|
||||
@@ -707,13 +706,8 @@ amd64_sysv_abi(Fn *fn)
|
||||
break;
|
||||
case Oarg:
|
||||
case Oargc:
|
||||
if (b->jmp.type != Jtail) {
|
||||
die("710 unreachable");
|
||||
} else {
|
||||
|
||||
}
|
||||
die("unreachable");
|
||||
}
|
||||
}
|
||||
if (b == fn->start)
|
||||
for (; ral; ral=ral->link)
|
||||
emiti(ral->i);
|
||||
|
||||
@@ -34,8 +34,12 @@
|
||||
gcc
|
||||
clang-analyzer
|
||||
clang-tools
|
||||
gdbgui
|
||||
];
|
||||
# shellHook = ''
|
||||
# [[ ! -z "$LD_LIBRARY_PATH" ]] \
|
||||
# && export LD_LIBRARY_PATH=:$LD_LIBRARY_PATH
|
||||
# export LD_LIBRARY_PATH="${self.packages.${system}.default.libllvm.lib}/lib$LD_LIBRARY_PATH"
|
||||
# '';
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
2
main.c
2
main.c
@@ -17,7 +17,6 @@ char debug['Z'+1] = {
|
||||
['L'] = 0, /* liveness */
|
||||
['S'] = 0, /* spilling */
|
||||
['R'] = 0, /* reg. allocation */
|
||||
['E'] = 0, /* enums */
|
||||
};
|
||||
|
||||
extern Target T_amd64_sysv;
|
||||
@@ -61,6 +60,7 @@ func(Fn *fn)
|
||||
if (debug['P']) {
|
||||
fprintf(stderr, "\n> After parsing:\n");
|
||||
printfn(fn, stderr);
|
||||
exit (1);
|
||||
}
|
||||
T.abi0(fn);
|
||||
fillcfg(fn);
|
||||
|
||||
2
parse.c
2
parse.c
@@ -1446,7 +1446,7 @@ printfn(Fn *fn, FILE *f)
|
||||
case Jtail:
|
||||
fprintf (f, "\ttail ");
|
||||
printref (b->jmp.arg, fn, f);
|
||||
fprintf (f, "\n");
|
||||
fprintf (f, "%d (%d)", i->op, Oarg);
|
||||
break;
|
||||
default:
|
||||
fprintf(f, "\t%s ", jtoa[b->jmp.type]);
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
function w $factorial (w %n, w %acc) {
|
||||
@start
|
||||
jnz %n, @nz, @z
|
||||
@z
|
||||
ret %acc
|
||||
@nz
|
||||
%n_next =w sub %n, 1
|
||||
%acc_next =w mul %n, %acc
|
||||
%r =w call $factorial (w %n_next, w %acc)
|
||||
ret %r
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
function w $factorial (w %n, w %acc) {
|
||||
@start
|
||||
jnz %n, @nz, @z
|
||||
jnz %n, @z, @nz
|
||||
@z
|
||||
ret %acc
|
||||
@nz
|
||||
|
||||
9
util.c
9
util.c
@@ -261,7 +261,6 @@ igroup(Blk *b, Ins *i, Ins **i0, Ins **i1)
|
||||
|
||||
ib = b->ins;
|
||||
ie = ib + b->nins;
|
||||
|
||||
switch (i->op) {
|
||||
case Oblit0:
|
||||
*i0 = i;
|
||||
@@ -286,12 +285,8 @@ igroup(Blk *b, Ins *i, Ins **i0, Ins **i1)
|
||||
*i0 = i;
|
||||
for (; i<ie && i->op != Ocall; i++)
|
||||
;
|
||||
if (b->jmp.type == Jtail) {
|
||||
*i1 = ie;
|
||||
} else {
|
||||
assert(i < ie);
|
||||
*i1 = i + 1;
|
||||
}
|
||||
assert(i < ie);
|
||||
*i1 = i + 1;
|
||||
return;
|
||||
case Osel1:
|
||||
for (; i>ib && (i-1)->op == Osel1; i--)
|
||||
|
||||
Reference in New Issue
Block a user