commit a5e164c3c1c4ba912837cdbda8686ecd37b42a38
Author:     Roberto E. Vargas Caballero <k...@shike2.com>
AuthorDate: Fri Sep 16 13:55:13 2016 +0200
Commit:     Roberto E. Vargas Caballero <k...@shike2.com>
CommitDate: Fri Sep 16 14:00:39 2016 +0200

    [cc2] Add FLOATF flag
    
    In some situations is better to check against float instead of
    checking against integers.

diff --git a/cc2/arch/amd64-sysv/types.c b/cc2/arch/amd64-sysv/types.c
index 6c61bed..c67d365 100644
--- 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
index 969a2ee..f92540f 100644
--- 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
index bb5f697..4d147e9 100644
--- 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
index 6c61bed..c67d365 100644
--- 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
index aeca21f..129bd13 100644
--- 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
index 1677c53..888f026 100644
--- 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,

Reply via email to