ref: d6e214cc6f13349e7b0b9d07a90298400287460e
parent: a4ef620605bf4c351c245fb921d898793e0a2470
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Apr 20 23:12:53 EDT 2016
[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.
--- a/cc2/arch/qbe/arch.h
+++ b/cc2/arch/qbe/arch.h
@@ -17,6 +17,7 @@
ASUDIVW,
ASSHLW,
ASSHRW,
+ ASUSHRW,
ASLTW,
ASULTW,
ASGTW,
@@ -41,6 +42,7 @@
ASUDIVL,
ASSHLL,
ASSHRL,
+ ASUSHRL,
ASLTL,
ASULTL,
ASGTL,
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
@@ -142,6 +142,7 @@
case OMEM:
case OAUTO:
return np;
+ case OSHR:
case OMOD:
case ODIV:
case OLT:
@@ -158,7 +159,6 @@
case OSUB:
case OMUL:
case OSHL:
- case OSHR:
case OBAND:
case OBOR:
case OBXOR:
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
@@ -27,7 +27,8 @@
[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 @@
[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'},
--
⑨