[hackers] [scc] [cc2-qbe] Add conversions from float to float || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 23 Apr 2016 18:07:30 +0200 (CEST)

commit f66f017585239582175ccc52b9c110a90f60f07b
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
AuthorDate: Fri Apr 22 21:04:30 2016 +0200
Commit: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
CommitDate: Fri Apr 22 21:04:30 2016 +0200

    [cc2-qbe] Add conversions from float to float
    
    These conversions were lost in the previous commit, and they
    were dealt like float to int conversions.

diff --git a/cc2/arch/qbe/arch.h b/cc2/arch/qbe/arch.h
index 031ec6e..ffd44cf 100644
--- a/cc2/arch/qbe/arch.h
+++ b/cc2/arch/qbe/arch.h
_AT_@ -124,5 +124,8 @@ enum asmop {
         ASSWTOD,
         ASSWTOS,
         ASSLTOD,
- ASSLTOS
+ ASSLTOS,
+
+ ASEXTS,
+ ASTRUNCD
 };
diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
index 300f8dd..9b4e61c 100644
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
_AT_@ -168,6 +168,10 @@ cast(Node *nd, Node *ns)
                 default:
                         abort();
                 }
+ /*
+ * unsigned version of operations are always +1 the
+ * signed version
+ */
                 op += (td->flags & SIGNF) == 0;
         } else if (disint) {
                 /* conversion from float to int */
_AT_@ -182,7 +186,7 @@ cast(Node *nd, Node *ns)
                         abort();
                 }
                 /* TODO: Add signess */
- } else {
+ } else if (sisint) {
                 /* conversion from int to float */
                 switch (ts->size) {
                 case 1:
_AT_@ -201,6 +205,9 @@ cast(Node *nd, Node *ns)
                         abort();
                 }
                 /* TODO: Add signess */
+ } else {
+ /* conversion from float to float */
+ op = (td->size == 4) ? ASEXTS : ASTRUNCD;
         }
         code(op, tmpnode(nd), ns, NULL);
         return nd;
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index 0092576..57170aa 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -118,6 +118,9 @@ static struct opdata {
         [ASSWTOS] = {.fun = unary, .txt = "swtof", .letter = 's'},
         [ASSLTOD] = {.fun = unary, .txt = "sltof", .letter = 'd'},
         [ASSLTOS] = {.fun = unary, .txt = "sltof", .letter = 's'},
+
+ [ASEXTS] = {.fun = unary, .txt = "exts", .letter = 'd'},
+ [ASSLTOS]= {.fun = unary, .txt = "truncd", .letter = 's'},
 };
 
 /*
Received on Sat Apr 23 2016 - 18:07:30 CEST

This archive was generated by hypermail 2.3.0 : Sat Apr 23 2016 - 18:12:14 CEST