summaryrefslogtreecommitdiff
path: root/6/isel.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-09-26 23:47:46 -0700
committerOri Bernstein <ori@eigenstate.org>2015-09-26 23:47:46 -0700
commitc74b0bc06994e9a4921131696a5714cf83642acc (patch)
tree415b1001ccfc44b55c7fa4d8a2d130ee38907ee2 /6/isel.c
parentbb4ff654b3f0ce2e067e707f83310af5ebc50679 (diff)
downloadmc-c74b0bc06994e9a4921131696a5714cf83642acc.tar.gz
Separate out the concepts of code and func ptrs.
In order to pass around functions with environments for closures, we need to refer to the type of a function pointer, as well as the type of code. This is ugly. When I rewrite the backend I should change it.
Diffstat (limited to '6/isel.c')
-rw-r--r--6/isel.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/6/isel.c b/6/isel.c
index b7a5ebb..928ec9d 100644
--- a/6/isel.c
+++ b/6/isel.c
@@ -68,7 +68,7 @@ static Mode tymode(Type *t)
case Tyflt32: return ModeF; break;
case Tyflt64: return ModeD; break;
default:
- if (stacktype(t))
+ if (isstacktype(t))
return ModeQ;
switch (tysize(t)) {
case 1: return ModeB; break;
@@ -485,6 +485,7 @@ static void call(Isel *s, Node *n)
if (isconstfn(n)) {
op = Icall;
+ assert(tybase(exprtype(n))->type == Tycode);
f = locmeml(htget(s->globls, n), NULL, NULL, mode(n));
} else {
op = Icallind;
@@ -499,7 +500,7 @@ static size_t countargs(Type *t)
t = tybase(t);
nargs = t->nsub - 1;
- if (stacktype(t->sub[0]))
+ if (isstacktype(t->sub[0]))
nargs++;
/* valists are replaced with hidden type parameter,
* which we want on the stack for ease of ABI */
@@ -521,10 +522,10 @@ static Loc *gencall(Isel *s, Node *n)
rsp = locphysreg(Rrsp);
t = exprtype(n);
- if (tybase(t)->type == Tyvoid || stacktype(t)) {
+ if (tybase(t)->type == Tyvoid || isstacktype(t)) {
retloc = NULL;
ret = NULL;
- } else if (floattype(t)) {
+ } else if (istyfloat(t)) {
retloc = coreg(Rxmm0d, mode(n));
ret = locreg(mode(n));
} else {
@@ -981,7 +982,7 @@ static void epilogue(Isel *s)
rbp = locphysreg(Rrbp);
if (s->ret) {
ret = loc(s, s->ret);
- if (floattype(exprtype(s->ret)))
+ if (istyfloat(exprtype(s->ret)))
g(s, Imovs, ret, coreg(Rxmm0d, ret->mode), NULL);
else
g(s, Imov, ret, coreg(Rax, ret->mode), NULL);