ubsan: fr30: left shift of negative value

Message ID 20200113014434.GI4433@bubble.grove.modra.org
State New
Headers show
Series
  • ubsan: fr30: left shift of negative value
Related show

Commit Message

Alan Modra Jan. 13, 2020, 1:44 a.m.
cpu/
	* fr30.cpu (f-disp9, f-disp10, f-s10, f-rel9, f-rel12): Don't
	left shift signed values.
opcodes/
	* fr30-ibld.c: Regenerate.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/cpu/fr30.cpu b/cpu/fr30.cpu
index 84c32cf5d7..07bf1daf11 100644
--- a/cpu/fr30.cpu
+++ b/cpu/fr30.cpu
@@ -193,15 +193,15 @@ 
 (df  f-disp8     "8 bit signed offset"   ()  4  8 INT #f #f)
 (df  f-disp9     "9 bit signed offset"   ()  4  8 INT
     ((value pc) (sra WI value (const 1)))
-    ((value pc) (sll WI value (const 1)))
+    ((value pc) (mul WI value (const 2)))
 )
 (df  f-disp10    "10 bit signed offset"  ()  4  8 INT
      ((value pc) (sra WI value (const 2)))
-     ((value pc) (sll WI value (const 2)))
+     ((value pc) (mul WI value (const 4)))
 )
 (df  f-s10       "10 bit signed offset"  ()  8  8 INT
      ((value pc) (sra WI value (const 2)))
-     ((value pc) (sll WI value (const 2)))
+     ((value pc) (mul WI value (const 4)))
 )
 (df  f-u10       "10 bit unsigned offset" ()  8  8 UINT
      ((value pc) (srl UWI value (const 2)))
@@ -209,7 +209,7 @@ 
 )
 (df  f-rel9 "9 pc relative signed offset" (PCREL-ADDR) 8 8 INT
      ((value pc) (sra WI (sub WI value (add WI pc (const 2))) (const 1)))
-     ((value pc) (add WI (sll WI value (const 1)) (add WI pc (const 2))))
+     ((value pc) (add WI (mul WI value (const 2)) (add WI pc (const 2))))
 )
 (dnf f-dir8      "8  bit direct address"  ()  8  8)
 (df  f-dir9      "9  bit direct address"  ()  8  8 UINT
@@ -222,7 +222,7 @@ 
 )
 (df  f-rel12     "12 bit pc relative signed offset" (PCREL-ADDR) 5 11 INT
      ((value pc) (sra WI (sub WI value (add WI pc (const 2))) (const 1)))
-     ((value pc) (add WI (sll WI value (const 1)) (add WI pc (const 2))))
+     ((value pc) (add WI (mul WI value (const 2)) (add WI pc (const 2))))
 )
 
 (dnf f-reglist_hi_st  "8 bit register mask for stm" () 8 8)