]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: cris: add error fallbacks when decoding condition & swap codes
authorMike Frysinger <vapier@gentoo.org>
Sun, 24 Dec 2023 10:13:42 +0000 (05:13 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sun, 7 Jan 2024 04:30:43 +0000 (23:30 -0500)
The condition & swap code decoder only checks known bits and sets
based on that.  If the variable is out of range, it ends up returning
uninitialized data.  Turn that case into a hard error.

This fixes build warnings like:
sim/cris/semcrisv10f-switch.c:13115:11: error:
variable 'tmp_condres' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

cpu/cris.cpu
sim/cris/semcrisv10f-switch.c
sim/cris/semcrisv32f-switch.c

index ba5ed18a3d41bbba8d86554a6e4576c1e8ecb46d..32a1e2dda82daff01d7cb2cc1967b788cd2879cf 100644 (file)
         (condn condc)
         ((eq tmpcond condn) (set condres (.sym condc -condition))))
        (.iota 16)
-       cris-condition-codes)))
+       cris-condition-codes))
+      (else (error "Unknown condition code")))
      condres)
 )
 
        ((eq tmpcode x-swapcode)
         (set tmpres ((.sym swap- x-swap) tmpval))))
        (.iota 16)
-       (.splice _ (.unsplice cris-swap-codes)))))
+       (.splice _ (.unsplice cris-swap-codes))))
+     (else (error "Unknown swapcode")))
     tmpres)
 )
 
index cae56fd5ca8e0fc668eb7bccbf6d9c21f692e2d6..8441c220fcba66724619dbdfd8aafd35dfedf888 100644 (file)
@@ -11090,6 +11090,9 @@ SET_H_VBIT_MOVE (0);
 ; ORSI (ANDSI (SLLSI (tmp_tmpb, 16), 0xffff0000), ANDSI (SRLSI (tmp_tmpb, 16), 65535)); });
 ; ORSI (ANDSI (SLLSI (tmp_tmpb, 8), 0xff00ff00), ANDSI (SRLSI (tmp_tmpb, 8), 16711935)); });
 ; ORSI (SLLSI (ANDSI (tmp_tmpr, 16843009), 7), ORSI (SLLSI (ANDSI (tmp_tmpr, 33686018), 5), ORSI (SLLSI (ANDSI (tmp_tmpr, 67372036), 3), ORSI (SLLSI (ANDSI (tmp_tmpr, 134744072), 1), ORSI (SRLSI (ANDSI (tmp_tmpr, 269488144), 1), ORSI (SRLSI (ANDSI (tmp_tmpr, 538976288), 3), ORSI (SRLSI (ANDSI (tmp_tmpr, 1077952576), 5), SRLSI (ANDSI (tmp_tmpr, 0x80808080), 7)))))))); });
+}
+ else {
+cgen_rtx_error (current_cpu, "Unknown swapcode");
 }
 ; tmp_tmpres; });
   {
@@ -12109,6 +12112,9 @@ if (NESI (ANDSI (tmp_tmp, SLLSI (1, 7)), 0)) {
 }
  else if (EQSI (tmp_tmpcond, 15)) {
   tmp_condres = CPU (h_pbit);
+}
+ else {
+cgen_rtx_error (current_cpu, "Unknown condition code");
 }
 ; tmp_condres; });
 crisv10f_branch_taken (current_cpu, pc, FLD (i_o_pcrel), tmp_truthval);
@@ -12241,6 +12247,9 @@ if (tmp_truthval) {
 }
  else if (EQSI (tmp_tmpcond, 15)) {
   tmp_condres = CPU (h_pbit);
+}
+ else {
+cgen_rtx_error (current_cpu, "Unknown condition code");
 }
 ; tmp_condres; });
 crisv10f_branch_taken (current_cpu, pc, FLD (i_o_word_pcrel), tmp_truthval);
@@ -13114,6 +13123,9 @@ SET_H_VBIT_MOVE (0);
 }
  else if (EQSI (tmp_tmpcond, 15)) {
   tmp_condres = CPU (h_pbit);
+}
+ else {
+cgen_rtx_error (current_cpu, "Unknown condition code");
 }
 ; tmp_condres; });
   {
index db2f7aa4710ee3c741e7f96b9ec423da2a42a5b0..77cd07a4ddf292e3bccaafd5c5641ac13dee2dfb 100644 (file)
@@ -11360,6 +11360,9 @@ SET_H_VBIT_MOVE (0);
 ; ORSI (ANDSI (SLLSI (tmp_tmpb, 16), 0xffff0000), ANDSI (SRLSI (tmp_tmpb, 16), 65535)); });
 ; ORSI (ANDSI (SLLSI (tmp_tmpb, 8), 0xff00ff00), ANDSI (SRLSI (tmp_tmpb, 8), 16711935)); });
 ; ORSI (SLLSI (ANDSI (tmp_tmpr, 16843009), 7), ORSI (SLLSI (ANDSI (tmp_tmpr, 33686018), 5), ORSI (SLLSI (ANDSI (tmp_tmpr, 67372036), 3), ORSI (SLLSI (ANDSI (tmp_tmpr, 134744072), 1), ORSI (SRLSI (ANDSI (tmp_tmpr, 269488144), 1), ORSI (SRLSI (ANDSI (tmp_tmpr, 538976288), 3), ORSI (SRLSI (ANDSI (tmp_tmpr, 1077952576), 5), SRLSI (ANDSI (tmp_tmpr, 0x80808080), 7)))))))); });
+}
+ else {
+cgen_rtx_error (current_cpu, "Unknown swapcode");
 }
 ; tmp_tmpres; });
   {
@@ -12509,6 +12512,9 @@ crisv32f_rfg_handler (current_cpu, pc);
 }
  else if (EQSI (tmp_tmpcond, 15)) {
   tmp_condres = CPU (h_pbit);
+}
+ else {
+cgen_rtx_error (current_cpu, "Unknown condition code");
 }
 ; tmp_condres; });
 crisv32f_branch_taken (current_cpu, pc, FLD (i_o_pcrel), tmp_truthval);
@@ -12641,6 +12647,9 @@ if (tmp_truthval) {
 }
  else if (EQSI (tmp_tmpcond, 15)) {
   tmp_condres = CPU (h_pbit);
+}
+ else {
+cgen_rtx_error (current_cpu, "Unknown condition code");
 }
 ; tmp_condres; });
 crisv32f_branch_taken (current_cpu, pc, FLD (i_o_word_pcrel), tmp_truthval);
@@ -13429,6 +13438,9 @@ SET_H_VBIT_MOVE (0);
 }
  else if (EQSI (tmp_tmpcond, 15)) {
   tmp_condres = CPU (h_pbit);
+}
+ else {
+cgen_rtx_error (current_cpu, "Unknown condition code");
 }
 ; tmp_condres; });
   {