diff options
author | Tristan Gingold | 2016-01-05 06:44:53 +0100 |
---|---|---|
committer | Tristan Gingold | 2016-01-06 18:38:37 +0100 |
commit | b5797a5cef6d25817da7998f6263afa53e196d25 (patch) | |
tree | ad3b67a93d16e8a06fab2d7a8c4d8993ff101b8a /src/ortho/mcode/symbolizer.adb | |
parent | 955e964b024de556c4c0db8fd745c6abdb8052fe (diff) | |
download | ghdl-b5797a5cef6d25817da7998f6263afa53e196d25.tar.gz ghdl-b5797a5cef6d25817da7998f6263afa53e196d25.tar.bz2 ghdl-b5797a5cef6d25817da7998f6263afa53e196d25.zip |
mcode: add support for x86-64
Diffstat (limited to 'src/ortho/mcode/symbolizer.adb')
-rw-r--r-- | src/ortho/mcode/symbolizer.adb | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/src/ortho/mcode/symbolizer.adb b/src/ortho/mcode/symbolizer.adb index 79e7de2..8f60bf4 100644 --- a/src/ortho/mcode/symbolizer.adb +++ b/src/ortho/mcode/symbolizer.adb @@ -69,6 +69,19 @@ package body Symbolizer is Addr := Addr + 4; end Read_Word4; + procedure Read_Word8 (Addr : in out Address; Res : out Unsigned_64) + is + B : Unsigned_8; + begin + Res := 0; + for I in 0 .. 7 loop + B := Read_Byte (Addr + Storage_Offset (I)); + -- FIXME: we assume little-endian + Res := Res or Shift_Left (Unsigned_64 (B), I * 8); + end loop; + Addr := Addr + 8; + end Read_Word8; + procedure Read_Word2 (Addr : in out Address; Res : out Unsigned_16) is @@ -231,15 +244,32 @@ package body Symbolizer is Addr := Addr + 1; end Skip_String; - procedure Read_Addr (Addr : in out Address; - Res : out Address) - is - function To_Address is new Ada.Unchecked_Conversion - (Unsigned_32, Address); - V : Unsigned_32; + procedure Read_Addr (Addr : in out Address; Res : out Address) is begin - Read_Word4 (Addr, V); - Res := To_Address (V); + pragma Warnings (Off, "*different size*"); + if Address'Size = Unsigned_32'Size then + declare + function To_Address is new Ada.Unchecked_Conversion + (Unsigned_32, Address); + V : Unsigned_32; + begin + Read_Word4 (Addr, V); + Res := To_Address (V); + end; + elsif Address'Size = Unsigned_64'Size then + declare + function To_Address is new Ada.Unchecked_Conversion + (Unsigned_64, Address); + V : Unsigned_64; + begin + Read_Word8 (Addr, V); + Res := To_Address (V); + end; + else + -- Unhandled address size. + raise Program_Error; + end if; + pragma Warnings (On, "*different size*"); end Read_Addr; procedure Read_Addr (Addr : in out Address; |