scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 60bbc9b93785a652d0f89146e3eefe9d2d0fb52b
parent 4fe052f8b8b9962366a33088871b73fa141b693a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 22 Jan 2017 11:30:15 +0100

[cc2-qbe] Add float types to size2asm/size2stack

Diffstat:
Mcc2/arch/qbe/code.c | 41+++++++++++++++++++++++------------------
1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c @@ -250,10 +250,8 @@ size2asm(Type *tp) { if (tp->flags & STRF) { return "b"; - } else { + } else if (tp->flags & INTF) { switch (tp->size) { - case 0: - return ""; case 1: return "b"; case 2: @@ -262,10 +260,14 @@ size2asm(Type *tp) return "w"; case 8: return "l"; - default: - abort(); } + } else if (tp->flags & FLOATF) { + if (tp->size == 4) + return "s"; + else if (tp->size == 8) + return "d"; } + abort(); } void @@ -306,20 +308,23 @@ data(Node *np) static char * size2stack(Type *tp) { - switch (tp->size) { - case 0: - return "w"; - case 1: - return "w"; - case 2: - return "w"; - case 4: - return "w"; - case 8: - return "l"; - default: - abort(); + if (tp->flags & INTF) { + switch (tp->size) { + case 0: + case 1: + case 2: + case 4: + return "w"; + case 8: + return "l"; + } + } else if (tp->flags & FLOATF) { + if (tp->size == 4) + return "s"; + else if (tp->size == 8) + return "d"; } + abort(); } void