scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 0480870c8d4e3c273758fc36f149d9634ea516b3
parent 8b6cc7d0182df1ccb3dd60ad44abfad031234f25
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
Date:   Thu, 21 Apr 2016 01:41:43 +0200

[cc2-qbe] Added signed/unsigned versions of div and rem

These two operators have different opcodes in qbe depending of the
signess of the types involved in the operation. It is a similar
situation to the comparisions.

Diffstat:
cc2/arch/qbe/arch.h | 4++++
cc2/arch/qbe/cgen.c | 4++--
cc2/arch/qbe/code.c | 4++++
3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/cc2/arch/qbe/arch.h b/cc2/arch/qbe/arch.h @@ -12,7 +12,9 @@ enum asmop { ASSUBW, ASMULW, ASMODW, + ASUMODW, ASDIVW, + ASUDIVW, ASSHLW, ASSHRW, ASLTW, @@ -34,7 +36,9 @@ enum asmop { ASSUBL, ASMULL, ASMODL, + ASUMODL, ASDIVL, + ASUDIVL, ASSHLL, ASSHRL, ASLTL, diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c @@ -142,6 +142,8 @@ cgen(Node *np) case OMEM: case OAUTO: return np; + case OMOD: + case ODIV: case OLT: case OGT: case OLE: @@ -155,8 +157,6 @@ cgen(Node *np) case OADD: case OSUB: case OMUL: - case OMOD: - case ODIV: case OSHL: case OSHR: case OBAND: diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c @@ -23,7 +23,9 @@ static struct opdata { [ASSUBW] = {.fun = binary, .txt = "sub", .letter = 'w'}, [ASMULW] = {.fun = binary, .txt = "mul", .letter = 'w'}, [ASMODW] = {.fun = binary, .txt = "rem", .letter = 'w'}, + [ASUMODW] = {.fun = binary, .txt = "urem", .letter = 'w'}, [ASDIVW] = {.fun = binary, .txt = "div", .letter = 'w'}, + [ASUDIVW] = {.fun = binary, .txt = "udiv", .letter = 'w'}, [ASSHLW] = {.fun = binary, .txt = "shl", .letter = 'w'}, [ASSHRW] = {.fun = binary, .txt = "shr", .letter = 'w'}, [ASLTW] = {.fun = binary, .txt = "csltw", .letter = 'w'}, @@ -44,7 +46,9 @@ static struct opdata { [ASSUBL] = {.fun = binary, .txt = "sub", .letter = 'l'}, [ASMULL] = {.fun = binary, .txt = "mul", .letter = 'l'}, [ASMODL] = {.fun = binary, .txt = "rem", .letter = 'l'}, + [ASUMODL] = {.fun = binary, .txt = "urem", .letter = 'l'}, [ASDIVL] = {.fun = binary, .txt = "div", .letter = 'l'}, + [ASUDIVL] = {.fun = binary, .txt = "udiv", .letter = 'l'}, [ASSHLL] = {.fun = binary, .txt = "shl", .letter = 'l'}, [ASSHRL] = {.fun = binary, .txt = "shr", .letter = 'l'}, [ASLTL] = {.fun = binary, .txt = "csltl", .letter = 'w'},