aboutsummaryrefslogtreecommitdiffstats
path: root/src/ortho
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2017-06-19 03:54:47 +0200
committerTristan Gingold <tgingold@free.fr>2017-06-19 03:54:47 +0200
commit7b2da98caf3c389c4bd29df887050414597aeb7f (patch)
tree9f815a12d894c2cee7ddeabc42313b8b56cb0b8e /src/ortho
parentc8e0f3b2f183ac92b74c6cdbc32b4ef4464876d6 (diff)
downloadghdl-7b2da98caf3c389c4bd29df887050414597aeb7f.tar.gz
ghdl-7b2da98caf3c389c4bd29df887050414597aeb7f.tar.bz2
ghdl-7b2da98caf3c389c4bd29df887050414597aeb7f.zip
WIP on mcode for win64.
Diffstat (limited to 'src/ortho')
-rw-r--r--src/ortho/mcode/ortho_code-x86-abi.adb28
-rw-r--r--src/ortho/mcode/ortho_code-x86-flags_linux.ads3
-rw-r--r--src/ortho/mcode/ortho_code-x86-flags_linux64.ads3
-rw-r--r--src/ortho/mcode/ortho_code-x86-flags_macosx.ads3
-rw-r--r--src/ortho/mcode/ortho_code-x86-flags_macosx64.ads3
-rw-r--r--src/ortho/mcode/ortho_code-x86-flags_windows.ads3
-rw-r--r--src/ortho/mcode/ortho_code-x86-flags_windows64.ads5
7 files changed, 35 insertions, 13 deletions
diff --git a/src/ortho/mcode/ortho_code-x86-abi.adb b/src/ortho/mcode/ortho_code-x86-abi.adb
index b474f2bd6..8c746c18a 100644
--- a/src/ortho/mcode/ortho_code-x86-abi.adb
+++ b/src/ortho/mcode/ortho_code-x86-abi.adb
@@ -42,11 +42,15 @@ package body Ortho_Code.X86.Abi is
Abi := (Offset => Subprg_Stack_Init, Inum => 0, Fnum => 0);
end Start_Subprogram;
- type Regs_List is array (Natural range <>) of O_Reg;
+ type Regs_List is array (Boolean range <>, Natural range <>) of O_Reg;
Int_Regs : constant Regs_List :=
- (R_Di, R_Si, R_Dx, R_Cx, R_R8, R_R9);
+ (False => (R_Di, R_Si, R_Dx, R_Cx, R_R8, R_R9),
+ True => (R_Cx, R_Dx, R_R8, R_R9, R_None, R_None));
Sse_Regs : constant Regs_List :=
- (R_Xmm0, R_Xmm1, R_Xmm2, R_Xmm3, R_Xmm4, R_Xmm5, R_Xmm6, R_Xmm7);
+ (False => (R_Xmm0, R_Xmm1, R_Xmm2, R_Xmm3,
+ R_Xmm4, R_Xmm5, R_Xmm6, R_Xmm7),
+ True => (R_Xmm0, R_Xmm1, R_Xmm2, R_Xmm3,
+ R_None, R_None, R_None, R_None));
procedure New_Interface (Inter : O_Dnode; Abi : in out O_Abi_Subprg)
is
@@ -59,26 +63,26 @@ package body Ortho_Code.X86.Abi is
if Flags.M64 then
-- AMD64 ABI 3.2.3 Parameter passing
-- The size of each argument gets rounded up to eight bytes.
- Size := 0;
case Get_Type_Mode (Itype) is
when Mode_Int | Mode_Uns | Mode_B2 | Mode_P64 =>
- if Abi.Inum <= Int_Regs'Last then
- Reg := Int_Regs (Abi.Inum);
+ if Abi.Inum <= Int_Regs'Last (2) then
+ Reg := Int_Regs (Flags.Win64, Abi.Inum);
Abi.Inum := Abi.Inum + 1;
- else
- Size := 8;
end if;
when Mode_Fp =>
- if Abi.Fnum <= Sse_Regs'Last then
- Reg := Sse_Regs (Abi.Fnum);
+ if Abi.Fnum <= Sse_Regs'Last (2) then
+ Reg := Sse_Regs (Flags.Win64, Abi.Fnum);
Abi.Fnum := Abi.Fnum + 1;
- else
- Size := 8;
end if;
when others =>
-- Parameters are scalars.
raise Program_Error;
end case;
+ if Reg = R_None then
+ Size := 8;
+ else
+ Size := 0;
+ end if;
else
Size := Get_Type_Size (Itype);
Size := (Size + 3) and not 3;
diff --git a/src/ortho/mcode/ortho_code-x86-flags_linux.ads b/src/ortho/mcode/ortho_code-x86-flags_linux.ads
index c60e0a7c1..490a7af21 100644
--- a/src/ortho/mcode/ortho_code-x86-flags_linux.ads
+++ b/src/ortho/mcode/ortho_code-x86-flags_linux.ads
@@ -31,4 +31,7 @@ package Ortho_Code.X86.Flags_Linux is
-- 32 bits.
M64 : constant Boolean := False;
+
+ -- Not Windows x64 calling convention.
+ Win64 : constant Boolean := False;
end Ortho_Code.X86.Flags_Linux;
diff --git a/src/ortho/mcode/ortho_code-x86-flags_linux64.ads b/src/ortho/mcode/ortho_code-x86-flags_linux64.ads
index 000e6e0cd..b832ee76e 100644
--- a/src/ortho/mcode/ortho_code-x86-flags_linux64.ads
+++ b/src/ortho/mcode/ortho_code-x86-flags_linux64.ads
@@ -31,4 +31,7 @@ package Ortho_Code.X86.Flags_Linux64 is
-- 32 bits.
M64 : constant Boolean := True;
+
+ -- Not Windows x64 calling convention.
+ Win64 : constant Boolean := False;
end Ortho_Code.X86.Flags_Linux64;
diff --git a/src/ortho/mcode/ortho_code-x86-flags_macosx.ads b/src/ortho/mcode/ortho_code-x86-flags_macosx.ads
index 8966e5340..b8bc5cef3 100644
--- a/src/ortho/mcode/ortho_code-x86-flags_macosx.ads
+++ b/src/ortho/mcode/ortho_code-x86-flags_macosx.ads
@@ -31,4 +31,7 @@ package Ortho_Code.X86.Flags_Macosx is
-- 32 bits.
M64 : constant Boolean := False;
+
+ -- Not Windows x64 calling convention.
+ Win64 : constant Boolean := False;
end Ortho_Code.X86.Flags_Macosx;
diff --git a/src/ortho/mcode/ortho_code-x86-flags_macosx64.ads b/src/ortho/mcode/ortho_code-x86-flags_macosx64.ads
index caf4e2a08..185c9cca0 100644
--- a/src/ortho/mcode/ortho_code-x86-flags_macosx64.ads
+++ b/src/ortho/mcode/ortho_code-x86-flags_macosx64.ads
@@ -31,4 +31,7 @@ package Ortho_Code.X86.Flags_Macosx64 is
-- 64 bits.
M64 : constant Boolean := True;
+
+ -- Not Windows x64 calling convention.
+ Win64 : constant Boolean := False;
end Ortho_Code.X86.Flags_Macosx64;
diff --git a/src/ortho/mcode/ortho_code-x86-flags_windows.ads b/src/ortho/mcode/ortho_code-x86-flags_windows.ads
index dfe6e678b..5398a747d 100644
--- a/src/ortho/mcode/ortho_code-x86-flags_windows.ads
+++ b/src/ortho/mcode/ortho_code-x86-flags_windows.ads
@@ -31,4 +31,7 @@ package Ortho_Code.X86.Flags_Windows is
-- 32 bits.
M64 : constant Boolean := False;
+
+ -- Not Windows x64 calling convention.
+ Win64 : constant Boolean := False;
end Ortho_Code.X86.Flags_Windows;
diff --git a/src/ortho/mcode/ortho_code-x86-flags_windows64.ads b/src/ortho/mcode/ortho_code-x86-flags_windows64.ads
index b2063e4d4..3ac655d28 100644
--- a/src/ortho/mcode/ortho_code-x86-flags_windows64.ads
+++ b/src/ortho/mcode/ortho_code-x86-flags_windows64.ads
@@ -29,6 +29,9 @@ package Ortho_Code.X86.Flags_Windows64 is
-- Alignment for double (64 bit float).
Mode_F64_Align : constant Natural := 3;
- -- 32 bits.
+ -- 64 bits.
M64 : constant Boolean := True;
+
+ -- Windows x64 calling convention.
+ Win64 : constant Boolean := True;
end Ortho_Code.X86.Flags_Windows64;