scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit f66f017585239582175ccc52b9c110a90f60f07b
parent 8013c0388602bef2e589f867a9bff8fa196247c7
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
Date:   Fri, 22 Apr 2016 21:04:30 +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.

Diffstat:
Mcc2/arch/qbe/arch.h | 5++++-
Mcc2/arch/qbe/cgen.c | 9++++++++-
Mcc2/arch/qbe/code.c | 3+++
3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/cc2/arch/qbe/arch.h b/cc2/arch/qbe/arch.h @@ -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 @@ -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 */ @@ -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: @@ -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 @@ -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'}, }; /*