diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-11-14 06:39:53 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-11-14 06:39:53 +0100 |
commit | 279fcbc246fc6438756b76cd4d3d5f1f3e4e1463 (patch) | |
tree | 3a11f301175db7618893a14726a1bf55e2e802c1 /src/vhdl | |
parent | fe338385f6c077e5b55b1fa2fc0fe4033894857d (diff) | |
download | ghdl-279fcbc246fc6438756b76cd4d3d5f1f3e4e1463.tar.gz ghdl-279fcbc246fc6438756b76cd4d3d5f1f3e4e1463.tar.bz2 ghdl-279fcbc246fc6438756b76cd4d3d5f1f3e4e1463.zip |
Fix overflow detection for **, implement ** for i64.
Fix #683
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/translate/trans-chap3.adb | 3 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap7.adb | 23 | ||||
-rw-r--r-- | src/vhdl/translate/trans.ads | 3 | ||||
-rw-r--r-- | src/vhdl/translate/trans_decls.ads | 3 | ||||
-rw-r--r-- | src/vhdl/translate/translation.adb | 23 |
5 files changed, 40 insertions, 15 deletions
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb index c9e639dd1..7938a278d 100644 --- a/src/vhdl/translate/trans-chap3.adb +++ b/src/vhdl/translate/trans-chap3.adb @@ -3233,8 +3233,7 @@ package body Trans.Chap3 is Allocate_Unbounded_Composite_Bounds (Alloc_Kind, Res, Obj_Type); Copy_Bounds (Chap3.Get_Composite_Bounds (Res), Bounds, Obj_Type); -- Allocate base. - Allocate_Unbounded_Composite_Base - (Alloc_Kind, Res, Obj_Type); + Allocate_Unbounded_Composite_Base (Alloc_Kind, Res, Obj_Type); else New_Assign_Stmt (M2Lp (Res), diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb index 20f7185d1..a0352a4dd 100644 --- a/src/vhdl/translate/trans-chap7.adb +++ b/src/vhdl/translate/trans-chap7.adb @@ -2456,11 +2456,24 @@ package body Trans.Chap7 is Right_Tree, Ghdl_Real_Exp); return New_Convert_Ov (Res, Res_Otype); when Iir_Predefined_Integer_Exp => - Res := Translate_Lib_Operator - (New_Convert_Ov (Left_Tree, Std_Integer_Otype), - Right_Tree, - Ghdl_Integer_Exp); - return New_Convert_Ov (Res, Res_Otype); + declare + Left_Tinfo : constant Type_Info_Acc := + Get_Info (Get_Type (Left)); + Opr : O_Dnode; + Etype : O_Tnode; + begin + case Type_Mode_Integers (Left_Tinfo.Type_Mode) is + when Type_Mode_I32 => + Opr := Ghdl_I32_Exp; + Etype := Ghdl_I32_Type; + when Type_Mode_I64 => + Opr := Ghdl_I64_Exp; + Etype := Ghdl_I64_Type; + end case; + Res := Translate_Lib_Operator + (New_Convert_Ov (Left_Tree, Etype), Right_Tree, Opr); + return New_Convert_Ov (Res, Res_Otype); + end; when Iir_Predefined_Array_Inequality | Iir_Predefined_Record_Inequality => diff --git a/src/vhdl/translate/trans.ads b/src/vhdl/translate/trans.ads index 960323ee8..f154d6d5d 100644 --- a/src/vhdl/translate/trans.ads +++ b/src/vhdl/translate/trans.ads @@ -1063,6 +1063,9 @@ package Trans is subtype Type_Mode_Scalar is Type_Mode_Type range Type_Mode_B1 .. Type_Mode_F64; + subtype Type_Mode_Integers is Type_Mode_Type range + Type_Mode_I32 .. Type_Mode_I64; + -- Composite types, with the vhdl meaning: record and arrays. subtype Type_Mode_Composite is Type_Mode_Type range Type_Mode_Static_Record .. Type_Mode_Protected; diff --git a/src/vhdl/translate/trans_decls.ads b/src/vhdl/translate/trans_decls.ads index d0011e653..2f9fa539a 100644 --- a/src/vhdl/translate/trans_decls.ads +++ b/src/vhdl/translate/trans_decls.ads @@ -164,7 +164,8 @@ package Trans_Decls is Ghdl_Malloc : O_Dnode; Ghdl_Malloc0 : O_Dnode; Ghdl_Real_Exp : O_Dnode; - Ghdl_Integer_Exp : O_Dnode; + Ghdl_I32_Exp : O_Dnode; + Ghdl_I64_Exp : O_Dnode; -- Procedure called in case of check failed. Ghdl_Program_Error : O_Dnode; diff --git a/src/vhdl/translate/translation.adb b/src/vhdl/translate/translation.adb index 68dd9a300..2edeba0be 100644 --- a/src/vhdl/translate/translation.adb +++ b/src/vhdl/translate/translation.adb @@ -1139,16 +1139,25 @@ package body Translation is Std_Integer_Otype); Finish_Subprogram_Decl (Interfaces, Ghdl_Real_Exp); - -- function __ghdl_integer_exp (left : std__standard__integer; - -- right : std__standard__integer) - -- return std__standard__integer; + -- function __ghdl_i32_exp (left : ghdl_i32; + -- right : std__standard__integer) + -- return ghdl_i32; Start_Function_Decl - (Interfaces, Get_Identifier ("__ghdl_integer_exp"), O_Storage_External, - Std_Integer_Otype); - New_Interface_Decl (Interfaces, Param, Wki_Left, Std_Integer_Otype); + (Interfaces, Get_Identifier ("__ghdl_i32_exp"), O_Storage_External, + Ghdl_I32_Type); + New_Interface_Decl (Interfaces, Param, Wki_Left, Ghdl_I32_Type); New_Interface_Decl (Interfaces, Param, Wki_Right, Std_Integer_Otype); - Finish_Subprogram_Decl (Interfaces, Ghdl_Integer_Exp); + Finish_Subprogram_Decl (Interfaces, Ghdl_I32_Exp); + -- function __ghdl_i64_exp (left : ghdl_i64; + -- right : std__standard__integer) + -- return ghdl_i64; + Start_Function_Decl + (Interfaces, Get_Identifier ("__ghdl_i64_exp"), O_Storage_External, + Ghdl_I64_Type); + New_Interface_Decl (Interfaces, Param, Wki_Left, Ghdl_I64_Type); + New_Interface_Decl (Interfaces, Param, Wki_Right, Std_Integer_Otype); + Finish_Subprogram_Decl (Interfaces, Ghdl_I64_Exp); -- procedure __ghdl_image_b1 (res : std_string_ptr_node; -- val : ghdl_bool_type; |