scc

suckless C compiler
git clone git://git.suckless.org/scc
Log | Files | Refs | README | LICENSE

commit 23efed866d272c23266cd233f24c68a6c2f580b6
parent 6572e37a3b1e74f494411b50bcc4f91a150c9d87
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu,  9 Mar 2017 09:15:28 +0100

[cc2-qbe] Remove int opeartions in float operands

Bitwise operations and modulo operations are defined only for
integers, and define them for floats is an error.

Diffstat:
cc2/arch/qbe/arch.h | 14--------------
cc2/arch/qbe/cgen.c | 25+++++++------------------
2 files changed, 7 insertions(+), 32 deletions(-)

diff --git a/cc2/arch/qbe/arch.h b/cc2/arch/qbe/arch.h @@ -73,38 +73,24 @@ enum asmop { ASADDS, ASSUBS, ASMULS, - ASMODS, ASDIVS, - ASSHLS, - ASSHRS, ASLTS, ASGTS, ASLES, ASGES, ASEQS, ASNES, - ASBANDS, - ASBORS, - ASBXORS, - ASCPLS, ASADDD, ASSUBD, ASMULD, - ASMODD, ASDIVD, - ASSHLD, - ASSHRD, ASLTD, ASGTD, ASLED, ASGED, ASEQD, ASNED, - ASBANDD, - ASBORD, - ASBXORD, - ASCPLD, ASEXTBW, ASUEXTBW, diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c @@ -58,39 +58,25 @@ static char opasms[] = { [OADD] = ASADDS, [OSUB] = ASSUBS, [OMUL] = ASMULS, - [OMOD] = ASMODS, [ODIV] = ASDIVS, - [OSHL] = ASSHLS, - [OSHR] = ASSHRS, [OLT] = ASLTS, [OGT] = ASGTS, [OLE] = ASLES, [OGE] = ASGES, [OEQ] = ASEQS, [ONE] = ASNES, - [OBAND] = ASBANDS, - [OBOR] = ASBORS, - [OBXOR] = ASBXORS, - [OCPL] = ASCPLS }; static char opasmd[] = { [OADD] = ASADDD, [OSUB] = ASSUBD, [OMUL] = ASMULD, - [OMOD] = ASMODD, [ODIV] = ASDIVD, - [OSHL] = ASSHLD, - [OSHR] = ASSHRD, [OLT] = ASLTD, [OGT] = ASGTD, [OLE] = ASLED, [OGE] = ASGED, [OEQ] = ASEQD, [ONE] = ASNED, - [OBAND] = ASBANDD, - [OBOR] = ASBORD, - [OBXOR] = ASBXORD, - [OCPL] = ASCPLD }; extern Type int32type, uint32type, ptrtype; @@ -515,8 +501,9 @@ rhs(Node *np, Node *ret) setlabel(phi->u.sym); return ret; - case OSHR: case OMOD: + case OSHR: + assert(tp->flags & INTF); case ODIV: case OLT: case OGT: @@ -528,13 +515,14 @@ rhs(Node *np, Node *ret) */ off = (tp->flags & SIGNF) == 0; goto binary; - case OADD: - case OSUB: - case OMUL: case OSHL: case OBAND: case OBOR: case OBXOR: + assert(tp->flags & INTF); + case OADD: + case OSUB: + case OMUL: case OEQ: case ONE: off = 0; @@ -708,6 +696,7 @@ sethi(Node *np) np->address = 11; break; case OCPL: + assert(np->type.flags & INTF); np->op = OBXOR; rp = constnode(NULL, ~(TUINT) 0, &np->type); goto binary;