commit a9ca038e47093dad4d9961bcd5f2e209635dbb79
parent 0480870c8d4e3c273758fc36f149d9634ea516b3
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
Date: Thu, 21 Apr 2016 03:12:53 +0200
[cc2-qbe] Add signed/unsigned version of shr
Shr can extend the sign if the type has sign, so it is important to
differentiate between them.
Diffstat:
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/cc2/arch/qbe/arch.h b/cc2/arch/qbe/arch.h
@@ -17,6 +17,7 @@ enum asmop {
ASUDIVW,
ASSHLW,
ASSHRW,
+ ASUSHRW,
ASLTW,
ASULTW,
ASGTW,
@@ -41,6 +42,7 @@ enum asmop {
ASUDIVL,
ASSHLL,
ASSHRL,
+ ASUSHRL,
ASLTL,
ASULTL,
ASGTL,
diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
@@ -142,6 +142,7 @@ cgen(Node *np)
case OMEM:
case OAUTO:
return np;
+ case OSHR:
case OMOD:
case ODIV:
case OLT:
@@ -158,7 +159,6 @@ cgen(Node *np)
case OSUB:
case OMUL:
case OSHL:
- case OSHR:
case OBAND:
case OBOR:
case OBXOR:
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
@@ -27,7 +27,8 @@ static struct opdata {
[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'},
+ [ASSHRW] = {.fun = binary, .txt = "shrs", .letter = 'w'},
+ [ASUSHRW] = {.fun = binary, .txt = "shrz", .letter = 'w'},
[ASLTW] = {.fun = binary, .txt = "csltw", .letter = 'w'},
[ASULTW] = {.fun = binary, .txt = "cultw", .letter = 'w'},
[ASGTW] = {.fun = binary, .txt = "csgtw", .letter = 'w'},
@@ -50,7 +51,8 @@ static struct opdata {
[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'},
+ [ASSHRL] = {.fun = binary, .txt = "shrs", .letter = 'l'},
+ [ASUSHRL] = {.fun = binary, .txt = "shrz", .letter = 'l'},
[ASLTL] = {.fun = binary, .txt = "csltl", .letter = 'w'},
[ASULTL] = {.fun = binary, .txt = "cultl", .letter = 'w'},
[ASGTL] = {.fun = binary, .txt = "csgtl", .letter = 'w'},