commit a5e164c3c1c4ba912837cdbda8686ecd37b42a38
parent ffdf276b7cc0f7e8fabc6217e13a880768add28b
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 16 Sep 2016 13:55:13 +0200
[cc2] Add FLOATF flag
In some situations is better to check against float instead of
checking against integers.
Diffstat:
6 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/cc2/arch/amd64-sysv/types.c b/cc2/arch/amd64-sysv/types.c
@@ -64,16 +64,19 @@ Type booltype = {
};
Type float32type = {
+ .flags = FLOATF,
.size = 4,
.align = 4
};
Type float64type = {
+ .flags = FLOATF,
.size = 8,
.align = 8
};
Type float80type = {
+ .flags = FLOATF,
.size = 16,
.align = 16
};
diff --git a/cc2/arch/i386-sysv/types.c b/cc2/arch/i386-sysv/types.c
@@ -64,16 +64,19 @@ Type booltype = {
};
Type float32type = {
+ .flags = FLOATF,
.size = 4,
.align = 4
};
Type float64type = {
+ .flags = FLOATF,
.size = 8,
.align = 4
};
Type float80type = {
+ .flags = FLOATF,
.size = 12,
.align = 4
};
diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
@@ -121,10 +121,10 @@ load(Type *tp, Node *np, Node *new)
op = ASLDH;
break;
case 4:
- op = (tp->flags & INTF) ? ASLDW : ASLDS;
+ op = (tp->flags & FLOATF) ? ASLDS : ASLDW;
break;
case 8:
- op = (tp->flags & INTF) ? ASLDL : ASLDD;
+ op = (tp->flags & FLOATF) ? ASLDD : ASLDL;
break;
default:
*new = *np;
@@ -267,10 +267,10 @@ assign(Type *tp, Node *to, Node *from)
op = ASSTH;
break;
case 4:
- op = (tp->flags & INTF) ? ASSTW : ASSTS;
+ op = (tp->flags & FLOATF) ? ASSTS : ASSTW;
break;
case 8:
- op = (tp->flags & INTF) ? ASSTL : ASSTD;
+ op = (tp->flags & FLOATF) ? ASSTD : ASSTL;
break;
default:
abort();
@@ -480,10 +480,10 @@ rhs(Node *np, Node *ret)
}
switch (tp->size) {
case 4:
- tbl = (tp->flags & INTF) ? opasmw : opasms;
+ tbl = (tp->flags & FLOATF) ? opasms : opasmw;
break;
case 8:
- tbl = (tp->flags & INTF) ? opasml : opasmd;
+ tbl = (tp->flags & FLOATF) ? opasmd : opasml;
break;
default:
abort();
diff --git a/cc2/arch/qbe/types.c b/cc2/arch/qbe/types.c
@@ -64,16 +64,19 @@ Type booltype = {
};
Type float32type = {
+ .flags = FLOATF,
.size = 4,
.align = 4
};
Type float64type = {
+ .flags = FLOATF,
.size = 8,
.align = 8
};
Type float80type = {
+ .flags = FLOATF,
.size = 16,
.align = 16
};
diff --git a/cc2/arch/z80/types.c b/cc2/arch/z80/types.c
@@ -64,16 +64,19 @@ Type booltype = {
};
Type float32type = {
+ .flags = FLOATF,
.size = 4,
.align = 1
};
Type float64type = {
+ .flags = FLOATF,
.size = 4,
.align = 1
};
Type float80type = {
+ .flags = FLOATF,
.size = 4,
.align = 1
};
diff --git a/cc2/cc2.h b/cc2/cc2.h
@@ -5,9 +5,10 @@ enum iflags {
};
enum tflags {
- SIGNF = 1,
- INTF = 2,
- STRF = 8,
+ SIGNF = 1,
+ INTF = 2,
+ FLOATF = 4,
+ STRF = 8,
UNIONF = 16,
FUNF = 32,
PARF = 64,