shithub: scc

Download patch

ref: 89ce7731fc48c5e3d374ef3082da7958a0e4bc49
parent: 4e6fb511b31c7d113f56e968c952575cb0130df3
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Mar 31 09:35:18 EDT 2022

cc2/qbe: Use unsigned char for asm codes

asm codes can go over 127, and it means that depending
in the ABI they can suffer sign extension that can
generate problems.

--- a/src/cmd/cc/cc2/target/qbe/cgen.c
+++ b/src/cmd/cc/cc2/target/qbe/cgen.c
@@ -7,7 +7,7 @@
 #include "arch.h"
 #include "../../cc2.h"
 
-static char opasmw[][2] = {
+static unsigned char opasmw[][2] = {
 	[OADD] = {ASADDW, ASADDW},
 	[OSUB] = {ASSUBW, ASSUBW},
 	[OMUL] = {ASMULW, ASMULW},
@@ -26,7 +26,7 @@
 	[OBXOR] = {ASBXORW, ASBXORW},
 };
 
-static char opasml[][2] = {
+static unsigned char opasml[][2] = {
 	[OADD] = {ASADDL, ASADDL},
 	[OSUB] = {ASSUBL, ASSUBL},
 	[OMUL] = {ASMULL, ASMULL},
@@ -45,7 +45,7 @@
 	[OBXOR] = {ASBXORL, ASBXORL},
 };
 
-static char opasms[][2] = {
+static unsigned char opasms[][2] = {
 	[OADD] = {ASADDS, ASADDS},
 	[OSUB] = {ASSUBS, ASSUBS},
 	[OMUL] = {ASMULS, ASMULS},
@@ -58,7 +58,7 @@
 	[ONE] = {ASNES, ASNES},
 };
 
-static char opasmd[][2] = {
+static unsigned char opasmd[][2] = {
 	[OADD] = {ASADDD, ASADDD},
 	[OSUB] = {ASSUBD, ASSUBD},
 	[OMUL] = {ASMULD, ASMULD},
@@ -71,7 +71,7 @@
 	[ONE] = {ASNED, ASNED},
 };
 
-static char (*opbin[][2])[2] = {
+static unsigned char (*opbin[][2])[2] = {
 	{opasmw, opasml},
 	{opasms, opasmd},
 };