[hackers] [scc] [cc2] Add FLOATF flag || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 16 Sep 2016 14:57:36 +0200 (CEST)

commit a5e164c3c1c4ba912837cdbda8686ecd37b42a38
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Sep 16 13:55:13 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_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
_AT_@ -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
_AT_@ -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
_AT_@ -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;
_AT_@ -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();
_AT_@ -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
_AT_@ -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
_AT_@ -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
_AT_@ -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,
Received on Fri Sep 16 2016 - 14:57:36 CEST

This archive was generated by hypermail 2.3.0 : Fri Sep 16 2016 - 15:00:23 CEST