Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #1212: llvmdc.diff

File llvmdc.diff, 15.7 kB (added by lindquist, 4 years ago)

updated patch for rev [3899]

  • object.di

    old new  
    150150    void function() dtor; 
    151151    void function() unitTest; 
    152152 
     153    void* xgetMembers; 
     154    void function() ictor; 
     155 
    153156    static int opApply( int delegate( inout ModuleInfo ) ); 
    154157} 
    155158 
  • lib/unittest.sh

    old new  
    1818  --help: This message 
    1919  --run-all: Reports result instead of breaking. Do not use this if you want to 
    2020         run unittest runner through a debugger. 
    21   dmd: Builds unittests for dmd 
    22   gdc: Builds unittests for gdc 
     21  dmd:    Builds unittests for dmd 
     22  gdc:    Builds unittests for gdc 
     23  llvmdc: Builds unittests for llvmdc 
    2324 
    2425  <none>: Builds unittests for all known compilers.' 
    2526  exit 0 
     
    8687void main() {} 
    8788EOF 
    8889 
    89         rebuild -w -d -g -L-ldl -L-lz -L-lbz2 -debug=UnitTest -debug -full -clean -unittest \ 
     90        rebuild -w -d -L-ldl -L-lz -L-lbz2 -debug=UnitTest -debug -full -clean -unittest \ 
    9091        -version=UnitTest $EXE.d tango/core/*.d tango/core/sync/*.d tango/io/digest/*.d \ 
    9192        tango/io/model/*.d tango/io/protocol/*.d tango/io/selector/*.d tango/io/*.d \ 
    9293        tango/io/vfs/*.d tango/io/vfs/model/*.d \ 
     
    125126        gdc) 
    126127            GDC=1 
    127128            ;; 
     129        llvmdc) 
     130            LLVMDC=1 
     131            ;; 
    128132        *) 
    129133            usage 
    130134            ;; 
     
    132136    shift 
    133137done 
    134138 
    135 if [ ! "$DMD" -a ! "$GDC"
     139if [ ! "$DMD" -a ! "$GDC" -a ! "$LLVMDC"
    136140then 
    137141    DMD=1 
    138142    GDC=1 
     143    LLVMDC=1 
    139144fi 
    140145 
    141146if [ "$DMD" = "1" ] 
     
    146151then 
    147152    compile gdc runUnitTest_gdc 
    148153fi 
    149  
     154if [ "$LLVMDC" = "1" ] 
     155then 
     156    compile llvmdc runUnitTest_llvmdc 
     157fi 
  • lib/common/tango/core/BitManip.d

    old new  
    171171     */ 
    172172    uint outpl( uint port_address, uint value ); 
    173173} 
     174else version( LLVMDC ) 
     175{ 
     176    public import llvmdc.bitmanip; 
     177} 
    174178else 
    175179{ 
    176180    public import std.intrinsic; 
  • lib/common/tango/core/Thread.d

    old new  
    255255            { 
    256256                __builtin_unwind_init(); 
    257257            } 
     258            else version( LLVMDC ) 
     259            { 
     260                pragma(msg, "don't know how to push registers on the stack for this architecture with LLVMDC"); 
     261            } 
    258262            else 
    259263            { 
    260264                static assert( false, "Architecture not supported." ); 
     
    308312            { 
    309313                // registers will be popped automatically 
    310314            } 
     315            else version( LLVMDC ) 
     316            { 
     317                // TODO 
     318            } 
    311319            else 
    312320            { 
    313321                static assert( false, "Architecture not supported." ); 
  • lib/gc/basic/gcx.d

    old new  
    21782178            __builtin_unwind_init(); 
    21792179            sp = & sp; 
    21802180        } 
     2181        else version(LLVMDC) 
     2182        { 
     2183            version(X86) 
     2184            { 
     2185                asm 
     2186                { 
     2187                    pushad              ; 
     2188                    mov sp[EBP],ESP     ; 
     2189                } 
     2190            } 
     2191            else 
     2192            { 
     2193                pragma(msg, "don't know how to push registers on the stack for this architecture with llvmdc"); 
     2194            } 
     2195        } 
    21812196        else 
    21822197        { 
    21832198        asm 
     
    21912206        { 
    21922207            // nothing to do 
    21932208        } 
     2209        else version(LLVMDC) 
     2210        { 
     2211            version(X86) 
     2212            { 
     2213                asm 
     2214                { 
     2215                    popad               ; 
     2216                } 
     2217            } 
     2218            else 
     2219            { 
     2220                // TODO 
     2221            } 
     2222        } 
    21942223        else 
    21952224        { 
    21962225        asm 
  • lib/gc/basic/gcbits.d

    old new  
    3939{ 
    4040    // use the unoptimized version 
    4141} 
     42else version(LLVMDC) 
     43{ 
     44    // ditto 
     45} 
    4246else version (D_InlineAsm_X86) 
    4347{ 
    4448    version = Asm86; 
  • tango/text/convert/Layout.d

    old new  
    4747        alias void* Arg; 
    4848        alias va_list ArgList; 
    4949        } 
     50else version(LLVMDC) 
     51        { 
     52        private import tango.core.Vararg; 
     53        alias void* Arg; 
     54        alias va_list ArgList; 
     55        } 
    5056     else 
    5157        { 
    5258        alias void* Arg; 
     
    197203                assert (formatStr, "null format specifier"); 
    198204                assert (arguments.length < 64, "too many args in Layout.convert"); 
    199205 
    200                 version (GNU
     206                version (LLVMDC
    201207                        { 
    202208                        Arg[64] arglist = void; 
     209                        foreach (i, arg; arguments) 
     210                                { 
     211                                arglist[i] = args; 
     212                                args += (arg.tsize + size_t.sizeof - 1) & ~ (size_t.sizeof - 1); 
     213                                } 
     214                        } 
     215                else version (GNU) 
     216                        { 
     217                        Arg[64] arglist = void; 
    203218                        int[64] intargs = void; 
    204219                        byte[64] byteargs = void; 
    205220                        long[64] longargs = void; 
  • tango/core/Vararg.d

    old new  
    1515{ 
    1616    public import std.stdarg; 
    1717} 
     18else version( LLVMDC ) 
     19{ 
     20    public import llvmdc.vararg; 
     21} 
    1822else 
    1923{ 
    2024    /** 
  • tango/core/Atomic.d

    old new  
    270270 
    271271 
    272272//////////////////////////////////////////////////////////////////////////////// 
     273// LLVMDC Atomics Implementation 
     274//////////////////////////////////////////////////////////////////////////////// 
     275 
     276 
     277else version( LLVMDC ) 
     278{ 
     279    import llvmdc.intrinsics; 
     280 
     281 
     282    //////////////////////////////////////////////////////////////////////////// 
     283    // Atomic Load 
     284    //////////////////////////////////////////////////////////////////////////// 
     285 
     286 
     287    template atomicLoad( msync ms = msync.seq, T ) 
     288    { 
     289        T atomicLoad(ref T val) 
     290        { 
     291            llvm_memory_barrier( 
     292                ms == msync.hlb || ms == msync.acq || ms == msync.seq, 
     293                ms == msync.hsb || ms == msync.acq || ms == msync.seq, 
     294                ms == msync.slb || ms == msync.rel || ms == msync.seq, 
     295                ms == msync.ssb || ms == msync.rel || ms == msync.seq, 
     296                false); 
     297            static if (isPointerType!(T)) 
     298            { 
     299                return cast(T)llvm_atomic_load_add!(size_t)(cast(size_t*)&val, 0); 
     300            } 
     301            else 
     302            { 
     303                return llvm_atomic_load_add!(T)(&val, cast(T)0); 
     304            } 
     305        } 
     306    } 
     307 
     308 
     309    //////////////////////////////////////////////////////////////////////////// 
     310    // Atomic Store 
     311    //////////////////////////////////////////////////////////////////////////// 
     312 
     313 
     314    template atomicStore( msync ms = msync.seq, T ) 
     315    { 
     316        void atomicStore( ref T val, T newval ) 
     317        { 
     318            llvm_memory_barrier( 
     319                ms == msync.hlb || ms == msync.acq || ms == msync.seq, 
     320                ms == msync.hsb || ms == msync.acq || ms == msync.seq, 
     321                ms == msync.slb || ms == msync.rel || ms == msync.seq, 
     322                ms == msync.ssb || ms == msync.rel || ms == msync.seq, 
     323                false); 
     324            static if (isPointerType!(T)) 
     325            { 
     326                llvm_atomic_swap!(size_t)(cast(size_t*)&val, cast(size_t)newval); 
     327            } 
     328            else static if (is(T == bool)) 
     329            { 
     330                llvm_atomic_swap!(ubyte)(cast(ubyte*)&val, newval?1:0); 
     331            } 
     332            else 
     333            { 
     334                llvm_atomic_swap!(T)(&val, newval); 
     335            } 
     336        } 
     337    } 
     338 
     339 
     340    //////////////////////////////////////////////////////////////////////////// 
     341    // Atomic Store If 
     342    //////////////////////////////////////////////////////////////////////////// 
     343 
     344 
     345    template atomicStoreIf( msync ms = msync.seq, T ) 
     346    { 
     347        bool atomicStoreIf( ref T val, T newval, T equalTo ) 
     348        { 
     349            llvm_memory_barrier( 
     350                ms == msync.hlb || ms == msync.acq || ms == msync.seq, 
     351                ms == msync.hsb || ms == msync.acq || ms == msync.seq, 
     352                ms == msync.slb || ms == msync.rel || ms == msync.seq, 
     353                ms == msync.ssb || ms == msync.rel || ms == msync.seq, 
     354                false); 
     355            T oldval = void; 
     356            static if (isPointerType!(T)) 
     357            { 
     358                oldval = cast(T)llvm_atomic_cmp_swap!(size_t)(cast(size_t*)&val, cast(size_t)equalTo, cast(size_t)newval); 
     359            } 
     360            else static if (is(T == bool)) 
     361            { 
     362                oldval = llvm_atomic_cmp_swap!(ubyte)(cast(ubyte*)&val, equalTo?1:0, newval?1:0)?0:1; 
     363            } 
     364            else 
     365            { 
     366                oldval = llvm_atomic_cmp_swap!(T)(&val, equalTo, newval); 
     367            } 
     368            return oldval == equalTo; 
     369        } 
     370    } 
     371     
     372     
     373    //////////////////////////////////////////////////////////////////////////// 
     374    // Atomic Increment 
     375    //////////////////////////////////////////////////////////////////////////// 
     376 
     377 
     378    template atomicIncrement( msync ms = msync.seq, T ) 
     379    { 
     380        // 
     381        // NOTE: This operation is only valid for integer or pointer types 
     382        // 
     383        static assert( isValidNumericType!(T) ); 
     384 
     385 
     386        T atomicIncrement( ref T val ) 
     387        { 
     388            static if (isPointerType!(T)) 
     389            { 
     390                return cast(T)llvm_atomic_load_add!(size_t)(cast(size_t*)&val, 1); 
     391            } 
     392            else 
     393            { 
     394                return llvm_atomic_load_add!(T)(&val, cast(T)1); 
     395            } 
     396        } 
     397    } 
     398     
     399     
     400    //////////////////////////////////////////////////////////////////////////// 
     401    // Atomic Decrement 
     402    //////////////////////////////////////////////////////////////////////////// 
     403 
     404 
     405    template atomicDecrement( msync ms = msync.seq, T ) 
     406    { 
     407        // 
     408        // NOTE: This operation is only valid for integer or pointer types 
     409        // 
     410        static assert( isValidNumericType!(T) ); 
     411 
     412 
     413        T atomicDecrement( ref T val ) 
     414        { 
     415            static if (isPointerType!(T)) 
     416            { 
     417                return cast(T)llvm_atomic_load_sub!(size_t)(cast(size_t*)&val, 1); 
     418            } 
     419            else 
     420            { 
     421                return llvm_atomic_load_sub!(T)(&val, cast(T)1); 
     422            } 
     423        } 
     424    } 
     425} 
     426 
     427//////////////////////////////////////////////////////////////////////////////// 
    273428// x86 Atomic Function Implementation 
    274429//////////////////////////////////////////////////////////////////////////////// 
    275430 
  • tango/math/Math.d

    old new  
    7676        version = DigitalMars_D_InlineAsm_X86; 
    7777    } 
    7878} 
     79else version(LLVMDC) 
     80{ 
     81    import llvmdc.intrinsics; 
     82    version(X86) 
     83    { 
     84        version = LLVMDC_X86; 
     85    } 
     86} 
    7987 
    8088/* 
    8189 * Constants 
     
    298306 * Bugs: 
    299307 *  Results are undefined if |x| >= $(POWER 2,64). 
    300308 */ 
     309version(LLVMDC) 
     310{ 
     311    alias llvm_cos_f32 cos; 
     312    alias llvm_cos_f64 cos; 
     313    version(X86) 
     314    { 
     315        alias llvm_cos_f80 cos; 
     316    } 
     317    else 
     318    { 
     319        real cos(real x) 
     320        { 
     321            return tango.stdc.math.cosl(x); 
     322        } 
     323    } 
     324} 
     325else 
     326{ 
    301327real cos(real x) /* intrinsic */ 
    302328{ 
    303329    version(D_InlineAsm_X86) 
     
    313339        return tango.stdc.math.cosl(x); 
    314340    } 
    315341} 
     342} 
    316343 
    317344debug(UnitTest) { 
    318345unittest { 
     
    333360 * Bugs: 
    334361 *  Results are undefined if |x| >= $(POWER 2,64). 
    335362 */ 
     363version(LLVMDC) 
     364{ 
     365    alias llvm_sin_f32 sin; 
     366    alias llvm_sin_f64 sin; 
     367    version(X86) 
     368    { 
     369        alias llvm_sin_f80 sin; 
     370    } 
     371    else 
     372    { 
     373        real sin(real x) 
     374        { 
     375            return tango.stdc.math.sinl(x); 
     376        } 
     377    } 
     378} 
     379else 
     380{ 
    336381real sin(real x) /* intrinsic */ 
    337382{ 
    338383    version(D_InlineAsm_X86) 
     
    348393        return tango.stdc.math.sinl(x); 
    349394    } 
    350395} 
     396} 
    351397 
    352398debug(UnitTest) { 
    353399unittest { 
     
    374420{ 
    375421    version (GNU) { 
    376422        return tanl(x); 
    377     } else { 
     423    } 
     424    else version(LLVMDC) { 
     425        return tango.stdc.math.tanl(x); 
     426    } 
     427    else { 
    378428    asm 
    379429    { 
    380430        fld x[EBP]      ; // load theta 
     
    947997 *  <tr> <td> +&infin; <td> +&infin; <td> no 
    948998 *  ) 
    949999 */ 
     1000version(LLVMDC) 
     1001{ 
     1002    alias llvm_sqrt_f32 sqrt; 
     1003    alias llvm_sqrt_f64 sqrt; 
     1004    version(X86) 
     1005    { 
     1006        alias llvm_sqrt_f80 sqrt; 
     1007    } 
     1008    else 
     1009    { 
     1010        real sqrt(real x) 
     1011        { 
     1012            return tango.stdc.math.sqrtl(x); 
     1013        } 
     1014    } 
     1015} 
     1016else 
     1017{ 
     1018 
    9501019float sqrt(float x) /* intrinsic */ 
    9511020{ 
    9521021    version(D_InlineAsm_X86) 
     
    9951064    } 
    9961065} 
    9971066 
     1067} 
     1068 
    9981069/** ditto */ 
    9991070creal sqrt(creal z) 
    10001071{ 
     
    14771548        } 
    14781549    } 
    14791550    } 
    1480     return tango.stdc.math.powl(x, y); 
     1551    version(LLVMDC_X86) 
     1552    { 
     1553        return llvm_pow_f80(x, y); 
     1554    } 
     1555    else 
     1556    { 
     1557        return tango.stdc.math.powl(x, y); 
     1558    } 
    14811559} 
    14821560 
    14831561debug(UnitTest) { 
  • tango/math/internal/BignumX86.d

    old new  
    5050private: 
    5151version(GNU) { 
    5252    // GDC is a filthy liar. It can't actually do inline asm. 
     53} else version(LLVMDC) { 
     54    // I guess the same goes for llvmdc to some extent :( 
    5355} else version(D_InlineAsm_X86) { 
    5456/* Duplicate string s, with n times, substituting index for '@'. 
    5557 * 
  • tango/math/internal/BiguintCore.d

    old new  
    1212} else version(GNU) { 
    1313    // GDC lies about its X86 support 
    1414private import tango.math.internal.BignumNoAsm;     
    15 } else version(D_InlineAsm_X86) {  
     15} else version(LLVMDC) { 
     16    // I guess llvmdc does too :( 
     17private import tango.math.internal.BignumNoAsm;     
     18} else version(D_InlineAsm_X86) { 
    1619private import tango.math.internal.BignumX86; 
    1720} else { 
    1821private import tango.math.internal.BignumNoAsm; 
  • tango/stdc/stdlib.d

    old new  
    9494{ 
    9595    void* alloca(size_t size); 
    9696} 
     97else version( LLVMDC ) 
     98{ 
     99    pragma(alloca) 
     100        void* alloca(size_t size); 
     101} 
    97102else version( GNU ) 
    98103{ 
    99104    private import gcc.builtins; 
  • tango/stdc/stdarg.d

    old new  
    1313{ 
    1414    public import std.c.stdarg; 
    1515} 
     16else version( LLVMDC ) 
     17{ 
     18    public import llvmdc.cstdarg; 
     19} 
    1620else 
    1721{ 
    1822    alias void* va_list;