commit 0480870c8d4e3c273758fc36f149d9634ea516b3
Author:     Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
AuthorDate: Thu Apr 21 01:41:43 2016 +0200
Commit:     Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
CommitDate: Thu Apr 21 01:41:43 2016 +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.

diff --git a/cc2/arch/qbe/arch.h b/cc2/arch/qbe/arch.h
index 79c43ef..78f058b 100644
--- 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
index c0bc1e9..7961178 100644
--- 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
index 165a102..b956dfb 100644
--- 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'},

Reply via email to