aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/translate/trans-chap3.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-04-03 11:43:42 +0200
committerTristan Gingold <tgingold@free.fr>2020-04-06 20:10:54 +0200
commit77d71c72f10cb8a1779dfddcf2a5053c728300ec (patch)
treea6adcc528dc1845e16cf7b4c992a5384a5cf6f1a /src/vhdl/translate/trans-chap3.adb
parent6ccedcb1f76081df973776f0e4e6909e21de8760 (diff)
downloadghdl-77d71c72f10cb8a1779dfddcf2a5053c728300ec.tar.gz
ghdl-77d71c72f10cb8a1779dfddcf2a5053c728300ec.tar.bz2
ghdl-77d71c72f10cb8a1779dfddcf2a5053c728300ec.zip
vhdl: add scalar_size. Size of scalar types is computed during analysis.
Diffstat (limited to 'src/vhdl/translate/trans-chap3.adb')
-rw-r--r--src/vhdl/translate/trans-chap3.adb43
1 files changed, 10 insertions, 33 deletions
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb
index 082a20810..b0f61fe7e 100644
--- a/src/vhdl/translate/trans-chap3.adb
+++ b/src/vhdl/translate/trans-chap3.adb
@@ -27,7 +27,6 @@ with Trans.Chap7;
with Trans.Chap14;
with Trans_Decls; use Trans_Decls;
with Trans.Helpers2; use Trans.Helpers2;
-with Translation;
package body Trans.Chap3 is
use Trans.Helpers;
@@ -332,45 +331,21 @@ package body Trans.Chap3 is
-- Integer --
---------------
- -- Return the number of bits (32 or 64) required to represent the
- -- (integer or physical) type definition DEF.
- type Type_Precision is (Precision_32, Precision_64);
- function Get_Type_Precision (Def : Iir) return Type_Precision
- is
- St : constant Iir :=
- Get_Subtype_Definition (Get_Type_Declarator (Def));
- L, H : Iir;
- Lv, Hv : Int64;
- subtype Int64_32 is Int64 range -(2 ** 31) .. 2 ** 31 - 1;
- begin
- Get_Low_High_Limit (Get_Range_Constraint (St), L, H);
- Lv := Get_Value (L);
- Hv := Get_Value (H);
- if Lv in Int64_32 and then Hv in Int64_32 then
- return Precision_32;
- else
- if Translation.Flag_Only_32b then
- Error_Msg_Sem
- (+St, "range of %n is too large", +Get_Type_Declarator (St));
- return Precision_32;
- end if;
- return Precision_64;
- end if;
- end Get_Type_Precision;
-
procedure Translate_Integer_Type (Def : Iir_Integer_Type_Definition)
is
Info : constant Type_Info_Acc := Get_Info (Def);
begin
- case Get_Type_Precision (Def) is
- when Precision_32 =>
+ case Get_Scalar_Size (Def) is
+ when Scalar_32 =>
Info.Ortho_Type (Mode_Value) := New_Signed_Type (32);
Info.Type_Mode := Type_Mode_I32;
Info.B.Align := Align_32;
- when Precision_64 =>
+ when Scalar_64 =>
Info.Ortho_Type (Mode_Value) := New_Signed_Type (64);
Info.Type_Mode := Type_Mode_I64;
Info.B.Align := Align_64;
+ when others =>
+ raise Internal_Error;
end case;
-- Integers are always in their ranges.
Info.S.Nocheck_Low := True;
@@ -406,15 +381,17 @@ package body Trans.Chap3 is
is
Info : constant Type_Info_Acc := Get_Info (Def);
begin
- case Get_Type_Precision (Def) is
- when Precision_32 =>
+ case Get_Scalar_Size (Def) is
+ when Scalar_32 =>
Info.Ortho_Type (Mode_Value) := New_Signed_Type (32);
Info.Type_Mode := Type_Mode_P32;
Info.B.Align := Align_32;
- when Precision_64 =>
+ when Scalar_64 =>
Info.Ortho_Type (Mode_Value) := New_Signed_Type (64);
Info.Type_Mode := Type_Mode_P64;
Info.B.Align := Align_64;
+ when others =>
+ raise Internal_Error;
end case;
-- Physical types are always in their ranges.
Info.S.Nocheck_Low := True;