[LLVMdev] [patch] native AMD64 support

John Criswell criswell at cs.uiuc.edu
Mon Jan 3 14:38:27 PST 2005


Markus F.X.J. Oberhumer wrote:
> Hello folks,
> 
> with the small patch attached below the whole llvm toolchain (llvm & llvm-gcc) 
> will compile and run under AMD64 Linux in native 64-bit LP64 mode.
> 
> This means that compilation, bytecode management and CWriter output all work 
> as expected. Of course there is no JIT, and the bytecode interpreter is still 
> very much untested - more patches may follow.

I just applied your X86-64 patches to llvm-gcc.  I've run them on a few 
programs on Linux/i386, and everything seems to work.

Thanks, Markus!

-- John T.

> 
> Cheers,
> Markus
> 
> --
> Markus F.X.J. Oberhumer
> oberhumer.com, http://www.oberhumer.com/
> Space-Grade Technology
> 
> 
> 
> ------------------------------------------------------------------------
> 
> Index: i386.c
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-gcc/gcc/config/i386/i386.c,v
> retrieving revision 1.1.1.2
> diff -u -r1.1.1.2 i386.c
> --- i386.c	13 Jan 2004 16:49:45 -0000	1.1.1.2
> +++ i386.c	23 Dec 2004 05:31:32 -0000
> @@ -1381,9 +1381,15 @@
>  	error ("-malign-double makes no sense in the 64bit mode");
>        if (TARGET_RTD)
>  	error ("-mrtd calling convention not supported in the 64bit mode");
> +#if EMIT_LLVM
> +      /* set to standard X86 values (using 64-bit long doubles under LLVM) */
> +      target_flags &= ~(MASK_SSE2 | MASK_SSE | MASK_MMX | MASK_128BIT_LONG_DOUBLE);
> +      ix86_fpmath = FPMATH_387;
> +#else
>        /* Enable by default the SSE and MMX builtins.  */
>        target_flags |= (MASK_SSE2 | MASK_SSE | MASK_MMX | MASK_128BIT_LONG_DOUBLE);
>        ix86_fpmath = FPMATH_SSE;
> +#endif
>       }
>    else
>      {
> @@ -2795,7 +2801,8 @@
>    tree f_gpr, f_fpr, f_ovf, f_sav, record, type_decl;
>  
>    /* For i386 we use plain pointer to argument area.  */
> -  if (!TARGET_64BIT)
> +  /* LLVM also uses the i386 standard version in 64-bit mode */
> +  if (!TARGET_64BIT || EMIT_LLVM)
>      return build_pointer_type (char_type_node);
>  
>    record = (*lang_hooks.types.make_type) (RECORD_TYPE);
> @@ -2858,7 +2865,8 @@
>    int stdarg_p;
>    int i;
>  
> -  if (!TARGET_64BIT)
> +  /* LLVM also uses the i386 standard version in 64-bit mode */
> +  if (!TARGET_64BIT || EMIT_LLVM)
>      return;
>  
>    /* Indicate to allocate space on the stack for varargs save area.  */
> @@ -2948,7 +2956,8 @@
>    tree gpr, fpr, ovf, sav, t;
>  
>    /* Only 64bit target needs something special.  */
> -  if (!TARGET_64BIT)
> +  /* LLVM also uses the i386 standard version in 64-bit mode */
> +  if (!TARGET_64BIT || EMIT_LLVM)
>      {
>        std_expand_builtin_va_start (valist, nextarg);
>        return;
> @@ -3015,7 +3024,8 @@
>    int indirect_p = 0;
>  
>    /* Only 64bit target needs something special.  */
> -  if (!TARGET_64BIT)
> +  /* LLVM also uses the i386 standard version in 64-bit mode */
> +  if (!TARGET_64BIT || EMIT_LLVM)
>      {
>        return std_expand_builtin_va_arg (valist, type);
>      }
> Index: i386.h
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-gcc/gcc/config/i386/i386.h,v
> retrieving revision 1.2
> diff -u -r1.2 i386.h
> --- i386.h	8 Jan 2004 23:03:36 -0000	1.2
> +++ i386.h	23 Dec 2004 05:31:34 -0000
> @@ -826,7 +826,7 @@
>  #if !EMIT_LLVM
>  #define BIGGEST_ALIGNMENT 128
>  #else
> -#define BIGGEST_ALIGNMENT 32
> +#define BIGGEST_ALIGNMENT 64
>  #endif
>  
>  /* Decide whether a variable of mode MODE should be 128 bit aligned.  */
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list