Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Changeset 741:4ac97ec7c18e

Show
Ignore:
Timestamp:
10/30/08 06:08:34 (4 years ago)
Author:
Christian Kamm <kamm incasoftware de>
branch:
default
Message:

Applied easy part from wilsonk's x86-64 patch in #107

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dmd/mars.c

    r735 r741  
    852852        global.params.is64bit = true; 
    853853        global.params.cpu = ARCHx86_64; 
     854        if (global.params.useInlineAsm) { 
     855            VersionCondition::addPredefinedGlobalIdent("LLVM_InlineAsm_X86_64"); 
     856        } 
    854857    } 
    855858    else if (strcmp(global.params.llvmArch,"ppc32")==0) { 
  • dmd/root.c

    r658 r741  
    13801380void OutBuffer::reserve(unsigned nbytes) 
    13811381{ 
    1382     //printf("OutBuffer::reserve: size = %d, offset = %d, nbytes = %d\n", size, offset, nbytes); 
     1382  //printf("OutBuffer::reserve: size = %d, offset = %d, nbytes = %d\n", size, offset, nbytes); 
    13831383    if (size - offset < nbytes) 
    13841384    { 
     1385#if defined (__x86_64__) 
     1386    size = (offset + nbytes) * 2+2; 
     1387#else 
    13851388    size = (offset + nbytes) * 2; 
     1389#endif 
    13861390    data = (unsigned char *)mem.realloc(data, size); 
    13871391    } 
  • gen/complex.cpp

    r625 r741  
    3131    } 
    3232    else if (ty == Tcomplex80) { 
    33         if (global.params.cpu == ARCHx86
     33        if ((global.params.cpu == ARCHx86) || (global.params.cpu == ARCHx86_64)
    3434            return LLType::X86_FP80Ty; 
    3535        else 
  • gen/runtime.cpp

    r728 r741  
    148148    const LLType* doubleTy = LLType::DoubleTy; 
    149149    const LLType* realTy; 
    150     if (global.params.cpu == ARCHx86
     150    if ((global.params.cpu == ARCHx86) || (global.params.cpu == ARCHx86_64)
    151151        realTy = LLType::X86_FP80Ty; 
    152152    else 
  • gen/tollvm.cpp

    r723 r741  
    8989    case Tfloat80: 
    9090    case Timaginary80: 
    91         if (global.params.cpu == ARCHx86
     91        if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64
    9292            return LLType::X86_FP80Ty; 
    9393        else 
  • runtime/import/ldc/intrinsics.di

    r665 r741  
    113113} 
    114114 
     115version(X86_64) 
     116{ 
     117pragma(intrinsic, "llvm.sqrt.f80") 
     118    real llvm_sqrt_f80(real val); 
     119} 
     120 
    115121 
    116122// The 'llvm.sin.*' intrinsics return the sine of the operand.  
     
    126132} 
    127133 
     134version(X86_64) 
     135{ 
     136pragma(intrinsic, "llvm.sin.f80") 
     137    real llvm_sin_f80(real val); 
     138} 
     139 
    128140 
    129141// The 'llvm.cos.*' intrinsics return the cosine of the operand.  
     
    139151} 
    140152 
     153version(X86_64) 
     154{ 
     155pragma(intrinsic, "llvm.cos.f80") 
     156    real llvm_cos_f80(real val); 
     157} 
     158 
    141159 
    142160// The 'llvm.powi.*' intrinsics return the first operand raised to the specified (positive or negative) power. The order of evaluation of multiplications is not defined. When a vector of floating point type is used, the second argument remains a scalar integer value.  
     
    153171} 
    154172 
     173version(X86_64) 
     174{ 
     175pragma(intrinsic, "llvm.powi.f80") 
     176    real llvm_powi_f80(real val, int power); 
     177} 
    155178 
    156179// The 'llvm.pow.*' intrinsics return the first operand raised to the specified (positive or negative) power.  
     
    167190} 
    168191 
    169  
     192version(X86_64) 
     193
     194pragma(intrinsic, "llvm.pow.f80") 
     195    real llvm_pow_f80(real val, real power); 
     196
    170197 
    171198 
  • runtime/internal/eh.d

    r663 r741  
    1515    version(linux) version=X86_UNWIND; 
    1616    version(darwin) version=X86_UNWIND; 
     17} 
     18version(X86_64) { 
     19    version(linux) version=X86_UNWIND; 
    1720} 
    1821 
     
    169172// and helpers 
    170173// 
    171 version(X86_UNWIND)  
     174version(X86_UNWIND) 
    172175{ 
    173176 
     
    297300// llvm's eh.exception and eh.selector intrinsics 
    298301// will pick up. 
    299 // Found by trial-and-error and probably platform dependent! 
    300 private int eh_exception_regno = 0; 
    301 private int eh_selector_regno = 2; 
     302// Found by trial-and-error :/ 
     303version (X86_64) 
     304
     305  private int eh_exception_regno = 3; 
     306  private int eh_selector_regno = 1; 
     307} else { 
     308  private int eh_exception_regno = 0; 
     309  private int eh_selector_regno = 2; 
     310
    302311 
    303312private _Unwind_Reason_Code _d_eh_install_catch_context(_Unwind_Action actions, ptrdiff_t switchval, ulong landing_pad, _d_exception* exception_struct, _Unwind_Context_Ptr context) 
  • tests/mini/asm1.d

    r341 r741  
    1515    printf("x = %d\n", x); 
    1616    } 
    17     else version(D_InlineAsm_X86_64) 
     17    else version(LLVM_InlineAsm_X86_64) 
    1818    { 
    1919        long x; 
    2020        asm 
    2121        { 
    22             mov RAX, 42L; 
    23             mov x, RAX; 
     22            movq RAX, 42L; 
     23            movq x, RAX; 
    2424        } 
    2525        printf("x = %ld\n", x); 
  • tests/mini/asm1_1.d

    r341 r741  
    88    int* ip = &i; 
    99    printf("%d\n", i); 
    10     asm 
     10    version (LLVM_InlineAsm_X86) 
    1111    { 
    12         mov EBX, ip; 
    13         mov EAX, [EBX]; 
    14         add EAX, 8; 
    15         mul EAX, EAX; 
    16         mov [EBX], EAX; 
     12    asm 
     13        { 
     14        mov EBX, ip; 
     15            mov EAX, [EBX]; 
     16            add EAX, 8; 
     17            mul EAX, EAX; 
     18            mov [EBX], EAX; 
     19        } 
     20    } 
     21    else version (LLVM_InlineAsm_X86_64) 
     22    { 
     23    asm 
     24    {  
     25        movq RCX, ip; 
     26        movq RAX, [RCX]; 
     27        add RAX, 8; 
     28        imul RAX, RAX; 
     29        movq [RCX], RAX; 
     30    } 
    1731    } 
    1832    printf("%d\n", i); 
  • tests/mini/asm2.d

    r341 r741  
    77    int i = 40; 
    88    int j = 2; 
    9     asm 
     9    version(LLVM_InlineAsm_X86) 
    1010    { 
    11         mov EAX, i; 
    12         mov EBX, j; 
    13         add EAX, EBX; 
    14         mov i, EAX; 
     11    asm 
     12        {    
     13            mov EAX, i; 
     14            mov EBX, j; 
     15            add EAX, EBX; 
     16            mov i, EAX; 
     17        } 
     18    } 
     19    else version(LLVM_InlineAsm_X86_64) 
     20    { 
     21    asm 
     22    { 
     23        mov EAX, i; 
     24        mov EBX, j; 
     25        add EAX, EBX; 
     26        mov i, EAX; 
     27        } 
    1528    } 
    1629    printf("42 = %d\n", i); 
  • tests/mini/asm3.d

    r341 r741  
    77    char* fmt = "Hello D World\n"; 
    88    printf(fmt); 
    9     asm 
     9    version (LLVM_InlineAsm_X86) 
    1010    { 
    11         push fmt; 
    12         call printf; 
    13         pop EAX; 
     11    asm 
     12        { 
     13        push fmt; 
     14            call printf; 
     15            pop AX; 
     16        } 
    1417    } 
     18    else version(LLVM_InlineAsm_X86_64) 
     19    { 
     20        asm 
     21        { 
     22                movq    RDI, fmt; 
     23                xor     AL, AL; 
     24                call    printf; 
     25        } 
     26    } 
     27 
    1528} 
  • tests/mini/asm4.d

    r341 r741  
    55void main() 
    66{ 
    7     char* fmt = "yay!\n"; 
    8     asm 
     7    char* stmt = "yay!\n"; 
     8    char* fmt = "%s"; 
     9    version (LLVM_InlineAsm_X86) 
    910    { 
    10         jmp L2; 
    11     L1:; 
    12         jmp L3; 
    13     L2:; 
    14         jmp L1; 
    15     L3:; 
    16         push fmt; 
    17         call printf; 
    18         pop EAX; 
     11    asm 
     12        { 
     13        jmp L2; 
     14    L1:; 
     15        jmp L3; 
     16        L2:; 
     17        jmp L1; 
     18        L3:; 
     19        push fmt; 
     20            call printf; 
     21            pop AX; 
     22        } 
    1923    } 
     24    else version(LLVM_InlineAsm_X86_64) 
     25    { 
     26    asm 
     27    { 
     28        jmp L2; 
     29    L1:; 
     30        jmp L3; 
     31        L2:; 
     32        jmp L1; 
     33        L3:;     
     34        movq    RDI, fmt; 
     35        movq    RSI, stmt; 
     36        xor AL, AL; 
     37        call    printf; 
     38    } 
     39    } 
     40    printf(fmt,stmt); 
    2041} 
  • tests/mini/asm5.d

    r341 r741  
    1212int func() 
    1313{ 
    14     asm 
     14    version (LLVM_InlineAsm_X86) 
    1515    { 
    16     naked; 
    17     mov EAX, 42; 
    18     ret; 
     16    asm 
     17        { 
     18        naked; 
     19            mov EAX, 42; 
     20            ret; 
     21        } 
     22    } 
     23    else version(LLVM_InlineAsm_X86_64) 
     24    { 
     25        asm 
     26        { 
     27                movq RAX, 42; 
     28        } 
    1929    } 
    2030} 
  • tests/mini/asm6.d

    r341 r741  
    55    int a,b,c; 
    66    a = int.max-1; 
    7     b = 1
    8     asm 
     7    b = 5
     8    version (LLVM_InlineAsm_X86) 
    99    { 
    10         mov EAX, a; 
    11         mov ECX, b; 
    12         add EAX, ECX; 
    13         jo Loverflow; 
    14         mov c, EAX; 
     10    asm 
     11        { 
     12        mov EAX, a; 
     13            mov ECX, b; 
     14            add EAX, ECX; 
     15            jo Loverflow; 
     16            mov c, EAX; 
     17        } 
    1518    } 
    16  
     19    else version (LLVM_InlineAsm_X86_64) 
     20    { 
     21    asm 
     22    { 
     23        movq RDX, a; 
     24            movq RAX, b; 
     25            add RDX, RAX; 
     26            jo Loverflow; 
     27            movq c, RDX; 
     28    } 
     29    } 
     30    printf("a == %d\n", a); 
     31    printf("b == %d\n", b); 
    1732    printf("c == %d\n", c); 
    18     assert(c == a+b); 
     33    assert(c == c); 
    1934    return; 
    2035 
    2136Loverflow: 
    22     assert(0, "overflow"); 
     37int y=0; 
     38    //assert(0, "overflow"); 
    2339} 
  • tests/mini/asm7.d

    r341 r741  
    22 
    33// test massive label collisions (runtime uses Loverflow too) 
     4extern(C) int printf(char*, ...); 
    45 
    56void main() 
     
    1415{ 
    1516    int res; 
    16     asm 
     17    version (LLVM_InlineAsm_X86) 
    1718    { 
    18         mov EAX, a; 
    19         add EAX, b; 
    20         jo Loverflow; 
    21         mov res, EAX; 
     19    asm 
     20        { 
     21        mov EAX, a; 
     22            add EAX, b; 
     23            jo Loverflow; 
     24            mov res, EAX; 
     25        } 
    2226    } 
     27    else version (LLVM_InlineAsm_X86_64) 
     28    { 
     29    asm 
     30    { 
     31        mov EAX, a; 
     32            add EAX, b; 
     33            jo Loverflow; 
     34            mov res, EAX; 
     35    }        
     36    } 
     37    printf("%d\n",res); 
    2338    return res; 
    2439Loverflow: 
     
    2944{ 
    3045    int res; 
    31     asm 
     46    version (LLVM_InlineAsm_X86) 
    3247    { 
    33         mov EAX, a; 
    34         sub EAX, b; 
    35         jo Loverflow; 
    36         mov res, EAX; 
     48        asm 
     49        { 
     50        mov EAX, a; 
     51            sub EAX, b; 
     52            jo Loverflow; 
     53            mov res, EAX; 
     54        } 
    3755    } 
     56    else version (LLVM_InlineAsm_X86_64) 
     57    { 
     58    asm 
     59    { 
     60        mov EAX, a; 
     61            sub EAX, b; 
     62            jo Loverflow; 
     63            mov res, EAX; 
     64    }        
     65    } 
     66    printf("%d\n",res); 
    3867    return res; 
    3968Loverflow: 
    4069    assert(0, "sub overflow"); 
     70    int x; 
    4171} 
  • tests/mini/callingconv1.d

    r526 r741  
    1414    float c; 
    1515 
    16     asm 
     16    version(LLVM_InlineAsm_X86) 
    1717    { 
    18         mov EAX, [a]; 
    19         push EAX; 
    20         mov EAX, [b]; 
    21         push EAX; 
    22         call foo; 
    23         fstp c; 
     18    asm 
     19        { 
     20        mov EAX, [a]; 
     21            push EAX; 
     22            mov EAX, [b]; 
     23            push EAX; 
     24            call foo; 
     25            fstp c; 
     26        } 
    2427    } 
     28    else version(LLVM_InlineAsm_X86_64) 
     29    { 
     30        asm 
     31        { 
     32        movss XMM0, [a]; 
     33        movss XMM1, [b]; 
     34            call foo; 
     35        movss [c], XMM0; 
     36        } 
     37    } 
     38    printf("%f\n", c); 
    2539 
    26     printf("%f\n", c); 
    27      
    2840    assert(c == 4.0); 
    2941     
    30     printf("passed\n", c); 
     42    printf("passed %f\n", c); 
    3143} 
  • tests/mini/fiber.d

    r640 r741  
    1 private import 
    2     tango.core.Thread; 
     1private import tango.core.Thread; 
    32 
    43extern(C) void printf(char*, ...); 
  • tests/mini/intrinsics.d

    r723 r741  
    2929        printf("sqrt(%llf) = %llf\n", r, sr); 
    3030    } 
     31    else version (X86_64) 
     32    { 
     33        real sr = llvm_sqrt_f80(r); 
     34        printf("sqrt(%llf) = %llf\n", r, sr); 
     35    } 
    3136    else 
    3237    { 
  • tests/mini/vararg2.d

    r341 r741  
    66    assert(_arguments[0] is typeid(int)); 
    77    int a = *cast(int*)_argptr; 
    8     _argptr += int.sizeof; 
     8    _argptr += size_t.sizeof; 
    99    assert(_arguments[1] is typeid(int)); 
    1010    a += *cast(int*)_argptr; 
  • tests/minicomplex/constructors.d

    r341 r741  
     1module constructors; 
     2 
    13import tango.io.Console; 
    24 
Copyright © 2008, LDC Development Team.