aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/translate/translation.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-10-02 13:57:49 +0200
committerTristan Gingold <tgingold@free.fr>2022-10-02 13:57:49 +0200
commit298fa787da01ded60f2b9d02c9529760aabd2921 (patch)
treef8697578f8ac6011720f561d5ecc5074849ae142 /src/vhdl/translate/translation.adb
parent7d642ac4d912c4111769f124a2da97fa83828548 (diff)
downloadghdl-298fa787da01ded60f2b9d02c9529760aabd2921.tar.gz
ghdl-298fa787da01ded60f2b9d02c9529760aabd2921.tar.bz2
ghdl-298fa787da01ded60f2b9d02c9529760aabd2921.zip
translate, grt: add lib function for div and rem.
Do not rely on hardware exceptions to catch division by 0, they are caught in windows by the c handler and not propagated
Diffstat (limited to 'src/vhdl/translate/translation.adb')
-rw-r--r--src/vhdl/translate/translation.adb30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/vhdl/translate/translation.adb b/src/vhdl/translate/translation.adb
index 5325e6276..cbca05a6a 100644
--- a/src/vhdl/translate/translation.adb
+++ b/src/vhdl/translate/translation.adb
@@ -1200,10 +1200,8 @@ package body Translation is
Start_Function_Decl
(Interfaces, Get_Identifier ("__ghdl_real_exp"), O_Storage_External,
Std_Real_Otype);
- New_Interface_Decl (Interfaces, Param, Get_Identifier ("left"),
- Std_Real_Otype);
- New_Interface_Decl (Interfaces, Param, Get_Identifier ("right"),
- Std_Integer_Otype);
+ New_Interface_Decl (Interfaces, Param, Wki_Left, Std_Real_Otype);
+ New_Interface_Decl (Interfaces, Param, Wki_Right, Std_Integer_Otype);
Finish_Subprogram_Decl (Interfaces, Ghdl_Real_Exp);
-- function __ghdl_i32_exp (left : ghdl_i32;
@@ -1226,6 +1224,30 @@ package body Translation is
New_Interface_Decl (Interfaces, Param, Wki_Right, Std_Integer_Otype);
Finish_Subprogram_Decl (Interfaces, Ghdl_I64_Exp);
+ declare
+ procedure Create_Div_Subprogram
+ (Name : String; T : O_Tnode; Decl : out O_Dnode) is
+ begin
+ Start_Function_Decl
+ (Interfaces, Get_Identifier (Name), O_Storage_External, T);
+ New_Interface_Decl (Interfaces, Param, Wki_Left, T);
+ New_Interface_Decl (Interfaces, Param, Wki_Right, T);
+ Finish_Subprogram_Decl (Interfaces, Decl);
+ end Create_Div_Subprogram;
+ begin
+ -- function __ghdl_i32_div (left, right : ghdl_i32) return ghdl_i32;
+ Create_Div_Subprogram ("__ghdl_i32_div", Ghdl_I32_Type, Ghdl_I32_Div);
+
+ -- function __ghdl_i64_div (left, right : ghdl_i64) return ghdl_i64;
+ Create_Div_Subprogram ("__ghdl_i64_div", Ghdl_I64_Type, Ghdl_I64_Div);
+
+ -- function __ghdl_i32_mod (left, right : ghdl_i32) return ghdl_i32;
+ Create_Div_Subprogram ("__ghdl_i32_mod", Ghdl_I32_Type, Ghdl_I32_Mod);
+
+ -- function __ghdl_i64_mod (left, right : ghdl_i64) return ghdl_i64;
+ Create_Div_Subprogram ("__ghdl_i64_mod", Ghdl_I64_Type, Ghdl_I64_Mod);
+ end;
+
-- procedure __ghdl_image_b1 (res : std_string_ptr_node;
-- val : ghdl_bool_type;
-- rti : ghdl_rti_access);