[hackers] [scc] [cc2-qbe] Added signed/unsigned versions of div and rem || Roberto E. Vargas Caballero
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
_AT_@ -12,7 +12,9 @@ enum asmop {
ASSUBW,
ASMULW,
ASMODW,
+ ASUMODW,
ASDIVW,
+ ASUDIVW,
ASSHLW,
ASSHRW,
ASLTW,
_AT_@ -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
_AT_@ -142,6 +142,8 @@ cgen(Node *np)
case OMEM:
case OAUTO:
return np;
+ case OMOD:
+ case ODIV:
case OLT:
case OGT:
case OLE:
_AT_@ -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
_AT_@ -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'},
_AT_@ -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'},
Received on Thu Apr 21 2016 - 19:54:48 CEST
This archive was generated by hypermail 2.3.0
: Thu Apr 21 2016 - 20:00:18 CEST