@samitouri / QOSamiQemu / commits / 311094b58d

target/hexagon: Suppress unused-variable warnings for sysemu source regs

The analyze_read() methods on GuestSource, GuestPairSource, SystemSource, and SystemPairSource were no-ops because these source registers do not need read-tracking in the analyze phase. However, gen_analyze_funcs.py unconditionally declares the register-number variable (e.g. GsN) via decl_reg_num() for all registers that are read or written. When building with hexagon-softmmu, the generated analyze function bodies are compiled (outside the #ifndef CONFIG_USER_ONLY guard), and the declared-but-unreferenced register-number variable triggers -Werror=unused-variable under both gcc and clang. Override decl_reg_num() in each class to declare the register number with G_GNUC_UNUSED, suppressing the warning. Reviewed-by: Taylor Simpson <ltaylorsimpson@gmail.com> Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>

Brian Cain committed Jun 22, 2026 at 15:27 UTC 311094b58d8b51cc921c509ed1eef7996c3c2738
1 file changed +16
target/hexagon/hex_common.py
+16
@@ -1068,6 +1068,10 @@ class GuestDest(GuestRegister, Single, Dest):
1068 """))
1069
1070 class GuestSource(GuestRegister, Single, OldSource):
1071 + def decl_reg_num(self, f, regno):
1072 + f.write(code_fmt(f"""\
1073 + const int {self.reg_num} G_GNUC_UNUSED = insn->regno[{regno}];
1074 + """))
1075 def decl_tcg(self, f, tag, regno):
1076 self.decl_reg_num(f, regno)
1077 f.write(code_fmt(f"""\
@@ -1093,6 +1097,10 @@ class GuestPairDest(GuestRegister, Pair, Dest):
1097 """))
1098
1099 class GuestPairSource(GuestRegister, Pair, OldSource):
1100 + def decl_reg_num(self, f, regno):
1101 + f.write(code_fmt(f"""\
1102 + const int {self.reg_num} G_GNUC_UNUSED = insn->regno[{regno}];
1103 + """))
1104 def decl_tcg(self, f, tag, regno):
1105 self.decl_reg_num(f, regno)
1106 f.write(code_fmt(f"""\
@@ -1118,6 +1126,10 @@ class SystemDest(Register, Single, Dest):
1126 """))
1127
1128 class SystemSource(Register, Single, OldSource):
1129 + def decl_reg_num(self, f, regno):
1130 + f.write(code_fmt(f"""\
1131 + const int {self.reg_num} G_GNUC_UNUSED = insn->regno[{regno}];
1132 + """))
1133 def decl_tcg(self, f, tag, regno):
1134 self.decl_reg_num(f, regno)
1135 f.write(code_fmt(f"""\
@@ -1143,6 +1155,10 @@ class SystemPairDest(Register, Pair, Dest):
1155 """))
1156
1157 class SystemPairSource(Register, Pair, OldSource):
1158 + def decl_reg_num(self, f, regno):
1159 + f.write(code_fmt(f"""\
1160 + const int {self.reg_num} G_GNUC_UNUSED = insn->regno[{regno}];
1161 + """))
1162 def decl_tcg(self, f, tag, regno):
1163 self.decl_reg_num(f, regno)
1164 f.write(code_fmt(f"""\