This chapter documents the Backend for the DEC Alpha processor family.

@section Additional options for this version

This backend provides the following additional options:

@table @option


    @item -merge-constants
                Place identical floating point constants at the same
                memory location. This can reduce program size and increase
                compilation time.

    @item -const-in-data
                By default constant data will be placed in the code
                section (and therefore is accessable with faster pc-relative
                addressing modes). Using this option it will be placed in the
                data section.
                Note that on operating systems with memory protection this
                option will disable write-protection of constant data.

    @item -no-builtins
                Do not replace certain builtin functions by inline code.
                This may be useful if you use this code generator with
                another frontend than vbcc.
                stdarg.h will not work with -no-builtins.

    @item -stabs
                Generate stabs debug infos (if -g is specified) rather than
                DWARF2 which is the default. Consider this obsolete.

@end table

@section ABI


        This backend supports the following registers:

        @itemize @minus
        @item @code{$0} through @code{$31} for the general purpose registers and
        @item @code{$f0} through @code{$f31} for the floating point registers.
        @end itemize

    The current version generates assembly output for use with the GNU
    assembler. The generated code should work on systems with 21064,
    21066, 21164 and higher Alpha CPUs.

    The registers @code{$0-$8, $16-$28, $f0, $f1} and @code{$f10-$f30}
    are used as scratch registers (i.e. they can be destroyed in function
    calls), all other registers are preserved. Of course @code{$31} and
    @code{$f31} cannot be used.

    The first 6 function arguments which have arithmetic or pointer types
    are passed in registers @code{$16/$f16} through @code{$21/$f21}.

    Integers and pointers are returned in @code{$0}, floats and doubles in
    @code{$f0}.
    All other types are returned by passing the function the address
    of the result as a hidden argument - so when you call such a function
    without a proper declaration in scope you can expect a crash.

    The elementary data types are represented like:

    @example
    type        size in bits        alignment in bytes 

    char                8                       1 
    short              16                       2 
    int                32                       4 
    long               64                       8
    long long          64                       8 
    all pointers       64                       8 
    float              32                       4 
    double             64                       8 
    @end example

@section Predefined Macros

        This backend defines the following macros:

@table @code
        @item __ALPHA__
        
@end table


@section Stdarg

    A possible <stdarg.h> could look like this:

@example

    typedef struct @{
      char *regbase;
      char *membase;
      int arg;
    @} va_list;

    char *__va_start(void);
    int __va_fixargs(void);

    #define va_start(vl,dummy) \
    (vl.arg=__va_fixargs(),vl.regbase=__va_start(),vl.membase=vl.regbase+(6-vl.arg)*16)

    #define va_end(vl) (vl.regbase=vl.membase=0)

    #define __va_size(type) ((sizeof(type)+7)/8*8)
    #define va_arg(vl,type) \
     ( \
      ((__typeof(type)&15)<=10&&++vl.arg<=6) ? \
       ( \
        ((__typeof(type)&15)>=6&&(__typeof(type)&15)<=8) ? \
          (vl.regbase+=16,*(type *)(vl.regbase-8)) \
        : \
          (vl.regbase+=16,*(type *)(vl.regbase-16)) \
       ) \
      : \
       (vl.membase+=__va_size(type),*(type *)(vl.membase-__va_size(type))) \
     )

@end example


@section Known problems

@itemize @minus
    @item generated code is rather poor
    @item several other problems
@end itemize


