From a14b9578ee5297d954103e05d7b2d322816ddd8f Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Sat, 1 Oct 2016 17:38:24 +0200 Subject: Support for 64-bit architectures: x86 in 64-bit mode This commit enriches the IA32 port so that it supports x86 processors in 64-bit mode as well as in 32-bit mode, depending on the value of Archi.ptr64, which itself is set from the configuration model. To activate x86-64 bit support, configure with "x86_64-linux". Main steps: - Enrich Op.v and Asm.v with 64-bit operations - SelectLong: in 64-bit mode, use 64-bit operations directly; in 32-bit mode, fall back on the old implementation based on pairs of 32-bit integers - Conventions1: support x86-64 ABI in addition to the 32-bit ABI. - Add support for the new 64-bit operations everywhere. - runtime/x86_64: implementation of the supporting library appropriate for x86 in 64-bit mode To do: - More optimizations are possible on 64-bit integer arithmetic operations. - Could add new chunks to load, say, an unsigned byte into a 64-bit long (currently we load as a 32-bit int then zero-extend). - Implements the wrong ABI for struct passing. --- ia32/CBuiltins.ml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'ia32/CBuiltins.ml') diff --git a/ia32/CBuiltins.ml b/ia32/CBuiltins.ml index 79a839f3..1fe3b200 100644 --- a/ia32/CBuiltins.ml +++ b/ia32/CBuiltins.ml @@ -19,12 +19,15 @@ open C let builtins = { Builtins.typedefs = [ - "__builtin_va_list", TPtr(TVoid [], []) + (* Actually a struct passed by reference; equivalent to 3 64-bit words *) + "__builtin_va_list", TArray(TInt(IULong, []), Some 3L, []) ]; Builtins.functions = [ (* Integer arithmetic *) "__builtin_bswap", (TInt(IUInt, []), [TInt(IUInt, [])], false); + "__builtin_bswap64", + (TInt(IULongLong, []), [TInt(IULongLong, [])], false); "__builtin_bswap32", (TInt(IUInt, []), [TInt(IUInt, [])], false); "__builtin_bswap16", @@ -79,8 +82,8 @@ let builtins = { ] } -let size_va_list = 4 -let va_list_scalar = true +let size_va_list = 3*8 +let va_list_scalar = false (* Expand memory references inside extended asm statements. Used in C2C. *) -- cgit