Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 618

Show
Ignore:
Timestamp:
08/15/10 20:25:05 (14 years ago)
Author:
walter
Message:

more 64

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmd-1.x/src/aggregate.h

    r520 r618  
    172172    ClassDeclaration *base; 
    173173    int offset;                         // 'this' pointer offset 
    174174    Array vtbl;                         // for interfaces: Array of FuncDeclaration's 
    175175                                        // making up the vtbl[] 
    176176 
    177177    int baseInterfaces_dim; 
    178178    BaseClass *baseInterfaces;          // if BaseClass is an interface, these 
    179179                                        // are a copy of the InterfaceDeclaration::interfaces 
    180180 
    181181    BaseClass(); 
    182182    BaseClass(Type *type, enum PROT protection); 
    183183 
    184184    int fillVtbl(ClassDeclaration *cd, Array *vtbl, int newinstance); 
    185185    void copyBaseInterfaces(BaseClasses *); 
    186186}; 
    187187 
    188188#if DMDV2 
    189189#define CLASSINFO_SIZE  (0x3C+16+4)     // value of ClassInfo.size 
    190190#else 
    191191#define CLASSINFO_SIZE  (0x3C+12+4)     // value of ClassInfo.size 
     192#define CLASSINFO_SIZE_64  (0x98)       // value of ClassInfo.size 
    192193#endif 
    193194 
    194195struct ClassDeclaration : AggregateDeclaration 
    195196{ 
    196197    static ClassDeclaration *object; 
    197198    static ClassDeclaration *classinfo; 
    198199 
    199200    ClassDeclaration *baseClass;        // NULL only if this is Object 
    200201#if DMDV1 
    201202    CtorDeclaration *ctor; 
    202203    CtorDeclaration *defaultCtor;       // default constructor 
    203204#endif 
    204205    FuncDeclaration *staticCtor; 
    205206    FuncDeclaration *staticDtor; 
    206207    Array vtbl;                         // Array of FuncDeclaration's making up the vtbl[] 
    207208    Array vtblFinal;                    // More FuncDeclaration's that aren't in vtbl[] 
    208209 
    209210    BaseClasses *baseclasses;           // Array of BaseClass's; first is super, 
    210211                                        // rest are Interface's 
    211212 
  • branches/dmd-1.x/src/backend/cdef.h

    r593 r618  
    879879    immed_t immed;              // immediate values in registers 
    880880    regm_t mvar;                // mask of register variables 
    881881    regm_t mpvar;               // mask of SCfastpar register variables 
    882882    regm_t indexregs;           // !=0 if more than 1 uncommitted index register 
    883883    regm_t used;                // mask of registers used 
    884884    regm_t params;              // mask of registers which still contain register 
    885885                                // function parameters 
    886886}; 
    887887 
    888888/********************************* 
    889889 * Bootstrap complex types. 
    890890 */ 
    891891 
    892892#include "bcomplex.h" 
    893893 
    894894/********************************* 
    895895 * Union of all data types. Storage allocated must be the right 
    896896 * size of the data on the TARGET, not the host. 
    897897 */ 
    898898 
     899struct Cent 
     900{ 
     901    targ_ullong lsw; 
     902    targ_ullong msw; 
     903}; 
     904 
    899905union eve 
    900906{ 
    901907        targ_char       Vchar; 
    902908        targ_schar      Vschar; 
    903909        targ_uchar      Vuchar; 
    904910        targ_short      Vshort; 
    905911        targ_ushort     Vushort; 
    906912        targ_int        Vint;    // also used for tmp numbers (FLtmp) 
    907913        targ_uns        Vuns; 
    908914        targ_long       Vlong; 
    909915        targ_ulong      Vulong; 
    910916        targ_llong      Vllong; 
    911917        targ_ullong     Vullong; 
     918        Cent            Vcent; 
    912919        targ_float      Vfloat; 
    913920        targ_double     Vdouble; 
    914921        targ_ldouble    Vldouble; 
    915922        Complex_f       Vcfloat;   // 2x float 
    916923        Complex_d       Vcdouble;  // 2x double 
    917924        Complex_ld      Vcldouble; // 2x long double 
    918925        targ_size_t     Vpointer; 
    919926        targ_ptrdiff_t  Vptrdiff; 
    920927        targ_uchar      Vreg;   // register number for OPreg elems 
    921928        struct                  // 48 bit 386 far pointer 
    922929        {   targ_long   Voff; 
    923930            targ_ushort Vseg; 
    924931        } Vfp; 
    925932        struct 
    926933        { 
    927934            targ_size_t Voffset;// offset from symbol 
    928935            Symbol *Vsym;       // pointer to symbol table 
    929936            union 
    930937            {   struct PARAM *Vtal;     // template-argument-list for SCfunctempl, 
    931938                                // used only to transmit it to cpp_overload() 
  • branches/dmd-1.x/src/backend/cgcod.c

    r596 r618  
    18331833                r = retregs & ~(msavereg | regcon.cse.mops); 
    18341834                if (!r) 
    18351835                {   r = retregs & ~msavereg; 
    18361836                    if (!r) 
    18371837                        r = retregs; 
    18381838                } 
    18391839            } 
    18401840        } 
    18411841        if (0 && r & ~fregsaved) 
    18421842            r &= ~fregsaved; 
    18431843 
    18441844        if (size <= REGSIZE) 
    18451845        { 
    18461846            if (r & ~mBP) 
    18471847                r &= ~mBP; 
    18481848 
    18491849            // If only one index register, prefer to not use LSW registers 
    18501850            if (!regcon.indexregs && r & ~mLSW) 
    18511851                r &= ~mLSW; 
    18521852 
    1853             if (pass == PASSfinal && r & ~lastretregs && I32
     1853            if (pass == PASSfinal && r & ~lastretregs && !I16
    18541854            {   // Try not to always allocate the same register, 
    18551855                // to schedule better 
    18561856 
    18571857                r &= ~lastretregs; 
    18581858                if (r & ~last2retregs) 
    18591859                {   r &= ~last2retregs; 
    18601860                    if (r & ~last3retregs) 
    18611861                    {   r &= ~last3retregs; 
    18621862                        if (r & ~last4retregs) 
    18631863                        {   r &= ~last4retregs; 
    18641864//                          if (r & ~last5retregs) 
    18651865//                              r &= ~last5retregs; 
    18661866                        } 
    18671867                    } 
    18681868                } 
    18691869                if (r & ~mfuncreg) 
    18701870                    r &= ~mfuncreg; 
    18711871            } 
    18721872            reg = findreg(r); 
    18731873            retregs = mask[reg]; 
     
    27142714    #define SMAX 64 
    27152715    static char str[NUM][SMAX + 1]; 
    27162716    static int i; 
    27172717    char *p; 
    27182718    char *s; 
    27192719    int j; 
    27202720 
    27212721    if (rm == 0) 
    27222722        return "0"; 
    27232723    if (rm == ALLREGS) 
    27242724        return "ALLREGS"; 
    27252725    if (rm == BYTEREGS) 
    27262726        return "BYTEREGS"; 
    27272727    if (rm == allregs) 
    27282728        return "allregs"; 
    27292729    p = str[i]; 
    27302730    if (++i == NUM) 
    27312731        i = 0; 
    27322732    s = p; 
    27332733    *p = 0; 
    2734     for (j = 0; j < 23; j++) 
     2734    for (j = 0; j < 32; j++) 
    27352735    { 
    27362736        if (mask[j] & rm) 
    27372737        { 
    27382738            strcat(p,regstring[j]); 
    27392739            rm &= ~mask[j]; 
    27402740            if (rm) 
    27412741                strcat(p,"|"); 
    27422742        } 
    27432743    } 
    27442744    if (rm) 
    27452745    {   s = p + strlen(p); 
    27462746        sprintf(s,"x%02x",rm); 
    27472747    } 
    27482748    assert(strlen(p) <= SMAX); 
    27492749    return strdup(p); 
    27502750} 
    27512751 
    27522752#endif 
    27532753 
    27542754#endif // !SPP 
  • branches/dmd-1.x/src/backend/cgelem.c

    r500 r618  
    19931993                    e->E1->Ety = touns(tym); 
    19941994                    break; 
    19951995 
    19961996                case OPmod: 
    19971997                    op = OPand; 
    19981998                    goto L3; 
    19991999                case OPmodass: 
    20002000                    op = OPandass; 
    20012001                L3: 
    20022002                    e2->EV.Vullong = el_tolong(e2) - 1; 
    20032003                    break; 
    20042004 
    20052005                default: 
    20062006                    assert(0); 
    20072007            } 
    20082008            e->Eoper = op; 
    20092009            return optelem(e,TRUE); 
    20102010        } 
    20112011#if TARGET_MAC 
    20122012        if (j != -1) 
    2013         {   elem *ea; 
    2014  
    2015             ea = el_copytree(e->E1); 
     2013        { 
     2014            elem *ea = el_copytree(e->E1); 
    20162015            e2->EV.Vint = j; 
    20172016            e->Eoper = OPshr; 
    20182017            e->E1->Ety = touns(tym); 
    20192018            e2->Ety = TYint; 
    20202019            e = el_una(OPneg,tym,e); 
    20212020            e = el_bin(OPeq,tym,ea,e); 
    20222021            return optelem(e,TRUE); 
    20232022        } 
    20242023#endif 
    20252024      } 
    20262025#if TARGET_MAC 
    20272026        unsigned short op; 
    20282027        tym_t tym2; 
    20292028        elem *e1 = e->E1; 
    20302029 
    20312030        tym = e->E1->Ety; 
    20322031        op = e1->Eoper; 
    20332032        if (op == OPu16_32 && e2->EV.Vulong <= (targ_ulong) SHORTMASK || 
    20342033         op == OPshtlng && e2->EV.Vlong == (targ_short) e2->EV.Vlong) 
    20352034                { 
     
    20802079 
    20812080    if (OPTIMIZER) 
    20822081    { 
    20832082        if (tyintegral(tym) && (e->Eoper == OPdiv || e->Eoper == OPmod)) 
    20842083        {   int sz = tysize(tym); 
    20852084 
    20862085            // See if we can replace with OPremquo 
    20872086            if (sz == intsize) 
    20882087            { 
    20892088                // Don't do it if there are special code sequences in the 
    20902089                // code generator (see cdmul()) 
    20912090                int pow2; 
    20922091                if (e->E2->Eoper == OPconst && 
    20932092                    sz == REGSIZE && !uns && 
    20942093                    (pow2 = ispow2(el_tolong(e->E2))) != -1 && 
    20952094                    !(config.target_cpu < TARGET_80286 && pow2 != 1 && e->Eoper == OPdiv) 
    20962095                   ) 
    20972096                    ; 
    20982097                else 
    20992098                { 
    2100                     int op; 
    2101  
    2102                     op = OPmsw; 
     2099                    assert(sz == 2 || sz == 4); 
     2100                    int op = OPmsw; 
    21032101                    if (e->Eoper == OPdiv) 
    21042102                    { 
    21052103                        op = (sz == 2) ? OP32_16 : OP64_32; 
    21062104                    } 
    21072105                    e->Eoper = OPremquo; 
    21082106                    e = el_una(op, tym, e); 
    21092107                    e->E1->Ety = (sz == 2) ? TYlong : TYllong; 
    21102108                } 
    21112109            } 
    21122110        } 
    21132111    } 
    21142112 
    21152113    return e; 
    21162114} 
    21172115 
    21182116 
    21192117/************************** 
    21202118 * Convert (a op b) op c to a op (b op c). 
    21212119 */ 
    21222120 
     
    38243822        if (tysize(ty) != tysize(e->E1->E1->Ety)) 
    38253823            break; 
    38263824        e = el_selecte1(el_selecte1(e)); 
    38273825        e->Ety = ty; 
    38283826        break; 
    38293827 
    38303828    case OPrpair: 
    38313829        if (tysize(ty) != tysize(e->E1->E2->Ety)) 
    38323830            break; 
    38333831        e = el_selecte2(el_selecte1(e)); 
    38343832        e->Ety = ty; 
    38353833        break; 
    38363834 
    38373835    case OPvar:                 // simply paint type of variable 
    38383836    case OPind: 
    38393837        e = el_selecte1(e); 
    38403838        break; 
    38413839 
    38423840    case OPshr:                 // OP64_32(x >> 32) => OPmsw(x) 
    38433841        if (e1->E2->Eoper == OPconst && 
    3844             el_tolong(e1->E2) == 32
     3842            el_tolong(e1->E2) == 32 && !I64
    38453843        { 
    38463844            e->Eoper = OPmsw; 
    38473845            e->E1 = el_selecte1(e->E1); 
    38483846        } 
    38493847        break; 
    38503848  } 
    38513849  return e; 
    38523850} 
    38533851 
    38543852 
    38553853/******************************* 
    38563854 * Convert complex to real. 
    38573855 */ 
    38583856 
    38593857STATIC elem *elc_r(elem *e) 
    38603858{ 
    38613859    elem *e1 = e->E1; 
    38623860 
    38633861    if (e1->Eoper == OPvar || e1->Eoper == OPind) 
    38643862    { 
  • branches/dmd-1.x/src/backend/cgreg.c

    r569 r618  
    675675        } 
    676676        if (inoutp == 1) 
    677677            cstore = cat(cstore,c); 
    678678        else 
    679679            cload = cat(cload,c); 
    680680        break; 
    681681    } 
    682682    el_free(e); 
    683683 
    684684    // Store old register values before loading in new ones 
    685685    *pcstore = cstore; 
    686686    *pcload = cload; 
    687687} 
    688688 
    689689/*************************** 
    690690 * Map symbol s into registers [NOREG,reglsw] or [regmsw, reglsw]. 
    691691 */ 
    692692 
    693693void cgreg_map(Symbol *s, unsigned regmsw, unsigned reglsw) 
    694694{ 
    695     assert(reglsw < 8); 
     695    assert(I64 || reglsw < 8); 
    696696 
    697697    if (vec_disjoint(s->Srange,regrange[reglsw]) && 
    698698        (regmsw == NOREG || vec_disjoint(s->Srange,regrange[regmsw])) 
    699699       ) 
    700700    { 
    701701        s->Sfl = FLreg; 
    702702        vec_copy(s->Slvreg,s->Srange); 
    703703    } 
    704704    else 
    705705    { 
    706706        s->Sflags |= SFLspill; 
    707707 
    708708        // Already computed by cgreg_benefit() 
    709709        //vec_sub(s->Slvreg,s->Srange,regrange[reglsw]); 
    710710 
    711711        if (s->Sfl == FLreg)            // if reassigned 
    712712        { 
    713713            switch (s->Sclass) 
    714714            { 
    715715                case SCauto: 
     
    897897            #ifdef DEBUG 
    898898            if (debugr) 
    899899            if (s->Sfl == FLreg) 
    900900                printf("symbol '%s' is in reg %s\n",s->Sident,regm_str(s->Sregm)); 
    901901            else if (s->Sflags & SFLspill) 
    902902                printf("symbol '%s' spilled in reg %s\n",s->Sident,regm_str(s->Sregm)); 
    903903            else 
    904904                printf("symbol '%s' is not a candidate\n",s->Sident); 
    905905            #endif 
    906906            continue; 
    907907        } 
    908908 
    909909        char *pseq; 
    910910        char *pseqmsw = NULL; 
    911911 
    912912        ty = s->ty(); 
    913913        sz = tysize(ty); 
    914914 
    915915        #ifdef DEBUG 
    916916            if (debugr) 
    917             {   printf("symbol '%3s', ty x%lx weight x%x sz %d\n   ", 
    918                 s->Sident,ty,s->Sweight,sz); 
     917            {   printf("symbol '%3s', ty x%x weight x%x sz %d\n   ", 
     918                s->Sident,ty,s->Sweight,(int)sz); 
    919919                vec_println(s->Srange); 
    920920            } 
    921921        #endif 
    922922 
    923923        if (I64) 
    924924        { 
    925925            if (sz == REGSIZE * 2) 
    926926            { 
    927927                static char seqmsw[] = {CX,DX,NOREG}; 
    928928                static char seqlsw[] = {AX,BX,SI,DI,NOREG}; 
    929929                pseq = seqlsw; 
    930930                pseqmsw = seqmsw; 
    931931            } 
    932932            else 
    933933            {   // R10 is reserved for the static link 
    934934                static char sequence[] = {AX,CX,DX,SI,DI,R8,R9,R11,BX,R12,R13,R14,R15,BP,NOREG}; 
    935935                pseq = sequence; 
    936936            } 
    937937        } 
    938938        else if (I32) 
  • branches/dmd-1.x/src/backend/cgsched.c

    r596 r618  
    31613161 
    31623162    if (ci == NULL) 
    31633163    { 
    31643164        printf("Cinfo 0\n"); 
    31653165        return; 
    31663166    } 
    31673167 
    31683168    printf("Cinfo %p:  c %p, pair %x, sz %d, isz %d, flags - ", 
    31693169           ci,c,pair,sz,isz); 
    31703170    if (ci->flags & CIFLarraybounds) 
    31713171        printf("arraybounds,"); 
    31723172    if (ci->flags & CIFLea) 
    31733173        printf("ea,"); 
    31743174    if (ci->flags & CIFLnostage) 
    31753175        printf("nostage,"); 
    31763176    if (ci->flags & CIFLpush) 
    31773177        printf("push,"); 
    31783178    if (ci->flags & ~(CIFLarraybounds|CIFLnostage|CIFLpush|CIFLea)) 
    31793179        printf("bad flag,"); 
    31803180    printf("\n\tr %lx w %lx a %lx reg %x uops %x sibmodrm %x spadjust %ld\n", 
    3181             r,w,a,reg,uops,sibmodrm,spadjust); 
     3181            (long)r,(long)w,(long)a,reg,uops,sibmodrm,(long)spadjust); 
    31823182    if (ci->fp_op) 
    31833183        printf("\tfp_op %s, fxch_pre %x, fxch_post %x\n", 
    31843184                fpops[fp_op-1],fxch_pre,fxch_post); 
    31853185} 
    31863186#endif 
    31873187#endif 
  • branches/dmd-1.x/src/backend/cod1.c

    r606 r618  
    17841784        else 
    17851785            assert(0); 
    17861786  } 
    17871787  code_orflag(ce,CFpsw); 
    17881788  return ce; 
    17891789} 
    17901790 
    17911791 
    17921792/****************************** 
    17931793 * Given the result of an expression is in retregs, 
    17941794 * generate necessary code to return result in *pretregs. 
    17951795 */ 
    17961796 
    17971797code *fixresult(elem *e,regm_t retregs,regm_t *pretregs) 
    17981798{ code *c,*ce; 
    17991799  unsigned reg,rreg; 
    18001800  regm_t forccs,forregs; 
    18011801  tym_t tym; 
    18021802  int sz; 
    18031803 
    1804 //  printf("fixresult(e = %p, retregs = %s, *pretregs = %s)\n", 
    1805 //      e,regm_str(retregs),regm_str(*pretregs)); 
     1804  //printf("fixresult(e = %p, retregs = %s, *pretregs = %s)\n",e,regm_str(retregs),regm_str(*pretregs)); 
    18061805  if (*pretregs == 0) return CNIL;      /* if don't want result         */ 
    18071806  assert(e && retregs);                 /* need something to work with  */ 
    18081807  forccs = *pretregs & mPSW; 
    18091808  forregs = *pretregs & (mST01 | mST0 | mBP | ALLREGS | mES | mSTACK); 
    18101809  tym = tybasic(e->Ety); 
    18111810#if 0 
    18121811  if (tym == TYstruct) 
    18131812        // Hack to support cdstreq() 
    18141813        tym = TYfptr; 
    18151814#else 
    18161815  if (tym == TYstruct) 
    18171816        // Hack to support cdstreq() 
    18181817        tym = (forregs & mMSW) ? TYfptr : TYnptr; 
    18191818#endif 
    18201819  c = CNIL; 
    18211820  sz = tysize[tym]; 
    18221821  if (sz == 1) 
    18231822  { 
    18241823        assert(retregs & BYTEREGS); 
    18251824        unsigned reg = findreg(retregs); 
     
    33093308            if (I16 && config.target_cpu >= TARGET_80386 && sz > 2 && 
    33103309                !e->Ecount) 
    33113310            {   regsize = 4; 
    33123311                flag |= CFopsize; 
    33133312            } 
    33143313            ce = loadea(e,&cs,0xFF,6,sz - regsize,RMload,0);    // PUSH EA+sz-2 
    33153314            code_orflag(ce,flag); 
    33163315            ce = genadjesp(ce,REGSIZE); 
    33173316            stackpush += sz; 
    33183317            while ((targ_int)(sz -= regsize) > 0) 
    33193318            {   ce = cat(ce,loadea(e,&cs,0xFF,6,sz - regsize,RMload,0)); 
    33203319                code_orflag(ce,flag); 
    33213320                ce = genadjesp(ce,REGSIZE); 
    33223321            } 
    33233322        } 
    33243323    L2: 
    33253324        freenode(e); 
    33263325        c = cat(c,ce); 
    33273326        goto ret; 
    33283327    case OPconst: 
    3329     {   targ_int *pi; 
    3330         targ_short *ps; 
     3328    { 
    33313329        char pushi = 0; 
    33323330        unsigned flag = 0; 
    3333         int i; 
    33343331        int regsize = REGSIZE; 
    33353332        targ_int value; 
    33363333 
    33373334        if (tycomplex(tym)) 
    33383335            break; 
    33393336 
    33403337        if (I32 && szb == 10)           // special case for long double constants 
    33413338        { 
    33423339            assert(sz == 12); 
    33433340            value = ((unsigned short *)&e->EV.Vldouble)[4]; 
    33443341            stackpush += sz; 
    33453342            ce = genadjesp(NULL,sz); 
    3346             for (i = 2; i >= 0; i--) 
     3343            for (int i = 2; i >= 0; i--) 
    33473344            { 
    33483345                if (reghasvalue(allregs, value, &reg)) 
    33493346                    ce = gen1(ce,0x50 + reg);           // PUSH reg 
    33503347                else 
    33513348                    ce = genc2(ce,0x68,0,value);        // PUSH value 
    33523349                value = ((unsigned *)&e->EV.Vldouble)[i - 1]; 
    33533350            } 
    33543351            goto L2; 
    33553352        } 
    33563353 
    3357         assert(sz <= LNGDBLSIZE); 
    3358         i = sz; 
    3359         if (I32 && i == 2) 
     3354        assert(I64 || sz <= LNGDBLSIZE); 
     3355        int i = sz; 
     3356        if (!I16 && i == 2) 
    33603357            flag = CFopsize; 
    33613358 
    33623359        if (config.target_cpu >= TARGET_80286) 
    33633360//       && (e->Ecount == 0 || e->Ecount != e->Ecomsub)) 
    33643361        {   pushi = 1; 
    33653362            if (I16 && config.target_cpu >= TARGET_80386 && i >= 4) 
    33663363            {   regsize = 4; 
    33673364                flag = CFopsize; 
    33683365            } 
    33693366        } 
    33703367        else if (i == REGSIZE) 
    33713368            break; 
    33723369 
    33733370        stackpush += sz; 
    33743371        ce = genadjesp(NULL,sz); 
    3375         pi = (targ_long *) &e->EV.Vdouble; 
    3376         ps = (targ_short *) pi; 
     3372        targ_uns *pi = (targ_uns *) &e->EV.Vdouble; 
     3373        targ_ushort *ps = (targ_ushort *) pi; 
     3374        targ_ullong *pl = (targ_ullong *)pi; 
    33773375        i /= regsize; 
    33783376        do 
    33793377        {   code *cp; 
    33803378 
    33813379            if (i)                      /* be careful not to go negative */ 
    33823380                i--; 
    3383             value = (regsize == 4) ? pi[i] : ps[i]; 
     3381            targ_size_t value = (regsize == 4) ? pi[i] : ps[i]; 
     3382            if (regsize == 8) 
     3383                value = pl[i]; 
    33843384            if (pushi) 
    33853385            { 
    33863386                if (regsize == REGSIZE && reghasvalue(allregs,value,&reg)) 
    33873387                    goto Preg; 
    33883388                ce = genc2(ce,(szb == 1) ? 0x6A : 0x68,0,value); // PUSH value 
    33893389            } 
    33903390            else 
    33913391            { 
    33923392                ce = regwithvalue(ce,allregs,value,&reg,0); 
    33933393            Preg: 
    33943394                ce = genpush(ce,reg);         // PUSH reg 
    33953395            } 
    33963396            code_orflag(ce,flag);                       /* operand size */ 
    33973397        } while (i); 
    33983398        goto L2; 
    33993399    } 
    34003400    default: 
    34013401        break; 
    34023402  } 
    34033403  retregs = tybyte(tym) ? BYTEREGS : allregs; 
     
    34493449                    c2 = genc1(CNIL,op,(modregrm(0,4,SP) << 8) | modregxrm(2,r,4),FLconst,sz/2); 
    34503450                    pop87(); 
    34513451                } 
    34523452                pop87(); 
    34533453                c2 = gen2sib(c2,op,modregrm(0,r,4),modregrm(0,4,SP));   // FSTP [ESP] 
    34543454            } 
    34553455            else 
    34563456            { 
    34573457                retregs = IDXREGS;                      /* get an index reg */ 
    34583458                c1 = allocreg(&retregs,&reg,TYoffset); 
    34593459                c1 = genregs(c1,0x89,SP,reg);           /* MOV reg,SP    */ 
    34603460                pop87(); 
    34613461                c2 = gen2(CNIL,op,modregrm(0,r,regtorm[reg]));          // FSTP [reg] 
    34623462            } 
    34633463            if (LARGEDATA) 
    34643464                c2->Iflags |= CFss;     /* want to store into stack     */ 
    34653465            genfwait(c2);               // FWAIT 
    34663466            c = cat3(c,c1,c2); 
    34673467            goto ret; 
    34683468        } 
    3469         else if (!I32 && (tym == TYdouble || tym == TYdouble_alias)) 
     3469        else if (I16 && (tym == TYdouble || tym == TYdouble_alias)) 
    34703470            retregs = mSTACK; 
    34713471  } 
    34723472#if LONGLONG 
    3473   else if (!I32 && sz == 8)             // if long long 
     3473  else if (I16 && sz == 8)             // if long long 
    34743474        retregs = mSTACK; 
    34753475#endif 
    34763476  c = cat(c,scodelem(e,&retregs,0,TRUE)); 
    34773477  if (retregs != mSTACK)                /* if stackpush not already inc'd */ 
    34783478      stackpush += sz; 
    34793479  if (sz <= REGSIZE) 
    34803480  { 
    34813481        c = genpush(c,findreg(retregs));        // PUSH reg 
    34823482        genadjesp(c,REGSIZE); 
    34833483  } 
    34843484  else if (sz == REGSIZE * 2) 
    34853485  {     c = genpush(c,findregmsw(retregs));     // PUSH msreg 
    34863486        genpush(c,findreglsw(retregs));         // PUSH lsreg 
    34873487        genadjesp(c,sz); 
    34883488  } 
    34893489ret: 
    34903490  return cat(cp,c); 
    34913491} 
    34923492 
    34933493 
     
    36933693            } 
    36943694            ce = movregconst(ce,reg,msw,mswflags); 
    36953695        } 
    36963696        else if (sz == 8) 
    36973697        { 
    36983698            if (I32) 
    36993699            {   targ_long *p = (targ_long *) &e->EV.Vdouble; 
    37003700                ce = movregconst(CNIL,findreglsw(forregs),p[0],0); 
    37013701                ce = movregconst(ce,findregmsw(forregs),p[1],0); 
    37023702            } 
    37033703            else 
    37043704            {   targ_short *p = (targ_short *) &e->EV.Vdouble; 
    37053705 
    37063706                assert(reg == AX); 
    37073707                ce = movregconst(CNIL,AX,p[3],0);       /* MOV AX,p[3]  */ 
    37083708                ce = movregconst(ce,DX,p[0],0); 
    37093709                ce = movregconst(ce,CX,p[1],0); 
    37103710                ce = movregconst(ce,BX,p[2],0); 
    37113711            } 
    37123712        } 
     3713        else if (I64 && sz == 16) 
     3714        { 
     3715            ce = movregconst(CNIL,findreglsw(forregs),e->EV.Vcent.lsw,0); 
     3716            ce = movregconst(ce,findregmsw(forregs),e->EV.Vcent.msw,0); 
     3717        } 
    37133718        else 
    37143719                assert(0); 
    37153720        c = cat(c,ce); 
    37163721  } 
    37173722  else 
    37183723  { 
    37193724    // See if we can use register that parameter was passed in 
    37203725    if (regcon.params && e->EV.sp.Vsym->Sclass == SCfastpar && 
    37213726        regcon.params & mask[e->EV.sp.Vsym->Spreg] && 
    37223727        !(e->Eoper == OPvar && e->EV.sp.Voffset > 0) && // Must be at the base of that variable 
    37233728        sz <= REGSIZE)                  // make sure no 'paint' to a larger size happened 
    37243729    { 
    37253730        reg = e->EV.sp.Vsym->Spreg; 
    37263731        forregs = mask[reg]; 
    37273732        mfuncreg &= ~forregs; 
    37283733        regcon.used |= forregs; 
    37293734        return fixresult(e,forregs,pretregs); 
    37303735    } 
    37313736 
    37323737    c = allocreg(&forregs,&reg,tym);            /* allocate registers   */ 
  • branches/dmd-1.x/src/backend/cod4.c

    r596 r618  
    24612461  {     assert(i < arraysize(clib)); 
    24622462        if (clib[i][0] == e->Eoper) 
    24632463        {   c2 = callclib(e,clib[i][1],pretregs,0); 
    24642464            break; 
    24652465        } 
    24662466  } 
    24672467  return cat(c1,c2); 
    24682468} 
    24692469 
    24702470 
    24712471/*************************** 
    24722472 * Convert short to long. 
    24732473 * For OPs16_32, OPu16_32, OPptrlptr, OPu32_64, OPs32_64 
    24742474 */ 
    24752475 
    24762476code *cdshtlng(elem *e,regm_t *pretregs) 
    24772477{ code *c,*ce,*c1,*c2,*c3,*c4; 
    24782478  unsigned reg; 
    24792479  unsigned char op; 
    24802480  regm_t retregs; 
    2481   int e1comsub; 
    2482  
    2483   e1comsub = e->E1->Ecount; 
     2481 
     2482  //printf("cdshtlng(e = %p, *pretregs = %s)\n", e, regm_str(*pretregs)); 
     2483  int e1comsub = e->E1->Ecount; 
    24842484  if ((*pretregs & (ALLREGS | mBP)) == 0)       // if don't need result in regs 
    24852485    c = codelem(e->E1,pretregs,FALSE);  /* then conversion isn't necessary */ 
    24862486 
    24872487  else if ((op = e->Eoper) == OPptrlptr || 
    24882488           (I16 && op == OPu16_32) || 
    24892489           (I32 && op == OPu32_64) 
    24902490          ) 
    24912491  { 
    24922492        regm_t regm; 
    24932493        tym_t tym1; 
    24942494 
    24952495        retregs = *pretregs & mLSW; 
    24962496        assert(retregs); 
    24972497        tym1 = tybasic(e->E1->Ety); 
    24982498        c = codelem(e->E1,&retregs,FALSE); 
    24992499 
    25002500        regm = *pretregs & (mMSW & ALLREGS); 
    25012501        if (regm == 0)                  /* *pretregs could be mES       */ 
    25022502            regm = mMSW & ALLREGS; 
    25032503        ce = allocreg(&regm,&reg,TYint); 
    25042504        if (e1comsub) 
    25052505            ce = cat(ce,getregs(retregs)); 
    25062506        if (op == OPptrlptr) 
    25072507        {   int segreg; 
    25082508 
    25092509            /* BUG: what about pointers to functions?   */ 
    25102510            switch (tym1) 
    25112511            { 
    25122512                case TYnptr:    segreg = SEG_DS;        break; 
    25132513                case TYcptr:    segreg = SEG_CS;        break; 
    25142514                case TYsptr:    segreg = SEG_SS;        break; 
    25152515                default:        assert(0); 
    25162516            } 
    25172517            ce = gen2(ce,0x8C,modregrm(3,segreg,reg));  /* MOV reg,segreg */ 
    25182518        } 
    25192519        else 
    25202520            ce = movregconst(ce,reg,0,0);               /* 0 extend     */ 
    25212521 
    25222522        c = cat3(c,ce,fixresult(e,retregs | regm,pretregs)); 
    25232523  } 
    2524   else if (!I16 && (op == OPs16_32 || op == OPu16_32)) 
     2524  else if (I64 && op == OPu32_64) 
     2525  { 
     2526        elem *e1 = e->E1; 
     2527        retregs = *pretregs; 
     2528        if (e1->Eoper == OPvar || (e1->Eoper == OPind && !e1->Ecount)) 
     2529        {   code cs; 
     2530 
     2531            c1 = allocreg(&retregs,&reg,TYint); 
     2532            c2 = NULL; 
     2533            c3 = loadea(e1,&cs,0x8B,reg,0,retregs,retregs);        //  MOV Ereg,EA 
     2534            freenode(e1); 
     2535        } 
     2536        else 
     2537        { 
     2538            *pretregs &= ~mPSW;                 // flags are set by eval of e1 
     2539            c1 = codelem(e1,&retregs,FALSE); 
     2540            c2 = getregs(retregs); 
     2541            reg = findreg(retregs); 
     2542            c3 = genregs(NULL,0x89,reg,reg);    // MOV Ereg,Ereg 
     2543        } 
     2544        c4 = fixresult(e,retregs,pretregs); 
     2545        c = cat4(c1,c2,c3,c4); 
     2546  } 
     2547  else if (!I16 && (op == OPs16_32 || op == OPu16_32) || 
     2548            I64 && op == OPs32_64) 
    25252549  { 
    25262550    elem *e11; 
    25272551 
    25282552    elem *e1 = e->E1; 
    25292553 
    25302554    if (e1->Eoper == OPu8_16 && !e1->Ecount && 
    25312555        ((e11 = e1->E1)->Eoper == OPvar || (e11->Eoper == OPind && !e11->Ecount)) 
    25322556       ) 
    25332557    {   code cs; 
    25342558 
    25352559        retregs = *pretregs & BYTEREGS; 
    25362560        if (!retregs) 
    25372561            retregs = BYTEREGS; 
    25382562        c1 = allocreg(&retregs,&reg,TYint); 
    25392563        c2 = movregconst(NULL,reg,0,0);                         //  XOR reg,reg 
    25402564        c3 = loadea(e11,&cs,0x8A,reg,0,retregs,retregs);        //  MOV regL,EA 
    25412565        freenode(e11); 
    25422566        freenode(e1); 
    25432567    } 
    2544     else if (e1->Eoper == OPvar || 
     2568    else if (e1->Eoper == OPvar && op != OPs32_64 || 
    25452569        (e1->Eoper == OPind && !e1->Ecount)) 
    25462570    {   code cs; 
    25472571        unsigned opcode; 
    25482572 
    25492573        if (op == OPu16_32 && config.flags4 & CFG4speed) 
    25502574            goto L2; 
    25512575        retregs = *pretregs; 
    25522576        c1 = allocreg(&retregs,&reg,TYint); 
    25532577        opcode = (op == OPu16_32) ? 0x0FB7 : 0x0FBF; /* MOVZX/MOVSX reg,EA */ 
    25542578        c2 = loadea(e1,&cs,opcode,reg,0,0,retregs); 
    25552579        c3 = CNIL; 
    25562580        freenode(e1); 
    25572581    } 
    25582582    else 
    25592583    { 
    25602584    L2: 
    25612585        retregs = *pretregs; 
    25622586        *pretregs &= ~mPSW;             /* flags are already set        */ 
     2587        if (op == OPs32_64) 
     2588            retregs = mAX; 
    25632589        c1 = codelem(e1,&retregs,FALSE); 
    25642590        c2 = getregs(retregs); 
    25652591        if (op == OPu16_32 && c1) 
    2566         {   code *cx; 
    2567  
    2568             cx = code_last(c1); 
     2592        { 
     2593            code *cx = code_last(c1); 
    25692594            if (cx->Iop == 0x81 && (cx->Irm & modregrm(3,7,0)) == modregrm(3,4,0)) 
    25702595            { 
    25712596                // Convert AND of a word to AND of a dword, zeroing upper word 
    25722597                retregs = mask[cx->Irm & 7]; 
    25732598                cx->Iflags &= ~CFopsize; 
    25742599                cx->IEV2.Vint &= 0xFFFF; 
    25752600                goto L1; 
    25762601            } 
    25772602        } 
    25782603        if (op == OPs16_32 && retregs == mAX) 
    25792604            c2 = gen1(c2,0x98);         /* CWDE                         */ 
     2605        else if (op == OPs32_64 && retregs == mAX) 
     2606        {   c2 = gen1(c2,0x98);         /* CDQE                         */ 
     2607            code_orrex(c2, REX_W); 
     2608        } 
    25802609        else 
    25812610        { 
    25822611            reg = findreg(retregs); 
    25832612            if (config.flags4 & CFG4speed && op == OPu16_32) 
    25842613            {   // AND reg,0xFFFF 
    25852614                c3 = genc2(NULL,0x81,modregrm(3,4,reg),0xFFFFu); 
    25862615            } 
    25872616            else 
    25882617            { 
    25892618                unsigned iop = (op == OPu16_32) ? 0x0FB7 : 0x0FBF; /* MOVZX/MOVSX reg,reg */ 
    25902619                c3 = genregs(CNIL,iop,reg,reg); 
    25912620            } 
    25922621            c2 = cat(c2,c3); 
    25932622        } 
    25942623     L1: 
    25952624        c3 = e1comsub ? getregs(retregs) : CNIL; 
    25962625    } 
    25972626    c4 = fixresult(e,retregs,pretregs); 
    25982627    c = cat4(c1,c2,c3,c4); 
    25992628  } 
     
    28062835 
    28072836  /* We "destroy" a reg by assigning it the result of a new e, even     */ 
    28082837  /* though the values are the same. Weakness of our CSE strategy that  */ 
    28092838  /* a register can only hold the contents of one elem at a time.       */ 
    28102839  if (e->Ecount) 
    28112840        c = cat(c,getregs(retregs)); 
    28122841  else 
    28132842        useregs(retregs); 
    28142843 
    28152844#ifdef DEBUG 
    28162845  if (!(!*pretregs || retregs)) 
    28172846        WROP(e->Eoper), 
    28182847        printf(" *pretregs = x%x, retregs = x%x, e = %p\n",*pretregs,retregs,e); 
    28192848#endif 
    28202849  assert(!*pretregs || retregs); 
    28212850  return cat(c,fixresult(e,retregs,pretregs));  /* lsw only             */ 
    28222851} 
    28232852 
    28242853/********************************************** 
    28252854 * Get top 32 bits of 64 bit value (I32) 
    2826  * or top 16 bits of 32 bit value (16 bit code). 
     2855 * or top 16 bits of 32 bit value (I16) 
     2856 * or top 64 bits of 128 bit value (I64). 
    28272857 * OPmsw 
    28282858 */ 
    28292859 
    28302860code *cdmsw(elem *e,regm_t *pretregs) 
    28312861{   regm_t retregs; 
    28322862    code *c; 
    28332863 
    28342864    //printf("cdmsw(e->Ecount = %d)\n", e->Ecount); 
    28352865    assert(e->Eoper == OPmsw); 
    28362866 
    28372867    retregs = *pretregs ? ALLREGS : 0; 
    28382868    c = codelem(e->E1,&retregs,FALSE); 
    2839     retregs &= mMSW;                    // want LSW only 
     2869    retregs &= mMSW;                    // want MSW only 
    28402870 
    28412871    // We "destroy" a reg by assigning it the result of a new e, even 
    28422872    // though the values are the same. Weakness of our CSE strategy that 
    28432873    // a register can only hold the contents of one elem at a time. 
    28442874    if (e->Ecount) 
    28452875        c = cat(c,getregs(retregs)); 
    28462876    else 
    28472877        useregs(retregs); 
    28482878 
    28492879#ifdef DEBUG 
    28502880    if (!(!*pretregs || retregs)) 
    28512881    {   WROP(e->Eoper); 
    28522882        printf(" *pretregs = x%x, retregs = x%x\n",*pretregs,retregs); 
    28532883    } 
    28542884#endif 
    28552885    assert(!*pretregs || retregs); 
    28562886    return cat(c,fixresult(e,retregs,pretregs));        // msw only 
    28572887} 
    28582888 
    28592889 
  • branches/dmd-1.x/src/backend/code.h

    r596 r618  
    8181 
    8282#define mR8     (1 << R8) 
    8383#define mR9     (1 << R9) 
    8484#define mR10    (1 << R10) 
    8585#define mR11    (1 << R11) 
    8686#define mR12    (1 << R12) 
    8787#define mR13    (1 << R13) 
    8888#define mR14    (1 << R14) 
    8989#define mR15    (1 << R15) 
    9090 
    9191#define mXMM0   (1 << XMM0) 
    9292#define mXMM1   (1 << XMM1) 
    9393#define mXMM2   (1 << XMM2) 
    9494#define mXMM3   (1 << XMM3) 
    9595#define mXMM4   (1 << XMM4) 
    9696#define mXMM5   (1 << XMM5) 
    9797#define mXMM6   (1 << XMM6) 
    9898#define mXMM7   (1 << XMM7) 
    9999#define XMMREGS  (mXMM0 |mXMM1 |mXMM2 |mXMM3 |mXMM4 |mXMM5 |mXMM6 |mXMM7) 
    100100 
    101 #define mES     (1 << ES)       // 0x10000 
    102 #define mPSW    (1 << PSW)      // 0x20000 
    103  
    104 #define mSTACK  (1 << STACK)    // 0x40000 
    105  
    106 #define mST0    (1 << ST0)      // 0x200000 
    107 #define mST01   (1 << ST01)     // 0x400000 
     101#define mES     (1 << ES)       // 0x1000000 
     102#define mPSW    (1 << PSW)      // 0x2000000 
     103 
     104#define mSTACK  (1 << STACK)    // 0x4000000 
     105 
     106#define mST0    (1 << ST0)      // 0x20000000 
     107#define mST01   (1 << ST01)     // 0x40000000 
    108108 
    109109// Flags for getlvalue (must fit in regm_t) 
    110110#define RMload  (1 << 30) 
    111111#define RMstore (1 << 31) 
    112112 
    113113#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS 
    114114    // To support positional independent code, 
    115115    // must be able to remove BX from available registers 
    116116extern regm_t ALLREGS; 
    117117#define ALLREGS_INIT            (mAX|mBX|mCX|mDX|mSI|mDI) 
    118118#define ALLREGS_INIT_PIC        (mAX|mCX|mDX|mSI|mDI) 
    119119extern regm_t BYTEREGS; 
    120120#define BYTEREGS_INIT           (mAX|mBX|mCX|mDX) 
    121121#define BYTEREGS_INIT_PIC       (mAX|mCX|mDX) 
    122122#else 
    123123#define ALLREGS                 (mAX|mBX|mCX|mDX|mSI|mDI) 
    124124#define ALLREGS_INIT            ALLREGS 
    125125#undef BYTEREGS 
    126126#define BYTEREGS                (mAX|mBX|mCX|mDX) 
    127127#endif 
     
    379379#define CFpsw          0x40     // we need the flags result after this instruction 
    380380#define CFopsize       0x80     // prefix with operand size 
    381381#define CFaddrsize    0x100     // prefix with address size 
    382382#define CFds          0x200     // need DS override (not with es, ss, or cs ) 
    383383#define CFcs          0x400     // need CS override 
    384384#define CFfs          0x800     // need FS override 
    385385#define CFgs    (CFcs | CFfs)   // need GS override 
    386386#define CFwait       0x1000     // If I32 it indicates when to output a WAIT 
    387387#define CFselfrel    0x2000     // if self-relative 
    388388#define CFunambig    0x4000     // indicates cannot be accessed by other addressing 
    389389                                // modes 
    390390#define CFtarg2      0x8000     // like CFtarg, but we can't optimize this away 
    391391#define CFvolatile  0x10000     // volatile reference, do not schedule 
    392392#define CFclassinit 0x20000     // class init code 
    393393#define CFoffset64  0x40000     // offset is 64 bits 
    394394#define CFpc32      0x80000     // I64: PC relative 32 bit fixup 
    395395 
    396396#define CFPREFIX (CFSEG | CFopsize | CFaddrsize) 
    397397#define CFSEG   (CFes | CFss | CFds | CFcs | CFfs | CFgs) 
    398398 
    399  
     399    /* The op code can be 1 to 3 bytes 
     400     */ 
    400401    unsigned Iop; 
    401402 
     403    /* The _EA is the "effective address" for the instruction, and consists of the modregrm byte, 
     404     * the sib byte, and the REX prefix byte. The 16 bit code generator just used the modregrm, 
     405     * the 32 bit x86 added the sib, and the 64 bit one added the rex. 
     406     */ 
    402407    union 
    403408    {   unsigned _Iea; 
    404409        struct 
    405410        { 
    406411            unsigned char _Irm;          // reg/mode 
    407412            unsigned char _Isib;         // SIB byte 
    408413            unsigned char _Irex;         // REX prefix 
    409414        } _ea; 
    410415    } _EA; 
    411416 
    412417#define Iea _EA._Iea 
    413418#define Irm _EA._ea._Irm 
    414419#define Isib _EA._ea._Isib 
    415420#define Irex _EA._ea._Irex 
     421 
     422 
     423    /* IFL1 and IEV1 are the first operand, which usually winds up being the offset to the Effective 
     424     * Address. IFL1 is the tag saying which variant type is in IEV1. IFL2 and IEV2 is the second 
     425     * operand, usually for immediate instructions. 
     426     */ 
    416427 
    417428    unsigned char IFL1,IFL2;    // FLavors of 1st, 2nd operands 
    418429    union evc IEV1;             // 1st operand, if any 
    419430      #define IEVpointer1 IEV1._EP.Vpointer 
    420431      #define IEVseg1     IEV1._EP.Vseg 
    421432      #define IEVsym1     IEV1.sp.Vsym 
    422433      #define IEVdsym1    IEV1.dsp.Vsym 
    423434      #define IEVoffset1  IEV1.sp.Voffset 
    424435      #define IEVlsym1    IEV1.lab.Vsym 
    425436      #define IEVint1     IEV1.Vint 
    426437    union evc IEV2;             // 2nd operand, if any 
    427438      #define IEVpointer2 IEV2._EP.Vpointer 
    428439      #define IEVseg2     IEV2._EP.Vseg 
    429440      #define IEVsym2     IEV2.sp.Vsym 
    430441      #define IEVdsym2    IEV2.dsp.Vsym 
    431442      #define IEVoffset2  IEV2.sp.Voffset 
    432443      #define IEVlsym2    IEV2.lab.Vsym 
    433444      #define IEVint2     IEV2.Vint 
    434445    void print();               // pretty-printer 
    435446 
  • branches/dmd-1.x/src/backend/debug.c

    r487 r618  
    9090        dbg_printf("mTYcs|"); 
    9191#endif 
    9292    if (t & mTYconst) 
    9393        dbg_printf("mTYconst|"); 
    9494    if (t & mTYvolatile) 
    9595        dbg_printf("mTYvolatile|"); 
    9696#if TARGET_MAC 
    9797    if (t & mTYpasret) 
    9898        dbg_printf("mTYpasret|"); 
    9999    if (t & mTYmachdl) 
    100100        dbg_printf("mTYmachdl|"); 
    101101    if (t & mTYpasobj) 
    102102        dbg_printf("mTYpasobj|"); 
    103103#endif 
    104104#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 
    105105    if (t & mTYtransu) 
    106106        dbg_printf("mTYtransu|"); 
    107107#endif 
    108108    t = tybasic(t); 
    109109    if (t >= TYMAX) 
    110     {   dbg_printf("TY %lx\n",t); 
     110    {   dbg_printf("TY %lx\n",(long)t); 
    111111        assert(0); 
    112112    } 
    113113    dbg_printf("TY%s ",tystring[tybasic(t)]); 
    114114} 
    115115 
    116116void WRBC(unsigned bc) 
    117117{ static char bcs[][7] = 
    118118        {"unde  ","goto  ","true  ","ret   ","retexp", 
    119119         "exit  ","asm   ","switch","ifthen","jmptab", 
    120120         "try   ","catch ","jump  ", 
    121121         "_try  ","_filte","_final","_ret  ","_excep", 
    122122         "jcatch", 
    123123         "jplace", 
    124124        }; 
    125125 
    126126    assert(sizeof(bcs) / sizeof(bcs[0]) == BCMAX); 
    127127    assert(bc < BCMAX); 
    128128    dbg_printf("BC%s",bcs[bc]); 
    129129} 
    130130 
     
    170170  } 
    171171  else if (e->Eoper == OPcomma && !nest) 
    172172  {     WReqn(e->E1); 
    173173        dbg_printf(";\n\t"); 
    174174        WReqn(e->E2); 
    175175  } 
    176176  else if (OTbinary(e->Eoper)) 
    177177  { 
    178178        if (OTbinary(e->E1->Eoper)) 
    179179        {       nest++; 
    180180                ferr("("); 
    181181                WReqn(e->E1); 
    182182                ferr(")"); 
    183183                nest--; 
    184184        } 
    185185        else 
    186186                WReqn(e->E1); 
    187187        ferr(" "); 
    188188        WROP(e->Eoper); 
    189189        if (e->Eoper == OPstreq) 
    190             dbg_printf("%ld",e->Enumbytes); 
     190            dbg_printf("%ld",(long)e->Enumbytes); 
    191191        ferr(" "); 
    192192        if (OTbinary(e->E2->Eoper)) 
    193193        {       nest++; 
    194194                ferr("("); 
    195195                WReqn(e->E2); 
    196196                ferr(")"); 
    197197                nest--; 
    198198        } 
    199199        else 
    200200                WReqn(e->E2); 
    201201  } 
    202202  else 
    203203  { 
    204204        switch (e->Eoper) 
    205205        {   case OPconst: 
    206206                switch (tybasic(e->Ety)) 
    207207                { 
    208208                    case TYfloat: 
    209209                        dbg_printf("%g <float> ",e->EV.Vfloat); 
    210210                        break; 
    211211                    case TYdouble: 
    212212                        dbg_printf("%g ",e->EV.Vdouble); 
    213213                        break; 
    214214                    default: 
    215215                        dbg_printf("%lld ",el_tolong(e)); 
    216216                        break; 
    217217                } 
    218218                break; 
    219219            case OPrelconst: 
    220220                ferr("#"); 
    221221                /* FALL-THROUGH */ 
    222222            case OPvar: 
    223223                dbg_printf("%s",e->EV.sp.Vsym->Sident); 
    224224                if (e->EV.sp.Vsym->Ssymnum != -1) 
    225225                    dbg_printf("(%d)",e->EV.sp.Vsym->Ssymnum); 
    226226                if (e->Eoffset != 0) 
    227                         dbg_printf(".%ld",e->Eoffset); 
     227                        dbg_printf(".%ld",(long)e->Eoffset); 
    228228                break; 
    229229            case OPasm: 
    230230#if TARGET_MAC 
    231231                if (e->Eflags & EFsmasm) 
    232232                    { 
    233233                    if (e->EV.mac.Vasmdat[1]) 
    234234                        dbg_printf("\"%c%c\"",e->EV.mac.Vasmdat[0],e->EV.mac.Vasmdat[1]); 
    235235                    else 
    236236                        dbg_printf("\"%c\"",e->EV.mac.Vasmdat[0]); 
    237237                    break; 
    238238                    }; 
    239239#endif 
    240240            case OPstring: 
    241241                dbg_printf("\"%s\"",e->EV.ss.Vstring); 
    242242                if (e->EV.ss.Voffset) 
    243                     dbg_printf("+%ld",e->EV.ss.Voffset); 
     243                    dbg_printf("+%ld",(long)e->EV.ss.Voffset); 
    244244                break; 
    245245            case OPmark: 
    246246            case OPgot: 
    247247            case OPframeptr: 
    248248                WROP(e->Eoper); 
    249249                break; 
    250250            case OPstrthis: 
    251251                break; 
    252252            default: 
    253253                WROP(e->Eoper); 
    254254                assert(0); 
    255255        } 
    256256  } 
    257257} 
    258258 
    259259void WRblocklist(list_t bl) 
    260260{ 
    261261        for (; bl; bl = list_next(bl)) 
    262262        {       register block *b = list_block(bl); 
    263263 
  • branches/dmd-1.x/src/backend/dt.c

    r569 r618  
    185185    *pdtend = dt; 
    186186    pdtend = &dt->DTnext; 
    187187    return pdtend; 
    188188} 
    189189 
    190190/********************** 
    191191 * Construct a DTibytes record, and return it. 
    192192 */ 
    193193 
    194194dt_t ** dtdword(dt_t **pdtend, int value) 
    195195{   dt_t *dt; 
    196196 
    197197    while (*pdtend) 
    198198        pdtend = &((*pdtend)->DTnext); 
    199199    dt = dt_calloc(DT_ibytes); 
    200200    dt->DTn = 4; 
    201201 
    202202    union { char* cp; int* lp; } u; 
    203203    u.cp = dt->DTdata; 
    204204    *u.lp = value; 
     205 
     206    *pdtend = dt; 
     207    pdtend = &dt->DTnext; 
     208    return pdtend; 
     209} 
     210 
     211dt_t ** dtsize_t(dt_t **pdtend, targ_size_t value) 
     212{   dt_t *dt; 
     213 
     214    while (*pdtend) 
     215        pdtend = &((*pdtend)->DTnext); 
     216    dt = dt_calloc(DT_ibytes); 
     217    dt->DTn = NPTRSIZE; 
     218 
     219    union { char* cp; int* lp; } u; 
     220    u.cp = dt->DTdata; 
     221    *u.lp = value; 
     222    if (NPTRSIZE == 8) 
     223        u.lp[1] = value >> 32; 
    205224 
    206225    *pdtend = dt; 
    207226    pdtend = &dt->DTnext; 
    208227    return pdtend; 
    209228} 
    210229 
    211230/********************** 
    212231 * Concatenate two dt_t's. 
    213232 */ 
    214233 
    215234dt_t ** dtcat(dt_t **pdtend,dt_t *dt) 
    216235{ 
    217236    while (*pdtend) 
    218237        pdtend = &((*pdtend)->DTnext); 
    219238    *pdtend = dt; 
    220239    pdtend = &dt->DTnext; 
    221240    return pdtend; 
    222241} 
    223242 
    224243/********************** 
  • branches/dmd-1.x/src/backend/dt.h

    r569 r618  
    3030 *                      the size 
    3131 *      DTcommon        # of 0 bytes (in a common block) 
    3232 *                      a 
    3333 *      DTxoff          offset from symbol 
    3434 *                      w a 
    3535 *                      w = symbol number (pointer for CPP) 
    3636 *                      a = offset 
    3737 *      DTcoff          offset into code segment 
    3838 *      DTend           mark end of list 
    3939 */ 
    4040 
    4141struct dt_t 
    4242{   dt_t *DTnext;                       // next in list 
    4343    char dt;                            // type (DTxxxx) 
    4444    unsigned char Dty;                  // pointer type 
    4545    union 
    4646    { 
    4747        struct                          // DTibytes 
    4848        {   char DTn_;                  // number of bytes 
    4949            #define DTn _DU._DI.DTn_ 
    50             char DTdata_[7];            // data 
     50            char DTdata_[8];            // data 
    5151            #define DTdata _DU._DI.DTdata_ 
    5252        }_DI; 
    5353        char DTonebyte_;                // DT1byte 
    5454        #define DTonebyte _DU.DTonebyte_ 
    5555        targ_size_t DTazeros_;          // DTazeros,DTcommon,DTsymsize 
    5656        #define DTazeros _DU.DTazeros_ 
    5757        struct                          // DTabytes 
    5858        { 
    5959            char *DTpbytes_;            // pointer to the bytes 
    6060            #define DTpbytes _DU._DN.DTpbytes_ 
    6161            unsigned DTnbytes_;         // # of bytes 
    6262            #define DTnbytes _DU._DN.DTnbytes_ 
    6363#if TX86 
    6464            int DTseg_;                 // segment it went into 
    6565            #define DTseg _DU._DN.DTseg_ 
    6666#endif 
    6767            targ_size_t DTabytes_;              // offset of abytes for DTabytes 
    6868            #define DTabytes _DU._DN.DTabytes_ 
    6969        }_DN; 
    7070        struct                          // DTxoff 
     
    8585    DT_1byte, 
    8686    DT_nbytes, 
    8787    DT_common, 
    8888    DT_symsize, 
    8989    DT_coff, 
    9090    DT_ibytes, // 8 
    9191}; 
    9292 
    9393#if TX86 
    9494dt_t *dt_calloc(char dtx); 
    9595void dt_free(dt_t *); 
    9696void dt_term(void); 
    9797#elif TARGET_MAC 
    9898dt_t *dt_calloc(void); 
    9999void dt_free(dt_t *); 
    100100#endif 
    101101 
    102102dt_t **dtnbytes(dt_t **,targ_size_t,const char *); 
    103103dt_t **dtabytes(dt_t **pdtend,tym_t ty, targ_size_t offset, targ_size_t size, const char *ptr); 
    104104dt_t **dtdword(dt_t **, int value); 
     105dt_t **dtsize_t(dt_t **, targ_size_t value); 
    105106dt_t **dtnzeros(dt_t **pdtend,targ_size_t size); 
    106107dt_t **dtxoff(dt_t **pdtend,symbol *s,targ_size_t offset,tym_t ty); 
    107108dt_t **dtselfoff(dt_t **pdtend,targ_size_t offset,tym_t ty); 
    108109dt_t **dtcoff(dt_t **pdtend,targ_size_t offset); 
    109110dt_t ** dtcat(dt_t **pdtend,dt_t *dt); 
    110111void dt_optimize(dt_t *dt); 
    111112void dtsymsize(symbol *); 
    112113void init_common(symbol *); 
    113114unsigned dt_size(dt_t *dtstart); 
    114115 
    115116#endif /* DT_H */ 
    116117 
  • branches/dmd-1.x/src/backend/el.c

    r581 r618  
    29442944        case TYcldouble: 
    29452945        case TYcdouble: 
    29462946        case TYcfloat: 
    29472947#if !DDRT 
    29482948            result = (targ_llong)el_toldouble(e); 
    29492949#else 
    29502950            result = Xxtoi(el_toldouble(e)); 
    29512951#endif 
    29522952            break; 
    29532953 
    29542954#if SCPP 
    29552955        case TYmemptr: 
    29562956            ty = tybasic(tym_conv(e->ET)); 
    29572957            goto L1; 
    29582958#endif 
    29592959        default: 
    29602960#if SCPP 
    29612961            // Can happen as result of syntax errors 
    29622962            assert(errcnt); 
    29632963#else 
     2964#ifdef DEBUG 
     2965            elem_print(e); 
     2966            *(char*)0=0; 
     2967#endif 
    29642968            assert(0); 
    29652969#endif 
    29662970    } 
    29672971    return result; 
    29682972} 
    29692973 
    29702974/*********************************** 
    29712975 * Determine if constant e is all ones or all zeros. 
    29722976 * Input: 
    29732977 *      bit 0:  all zeros 
    29742978 *          1:  1 
    29752979 *         -1:  all ones 
    29762980 */ 
    29772981 
    29782982int el_allbits(elem *e,int bit) 
    29792983{   targ_llong value; 
    29802984 
    29812985    elem_debug(e); 
    29822986    assert(e->Eoper == OPconst); 
    29832987    value = e->EV.Vullong; 
     
    32723276                    case TYulong: 
    32733277                    case TYdchar: 
    32743278                    case TYfptr: 
    32753279#if TX86 
    32763280                    case TYvptr: 
    32773281                    case TYhptr: 
    32783282#endif 
    32793283                    L1: 
    32803284                        dbg_printf("%dL ",e->EV.Vlong); 
    32813285                        break; 
    32823286 
    32833287                    case TYllong: 
    32843288                    L2: 
    32853289                        dbg_printf("%lldLL ",e->EV.Vllong); 
    32863290                        break; 
    32873291 
    32883292                    case TYullong: 
    32893293                        dbg_printf("%lluLL ",e->EV.Vullong); 
    32903294                        break; 
    32913295 
     3296                    case TYcent: 
     3297                    case TYucent: 
     3298                        dbg_printf("%lluLL+%lluLL ", e->EV.Vcent.msw, e->EV.Vcent.lsw); 
     3299                        break; 
     3300 
    32923301                    case TYfloat: 
    32933302                        dbg_printf("%gf ",(double)e->EV.Vfloat); 
    32943303                        break; 
    32953304                    case TYdouble: 
    32963305                    case TYdouble_alias: 
    32973306                        dbg_printf("%g ",(double)e->EV.Vdouble); 
    32983307                        break; 
    32993308                    case TYldouble: 
    33003309#if TARGET_MAC 
    33013310#if (TARGET_POWERPC) 
    33023311                        if (config.flags & CFGldblisdbl) 
    33033312                            dbg_printf("%gL ",e->EV.Vdouble); 
    33043313                        else 
    33053314#endif 
    33063315#if !DDRT 
    33073316                            dbg_printf("%LgL ",e->EV.Vldouble); 
    33083317#else /* DDRT */ 
    33093318                        { 
    33103319                            static char buffer[75]; 
    33113320                            __g_fmt(buffer, (DD)e->EV.Vldouble); 
  • branches/dmd-1.x/src/backend/evalu8.c

    r569 r618  
    565565{   elem *e1,*e2; 
    566566    tym_t tym,tym2,uns; 
    567567    unsigned op; 
    568568#if TARGET_MAC 
    569569    targ_short i1,i2; 
    570570    targ_char c1,c2; 
    571571#else 
    572572    targ_int i1,i2; 
    573573#endif 
    574574    int i; 
    575575    targ_llong l1,l2; 
    576576    targ_ldouble d1,d2; 
    577577    elem esave; 
    578578 
    579579//    assert((_status87() & 0x3800) == 0); 
    580580    assert(e && EOP(e)); 
    581581    op = e->Eoper; 
    582582    elem_debug(e); 
    583583    e1 = e->E1; 
    584584 
    585     //printf("evalu8(): "); //elem_print(e); 
     585    //printf("evalu8(): "); elem_print(e); 
    586586    elem_debug(e1); 
    587587    if (e1->Eoper == OPconst) 
    588588    { 
    589589        tym2 = 0; 
    590590        e2 = NULL; 
    591591        if (EBIN(e)) 
    592592        {   e2 = e->E2; 
    593593            elem_debug(e2); 
    594594            if (e2->Eoper == OPconst) 
    595595            { 
    596596                T68000(c2 =) i2 = l2 = el_tolong(e2); 
    597597                d2 = el_toldouble(e2); 
    598598            } 
    599599            else 
    600600                return e; 
    601601            tym2 = tybasic(typemask(e2)); 
    602602        } 
    603603        T68000(c1 =) i1 = l1 = el_tolong(e1); 
    604604        d1 = el_toldouble(e1); 
    605605        tym = tybasic(typemask(e1));    /* type of op is type of left child */ 
     
    11831183                case TYcldouble: 
    11841184                    switch (tym2) 
    11851185                    { 
    11861186                        case TYldouble: 
    11871187                            e->EV.Vcldouble.re = e1->EV.Vcldouble.re * d2; 
    11881188                            e->EV.Vcldouble.im = e1->EV.Vcldouble.im * d2; 
    11891189                            break; 
    11901190                        case TYildouble: 
    11911191                            e->EV.Vcldouble.re = -e1->EV.Vcldouble.im * d2; 
    11921192                            e->EV.Vcldouble.im =  e1->EV.Vcldouble.re * d2; 
    11931193                            break; 
    11941194                        case TYcldouble: 
    11951195                            e->EV.Vcldouble = Complex_ld::mul(e1->EV.Vcldouble, e2->EV.Vcldouble); 
    11961196                            break; 
    11971197                        default: 
    11981198                            assert(0); 
    11991199                    } 
    12001200                    break; 
    12011201                default: 
    12021202#ifdef DEBUG 
    1203                     dbg_printf("tym = x%lx\n",tym); 
     1203                    dbg_printf("tym = x%x\n",tym); 
    12041204                    elem_print(e); 
    12051205#endif 
    12061206                    assert(0); 
    12071207            } 
    12081208        } 
    12091209        break; 
    12101210    case OPdiv: 
    12111211        if (!boolres(e2))                       // divide by 0 
    12121212        { 
    12131213#if SCPP 
    12141214            if (!tyfloating(tym)) 
    12151215#endif 
    12161216                goto div0; 
    12171217        } 
    12181218        if (uns) 
    12191219            e->EV.Vullong = ((targ_ullong) l1) / ((targ_ullong) l2); 
    12201220        else 
    12211221        {   switch (tym) 
    12221222            { 
    12231223                case TYfloat: 
     
    20302030#endif 
    20312031        e->EV.Vint = l1; 
    20322032        break; 
    20332033    case OP64_32: 
    20342034        e->EV.Vlong = l1; 
    20352035        break; 
    20362036    case OPlngllng: 
    20372037        e->EV.Vllong = (targ_long) l1; 
    20382038        break; 
    20392039    case OPulngllng: 
    20402040        e->EV.Vllong = (targ_ulong) l1; 
    20412041        break; 
    20422042    case OPmsw: 
    20432043        switch (tysize(tym)) 
    20442044        { 
    20452045            case 4: 
    20462046                e->EV.Vllong = (l1 >> 16) & 0xFFFF; 
    20472047                break; 
    20482048            case 8: 
    20492049                e->EV.Vllong = (l1 >> 32) & 0xFFFFFFFF; 
     2050                break; 
     2051            case 16: 
     2052                e->EV.Vllong = e1->EV.Vcent.msw; 
    20502053                break; 
    20512054            default: 
    20522055                assert(0); 
    20532056        } 
    20542057        break; 
    20552058    case OPb_8: 
    20562059        e->EV.Vlong = i1 & 1; 
    20572060        break; 
    20582061    case OPbswap: 
    20592062        e->EV.Vint = ((i1 >> 24) & 0x000000FF) | 
    20602063                     ((i1 >>  8) & 0x0000FF00) | 
    20612064                     ((i1 <<  8) & 0x00FF0000) | 
    20622065                     ((i1 << 24) & 0xFF000000); 
    20632066        break; 
    20642067    case OPind: 
    20652068#if 0 && MARS 
    20662069        /* The problem with this is that although the only reaching definition 
    20672070         * of the variable is null, it still may never get executed, as in: 
    20682071         *   int* p = null; if (p) *p = 3; 
    20692072         * and the error will be spurious. 
  • branches/dmd-1.x/src/backend/ptrntab.c

    r606 r618  
    11// Copyright (C) 1985-1998 by Symantec 
    2 // Copyright (C) 2000-2009 by Digital Mars 
     2// Copyright (C) 2000-2010 by Digital Mars 
    33// All Rights Reserved 
    44// http://www.digitalmars.com 
    55/* 
    66 * This source file is made available for personal use 
    77 * only. The license is in /dmd/src/dmd/backendlicense.txt 
    88 * or /dm/src/dmd/backendlicense.txt 
    99 * For any other uses, please contact Digital Mars. 
    1010 */ 
    1111 
    1212#if !DEMO && !SPP 
    1313 
    1414#include        <stdio.h> 
    1515#include        <stdlib.h> 
    1616#include        <string.h> 
    1717#include        <time.h> 
    1818 
    1919#include        "cc.h" 
    2020#include        "code.h" 
    2121#include        "iasm.h" 
    2222 
     
    3535PTRNTAB0 aptb0AAA[] = /* AAA */ { 
    3636        { 0x37, _modax }, 
    3737}; 
    3838 
    3939PTRNTAB0 aptb0AAD[] = /* AAD */ { 
    4040        { 0xd50a, _modax } 
    4141}; 
    4242 
    4343PTRNTAB0 aptb0AAM[] = /* AAM */ { 
    4444        { 0xd40a, _modax } 
    4545}; 
    4646PTRNTAB0 aptb0AAS[] = /* AAS */ { 
    4747        { 0x3f, _modax } 
    4848}; 
    4949PTRNTAB0 aptb0CBW[] = /* CBW */ { 
    5050        { 0x98, _16_bit | _modax } 
    5151}; 
    5252PTRNTAB0 aptb0CWDE[] = /* CWDE */ { 
    5353        { 0x98, _32_bit | _I386 | _modax } 
    5454}; 
     55PTRNTAB0 aptb0CDQE[] = /* CDQE */ { 
     56        { 0x98, _64_bit | _modax } 
     57}; 
    5558PTRNTAB0 aptb0CLC[] =  /* CLC */ { 
    5659        { 0xf8, 0 } 
    5760}; 
    5861 
    5962PTRNTAB0 aptb0CLD[] = /* CLD */ { 
    6063        { 0xfc, 0 } 
    6164}; 
    6265PTRNTAB0 aptb0CLI[] =  /* CLI */ { 
    6366        { 0xfa, 0 } 
    6467}; 
    6568 
    6669PTRNTAB0 aptb0CLTS[] =  /* CLTS */ { 
    6770        { 0x0f06, 0 } 
    6871}; 
    6972 
    7073PTRNTAB0 aptb0CMC[] =  /* CMC */ { 
    7174        { 0xf5, 0 } 
    7275}; 
    7376 
    7477PTRNTAB0 aptb0CMPSB[] =  /* CMPSB */ { 
    7578        { 0xa6, _modsidi } 
    7679}; 
    7780 
    7881PTRNTAB0 aptb0CMPSW[] =  /* CMPSW */ { 
    7982        { 0xa7, _16_bit | _modsidi } 
    8083}; 
    8184 
    8285#if 0 
    8386PTRNTAB0 aptb0CMPSD[] =  /* CMPSD */ { 
    8487        { 0xa7, _32_bit | _I386 | _modsidi } 
    8588}; 
    8689#endif 
    8790 
    8891PTRNTAB0 aptb0CWD[] =  /* CWD */ { 
    8992        { 0x99, _16_bit | _modaxdx } 
    9093}; 
    9194 
    9295PTRNTAB0 aptb0CDQ[] =  /* CDQ */ { 
    9396        { 0x99, _32_bit | _I386 | _modaxdx } 
     97}; 
     98 
     99PTRNTAB0 aptb0CQO[] =  /* CQO */ { 
     100        { 0x99, _64_bit | _modaxdx } 
    94101}; 
    95102 
    96103PTRNTAB0 aptb0DAA[] =  /* DAA */ { 
    97104        { 0x27, _modax } 
    98105}; 
    99106 
    100107PTRNTAB0 aptb0DAS[] =  /* DAS */ { 
    101108        { 0x2f, _modax } 
    102109}; 
    103110 
    104111PTRNTAB0 aptb0HLT[] =  /* HLT */ { 
    105112        { 0xf4, 0 } 
    106113}; 
    107114 
    108115PTRNTAB0 aptb0INSB[] =  /* INSB */ { 
    109116        { 0x6c,  _I386 | _modsi } 
    110117}; 
    111118 
    112119PTRNTAB0 aptb0INSW[] =  /* INSW */ { 
    113120        { 0x6d, _16_bit | _I386 | _modsi } 
     
    31413148        X("addss",      2,              (P) aptb2ADDSS ) \ 
    31423149        X("addsubpd",   2,              (P) aptb2ADDSUBPD ) \ 
    31433150        X("addsubps",   2,              (P) aptb2ADDSUBPS ) \ 
    31443151        X("and",        2,              (P) aptb2AND ) \ 
    31453152        X("andnpd",     2,              (P) aptb2ANDNPD ) \ 
    31463153        X("andnps",     2,              (P) aptb2ANDNPS ) \ 
    31473154        X("andpd",      2,              (P) aptb2ANDPD ) \ 
    31483155        X("andps",      2,              (P) aptb2ANDPS ) \ 
    31493156        X("arpl",       2,              (P) aptb2ARPL ) \ 
    31503157        X("bound",      2,              (P) aptb2BOUND ) \ 
    31513158        X("bsf",        2,              (P) aptb2BSF ) \ 
    31523159        X("bsr",        2,              (P) aptb2BSR ) \ 
    31533160        X("bswap",      1,              (P) aptb1BSWAP ) \ 
    31543161        X("bt",         2,              (P) aptb2BT ) \ 
    31553162        X("btc",        2,              (P) aptb2BTC ) \ 
    31563163        X("btr",        2,              (P) aptb2BTR ) \ 
    31573164        X("bts",        2,              (P) aptb2BTS ) \ 
    31583165        X("call",       ITjump | 1,     (P) aptb1CALL ) \ 
    31593166        X("cbw",        0,              aptb0CBW ) \ 
    31603167        X("cdq",        0,              aptb0CDQ ) \ 
     3168        X("cdqe",       0,              aptb0CDQE ) \ 
    31613169        X("clc",        0,              aptb0CLC ) \ 
    31623170        X("cld",        0,              aptb0CLD ) \ 
    31633171        X("clflush",    1,              (P) aptb1CLFLUSH ) \ 
    31643172        X("cli",        0,              aptb0CLI ) \ 
    31653173        X("clts",       0,              aptb0CLTS ) \ 
    31663174        X("cmc",        0,              aptb0CMC ) \ 
    31673175        X("cmova",      2,              (P) aptb2CMOVNBE ) \ 
    31683176        X("cmovae",     2,              (P) aptb2CMOVNB ) \ 
    31693177        X("cmovb",      2,              (P) aptb2CMOVB ) \ 
    31703178        X("cmovbe",     2,              (P) aptb2CMOVBE ) \ 
    31713179        X("cmovc",      2,              (P) aptb2CMOVB ) \ 
    31723180        X("cmove",      2,              (P) aptb2CMOVZ ) \ 
    31733181        X("cmovg",      2,              (P) aptb2CMOVNLE ) \ 
    31743182        X("cmovge",     2,              (P) aptb2CMOVNL ) \ 
    31753183        X("cmovl",      2,              (P) aptb2CMOVL ) \ 
    31763184        X("cmovle",     2,              (P) aptb2CMOVLE ) \ 
    31773185        X("cmovna",     2,              (P) aptb2CMOVBE ) \ 
    31783186        X("cmovnae",    2,              (P) aptb2CMOVB ) \ 
    31793187        X("cmovnb",     2,              (P) aptb2CMOVNB ) \ 
    31803188        X("cmovnbe",    2,              (P) aptb2CMOVNBE ) \ 
     
    31913199        X("cmovo",      2,              (P) aptb2CMOVO ) \ 
    31923200        X("cmovp",      2,              (P) aptb2CMOVP ) \ 
    31933201        X("cmovpe",     2,              (P) aptb2CMOVP ) \ 
    31943202        X("cmovpo",     2,              (P) aptb2CMOVNP ) \ 
    31953203        X("cmovs",      2,              (P) aptb2CMOVS ) \ 
    31963204        X("cmovz",      2,              (P) aptb2CMOVZ ) \ 
    31973205        X("cmp",        2,              (P) aptb2CMP ) \ 
    31983206        X("cmppd",      3,              (P) aptb3CMPPD ) \ 
    31993207        X("cmpps",      3,              (P) aptb3CMPPS ) \ 
    32003208        X("cmps",       2,              (P) aptb2CMPS ) \ 
    32013209        X("cmpsb",      0,              aptb0CMPSB ) \ 
    32023210        /*X("cmpsd",    0,              aptb0CMPSD )*/ \ 
    32033211        X("cmpsd",      ITopt|3,        (P) aptb3CMPSD ) \ 
    32043212        X("cmpss",      3,              (P) aptb3CMPSS ) \ 
    32053213        X("cmpsw",      0,              aptb0CMPSW ) \ 
    32063214        X("cmpxch8b",   1,              (P) aptb1CMPXCH8B ) \ 
    32073215        X("cmpxchg",    2,              (P) aptb2CMPXCHG ) \ 
    32083216        X("comisd",     2,              (P) aptb2COMISD ) \ 
    32093217        X("comiss",     2,              (P) aptb2COMISS ) \ 
    32103218        X("cpuid",      0,              aptb0CPUID ) \ 
     3219        X("cqo",        0,              aptb0CQO ) \ 
    32113220        X("cvtdq2pd",   2,              (P) aptb2CVTDQ2PD ) \ 
    32123221        X("cvtdq2ps",   2,              (P) aptb2CVTDQ2PS ) \ 
    32133222        X("cvtpd2dq",   2,              (P) aptb2CVTPD2DQ ) \ 
    32143223        X("cvtpd2pi",   2,              (P) aptb2CVTPD2PI ) \ 
    32153224        X("cvtpd2ps",   2,              (P) aptb2CVTPD2PS ) \ 
    32163225        X("cvtpi2pd",   2,              (P) aptb2CVTPI2PD ) \ 
    32173226        X("cvtpi2ps",   2,              (P) aptb2CVTPI2PS ) \ 
    32183227        X("cvtps2dq",   2,              (P) aptb2CVTPS2DQ ) \ 
    32193228        X("cvtps2pd",   2,              (P) aptb2CVTPS2PD ) \ 
    32203229        X("cvtps2pi",   2,              (P) aptb2CVTPS2PI ) \ 
    32213230        X("cvtsd2si",   2,              (P) aptb2CVTSD2SI ) \ 
    32223231        X("cvtsd2ss",   2,              (P) aptb2CVTSD2SS ) \ 
    32233232        X("cvtsi2sd",   2,              (P) aptb2CVTSI2SD ) \ 
    32243233        X("cvtsi2ss",   2,              (P) aptb2CVTSI2SS ) \ 
    32253234        X("cvtss2sd",   2,              (P) aptb2CVTSS2SD ) \ 
    32263235        X("cvtss2si",   2,              (P) aptb2CVTSS2SI ) \ 
    32273236        X("cvttpd2dq",  2,              (P) aptb2CVTTPD2DQ ) \ 
    32283237        X("cvttpd2pi",  2,              (P) aptb2CVTTPD2PI ) \ 
    32293238        X("cvttps2dq",  2,              (P) aptb2CVTTPS2DQ ) \ 
    32303239        X("cvttps2pi",  2,              (P) aptb2CVTTPS2PI ) \ 
  • branches/dmd-1.x/src/backend/ty.h

    r606 r618  
    9090    TYident             = 0x30, // type-argument 
    9191    TYtemplate          = 0x31, // unexpanded class template 
    9292    TYvtshape           = 0x32, // virtual function table 
    9393    TYptr               = 0x33, // generic pointer type 
    9494    TYf16func           = 0x34, // _far16 _pascal function 
    9595    TYnsysfunc          = 0x35, // near __syscall func 
    9696    TYfsysfunc          = 0x36, // far __syscall func 
    9797    TYmfunc             = 0x37, // NT C++ member func 
    9898    TYjfunc             = 0x38, // LINKd D function 
    9999    TYhfunc             = 0x39, // C function with hidden parameter 
    100100    TYnref              = 0x3A, // near reference 
    101101    TYfref              = 0x3B, // far reference 
    102102 
    103103    TYcent              = 0x3C, // 128 bit signed integer 
    104104    TYucent             = 0x3D, // 128 bit unsigned integer 
    105105 
    106106    TYMAX               = 0x3E, 
    107107 
    108108#if MARS 
    109109#define TYaarray        TYnptr 
    110 #define TYdelegate      TYllong 
    111 #define TYdarray        TYullong 
     110#define TYdelegate      (I64 ? TYcent : TYllong) 
     111#define TYdarray        (I64 ? TYucent : TYullong) 
    112112#endif 
    113113}; 
    114114 
    115115// These change depending on memory model 
    116116extern int TYptrdiff, TYsize, TYsize_t; 
    117117 
    118118/* Linkage type                 */ 
    119119#define mTYnear         0x100 
    120120#define mTYfar          0x200 
    121121#define mTYcs           0x400           // in code segment 
    122122#define mTYthread       0x800 
    123123#define mTYLINK         0xF00           // all linkage bits 
    124124 
    125125#define mTYloadds       0x1000 
    126126#define mTYexport       0x2000 
    127127#define mTYweak         0x0000 
    128128#define mTYimport       0x4000 
    129129#define mTYnaked        0x8000 
    130130#define mTYMOD          0xF000          // all modifier bits 
    131131 
     
    181181 
    182182/* Groupings of types   */ 
    183183 
    184184#define tyintegral(ty)  (tytab[(ty) & 0xFF] & TYFLintegral) 
    185185 
    186186#define tyarithmetic(ty) (tytab[(ty) & 0xFF] & (TYFLintegral | TYFLreal | TYFLimaginary | TYFLcomplex)) 
    187187 
    188188#define tyaggregate(ty) (tytab[(ty) & 0xFF] & TYFLaggregate) 
    189189 
    190190#define tyscalar(ty)    (tytab[(ty) & 0xFF] & (TYFLintegral | TYFLreal | TYFLimaginary | TYFLcomplex | TYFLptr | TYFLmptr | TYFLnullptr)) 
    191191 
    192192#define tyfloating(ty)  (tytab[(ty) & 0xFF] & (TYFLreal | TYFLimaginary | TYFLcomplex)) 
    193193 
    194194#define tyimaginary(ty) (tytab[(ty) & 0xFF] & TYFLimaginary) 
    195195 
    196196#define tycomplex(ty)   (tytab[(ty) & 0xFF] & TYFLcomplex) 
    197197 
    198198#define tyreal(ty)      (tytab[(ty) & 0xFF] & TYFLreal) 
    199199 
    200200// Fits into 64 bit register 
    201 #define ty64reg(ty)     (tytab[(ty) & 0xFF] & (TYFLintegral | TYFLptr)
     201#define ty64reg(ty)     (tytab[(ty) & 0xFF] & (TYFLintegral | TYFLptr) && tysize(ty) <= NPTRSIZE
    202202 
    203203#ifndef tyshort 
    204204/* Types that are chars or shorts       */ 
    205205#define tyshort(ty)     (tytab[(ty) & 0xFF] & TYFLshort) 
    206206#endif 
    207207 
    208208/* Detect TYlong or TYulong     */ 
    209209#ifndef tylong 
    210210#define tylong(ty)      (tybasic(ty) == TYlong || tybasic(ty) == TYulong) 
    211211#endif 
    212212 
    213213/* Use to detect a pointer type */ 
    214214#ifndef typtr 
    215215#define typtr(ty)       (tytab[(ty) & 0xFF] & TYFLptr) 
    216216#endif 
    217217 
    218218/* Use to detect a reference type */ 
    219219#ifndef tyref 
    220220#define tyref(ty)       (tytab[(ty) & 0xFF] & TYFLref) 
    221221#endif 
  • branches/dmd-1.x/src/backend/var.c

    r558 r618  
    222222unsigned 
    223223         maxblks = 0,   /* array max for all block stuff                */ 
    224224                        /* dfoblks <= numblks <= maxblks                */ 
    225225         numcse,        /* number of common subexpressions              */ 
    226226         deftop = 0,    /* # of entries in defnod[]                     */ 
    227227         exptop = 0;    /* top of expnod[]                              */ 
    228228 
    229229vec_t   defkill = NULL,         /* vector of AEs killed by an ambiguous */ 
    230230                                /* definition                           */ 
    231231        starkill = NULL,        /* vector of AEs killed by a definition */ 
    232232                                /* of something that somebody could be  */ 
    233233                                /* pointing to                          */ 
    234234        vptrkill = NULL;        /* vector of AEs killed by an access    */ 
    235235                                /* to a vptr                            */ 
    236236 
    237237/* From debug.c */ 
    238238#if DEBUG 
    239239const char *regstring[32] = {"AX","CX","DX","BX","SP","BP","SI","DI", 
    240240                             "R8","R9","R10","R11","R12","R13","R14","R15", 
    241241                             "XMM0","XMM1","XMM2","XMM3","XMM4","XMM5","XMM6","XMM7", 
    242                              "ES","PSW","STACK","ST0", "ST01"}; 
     242                             "ES","PSW","STACK","ST0","ST01","NOREG","RMload","RMstore"}; 
    243243#endif 
    244244 
    245245/* From nwc.c */ 
    246246 
    247247type *chartype;                 /* default 'char' type                  */ 
    248248 
  • branches/dmd-1.x/src/e2ir.c

    r600 r618  
    408408 * Convert array to a dynamic array. 
    409409 */ 
    410410 
    411411elem *array_toDarray(Type *t, elem *e) 
    412412{ 
    413413    unsigned dim; 
    414414    elem *ef = NULL; 
    415415    elem *ex; 
    416416 
    417417    //printf("array_toDarray(t = %s)\n", t->toChars()); 
    418418    //elem_print(e); 
    419419    t = t->toBasetype(); 
    420420    switch (t->ty) 
    421421    { 
    422422        case Tarray: 
    423423            break; 
    424424 
    425425        case Tsarray: 
    426426            e = el_una(OPaddr, TYnptr, e); 
    427427            dim = ((TypeSArray *)t)->dim->toInteger(); 
    428             e = el_pair(TYullong, el_long(TYint, dim), e); 
     428            e = el_pair(TYdarray, el_long(TYint, dim), e); 
    429429            break; 
    430430 
    431431        default: 
    432432        L1: 
    433433            switch (e->Eoper) 
    434434            { 
    435435                case OPconst: 
    436436                { 
    437437                    size_t len = tysize[tybasic(e->Ety)]; 
    438438                    elem *es = el_calloc(); 
    439439                    es->Eoper = OPstring; 
    440440 
    441441                    // Match MEM_PH_FREE for OPstring in ztc\el.c 
    442442                    es->EV.ss.Vstring = (char *)mem_malloc(len); 
    443443                    memcpy(es->EV.ss.Vstring, &e->EV, len); 
    444444 
    445445                    es->EV.ss.Vstrlen = len; 
    446446                    es->Ety = TYnptr; 
    447447                    e = es; 
    448448                    break; 
     
    474474                    // Copy expression to a variable and take the 
    475475                    // address of that variable. 
    476476                    Symbol *stmp; 
    477477                    tym_t ty = tybasic(e->Ety); 
    478478 
    479479                    if (ty == TYstruct) 
    480480                    { 
    481481                        if (e->Enumbytes == 4) 
    482482                            ty = TYint; 
    483483                        else if (e->Enumbytes == 8) 
    484484                            ty = TYllong; 
    485485                    } 
    486486                    e->Ety = ty; 
    487487                    stmp = symbol_genauto(type_fake(ty)); 
    488488                    e = el_bin(OPeq, e->Ety, el_var(stmp), e); 
    489489                    e = el_bin(OPcomma, TYnptr, e, el_una(OPaddr, TYnptr, el_var(stmp))); 
    490490                    break; 
    491491                } 
    492492            } 
    493493            dim = 1; 
    494             e = el_pair(TYullong, el_long(TYint, dim), e); 
     494            e = el_pair(TYdarray, el_long(TYint, dim), e); 
    495495            break; 
    496496    } 
    497497    return el_combine(ef, e); 
    498498} 
    499499 
    500500/***************************************** 
    501501 * Evaluate elem and convert to dynamic array. 
    502502 */ 
    503503 
    504504elem *eval_Darray(IRState *irs, Expression *e) 
    505505{ 
    506506    elem *ex; 
    507507 
    508508    ex = e->toElem(irs); 
    509509    return array_toDarray(e->type, ex); 
    510510} 
    511511 
    512512/************************************ 
    513513 */ 
    514514 
     
    518518    //elem_print(e); 
    519519 
    520520    elem *elen; 
    521521    unsigned dim = ((TypeSArray *)tfrom)->dim->toInteger(); 
    522522 
    523523    if (tto) 
    524524    { 
    525525        unsigned fsize = tfrom->nextOf()->size(); 
    526526        unsigned tsize = tto->nextOf()->size(); 
    527527 
    528528        if ((dim * fsize) % tsize != 0) 
    529529        { 
    530530          Lerr: 
    531531            error(loc, "cannot cast %s to %s since sizes don't line up", tfrom->toChars(), tto->toChars()); 
    532532        } 
    533533        dim = (dim * fsize) / tsize; 
    534534    } 
    535535  L1: 
    536536    elen = el_long(TYint, dim); 
    537537    e = el_una(OPaddr, TYnptr, e); 
    538     e = el_pair(TYullong, elen, e); 
     538    e = el_pair(TYdarray, elen, e); 
    539539    return e; 
    540540} 
    541541 
    542542/******************************************* 
    543543 * Set an array pointed to by eptr to evalue: 
    544544 *      eptr[0..edim] = evalue; 
    545545 * Input: 
    546546 *      eptr    where to write the data to 
    547547 *      evalue  value to write 
    548548 *      edim    number of times to write evalue to eptr[] 
    549549 *      tb      type of evalue 
    550550 */ 
    551551 
    552552elem *setArray(elem *eptr, elem *edim, Type *tb, elem *evalue) 
    553553{   int r; 
    554554    elem *e; 
    555555    int sz = tb->size(); 
    556556 
    557557    if (tb->ty == Tfloat80 || tb->ty == Timaginary80) 
    558558        r = RTLSYM_MEMSET80; 
    559559    else if (tb->ty == Tcomplex80) 
    560560        r = RTLSYM_MEMSET160; 
    561561    else if (tb->ty == Tcomplex64) 
    562562        r = RTLSYM_MEMSET128; 
    563563    else 
    564564    { 
    565565        switch (sz) 
    566566        { 
    567567            case 1:      r = RTLSYM_MEMSET8;    break; 
    568568            case 2:      r = RTLSYM_MEMSET16;   break; 
    569569            case 4:      r = RTLSYM_MEMSET32;   break; 
    570570            case 8:      r = RTLSYM_MEMSET64;   break; 
     571            case 16:     r = RTLSYM_MEMSET128;  break; 
    571572 
    572573            default: 
    573574                r = RTLSYM_MEMSETN; 
    574575                evalue = el_una(OPaddr, TYnptr, evalue); 
    575576                elem *esz = el_long(TYint, sz); 
    576577                e = el_params(esz, edim, evalue, eptr, NULL); 
    577578                e = el_bin(OPcall,TYnptr,el_var(rtlsym[r]),e); 
    578579                return e; 
    579580        } 
    580581    } 
    581582    if (sz > 1 && sz <= 8 && 
    582583        evalue->Eoper == OPconst && el_allbits(evalue, 0)) 
    583584    { 
    584585        r = RTLSYM_MEMSET8; 
    585586        edim = el_bin(OPmul, TYuint, edim, el_long(TYuint, sz)); 
    586587    } 
    587588 
    588589    if (tybasic(evalue->Ety) == TYstruct) 
    589590    { 
    590591        evalue = el_una(OPstrpar, TYstruct, evalue); 
     
    722723    } 
    723724    el_setLoc(e,loc); 
    724725    return e; 
    725726} 
    726727#endif 
    727728 
    728729/************************************** 
    729730 */ 
    730731 
    731732elem *FuncExp::toElem(IRState *irs) 
    732733{ 
    733734    elem *e; 
    734735    Symbol *s; 
    735736 
    736737    //printf("FuncExp::toElem() %s\n", toChars()); 
    737738    s = fd->toSymbol(); 
    738739    e = el_ptr(s); 
    739740    if (fd->isNested()) 
    740741    { 
    741742        elem *ethis = getEthis(loc, irs, fd); 
    742         e = el_pair(TYullong, ethis, e); 
     743        e = el_pair(TYdelegate, ethis, e); 
    743744    } 
    744745 
    745746    irs->deferToObj->push(fd); 
    746747    el_setLoc(e,loc); 
    747748    return e; 
    748749} 
    749750 
    750751/************************************** 
    751752 */ 
    752753 
    753754elem *Dsymbol_toElem(Dsymbol *s, IRState *irs) 
    754755{ 
    755756    elem *e = NULL; 
    756757    Symbol *sp; 
    757758    AttribDeclaration *ad; 
    758759    VarDeclaration *vd; 
    759760    ClassDeclaration *cd; 
    760761    StructDeclaration *sd; 
    761762    FuncDeclaration *fd; 
    762763    TemplateMixin *tm; 
     
    22562257        } 
    22572258#endif 
    22582259 
    22592260        e = el_bin(OPcall, type->totym(), el_var(rtlsym[r]), ep); 
    22602261        el_setLoc(e, loc); 
    22612262        return e; 
    22622263    } 
    22632264 
    22642265    // Look for array[]=n 
    22652266    if (e1->op == TOKslice) 
    22662267    { 
    22672268        SliceExp *are = (SliceExp *)(e1); 
    22682269        Type *t1 = t1b; 
    22692270        Type *t2 = e2->type->toBasetype(); 
    22702271 
    22712272        // which we do if the 'next' types match 
    22722273        if (ismemset) 
    22732274        {   // Do a memset for array[]=v 
    22742275            //printf("Lpair %s\n", toChars()); 
    22752276            SliceExp *are = (SliceExp *)e1; 
    2276             elem *elwr; 
    2277             elem *eupr; 
    2278             elem *n1; 
    22792277            elem *evalue; 
    22802278            elem *enbytes; 
    22812279            elem *elength; 
    22822280            elem *einit; 
    22832281            dinteger_t value; 
    22842282            Type *ta = are->e1->type->toBasetype(); 
    22852283            Type *tb = ta->nextOf()->toBasetype(); 
    22862284            int sz = tb->size(); 
    22872285            tym_t tym = type->totym(); 
    22882286 
    2289             n1 = are->e1->toElem(irs); 
    2290             elwr = are->lwr ? are->lwr->toElem(irs) : NULL; 
    2291             eupr = are->upr ? are->upr->toElem(irs) : NULL; 
     2287            elem *n1 = are->e1->toElem(irs); 
     2288            elem *elwr = are->lwr ? are->lwr->toElem(irs) : NULL; 
     2289            elem *eupr = are->upr ? are->upr->toElem(irs) : NULL; 
    22922290 
    22932291            elem *n1x = n1; 
    22942292 
    22952293            // Look for array[]=n 
    22962294            if (ta->ty == Tsarray) 
    22972295            { 
    2298                 TypeSArray *ts; 
    2299  
    2300                 ts = (TypeSArray *) ta; 
     2296                TypeSArray *ts = (TypeSArray *) ta; 
    23012297                n1 = array_toPtr(ta, n1); 
    23022298                enbytes = ts->dim->toElem(irs); 
    23032299                n1x = n1; 
    23042300                n1 = el_same(&n1x); 
    23052301                einit = resolveLengthVar(are->lengthVar, &n1, ta); 
    23062302            } 
    23072303            else if (ta->ty == Tarray) 
    23082304            { 
    23092305                n1 = el_same(&n1x); 
    23102306                einit = resolveLengthVar(are->lengthVar, &n1, ta); 
    23112307                enbytes = el_copytree(n1); 
    23122308                n1 = array_toPtr(ta, n1); 
    23132309                enbytes = el_una(OP64_32, TYint, enbytes); 
    23142310            } 
    23152311            else if (ta->ty == Tpointer) 
    23162312            { 
    23172313                n1 = el_same(&n1x); 
    23182314                enbytes = el_long(TYint, -1);   // largest possible index 
    23192315                einit = NULL; 
    23202316            } 
     
    23782374                sassert = irs->blx->module->toModuleArray(); 
    23792375                ea = el_bin(OPcall,TYvoid,el_var(sassert), el_long(TYint, loc.linnum)); 
    23802376                eb = el_bin(OPoror,TYvoid,c1,ea); 
    23812377                einit = el_combine(einit, eb); 
    23822378            } 
    23832379 
    23842380            if (elwr) 
    23852381            {   elem *elwr2; 
    23862382 
    23872383                el_free(enbytes); 
    23882384                elwr2 = el_copytree(elwr); 
    23892385                elwr2 = el_bin(OPmul, TYint, elwr2, el_long(TYint, sz)); 
    23902386                n1 = el_bin(OPadd, TYnptr, n1, elwr2); 
    23912387                enbytes = el_bin(OPmin, TYint, eupr, elwr); 
    23922388                elength = el_copytree(enbytes); 
    23932389            } 
    23942390            else 
    23952391                elength = el_copytree(enbytes); 
    23962392            e = setArray(n1, enbytes, tb, evalue); 
    23972393        Lpair: 
    2398             e = el_pair(TYullong, elength, e); 
     2394            e = el_pair(TYdarray, elength, e); 
    23992395        Lret2: 
    24002396            e = el_combine(einit, e); 
    24012397            //elem_print(e); 
    24022398            goto Lret; 
    24032399        } 
    24042400#if 0 
    24052401        else if (e2->op == TOKadd || e2->op == TOKmin) 
    24062402        { 
    24072403            /* It's ea[] = eb[] +- ec[] 
    24082404             */ 
    24092405            BinExp *e2a = (BinExp *)e2; 
    24102406            Type *t = e2->type->toBasetype()->nextOf()->toBasetype(); 
    24112407            if (t->ty != Tfloat32 && t->ty != Tfloat64 && t->ty != Tfloat80) 
    24122408            { 
    24132409                e2->error("array add/min for %s not supported", t->toChars()); 
    24142410                return el_long(TYint, 0); 
    24152411            } 
    24162412            elem *ea = e1->toElem(irs); 
    24172413            ea = array_toDarray(e1->type, ea); 
    24182414            elem *eb = e2a->e1->toElem(irs); 
     
    30103006        else 
    30113007        { 
    30123008            // Get pointer to function out of virtual table 
    30133009            unsigned vindex; 
    30143010 
    30153011            assert(ethis); 
    30163012            ep = el_same(&ethis); 
    30173013            ep = el_una(OPind, TYnptr, ep); 
    30183014            vindex = func->vtblIndex; 
    30193015 
    30203016            // Build *(ep + vindex * 4) 
    30213017            ep = el_bin(OPadd,TYnptr,ep,el_long(TYint, vindex * 4)); 
    30223018            ep = el_una(OPind,TYnptr,ep); 
    30233019        } 
    30243020 
    30253021//      if (func->tintro) 
    30263022//          func->error(loc, "cannot form delegate due to covariant return type"); 
    30273023    } 
    30283024    if (ethis->Eoper == OPcomma) 
    30293025    { 
    3030         ethis->E2 = el_pair(TYullong, ethis->E2, ep); 
    3031         ethis->Ety = TYullong
     3026        ethis->E2 = el_pair(TYdarray, ethis->E2, ep); 
     3027        ethis->Ety = TYdarray
    30323028        e = ethis; 
    30333029    } 
    30343030    else 
    3035         e = el_pair(TYullong, ethis, ep); 
     3031        e = el_pair(TYdarray, ethis, ep); 
    30363032    el_setLoc(e,loc); 
    30373033    return e; 
    30383034} 
    30393035 
    30403036elem *DotTypeExp::toElem(IRState *irs) 
    30413037{ 
    30423038    // Just a pass-thru to e1 
    30433039    elem *e; 
    30443040 
    30453041    //printf("DotTypeExp::toElem() %s\n", toChars()); 
    30463042    e = e1->toElem(irs); 
    30473043    el_setLoc(e,loc); 
    30483044    return e; 
    30493045} 
    30503046 
    30513047elem *CallExp::toElem(IRState *irs) 
    30523048{ 
    30533049    //printf("CallExp::toElem('%s')\n", toChars()); 
    30543050    assert(e1->type); 
    30553051    elem *ec; 
     
    40124008 
    40134009            L2: 
    40144010                // Construct: (c1 || ModuleArray(line)) 
    40154011                Symbol *sassert; 
    40164012 
    40174013                sassert = irs->blx->module->toModuleArray(); 
    40184014                ea = el_bin(OPcall,TYvoid,el_var(sassert), el_long(TYint, loc.linnum)); 
    40194015                eb = el_bin(OPoror,TYvoid,c1,ea); 
    40204016                elwr = el_combine(elwr, eb); 
    40214017 
    40224018                elwr2 = el_copytree(elwr2); 
    40234019                eupr = el_copytree(eupr2); 
    40244020            } 
    40254021        } 
    40264022 
    40274023        eptr = array_toPtr(e1->type, e); 
    40284024 
    40294025        elem *elength = el_bin(OPmin, TYint, eupr, elwr2); 
    40304026        eptr = el_bin(OPadd, TYnptr, eptr, el_bin(OPmul, TYint, el_copytree(elwr2), el_long(TYint, sz))); 
    40314027 
    4032         e = el_pair(TYullong, elength, eptr); 
     4028        e = el_pair(TYdarray, elength, eptr); 
    40334029        e = el_combine(elwr, e); 
    40344030        e = el_combine(einit, e); 
    40354031    } 
    40364032    else if (t1->ty == Tsarray) 
    40374033    { 
    40384034        e = sarray_toDarray(loc, t1, NULL, e); 
    40394035    } 
    40404036    el_setLoc(e,loc); 
    40414037    return e; 
    40424038} 
    40434039 
    40444040elem *IndexExp::toElem(IRState *irs) 
    40454041{   elem *e; 
    40464042    elem *n1 = e1->toElem(irs); 
    40474043    elem *eb = NULL; 
    40484044    Type *t1; 
    40494045 
    40504046    //printf("IndexExp::toElem() %s\n", toChars()); 
    40514047    t1 = e1->type->toBasetype(); 
    40524048    if (t1->ty == Taarray) 
     
    42194215    else 
    42204216    {   dim = 0; 
    42214217        e = el_long(TYint, 0); 
    42224218    } 
    42234219    Type *tb = type->toBasetype(); 
    42244220#if 1 
    42254221    e = el_param(e, type->getTypeInfo(NULL)->toElem(irs)); 
    42264222 
    42274223    // call _d_arrayliteralT(ti, dim, ...) 
    42284224    e = el_bin(OPcall,TYnptr,el_var(rtlsym[RTLSYM_ARRAYLITERALT]),e); 
    42294225    e->Eflags |= EFLAGS_variadic; 
    42304226#else 
    42314227    e = el_param(e, el_long(TYint, tb->next->size())); 
    42324228 
    42334229    // call _d_arrayliteral(size, dim, ...) 
    42344230    e = el_bin(OPcall,TYnptr,el_var(rtlsym[RTLSYM_ARRAYLITERAL]),e); 
    42354231    e->Eflags |= EFLAGS_variadic; 
    42364232#endif 
    42374233    if (tb->ty == Tarray) 
    42384234    { 
    4239         e = el_pair(TYullong, el_long(TYint, dim), e); 
     4235        e = el_pair(TYdarray, el_long(TYint, dim), e); 
    42404236    } 
    42414237    else if (tb->ty == Tpointer) 
    42424238    { 
    42434239    } 
    42444240    else 
    42454241    { 
    42464242        e = el_una(OPind,TYstruct,e); 
    42474243        e->Enumbytes = type->size(); 
    42484244    } 
    42494245 
    42504246    el_setLoc(e,loc); 
    42514247    return e; 
    42524248} 
    42534249 
    42544250 
    42554251elem *AssocArrayLiteralExp::toElem(IRState *irs) 
    42564252{   elem *e; 
    42574253    size_t dim; 
    42584254 
    42594255    //printf("AssocArrayLiteralExp::toElem() %s\n", toChars()); 
  • branches/dmd-1.x/src/iasm.c

    r606 r618  
    12311231L386_WARNING2: 
    12321232                        if (config.target_cpu < TARGET_80386) 
    12331233                        {   // Reference to %s caused a 386 instruction to be generated 
    12341234                            //warerr(WM_386_op, id->toChars()); 
    12351235                        } 
    12361236                    } 
    12371237                    break; 
    12381238                case 2: 
    12391239                case 3:     // The third operand is always an _imm 
    12401240                    if (popnd1 && popnd1->s) 
    12411241                        goto L386_WARNING; 
    12421242                    if (popnd2 && popnd2->s) 
    12431243                    { 
    12441244                        id = popnd2->s->ident; 
    12451245                        goto L386_WARNING2; 
    12461246                    } 
    12471247                    break; 
    12481248            } 
    12491249        } 
    12501250 
     1251        if (ptb.pptb0->usFlags & _64_bit && !I64) 
     1252            error(asmstate.loc, "use -m64 to compile 64 bit instructions"); 
     1253 
    12511254        switch (usNumops) 
    12521255        { 
    12531256            case 0: 
    1254                 if ((I32 && (ptb.pptb0->usFlags & _16_bit)) || 
     1257                if (((I32 | I64) && (ptb.pptb0->usFlags & _16_bit)) || 
    12551258                        (I16 && (ptb.pptb0->usFlags & _32_bit))) 
    12561259                { 
    12571260                        emit(0x66); 
    12581261                        pc->Iflags |= CFopsize; 
     1262                } 
     1263                else if (I64 && (ptb.pptb0->usFlags & _64_bit)) 
     1264                { 
     1265                        emit(REX | REX_W); 
     1266                        pc->Irex |= REX_W; 
    12591267                } 
    12601268                break; 
    12611269 
    12621270            // 3 and 2 are the same because the third operand is always 
    12631271            // an immediate and does not affect operation size 
    12641272            case 3: 
    12651273            case 2: 
    12661274                if ((I32 && 
    12671275                      (amod2 == _addr16 || 
    12681276                       (uSizemaskTable2 & _16 && aoptyTable2 == _rel) || 
    12691277                       (uSizemaskTable2 & _32 && aoptyTable2 == _mnoi) || 
    12701278                       (ptb.pptb2->usFlags & _16_bit_addr) 
    12711279                     ) 
    12721280                    ) || 
    12731281                     (I16 && 
    12741282                       (amod2 == _addr32 || 
    12751283                        (uSizemaskTable2 & _32 && aoptyTable2 == _rel) || 
    12761284                        (uSizemaskTable2 & _48 && aoptyTable2 == _mnoi) || 
    12771285                        (ptb.pptb2->usFlags & _32_bit_addr))) 
    12781286                  ) 
  • branches/dmd-1.x/src/mars.c

    r584 r618  
    7474#else 
    7575#error "fix this" 
    7676#endif 
    7777 
    7878#if TARGET_WINDOS 
    7979    dll_ext  = "dll"; 
    8080#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS 
    8181    dll_ext  = "so"; 
    8282#elif TARGET_OSX 
    8383    dll_ext = "dylib"; 
    8484#else 
    8585#error "fix this" 
    8686#endif 
    8787 
    8888    copyright = "Copyright (c) 1999-2010 by Digital Mars"; 
    8989    written = "written by Walter Bright" 
    9090#if TARGET_NET 
    9191    "\nMSIL back-end (alpha release) by Cristian L. Vlasceanu and associates."; 
    9292#endif 
    9393    ; 
    94     version = "v1.063"; 
     94    version = "v1.064"; 
    9595    global.structalign = 8; 
    9696 
    9797    memset(&params, 0, sizeof(Param)); 
    9898} 
    9999 
    100100char *Loc::toChars() 
    101101{ 
    102102    OutBuffer buf; 
    103103    char *p; 
    104104 
    105105    if (filename) 
    106106    { 
    107107        buf.printf("%s", filename); 
    108108    } 
    109109 
    110110    if (linnum) 
    111111        buf.printf("(%d)", linnum); 
    112112    buf.writeByte(0); 
    113113    return (char *)buf.extractData(); 
    114114} 
  • branches/dmd-1.x/src/s2ir.c

    r567 r618  
    957957         */ 
    958958        block_goto(blx, BCgoto, mystate.breakBlock); 
    959959        return; 
    960960    } 
    961961#endif 
    962962 
    963963    if (condition->type->isString()) 
    964964    { 
    965965        // Number the cases so we can unscramble things after the sort() 
    966966        for (int i = 0; i < numcases; i++) 
    967967        {   CaseStatement *cs = (CaseStatement *)cases->data[i]; 
    968968            cs->index = i; 
    969969        } 
    970970 
    971971        cases->sort(); 
    972972 
    973973        /* Create a sorted array of the case strings, and si 
    974974         * will be the symbol for it. 
    975975         */ 
    976976        dt_t *dt = NULL; 
    977         Symbol *si = symbol_generate(SCstatic,type_fake(TYullong)); 
     977        Symbol *si = symbol_generate(SCstatic,type_fake(TYdarray)); 
    978978#if MACHOBJ 
    979979        si->Sseg = DATA; 
    980980#endif 
    981         dtdword(&dt, numcases); 
    982         dtxoff(&dt, si, 8, TYnptr); 
     981        dtsize_t(&dt, numcases); 
     982        dtxoff(&dt, si, PTRSIZE * 2, TYnptr); 
    983983 
    984984        for (int i = 0; i < numcases; i++) 
    985985        {   CaseStatement *cs = (CaseStatement *)cases->data[i]; 
    986986 
    987987            if (cs->exp->op != TOKstring) 
    988988            {   error("case '%s' is not a string", cs->exp->toChars()); // BUG: this should be an assert 
    989989            } 
    990990            else 
    991991            { 
    992992                StringExp *se = (StringExp *)(cs->exp); 
    993993                unsigned len = se->len; 
    994994                dtdword(&dt, len); 
    995995                dtabytes(&dt, TYnptr, 0, se->len * se->sz, (char *)se->string); 
    996996            } 
    997997        } 
    998998 
    999999        si->Sdt = dt; 
    10001000        si->Sfl = FLdata; 
    10011001        outdata(si); 
    10021002 
  • branches/dmd-1.x/src/toobj.c

    r428 r618  
    334334    /* The layout is: 
    335335       { 
    336336            void **vptr; 
    337337            monitor_t monitor; 
    338338            byte[] initializer;         // static initialization data 
    339339            char[] name;                // class name 
    340340            void *[] vtbl; 
    341341            Interface[] interfaces; 
    342342            ClassInfo *base;            // base class 
    343343            void *destructor; 
    344344            void *invariant;            // class invariant 
    345345            uint flags; 
    346346            void *deallocator; 
    347347            OffsetTypeInfo[] offTi; 
    348348            void *defaultConstructor; 
    349349            const(MemberInfo[]) function(string) xgetMembers;   // module getMembers() function 
    350350            TypeInfo typeinfo; 
    351351       } 
    352352     */ 
    353353    dt_t *dt = NULL; 
    354     offset = CLASSINFO_SIZE;                    // must be ClassInfo.size 
     354    unsigned classinfo_size = global.params.isX86_64 ? CLASSINFO_SIZE_64 : CLASSINFO_SIZE;    // must be ClassInfo.size 
     355    offset = classinfo_size; 
    355356    if (classinfo) 
    356357    { 
    357         if (classinfo->structsize != CLASSINFO_SIZE) 
    358         { 
     358        if (classinfo->structsize != classinfo_size) 
     359        { 
     360#ifdef DEBUG 
     361            printf("CLASSINFO_SIZE = x%x, classinfo->structsize = x%x\n", offset, classinfo->structsize); 
     362#endif 
    359363            error("mismatch between dmd and object.d or object.di found. Check installation and import paths with -v compiler switch."); 
    360364            fatal(); 
    361365        } 
    362366    } 
    363367 
    364368    if (classinfo) 
    365369        dtxoff(&dt, classinfo->toVtblSymbol(), 0, TYnptr); // vtbl for ClassInfo 
    366370    else 
    367371        dtdword(&dt, 0);                // BUG: should be an assert() 
    368372    dtdword(&dt, 0);                    // monitor 
    369373 
    370374    // initializer[] 
    371375    assert(structsize >= 8); 
    372376    dtdword(&dt, structsize);           // size 
    373377    dtxoff(&dt, sinit, 0, TYnptr);      // initializer 
    374378 
    375379    // name[] 
    376380    const char *name = ident->toChars(); 
    377381    size_t namelen = strlen(name); 
    378382    if (!(namelen > 9 && memcmp(name, "TypeInfo_", 9) == 0)) 
     
    485489        // Fill in vtbl[] 
    486490        b->fillVtbl(this, &b->vtbl, 1); 
    487491 
    488492        dtxoff(&dt, id->toSymbol(), 0, TYnptr);         // ClassInfo 
    489493 
    490494        // vtbl[] 
    491495        dtdword(&dt, id->vtbl.dim); 
    492496        dtxoff(&dt, csym, offset, TYnptr); 
    493497 
    494498        dtdword(&dt, b->offset);                        // this offset 
    495499 
    496500        offset += id->vtbl.dim * PTRSIZE; 
    497501    } 
    498502 
    499503    // Put out the vtblInterfaces->data[].vtbl[] 
    500504    // This must be mirrored with ClassDeclaration::baseVtblOffset() 
    501505    //printf("putting out %d interface vtbl[]s for '%s'\n", vtblInterfaces->dim, toChars()); 
    502506    for (i = 0; i < vtblInterfaces->dim; i++) 
    503507    {   BaseClass *b = (BaseClass *)vtblInterfaces->data[i]; 
    504508        ClassDeclaration *id = b->base; 
    505         int j; 
    506509 
    507510        //printf("    interface[%d] is '%s'\n", i, id->toChars()); 
    508         j = 0; 
     511        int j = 0; 
    509512        if (id->vtblOffset()) 
    510513        { 
    511514            // First entry is ClassInfo reference 
    512515            //dtxoff(&dt, id->toSymbol(), 0, TYnptr); 
    513516 
    514517            // First entry is struct Interface reference 
    515518            dtxoff(&dt, csym, CLASSINFO_SIZE + i * (4 * PTRSIZE), TYnptr); 
    516519            j = 1; 
    517520        } 
    518521        assert(id->vtbl.dim == b->vtbl.dim); 
    519522        for (; j < id->vtbl.dim; j++) 
    520523        { 
    521             FuncDeclaration *fd; 
    522  
    523524            assert(j < b->vtbl.dim); 
    524525#if 0 
    525526            Object *o = (Object *)b->vtbl.data[j]; 
    526527            if (o) 
    527528            { 
    528529                printf("o = %p\n", o); 
    529530                assert(o->dyncast() == DYNCAST_DSYMBOL); 
    530531                Dsymbol *s = (Dsymbol *)o; 
    531532                printf("s->kind() = '%s'\n", s->kind()); 
    532533            } 
    533534#endif 
    534             fd = (FuncDeclaration *)b->vtbl.data[j]; 
     535            FuncDeclaration *fd = (FuncDeclaration *)b->vtbl.data[j]; 
    535536            if (fd) 
    536537                dtxoff(&dt, fd->toThunkSymbol(b->offset), 0, TYnptr); 
    537538            else 
    538539                dtdword(&dt, 0); 
    539540        } 
    540541    } 
    541542 
    542543#if 1 
    543544    // Put out the overriding interface vtbl[]s. 
    544545    // This must be mirrored with ClassDeclaration::baseVtblOffset() 
    545546    //printf("putting out overriding interface vtbl[]s for '%s' at offset x%x\n", toChars(), offset); 
    546547    ClassDeclaration *cd; 
    547548    Array bvtbl; 
    548549 
    549550    for (cd = this->baseClass; cd; cd = cd->baseClass) 
    550551    { 
    551552        for (int k = 0; k < cd->vtblInterfaces->dim; k++) 
    552553        {   BaseClass *bs = (BaseClass *)cd->vtblInterfaces->data[k]; 
    553554 
    554555            if (bs->fillVtbl(this, &bvtbl, 0)) 
     
    700701#endif 
    701702#if MACHOBJ 
    702703    vtblsym->Sseg = DATA; 
    703704#endif 
    704705    outdata(vtblsym); 
    705706    if (isExport()) 
    706707        obj_export(vtblsym,0); 
    707708} 
    708709 
    709710/****************************************** 
    710711 * Get offset of base class's vtbl[] initializer from start of csym. 
    711712 * Returns ~0 if not this csym. 
    712713 */ 
    713714 
    714715unsigned ClassDeclaration::baseVtblOffset(BaseClass *bc) 
    715716{ 
    716717    unsigned csymoffset; 
    717718    int i; 
    718719 
    719720    //printf("ClassDeclaration::baseVtblOffset('%s', bc = %p)\n", toChars(), bc); 
    720     csymoffset = CLASSINFO_SIZE; 
     721    csymoffset = global.params.isX86_64 ? CLASSINFO_SIZE_64 : CLASSINFO_SIZE;    // must be ClassInfo.size 
    721722    csymoffset += vtblInterfaces->dim * (4 * PTRSIZE); 
    722723 
    723724    for (i = 0; i < vtblInterfaces->dim; i++) 
    724725    { 
    725726        BaseClass *b = (BaseClass *)vtblInterfaces->data[i]; 
    726727 
    727728        if (b == bc) 
    728729            return csymoffset; 
    729730        csymoffset += b->base->vtbl.dim * PTRSIZE; 
    730731    } 
    731732 
    732733#if 1 
    733734    // Put out the overriding interface vtbl[]s. 
    734735    // This must be mirrored with ClassDeclaration::baseVtblOffset() 
    735736    //printf("putting out overriding interface vtbl[]s for '%s' at offset x%x\n", toChars(), offset); 
    736737    ClassDeclaration *cd; 
    737738    Array bvtbl; 
    738739 
    739740    for (cd = this->baseClass; cd; cd = cd->baseClass) 
    740741    { 
     
    782783void InterfaceDeclaration::toObjFile(int multiobj) 
    783784{   unsigned i; 
    784785    unsigned offset; 
    785786    Symbol *sinit; 
    786787    enum_SC scclass; 
    787788 
    788789    //printf("InterfaceDeclaration::toObjFile('%s')\n", toChars()); 
    789790 
    790791    if (!members) 
    791792        return; 
    792793 
    793794    if (global.params.symdebug) 
    794795        toDebug(); 
    795796 
    796797    scclass = SCglobal; 
    797798    if (inTemplateInstance()) 
    798799        scclass = SCcomdat; 
    799800 
    800801    // Put out the members 
    801802    for (i = 0; i < members->dim; i++) 
    802     { 
    803         Dsymbol *member; 
    804  
    805         member = (Dsymbol *)members->data[i]; 
     803    {   Dsymbol *member = (Dsymbol *)members->data[i]; 
    806804        if (!member->isFuncDeclaration()) 
    807805            member->toObjFile(0); 
    808806    } 
    809807 
    810808    // Generate C symbols 
    811809    toSymbol(); 
    812810 
    813811    ////////////////////////////////////////////// 
    814812 
    815813    // Put out the TypeInfo 
    816814    type->getTypeInfo(NULL); 
    817815    type->vtinfo->toObjFile(multiobj); 
    818816 
    819817    ////////////////////////////////////////////// 
    820818 
    821819    // Put out the ClassInfo 
    822820    csym->Sclass = scclass; 
    823821    csym->Sfl = FLdata; 
    824822 
    825823    /* The layout is: 
     
    852850    dtdword(&dt, 0);                    // monitor 
    853851 
    854852    // initializer[] 
    855853    dtdword(&dt, 0);                    // size 
    856854    dtdword(&dt, 0);                    // initializer 
    857855 
    858856    // name[] 
    859857    const char *name = toPrettyChars(); 
    860858    size_t namelen = strlen(name); 
    861859    dtdword(&dt, namelen); 
    862860    dtabytes(&dt, TYnptr, 0, namelen + 1, name); 
    863861 
    864862    // vtbl[] 
    865863    dtdword(&dt, 0); 
    866864    dtdword(&dt, 0); 
    867865 
    868866    // vtblInterfaces->data[] 
    869867    dtdword(&dt, vtblInterfaces->dim); 
    870868    if (vtblInterfaces->dim) 
    871869    { 
     870        offset = global.params.isX86_64 ? CLASSINFO_SIZE_64 : CLASSINFO_SIZE;    // must be ClassInfo.size 
    872871        if (classinfo) 
    873872        { 
    874             if (classinfo->structsize != CLASSINFO_SIZE
     873            if (classinfo->structsize != offset
    875874            { 
    876875                error("mismatch between dmd and object.d or object.di found. Check installation and import paths with -v compiler switch."); 
    877876                fatal(); 
    878877            } 
    879878        } 
    880         offset = CLASSINFO_SIZE; 
    881879        dtxoff(&dt, csym, offset, TYnptr);      // (*) 
    882880    } 
    883881    else 
    884882        dtdword(&dt, 0); 
    885883 
    886884    // base 
    887885    assert(!baseClass); 
    888886    dtdword(&dt, 0); 
    889887 
    890888    // dtor 
    891889    dtdword(&dt, 0); 
    892890 
    893891    // invariant 
    894892    dtdword(&dt, 0); 
    895893 
    896894    // flags 
    897895    dtdword(&dt, 4 | isCOMinterface() | 32); 
    898896 
    899897    // deallocator 
    900898    dtdword(&dt, 0); 
  • trunk/src/aggregate.h

    r520 r618  
    172172    Type *type;                         // (before semantic processing) 
    173173    enum PROT protection;               // protection for the base interface 
    174174 
    175175    ClassDeclaration *base; 
    176176    int offset;                         // 'this' pointer offset 
    177177    Array vtbl;                         // for interfaces: Array of FuncDeclaration's 
    178178                                        // making up the vtbl[] 
    179179 
    180180    int baseInterfaces_dim; 
    181181    BaseClass *baseInterfaces;          // if BaseClass is an interface, these 
    182182                                        // are a copy of the InterfaceDeclaration::interfaces 
    183183 
    184184    BaseClass(); 
    185185    BaseClass(Type *type, enum PROT protection); 
    186186 
    187187    int fillVtbl(ClassDeclaration *cd, Array *vtbl, int newinstance); 
    188188    void copyBaseInterfaces(BaseClasses *); 
    189189}; 
    190190 
    191191#if DMDV2 
     192#define CLASSINFO_SIZE_64  (0x3C+12+4)     // value of ClassInfo.size 
    192193#define CLASSINFO_SIZE  (0x3C+12+4)     // value of ClassInfo.size 
    193194#else 
    194195#define CLASSINFO_SIZE  (0x3C+12+4)     // value of ClassInfo.size 
    195196#endif 
    196197 
    197198struct ClassDeclaration : AggregateDeclaration 
    198199{ 
    199200    static ClassDeclaration *object; 
    200201    static ClassDeclaration *classinfo; 
    201202 
    202203    ClassDeclaration *baseClass;        // NULL only if this is Object 
    203204#if DMDV1 
    204205    CtorDeclaration *ctor; 
    205206    CtorDeclaration *defaultCtor;       // default constructor 
    206207#endif 
    207208    FuncDeclaration *staticCtor; 
    208209    FuncDeclaration *staticDtor; 
    209210    Array vtbl;                         // Array of FuncDeclaration's making up the vtbl[] 
    210211    Array vtblFinal;                    // More FuncDeclaration's that aren't in vtbl[] 
    211212 
  • trunk/src/backend/cdef.h

    r593 r618  
    879879    immed_t immed;              // immediate values in registers 
    880880    regm_t mvar;                // mask of register variables 
    881881    regm_t mpvar;               // mask of SCfastpar register variables 
    882882    regm_t indexregs;           // !=0 if more than 1 uncommitted index register 
    883883    regm_t used;                // mask of registers used 
    884884    regm_t params;              // mask of registers which still contain register 
    885885                                // function parameters 
    886886}; 
    887887 
    888888/********************************* 
    889889 * Bootstrap complex types. 
    890890 */ 
    891891 
    892892#include "bcomplex.h" 
    893893 
    894894/********************************* 
    895895 * Union of all data types. Storage allocated must be the right 
    896896 * size of the data on the TARGET, not the host. 
    897897 */ 
    898898 
     899struct Cent 
     900{ 
     901    targ_ullong lsw; 
     902    targ_ullong msw; 
     903}; 
     904 
    899905union eve 
    900906{ 
    901907        targ_char       Vchar; 
    902908        targ_schar      Vschar; 
    903909        targ_uchar      Vuchar; 
    904910        targ_short      Vshort; 
    905911        targ_ushort     Vushort; 
    906912        targ_int        Vint;    // also used for tmp numbers (FLtmp) 
    907913        targ_uns        Vuns; 
    908914        targ_long       Vlong; 
    909915        targ_ulong      Vulong; 
    910916        targ_llong      Vllong; 
    911917        targ_ullong     Vullong; 
     918        Cent            Vcent; 
    912919        targ_float      Vfloat; 
    913920        targ_double     Vdouble; 
    914921        targ_ldouble    Vldouble; 
    915922        Complex_f       Vcfloat;   // 2x float 
    916923        Complex_d       Vcdouble;  // 2x double 
    917924        Complex_ld      Vcldouble; // 2x long double 
    918925        targ_size_t     Vpointer; 
    919926        targ_ptrdiff_t  Vptrdiff; 
    920927        targ_uchar      Vreg;   // register number for OPreg elems 
    921928        struct                  // 48 bit 386 far pointer 
    922929        {   targ_long   Voff; 
    923930            targ_ushort Vseg; 
    924931        } Vfp; 
    925932        struct 
    926933        { 
    927934            targ_size_t Voffset;// offset from symbol 
    928935            Symbol *Vsym;       // pointer to symbol table 
    929936            union 
    930937            {   struct PARAM *Vtal;     // template-argument-list for SCfunctempl, 
    931938                                // used only to transmit it to cpp_overload() 
  • trunk/src/backend/cgcod.c

    r596 r618  
    18331833                r = retregs & ~(msavereg | regcon.cse.mops); 
    18341834                if (!r) 
    18351835                {   r = retregs & ~msavereg; 
    18361836                    if (!r) 
    18371837                        r = retregs; 
    18381838                } 
    18391839            } 
    18401840        } 
    18411841        if (0 && r & ~fregsaved) 
    18421842            r &= ~fregsaved; 
    18431843 
    18441844        if (size <= REGSIZE) 
    18451845        { 
    18461846            if (r & ~mBP) 
    18471847                r &= ~mBP; 
    18481848 
    18491849            // If only one index register, prefer to not use LSW registers 
    18501850            if (!regcon.indexregs && r & ~mLSW) 
    18511851                r &= ~mLSW; 
    18521852 
    1853             if (pass == PASSfinal && r & ~lastretregs && I32
     1853            if (pass == PASSfinal && r & ~lastretregs && !I16
    18541854            {   // Try not to always allocate the same register, 
    18551855                // to schedule better 
    18561856 
    18571857                r &= ~lastretregs; 
    18581858                if (r & ~last2retregs) 
    18591859                {   r &= ~last2retregs; 
    18601860                    if (r & ~last3retregs) 
    18611861                    {   r &= ~last3retregs; 
    18621862                        if (r & ~last4retregs) 
    18631863                        {   r &= ~last4retregs; 
    18641864//                          if (r & ~last5retregs) 
    18651865//                              r &= ~last5retregs; 
    18661866                        } 
    18671867                    } 
    18681868                } 
    18691869                if (r & ~mfuncreg) 
    18701870                    r &= ~mfuncreg; 
    18711871            } 
    18721872            reg = findreg(r); 
    18731873            retregs = mask[reg]; 
     
    27142714    #define SMAX 64 
    27152715    static char str[NUM][SMAX + 1]; 
    27162716    static int i; 
    27172717    char *p; 
    27182718    char *s; 
    27192719    int j; 
    27202720 
    27212721    if (rm == 0) 
    27222722        return "0"; 
    27232723    if (rm == ALLREGS) 
    27242724        return "ALLREGS"; 
    27252725    if (rm == BYTEREGS) 
    27262726        return "BYTEREGS"; 
    27272727    if (rm == allregs) 
    27282728        return "allregs"; 
    27292729    p = str[i]; 
    27302730    if (++i == NUM) 
    27312731        i = 0; 
    27322732    s = p; 
    27332733    *p = 0; 
    2734     for (j = 0; j < 23; j++) 
     2734    for (j = 0; j < 32; j++) 
    27352735    { 
    27362736        if (mask[j] & rm) 
    27372737        { 
    27382738            strcat(p,regstring[j]); 
    27392739            rm &= ~mask[j]; 
    27402740            if (rm) 
    27412741                strcat(p,"|"); 
    27422742        } 
    27432743    } 
    27442744    if (rm) 
    27452745    {   s = p + strlen(p); 
    27462746        sprintf(s,"x%02x",rm); 
    27472747    } 
    27482748    assert(strlen(p) <= SMAX); 
    27492749    return strdup(p); 
    27502750} 
    27512751 
    27522752#endif 
    27532753 
    27542754#endif // !SPP 
  • trunk/src/backend/cgelem.c

    r500 r618  
    19931993                    e->E1->Ety = touns(tym); 
    19941994                    break; 
    19951995 
    19961996                case OPmod: 
    19971997                    op = OPand; 
    19981998                    goto L3; 
    19991999                case OPmodass: 
    20002000                    op = OPandass; 
    20012001                L3: 
    20022002                    e2->EV.Vullong = el_tolong(e2) - 1; 
    20032003                    break; 
    20042004 
    20052005                default: 
    20062006                    assert(0); 
    20072007            } 
    20082008            e->Eoper = op; 
    20092009            return optelem(e,TRUE); 
    20102010        } 
    20112011#if TARGET_MAC 
    20122012        if (j != -1) 
    2013         {   elem *ea; 
    2014  
    2015             ea = el_copytree(e->E1); 
     2013        { 
     2014            elem *ea = el_copytree(e->E1); 
    20162015            e2->EV.Vint = j; 
    20172016            e->Eoper = OPshr; 
    20182017            e->E1->Ety = touns(tym); 
    20192018            e2->Ety = TYint; 
    20202019            e = el_una(OPneg,tym,e); 
    20212020            e = el_bin(OPeq,tym,ea,e); 
    20222021            return optelem(e,TRUE); 
    20232022        } 
    20242023#endif 
    20252024      } 
    20262025#if TARGET_MAC 
    20272026        unsigned short op; 
    20282027        tym_t tym2; 
    20292028        elem *e1 = e->E1; 
    20302029 
    20312030        tym = e->E1->Ety; 
    20322031        op = e1->Eoper; 
    20332032        if (op == OPu16_32 && e2->EV.Vulong <= (targ_ulong) SHORTMASK || 
    20342033         op == OPshtlng && e2->EV.Vlong == (targ_short) e2->EV.Vlong) 
    20352034                { 
     
    20802079 
    20812080    if (OPTIMIZER) 
    20822081    { 
    20832082        if (tyintegral(tym) && (e->Eoper == OPdiv || e->Eoper == OPmod)) 
    20842083        {   int sz = tysize(tym); 
    20852084 
    20862085            // See if we can replace with OPremquo 
    20872086            if (sz == intsize) 
    20882087            { 
    20892088                // Don't do it if there are special code sequences in the 
    20902089                // code generator (see cdmul()) 
    20912090                int pow2; 
    20922091                if (e->E2->Eoper == OPconst && 
    20932092                    sz == REGSIZE && !uns && 
    20942093                    (pow2 = ispow2(el_tolong(e->E2))) != -1 && 
    20952094                    !(config.target_cpu < TARGET_80286 && pow2 != 1 && e->Eoper == OPdiv) 
    20962095                   ) 
    20972096                    ; 
    20982097                else 
    20992098                { 
    2100                     int op; 
    2101  
    2102                     op = OPmsw; 
     2099                    assert(sz == 2 || sz == 4); 
     2100                    int op = OPmsw; 
    21032101                    if (e->Eoper == OPdiv) 
    21042102                    { 
    21052103                        op = (sz == 2) ? OP32_16 : OP64_32; 
    21062104                    } 
    21072105                    e->Eoper = OPremquo; 
    21082106                    e = el_una(op, tym, e); 
    21092107                    e->E1->Ety = (sz == 2) ? TYlong : TYllong; 
    21102108                } 
    21112109            } 
    21122110        } 
    21132111    } 
    21142112 
    21152113    return e; 
    21162114} 
    21172115 
    21182116 
    21192117/************************** 
    21202118 * Convert (a op b) op c to a op (b op c). 
    21212119 */ 
    21222120 
     
    38243822        if (tysize(ty) != tysize(e->E1->E1->Ety)) 
    38253823            break; 
    38263824        e = el_selecte1(el_selecte1(e)); 
    38273825        e->Ety = ty; 
    38283826        break; 
    38293827 
    38303828    case OPrpair: 
    38313829        if (tysize(ty) != tysize(e->E1->E2->Ety)) 
    38323830            break; 
    38333831        e = el_selecte2(el_selecte1(e)); 
    38343832        e->Ety = ty; 
    38353833        break; 
    38363834 
    38373835    case OPvar:                 // simply paint type of variable 
    38383836    case OPind: 
    38393837        e = el_selecte1(e); 
    38403838        break; 
    38413839 
    38423840    case OPshr:                 // OP64_32(x >> 32) => OPmsw(x) 
    38433841        if (e1->E2->Eoper == OPconst && 
    3844             el_tolong(e1->E2) == 32
     3842            el_tolong(e1->E2) == 32 && !I64
    38453843        { 
    38463844            e->Eoper = OPmsw; 
    38473845            e->E1 = el_selecte1(e->E1); 
    38483846        } 
    38493847        break; 
    38503848  } 
    38513849  return e; 
    38523850} 
    38533851 
    38543852 
    38553853/******************************* 
    38563854 * Convert complex to real. 
    38573855 */ 
    38583856 
    38593857STATIC elem *elc_r(elem *e) 
    38603858{ 
    38613859    elem *e1 = e->E1; 
    38623860 
    38633861    if (e1->Eoper == OPvar || e1->Eoper == OPind) 
    38643862    { 
  • trunk/src/backend/cgreg.c

    r569 r618  
    675675        } 
    676676        if (inoutp == 1) 
    677677            cstore = cat(cstore,c); 
    678678        else 
    679679            cload = cat(cload,c); 
    680680        break; 
    681681    } 
    682682    el_free(e); 
    683683 
    684684    // Store old register values before loading in new ones 
    685685    *pcstore = cstore; 
    686686    *pcload = cload; 
    687687} 
    688688 
    689689/*************************** 
    690690 * Map symbol s into registers [NOREG,reglsw] or [regmsw, reglsw]. 
    691691 */ 
    692692 
    693693void cgreg_map(Symbol *s, unsigned regmsw, unsigned reglsw) 
    694694{ 
    695     assert(reglsw < 8); 
     695    assert(I64 || reglsw < 8); 
    696696 
    697697    if (vec_disjoint(s->Srange,regrange[reglsw]) && 
    698698        (regmsw == NOREG || vec_disjoint(s->Srange,regrange[regmsw])) 
    699699       ) 
    700700    { 
    701701        s->Sfl = FLreg; 
    702702        vec_copy(s->Slvreg,s->Srange); 
    703703    } 
    704704    else 
    705705    { 
    706706        s->Sflags |= SFLspill; 
    707707 
    708708        // Already computed by cgreg_benefit() 
    709709        //vec_sub(s->Slvreg,s->Srange,regrange[reglsw]); 
    710710 
    711711        if (s->Sfl == FLreg)            // if reassigned 
    712712        { 
    713713            switch (s->Sclass) 
    714714            { 
    715715                case SCauto: 
     
    897897            #ifdef DEBUG 
    898898            if (debugr) 
    899899            if (s->Sfl == FLreg) 
    900900                printf("symbol '%s' is in reg %s\n",s->Sident,regm_str(s->Sregm)); 
    901901            else if (s->Sflags & SFLspill) 
    902902                printf("symbol '%s' spilled in reg %s\n",s->Sident,regm_str(s->Sregm)); 
    903903            else 
    904904                printf("symbol '%s' is not a candidate\n",s->Sident); 
    905905            #endif 
    906906            continue; 
    907907        } 
    908908 
    909909        char *pseq; 
    910910        char *pseqmsw = NULL; 
    911911 
    912912        ty = s->ty(); 
    913913        sz = tysize(ty); 
    914914 
    915915        #ifdef DEBUG 
    916916            if (debugr) 
    917             {   printf("symbol '%3s', ty x%lx weight x%x sz %d\n   ", 
    918                 s->Sident,ty,s->Sweight,sz); 
     917            {   printf("symbol '%3s', ty x%x weight x%x sz %d\n   ", 
     918                s->Sident,ty,s->Sweight,(int)sz); 
    919919                vec_println(s->Srange); 
    920920            } 
    921921        #endif 
    922922 
    923923        if (I64) 
    924924        { 
    925925            if (sz == REGSIZE * 2) 
    926926            { 
    927927                static char seqmsw[] = {CX,DX,NOREG}; 
    928928                static char seqlsw[] = {AX,BX,SI,DI,NOREG}; 
    929929                pseq = seqlsw; 
    930930                pseqmsw = seqmsw; 
    931931            } 
    932932            else 
    933933            {   // R10 is reserved for the static link 
    934934                static char sequence[] = {AX,CX,DX,SI,DI,R8,R9,R11,BX,R12,R13,R14,R15,BP,NOREG}; 
    935935                pseq = sequence; 
    936936            } 
    937937        } 
    938938        else if (I32) 
  • trunk/src/backend/cgsched.c

    r596 r618  
    31613161 
    31623162    if (ci == NULL) 
    31633163    { 
    31643164        printf("Cinfo 0\n"); 
    31653165        return; 
    31663166    } 
    31673167 
    31683168    printf("Cinfo %p:  c %p, pair %x, sz %d, isz %d, flags - ", 
    31693169           ci,c,pair,sz,isz); 
    31703170    if (ci->flags & CIFLarraybounds) 
    31713171        printf("arraybounds,"); 
    31723172    if (ci->flags & CIFLea) 
    31733173        printf("ea,"); 
    31743174    if (ci->flags & CIFLnostage) 
    31753175        printf("nostage,"); 
    31763176    if (ci->flags & CIFLpush) 
    31773177        printf("push,"); 
    31783178    if (ci->flags & ~(CIFLarraybounds|CIFLnostage|CIFLpush|CIFLea)) 
    31793179        printf("bad flag,"); 
    31803180    printf("\n\tr %lx w %lx a %lx reg %x uops %x sibmodrm %x spadjust %ld\n", 
    3181             r,w,a,reg,uops,sibmodrm,spadjust); 
     3181            (long)r,(long)w,(long)a,reg,uops,sibmodrm,(long)spadjust); 
    31823182    if (ci->fp_op) 
    31833183        printf("\tfp_op %s, fxch_pre %x, fxch_post %x\n", 
    31843184                fpops[fp_op-1],fxch_pre,fxch_post); 
    31853185} 
    31863186#endif 
    31873187#endif 
  • trunk/src/backend/cod1.c

    r605 r618  
    17841784        else 
    17851785            assert(0); 
    17861786  } 
    17871787  code_orflag(ce,CFpsw); 
    17881788  return ce; 
    17891789} 
    17901790 
    17911791 
    17921792/****************************** 
    17931793 * Given the result of an expression is in retregs, 
    17941794 * generate necessary code to return result in *pretregs. 
    17951795 */ 
    17961796 
    17971797code *fixresult(elem *e,regm_t retregs,regm_t *pretregs) 
    17981798{ code *c,*ce; 
    17991799  unsigned reg,rreg; 
    18001800  regm_t forccs,forregs; 
    18011801  tym_t tym; 
    18021802  int sz; 
    18031803 
    1804 //  printf("fixresult(e = %p, retregs = %s, *pretregs = %s)\n", 
    1805 //      e,regm_str(retregs),regm_str(*pretregs)); 
     1804  //printf("fixresult(e = %p, retregs = %s, *pretregs = %s)\n",e,regm_str(retregs),regm_str(*pretregs)); 
    18061805  if (*pretregs == 0) return CNIL;      /* if don't want result         */ 
    18071806  assert(e && retregs);                 /* need something to work with  */ 
    18081807  forccs = *pretregs & mPSW; 
    18091808  forregs = *pretregs & (mST01 | mST0 | mBP | ALLREGS | mES | mSTACK); 
    18101809  tym = tybasic(e->Ety); 
    18111810#if 0 
    18121811  if (tym == TYstruct) 
    18131812        // Hack to support cdstreq() 
    18141813        tym = TYfptr; 
    18151814#else 
    18161815  if (tym == TYstruct) 
    18171816        // Hack to support cdstreq() 
    18181817        tym = (forregs & mMSW) ? TYfptr : TYnptr; 
    18191818#endif 
    18201819  c = CNIL; 
    18211820  sz = tysize[tym]; 
    18221821  if (sz == 1) 
    18231822  { 
    18241823        assert(retregs & BYTEREGS); 
    18251824        unsigned reg = findreg(retregs); 
     
    33093308            if (I16 && config.target_cpu >= TARGET_80386 && sz > 2 && 
    33103309                !e->Ecount) 
    33113310            {   regsize = 4; 
    33123311                flag |= CFopsize; 
    33133312            } 
    33143313            ce = loadea(e,&cs,0xFF,6,sz - regsize,RMload,0);    // PUSH EA+sz-2 
    33153314            code_orflag(ce,flag); 
    33163315            ce = genadjesp(ce,REGSIZE); 
    33173316            stackpush += sz; 
    33183317            while ((targ_int)(sz -= regsize) > 0) 
    33193318            {   ce = cat(ce,loadea(e,&cs,0xFF,6,sz - regsize,RMload,0)); 
    33203319                code_orflag(ce,flag); 
    33213320                ce = genadjesp(ce,REGSIZE); 
    33223321            } 
    33233322        } 
    33243323    L2: 
    33253324        freenode(e); 
    33263325        c = cat(c,ce); 
    33273326        goto ret; 
    33283327    case OPconst: 
    3329     {   targ_int *pi; 
    3330         targ_short *ps; 
     3328    { 
    33313329        char pushi = 0; 
    33323330        unsigned flag = 0; 
    3333         int i; 
    33343331        int regsize = REGSIZE; 
    33353332        targ_int value; 
    33363333 
    33373334        if (tycomplex(tym)) 
    33383335            break; 
    33393336 
    33403337        if (I32 && szb == 10)           // special case for long double constants 
    33413338        { 
    33423339            assert(sz == 12); 
    33433340            value = ((unsigned short *)&e->EV.Vldouble)[4]; 
    33443341            stackpush += sz; 
    33453342            ce = genadjesp(NULL,sz); 
    3346             for (i = 2; i >= 0; i--) 
     3343            for (int i = 2; i >= 0; i--) 
    33473344            { 
    33483345                if (reghasvalue(allregs, value, &reg)) 
    33493346                    ce = gen1(ce,0x50 + reg);           // PUSH reg 
    33503347                else 
    33513348                    ce = genc2(ce,0x68,0,value);        // PUSH value 
    33523349                value = ((unsigned *)&e->EV.Vldouble)[i - 1]; 
    33533350            } 
    33543351            goto L2; 
    33553352        } 
    33563353 
    3357         assert(sz <= LNGDBLSIZE); 
    3358         i = sz; 
    3359         if (I32 && i == 2) 
     3354        assert(I64 || sz <= LNGDBLSIZE); 
     3355        int i = sz; 
     3356        if (!I16 && i == 2) 
    33603357            flag = CFopsize; 
    33613358 
    33623359        if (config.target_cpu >= TARGET_80286) 
    33633360//       && (e->Ecount == 0 || e->Ecount != e->Ecomsub)) 
    33643361        {   pushi = 1; 
    33653362            if (I16 && config.target_cpu >= TARGET_80386 && i >= 4) 
    33663363            {   regsize = 4; 
    33673364                flag = CFopsize; 
    33683365            } 
    33693366        } 
    33703367        else if (i == REGSIZE) 
    33713368            break; 
    33723369 
    33733370        stackpush += sz; 
    33743371        ce = genadjesp(NULL,sz); 
    3375         pi = (targ_long *) &e->EV.Vdouble; 
    3376         ps = (targ_short *) pi; 
     3372        targ_uns *pi = (targ_uns *) &e->EV.Vdouble; 
     3373        targ_ushort *ps = (targ_ushort *) pi; 
     3374        targ_ullong *pl = (targ_ullong *)pi; 
    33773375        i /= regsize; 
    33783376        do 
    33793377        {   code *cp; 
    33803378 
    33813379            if (i)                      /* be careful not to go negative */ 
    33823380                i--; 
    3383             value = (regsize == 4) ? pi[i] : ps[i]; 
     3381            targ_size_t value = (regsize == 4) ? pi[i] : ps[i]; 
     3382            if (regsize == 8) 
     3383                value = pl[i]; 
    33843384            if (pushi) 
    33853385            { 
    33863386                if (regsize == REGSIZE && reghasvalue(allregs,value,&reg)) 
    33873387                    goto Preg; 
    33883388                ce = genc2(ce,(szb == 1) ? 0x6A : 0x68,0,value); // PUSH value 
    33893389            } 
    33903390            else 
    33913391            { 
    33923392                ce = regwithvalue(ce,allregs,value,&reg,0); 
    33933393            Preg: 
    33943394                ce = genpush(ce,reg);         // PUSH reg 
    33953395            } 
    33963396            code_orflag(ce,flag);                       /* operand size */ 
    33973397        } while (i); 
    33983398        goto L2; 
    33993399    } 
    34003400    default: 
    34013401        break; 
    34023402  } 
    34033403  retregs = tybyte(tym) ? BYTEREGS : allregs; 
     
    34493449                    c2 = genc1(CNIL,op,(modregrm(0,4,SP) << 8) | modregxrm(2,r,4),FLconst,sz/2); 
    34503450                    pop87(); 
    34513451                } 
    34523452                pop87(); 
    34533453                c2 = gen2sib(c2,op,modregrm(0,r,4),modregrm(0,4,SP));   // FSTP [ESP] 
    34543454            } 
    34553455            else 
    34563456            { 
    34573457                retregs = IDXREGS;                      /* get an index reg */ 
    34583458                c1 = allocreg(&retregs,&reg,TYoffset); 
    34593459                c1 = genregs(c1,0x89,SP,reg);           /* MOV reg,SP    */ 
    34603460                pop87(); 
    34613461                c2 = gen2(CNIL,op,modregrm(0,r,regtorm[reg]));          // FSTP [reg] 
    34623462            } 
    34633463            if (LARGEDATA) 
    34643464                c2->Iflags |= CFss;     /* want to store into stack     */ 
    34653465            genfwait(c2);               // FWAIT 
    34663466            c = cat3(c,c1,c2); 
    34673467            goto ret; 
    34683468        } 
    3469         else if (!I32 && (tym == TYdouble || tym == TYdouble_alias)) 
     3469        else if (I16 && (tym == TYdouble || tym == TYdouble_alias)) 
    34703470            retregs = mSTACK; 
    34713471  } 
    34723472#if LONGLONG 
    3473   else if (!I32 && sz == 8)             // if long long 
     3473  else if (I16 && sz == 8)             // if long long 
    34743474        retregs = mSTACK; 
    34753475#endif 
    34763476  c = cat(c,scodelem(e,&retregs,0,TRUE)); 
    34773477  if (retregs != mSTACK)                /* if stackpush not already inc'd */ 
    34783478      stackpush += sz; 
    34793479  if (sz <= REGSIZE) 
    34803480  { 
    34813481        c = genpush(c,findreg(retregs));        // PUSH reg 
    34823482        genadjesp(c,REGSIZE); 
    34833483  } 
    34843484  else if (sz == REGSIZE * 2) 
    34853485  {     c = genpush(c,findregmsw(retregs));     // PUSH msreg 
    34863486        genpush(c,findreglsw(retregs));         // PUSH lsreg 
    34873487        genadjesp(c,sz); 
    34883488  } 
    34893489ret: 
    34903490  return cat(cp,c); 
    34913491} 
    34923492 
    34933493 
     
    36933693            } 
    36943694            ce = movregconst(ce,reg,msw,mswflags); 
    36953695        } 
    36963696        else if (sz == 8) 
    36973697        { 
    36983698            if (I32) 
    36993699            {   targ_long *p = (targ_long *) &e->EV.Vdouble; 
    37003700                ce = movregconst(CNIL,findreglsw(forregs),p[0],0); 
    37013701                ce = movregconst(ce,findregmsw(forregs),p[1],0); 
    37023702            } 
    37033703            else 
    37043704            {   targ_short *p = (targ_short *) &e->EV.Vdouble; 
    37053705 
    37063706                assert(reg == AX); 
    37073707                ce = movregconst(CNIL,AX,p[3],0);       /* MOV AX,p[3]  */ 
    37083708                ce = movregconst(ce,DX,p[0],0); 
    37093709                ce = movregconst(ce,CX,p[1],0); 
    37103710                ce = movregconst(ce,BX,p[2],0); 
    37113711            } 
    37123712        } 
     3713        else if (I64 && sz == 16) 
     3714        { 
     3715            ce = movregconst(CNIL,findreglsw(forregs),e->EV.Vcent.lsw,0); 
     3716            ce = movregconst(ce,findregmsw(forregs),e->EV.Vcent.msw,0); 
     3717        } 
    37133718        else 
    37143719                assert(0); 
    37153720        c = cat(c,ce); 
    37163721  } 
    37173722  else 
    37183723  { 
    37193724    // See if we can use register that parameter was passed in 
    37203725    if (regcon.params && e->EV.sp.Vsym->Sclass == SCfastpar && 
    37213726        regcon.params & mask[e->EV.sp.Vsym->Spreg] && 
    37223727        !(e->Eoper == OPvar && e->EV.sp.Voffset > 0) && // Must be at the base of that variable 
    37233728        sz <= REGSIZE)                  // make sure no 'paint' to a larger size happened 
    37243729    { 
    37253730        reg = e->EV.sp.Vsym->Spreg; 
    37263731        forregs = mask[reg]; 
    37273732        mfuncreg &= ~forregs; 
    37283733        regcon.used |= forregs; 
    37293734        return fixresult(e,forregs,pretregs); 
    37303735    } 
    37313736 
    37323737    c = allocreg(&forregs,&reg,tym);            /* allocate registers   */ 
  • trunk/src/backend/cod4.c

    r596 r618  
    24612461  {     assert(i < arraysize(clib)); 
    24622462        if (clib[i][0] == e->Eoper) 
    24632463        {   c2 = callclib(e,clib[i][1],pretregs,0); 
    24642464            break; 
    24652465        } 
    24662466  } 
    24672467  return cat(c1,c2); 
    24682468} 
    24692469 
    24702470 
    24712471/*************************** 
    24722472 * Convert short to long. 
    24732473 * For OPs16_32, OPu16_32, OPptrlptr, OPu32_64, OPs32_64 
    24742474 */ 
    24752475 
    24762476code *cdshtlng(elem *e,regm_t *pretregs) 
    24772477{ code *c,*ce,*c1,*c2,*c3,*c4; 
    24782478  unsigned reg; 
    24792479  unsigned char op; 
    24802480  regm_t retregs; 
    2481   int e1comsub; 
    2482  
    2483   e1comsub = e->E1->Ecount; 
     2481 
     2482  //printf("cdshtlng(e = %p, *pretregs = %s)\n", e, regm_str(*pretregs)); 
     2483  int e1comsub = e->E1->Ecount; 
    24842484  if ((*pretregs & (ALLREGS | mBP)) == 0)       // if don't need result in regs 
    24852485    c = codelem(e->E1,pretregs,FALSE);  /* then conversion isn't necessary */ 
    24862486 
    24872487  else if ((op = e->Eoper) == OPptrlptr || 
    24882488           (I16 && op == OPu16_32) || 
    24892489           (I32 && op == OPu32_64) 
    24902490          ) 
    24912491  { 
    24922492        regm_t regm; 
    24932493        tym_t tym1; 
    24942494 
    24952495        retregs = *pretregs & mLSW; 
    24962496        assert(retregs); 
    24972497        tym1 = tybasic(e->E1->Ety); 
    24982498        c = codelem(e->E1,&retregs,FALSE); 
    24992499 
    25002500        regm = *pretregs & (mMSW & ALLREGS); 
    25012501        if (regm == 0)                  /* *pretregs could be mES       */ 
    25022502            regm = mMSW & ALLREGS; 
    25032503        ce = allocreg(&regm,&reg,TYint); 
    25042504        if (e1comsub) 
    25052505            ce = cat(ce,getregs(retregs)); 
    25062506        if (op == OPptrlptr) 
    25072507        {   int segreg; 
    25082508 
    25092509            /* BUG: what about pointers to functions?   */ 
    25102510            switch (tym1) 
    25112511            { 
    25122512                case TYnptr:    segreg = SEG_DS;        break; 
    25132513                case TYcptr:    segreg = SEG_CS;        break; 
    25142514                case TYsptr:    segreg = SEG_SS;        break; 
    25152515                default:        assert(0); 
    25162516            } 
    25172517            ce = gen2(ce,0x8C,modregrm(3,segreg,reg));  /* MOV reg,segreg */ 
    25182518        } 
    25192519        else 
    25202520            ce = movregconst(ce,reg,0,0);               /* 0 extend     */ 
    25212521 
    25222522        c = cat3(c,ce,fixresult(e,retregs | regm,pretregs)); 
    25232523  } 
    2524   else if (!I16 && (op == OPs16_32 || op == OPu16_32)) 
     2524  else if (I64 && op == OPu32_64) 
     2525  { 
     2526        elem *e1 = e->E1; 
     2527        retregs = *pretregs; 
     2528        if (e1->Eoper == OPvar || (e1->Eoper == OPind && !e1->Ecount)) 
     2529        {   code cs; 
     2530 
     2531            c1 = allocreg(&retregs,&reg,TYint); 
     2532            c2 = NULL; 
     2533            c3 = loadea(e1,&cs,0x8B,reg,0,retregs,retregs);        //  MOV Ereg,EA 
     2534            freenode(e1); 
     2535        } 
     2536        else 
     2537        { 
     2538            *pretregs &= ~mPSW;                 // flags are set by eval of e1 
     2539            c1 = codelem(e1,&retregs,FALSE); 
     2540            c2 = getregs(retregs); 
     2541            reg = findreg(retregs); 
     2542            c3 = genregs(NULL,0x89,reg,reg);    // MOV Ereg,Ereg 
     2543        } 
     2544        c4 = fixresult(e,retregs,pretregs); 
     2545        c = cat4(c1,c2,c3,c4); 
     2546  } 
     2547  else if (!I16 && (op == OPs16_32 || op == OPu16_32) || 
     2548            I64 && op == OPs32_64) 
    25252549  { 
    25262550    elem *e11; 
    25272551 
    25282552    elem *e1 = e->E1; 
    25292553 
    25302554    if (e1->Eoper == OPu8_16 && !e1->Ecount && 
    25312555        ((e11 = e1->E1)->Eoper == OPvar || (e11->Eoper == OPind && !e11->Ecount)) 
    25322556       ) 
    25332557    {   code cs; 
    25342558 
    25352559        retregs = *pretregs & BYTEREGS; 
    25362560        if (!retregs) 
    25372561            retregs = BYTEREGS; 
    25382562        c1 = allocreg(&retregs,&reg,TYint); 
    25392563        c2 = movregconst(NULL,reg,0,0);                         //  XOR reg,reg 
    25402564        c3 = loadea(e11,&cs,0x8A,reg,0,retregs,retregs);        //  MOV regL,EA 
    25412565        freenode(e11); 
    25422566        freenode(e1); 
    25432567    } 
    2544     else if (e1->Eoper == OPvar || 
     2568    else if (e1->Eoper == OPvar && op != OPs32_64 || 
    25452569        (e1->Eoper == OPind && !e1->Ecount)) 
    25462570    {   code cs; 
    25472571        unsigned opcode; 
    25482572 
    25492573        if (op == OPu16_32 && config.flags4 & CFG4speed) 
    25502574            goto L2; 
    25512575        retregs = *pretregs; 
    25522576        c1 = allocreg(&retregs,&reg,TYint); 
    25532577        opcode = (op == OPu16_32) ? 0x0FB7 : 0x0FBF; /* MOVZX/MOVSX reg,EA */ 
    25542578        c2 = loadea(e1,&cs,opcode,reg,0,0,retregs); 
    25552579        c3 = CNIL; 
    25562580        freenode(e1); 
    25572581    } 
    25582582    else 
    25592583    { 
    25602584    L2: 
    25612585        retregs = *pretregs; 
    25622586        *pretregs &= ~mPSW;             /* flags are already set        */ 
     2587        if (op == OPs32_64) 
     2588            retregs = mAX; 
    25632589        c1 = codelem(e1,&retregs,FALSE); 
    25642590        c2 = getregs(retregs); 
    25652591        if (op == OPu16_32 && c1) 
    2566         {   code *cx; 
    2567  
    2568             cx = code_last(c1); 
     2592        { 
     2593            code *cx = code_last(c1); 
    25692594            if (cx->Iop == 0x81 && (cx->Irm & modregrm(3,7,0)) == modregrm(3,4,0)) 
    25702595            { 
    25712596                // Convert AND of a word to AND of a dword, zeroing upper word 
    25722597                retregs = mask[cx->Irm & 7]; 
    25732598                cx->Iflags &= ~CFopsize; 
    25742599                cx->IEV2.Vint &= 0xFFFF; 
    25752600                goto L1; 
    25762601            } 
    25772602        } 
    25782603        if (op == OPs16_32 && retregs == mAX) 
    25792604            c2 = gen1(c2,0x98);         /* CWDE                         */ 
     2605        else if (op == OPs32_64 && retregs == mAX) 
     2606        {   c2 = gen1(c2,0x98);         /* CDQE                         */ 
     2607            code_orrex(c2, REX_W); 
     2608        } 
    25802609        else 
    25812610        { 
    25822611            reg = findreg(retregs); 
    25832612            if (config.flags4 & CFG4speed && op == OPu16_32) 
    25842613            {   // AND reg,0xFFFF 
    25852614                c3 = genc2(NULL,0x81,modregrm(3,4,reg),0xFFFFu); 
    25862615            } 
    25872616            else 
    25882617            { 
    25892618                unsigned iop = (op == OPu16_32) ? 0x0FB7 : 0x0FBF; /* MOVZX/MOVSX reg,reg */ 
    25902619                c3 = genregs(CNIL,iop,reg,reg); 
    25912620            } 
    25922621            c2 = cat(c2,c3); 
    25932622        } 
    25942623     L1: 
    25952624        c3 = e1comsub ? getregs(retregs) : CNIL; 
    25962625    } 
    25972626    c4 = fixresult(e,retregs,pretregs); 
    25982627    c = cat4(c1,c2,c3,c4); 
    25992628  } 
     
    28062835 
    28072836  /* We "destroy" a reg by assigning it the result of a new e, even     */ 
    28082837  /* though the values are the same. Weakness of our CSE strategy that  */ 
    28092838  /* a register can only hold the contents of one elem at a time.       */ 
    28102839  if (e->Ecount) 
    28112840        c = cat(c,getregs(retregs)); 
    28122841  else 
    28132842        useregs(retregs); 
    28142843 
    28152844#ifdef DEBUG 
    28162845  if (!(!*pretregs || retregs)) 
    28172846        WROP(e->Eoper), 
    28182847        printf(" *pretregs = x%x, retregs = x%x, e = %p\n",*pretregs,retregs,e); 
    28192848#endif 
    28202849  assert(!*pretregs || retregs); 
    28212850  return cat(c,fixresult(e,retregs,pretregs));  /* lsw only             */ 
    28222851} 
    28232852 
    28242853/********************************************** 
    28252854 * Get top 32 bits of 64 bit value (I32) 
    2826  * or top 16 bits of 32 bit value (16 bit code). 
     2855 * or top 16 bits of 32 bit value (I16) 
     2856 * or top 64 bits of 128 bit value (I64). 
    28272857 * OPmsw 
    28282858 */ 
    28292859 
    28302860code *cdmsw(elem *e,regm_t *pretregs) 
    28312861{   regm_t retregs; 
    28322862    code *c; 
    28332863 
    28342864    //printf("cdmsw(e->Ecount = %d)\n", e->Ecount); 
    28352865    assert(e->Eoper == OPmsw); 
    28362866 
    28372867    retregs = *pretregs ? ALLREGS : 0; 
    28382868    c = codelem(e->E1,&retregs,FALSE); 
    2839     retregs &= mMSW;                    // want LSW only 
     2869    retregs &= mMSW;                    // want MSW only 
    28402870 
    28412871    // We "destroy" a reg by assigning it the result of a new e, even 
    28422872    // though the values are the same. Weakness of our CSE strategy that 
    28432873    // a register can only hold the contents of one elem at a time. 
    28442874    if (e->Ecount) 
    28452875        c = cat(c,getregs(retregs)); 
    28462876    else 
    28472877        useregs(retregs); 
    28482878 
    28492879#ifdef DEBUG 
    28502880    if (!(!*pretregs || retregs)) 
    28512881    {   WROP(e->Eoper); 
    28522882        printf(" *pretregs = x%x, retregs = x%x\n",*pretregs,retregs); 
    28532883    } 
    28542884#endif 
    28552885    assert(!*pretregs || retregs); 
    28562886    return cat(c,fixresult(e,retregs,pretregs));        // msw only 
    28572887} 
    28582888 
    28592889 
  • trunk/src/backend/code.h

    r596 r618  
    8181 
    8282#define mR8     (1 << R8) 
    8383#define mR9     (1 << R9) 
    8484#define mR10    (1 << R10) 
    8585#define mR11    (1 << R11) 
    8686#define mR12    (1 << R12) 
    8787#define mR13    (1 << R13) 
    8888#define mR14    (1 << R14) 
    8989#define mR15    (1 << R15) 
    9090 
    9191#define mXMM0   (1 << XMM0) 
    9292#define mXMM1   (1 << XMM1) 
    9393#define mXMM2   (1 << XMM2) 
    9494#define mXMM3   (1 << XMM3) 
    9595#define mXMM4   (1 << XMM4) 
    9696#define mXMM5   (1 << XMM5) 
    9797#define mXMM6   (1 << XMM6) 
    9898#define mXMM7   (1 << XMM7) 
    9999#define XMMREGS  (mXMM0 |mXMM1 |mXMM2 |mXMM3 |mXMM4 |mXMM5 |mXMM6 |mXMM7) 
    100100 
    101 #define mES     (1 << ES)       // 0x10000 
    102 #define mPSW    (1 << PSW)      // 0x20000 
    103  
    104 #define mSTACK  (1 << STACK)    // 0x40000 
    105  
    106 #define mST0    (1 << ST0)      // 0x200000 
    107 #define mST01   (1 << ST01)     // 0x400000 
     101#define mES     (1 << ES)       // 0x1000000 
     102#define mPSW    (1 << PSW)      // 0x2000000 
     103 
     104#define mSTACK  (1 << STACK)    // 0x4000000 
     105 
     106#define mST0    (1 << ST0)      // 0x20000000 
     107#define mST01   (1 << ST01)     // 0x40000000 
    108108 
    109109// Flags for getlvalue (must fit in regm_t) 
    110110#define RMload  (1 << 30) 
    111111#define RMstore (1 << 31) 
    112112 
    113113#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS 
    114114    // To support positional independent code, 
    115115    // must be able to remove BX from available registers 
    116116extern regm_t ALLREGS; 
    117117#define ALLREGS_INIT            (mAX|mBX|mCX|mDX|mSI|mDI) 
    118118#define ALLREGS_INIT_PIC        (mAX|mCX|mDX|mSI|mDI) 
    119119extern regm_t BYTEREGS; 
    120120#define BYTEREGS_INIT           (mAX|mBX|mCX|mDX) 
    121121#define BYTEREGS_INIT_PIC       (mAX|mCX|mDX) 
    122122#else 
    123123#define ALLREGS                 (mAX|mBX|mCX|mDX|mSI|mDI) 
    124124#define ALLREGS_INIT            ALLREGS 
    125125#undef BYTEREGS 
    126126#define BYTEREGS                (mAX|mBX|mCX|mDX) 
    127127#endif 
     
    379379#define CFpsw          0x40     // we need the flags result after this instruction 
    380380#define CFopsize       0x80     // prefix with operand size 
    381381#define CFaddrsize    0x100     // prefix with address size 
    382382#define CFds          0x200     // need DS override (not with es, ss, or cs ) 
    383383#define CFcs          0x400     // need CS override 
    384384#define CFfs          0x800     // need FS override 
    385385#define CFgs    (CFcs | CFfs)   // need GS override 
    386386#define CFwait       0x1000     // If I32 it indicates when to output a WAIT 
    387387#define CFselfrel    0x2000     // if self-relative 
    388388#define CFunambig    0x4000     // indicates cannot be accessed by other addressing 
    389389                                // modes 
    390390#define CFtarg2      0x8000     // like CFtarg, but we can't optimize this away 
    391391#define CFvolatile  0x10000     // volatile reference, do not schedule 
    392392#define CFclassinit 0x20000     // class init code 
    393393#define CFoffset64  0x40000     // offset is 64 bits 
    394394#define CFpc32      0x80000     // I64: PC relative 32 bit fixup 
    395395 
    396396#define CFPREFIX (CFSEG | CFopsize | CFaddrsize) 
    397397#define CFSEG   (CFes | CFss | CFds | CFcs | CFfs | CFgs) 
    398398 
    399  
     399    /* The op code can be 1 to 3 bytes 
     400     */ 
    400401    unsigned Iop; 
    401402 
     403    /* The _EA is the "effective address" for the instruction, and consists of the modregrm byte, 
     404     * the sib byte, and the REX prefix byte. The 16 bit code generator just used the modregrm, 
     405     * the 32 bit x86 added the sib, and the 64 bit one added the rex. 
     406     */ 
    402407    union 
    403408    {   unsigned _Iea; 
    404409        struct 
    405410        { 
    406411            unsigned char _Irm;          // reg/mode 
    407412            unsigned char _Isib;         // SIB byte 
    408413            unsigned char _Irex;         // REX prefix 
    409414        } _ea; 
    410415    } _EA; 
    411416 
    412417#define Iea _EA._Iea 
    413418#define Irm _EA._ea._Irm 
    414419#define Isib _EA._ea._Isib 
    415420#define Irex _EA._ea._Irex 
     421 
     422 
     423    /* IFL1 and IEV1 are the first operand, which usually winds up being the offset to the Effective 
     424     * Address. IFL1 is the tag saying which variant type is in IEV1. IFL2 and IEV2 is the second 
     425     * operand, usually for immediate instructions. 
     426     */ 
    416427 
    417428    unsigned char IFL1,IFL2;    // FLavors of 1st, 2nd operands 
    418429    union evc IEV1;             // 1st operand, if any 
    419430      #define IEVpointer1 IEV1._EP.Vpointer 
    420431      #define IEVseg1     IEV1._EP.Vseg 
    421432      #define IEVsym1     IEV1.sp.Vsym 
    422433      #define IEVdsym1    IEV1.dsp.Vsym 
    423434      #define IEVoffset1  IEV1.sp.Voffset 
    424435      #define IEVlsym1    IEV1.lab.Vsym 
    425436      #define IEVint1     IEV1.Vint 
    426437    union evc IEV2;             // 2nd operand, if any 
    427438      #define IEVpointer2 IEV2._EP.Vpointer 
    428439      #define IEVseg2     IEV2._EP.Vseg 
    429440      #define IEVsym2     IEV2.sp.Vsym 
    430441      #define IEVdsym2    IEV2.dsp.Vsym 
    431442      #define IEVoffset2  IEV2.sp.Voffset 
    432443      #define IEVlsym2    IEV2.lab.Vsym 
    433444      #define IEVint2     IEV2.Vint 
    434445    void print();               // pretty-printer 
    435446 
  • trunk/src/backend/debug.c

    r487 r618  
    9090        dbg_printf("mTYcs|"); 
    9191#endif 
    9292    if (t & mTYconst) 
    9393        dbg_printf("mTYconst|"); 
    9494    if (t & mTYvolatile) 
    9595        dbg_printf("mTYvolatile|"); 
    9696#if TARGET_MAC 
    9797    if (t & mTYpasret) 
    9898        dbg_printf("mTYpasret|"); 
    9999    if (t & mTYmachdl) 
    100100        dbg_printf("mTYmachdl|"); 
    101101    if (t & mTYpasobj) 
    102102        dbg_printf("mTYpasobj|"); 
    103103#endif 
    104104#if linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4 
    105105    if (t & mTYtransu) 
    106106        dbg_printf("mTYtransu|"); 
    107107#endif 
    108108    t = tybasic(t); 
    109109    if (t >= TYMAX) 
    110     {   dbg_printf("TY %lx\n",t); 
     110    {   dbg_printf("TY %lx\n",(long)t); 
    111111        assert(0); 
    112112    } 
    113113    dbg_printf("TY%s ",tystring[tybasic(t)]); 
    114114} 
    115115 
    116116void WRBC(unsigned bc) 
    117117{ static char bcs[][7] = 
    118118        {"unde  ","goto  ","true  ","ret   ","retexp", 
    119119         "exit  ","asm   ","switch","ifthen","jmptab", 
    120120         "try   ","catch ","jump  ", 
    121121         "_try  ","_filte","_final","_ret  ","_excep", 
    122122         "jcatch", 
    123123         "jplace", 
    124124        }; 
    125125 
    126126    assert(sizeof(bcs) / sizeof(bcs[0]) == BCMAX); 
    127127    assert(bc < BCMAX); 
    128128    dbg_printf("BC%s",bcs[bc]); 
    129129} 
    130130 
     
    170170  } 
    171171  else if (e->Eoper == OPcomma && !nest) 
    172172  {     WReqn(e->E1); 
    173173        dbg_printf(";\n\t"); 
    174174        WReqn(e->E2); 
    175175  } 
    176176  else if (OTbinary(e->Eoper)) 
    177177  { 
    178178        if (OTbinary(e->E1->Eoper)) 
    179179        {       nest++; 
    180180                ferr("("); 
    181181                WReqn(e->E1); 
    182182                ferr(")"); 
    183183                nest--; 
    184184        } 
    185185        else 
    186186                WReqn(e->E1); 
    187187        ferr(" "); 
    188188        WROP(e->Eoper); 
    189189        if (e->Eoper == OPstreq) 
    190             dbg_printf("%ld",e->Enumbytes); 
     190            dbg_printf("%ld",(long)e->Enumbytes); 
    191191        ferr(" "); 
    192192        if (OTbinary(e->E2->Eoper)) 
    193193        {       nest++; 
    194194                ferr("("); 
    195195                WReqn(e->E2); 
    196196                ferr(")"); 
    197197                nest--; 
    198198        } 
    199199        else 
    200200                WReqn(e->E2); 
    201201  } 
    202202  else 
    203203  { 
    204204        switch (e->Eoper) 
    205205        {   case OPconst: 
    206206                switch (tybasic(e->Ety)) 
    207207                { 
    208208                    case TYfloat: 
    209209                        dbg_printf("%g <float> ",e->EV.Vfloat); 
    210210                        break; 
    211211                    case TYdouble: 
    212212                        dbg_printf("%g ",e->EV.Vdouble); 
    213213                        break; 
    214214                    default: 
    215215                        dbg_printf("%lld ",el_tolong(e)); 
    216216                        break; 
    217217                } 
    218218                break; 
    219219            case OPrelconst: 
    220220                ferr("#"); 
    221221                /* FALL-THROUGH */ 
    222222            case OPvar: 
    223223                dbg_printf("%s",e->EV.sp.Vsym->Sident); 
    224224                if (e->EV.sp.Vsym->Ssymnum != -1) 
    225225                    dbg_printf("(%d)",e->EV.sp.Vsym->Ssymnum); 
    226226                if (e->Eoffset != 0) 
    227                         dbg_printf(".%ld",e->Eoffset); 
     227                        dbg_printf(".%ld",(long)e->Eoffset); 
    228228                break; 
    229229            case OPasm: 
    230230#if TARGET_MAC 
    231231                if (e->Eflags & EFsmasm) 
    232232                    { 
    233233                    if (e->EV.mac.Vasmdat[1]) 
    234234                        dbg_printf("\"%c%c\"",e->EV.mac.Vasmdat[0],e->EV.mac.Vasmdat[1]); 
    235235                    else 
    236236                        dbg_printf("\"%c\"",e->EV.mac.Vasmdat[0]); 
    237237                    break; 
    238238                    }; 
    239239#endif 
    240240            case OPstring: 
    241241                dbg_printf("\"%s\"",e->EV.ss.Vstring); 
    242242                if (e->EV.ss.Voffset) 
    243                     dbg_printf("+%ld",e->EV.ss.Voffset); 
     243                    dbg_printf("+%ld",(long)e->EV.ss.Voffset); 
    244244                break; 
    245245            case OPmark: 
    246246            case OPgot: 
    247247            case OPframeptr: 
    248248                WROP(e->Eoper); 
    249249                break; 
    250250            case OPstrthis: 
    251251                break; 
    252252            default: 
    253253                WROP(e->Eoper); 
    254254                assert(0); 
    255255        } 
    256256  } 
    257257} 
    258258 
    259259void WRblocklist(list_t bl) 
    260260{ 
    261261        for (; bl; bl = list_next(bl)) 
    262262        {       register block *b = list_block(bl); 
    263263 
  • trunk/src/backend/dt.c

    r569 r618  
    185185    *pdtend = dt; 
    186186    pdtend = &dt->DTnext; 
    187187    return pdtend; 
    188188} 
    189189 
    190190/********************** 
    191191 * Construct a DTibytes record, and return it. 
    192192 */ 
    193193 
    194194dt_t ** dtdword(dt_t **pdtend, int value) 
    195195{   dt_t *dt; 
    196196 
    197197    while (*pdtend) 
    198198        pdtend = &((*pdtend)->DTnext); 
    199199    dt = dt_calloc(DT_ibytes); 
    200200    dt->DTn = 4; 
    201201 
    202202    union { char* cp; int* lp; } u; 
    203203    u.cp = dt->DTdata; 
    204204    *u.lp = value; 
     205 
     206    *pdtend = dt; 
     207    pdtend = &dt->DTnext; 
     208    return pdtend; 
     209} 
     210 
     211dt_t ** dtsize_t(dt_t **pdtend, targ_size_t value) 
     212{   dt_t *dt; 
     213 
     214    while (*pdtend) 
     215        pdtend = &((*pdtend)->DTnext); 
     216    dt = dt_calloc(DT_ibytes); 
     217    dt->DTn = NPTRSIZE; 
     218 
     219    union { char* cp; int* lp; } u; 
     220    u.cp = dt->DTdata; 
     221    *u.lp = value; 
     222    if (NPTRSIZE == 8) 
     223        u.lp[1] = value >> 32; 
    205224 
    206225    *pdtend = dt; 
    207226    pdtend = &dt->DTnext; 
    208227    return pdtend; 
    209228} 
    210229 
    211230/********************** 
    212231 * Concatenate two dt_t's. 
    213232 */ 
    214233 
    215234dt_t ** dtcat(dt_t **pdtend,dt_t *dt) 
    216235{ 
    217236    while (*pdtend) 
    218237        pdtend = &((*pdtend)->DTnext); 
    219238    *pdtend = dt; 
    220239    pdtend = &dt->DTnext; 
    221240    return pdtend; 
    222241} 
    223242 
    224243/********************** 
  • trunk/src/backend/dt.h

    r569 r618  
    3030 *                      the size 
    3131 *      DTcommon        # of 0 bytes (in a common block) 
    3232 *                      a 
    3333 *      DTxoff          offset from symbol 
    3434 *                      w a 
    3535 *                      w = symbol number (pointer for CPP) 
    3636 *                      a = offset 
    3737 *      DTcoff          offset into code segment 
    3838 *      DTend           mark end of list 
    3939 */ 
    4040 
    4141struct dt_t 
    4242{   dt_t *DTnext;                       // next in list 
    4343    char dt;                            // type (DTxxxx) 
    4444    unsigned char Dty;                  // pointer type 
    4545    union 
    4646    { 
    4747        struct                          // DTibytes 
    4848        {   char DTn_;                  // number of bytes 
    4949            #define DTn _DU._DI.DTn_ 
    50             char DTdata_[7];            // data 
     50            char DTdata_[8];            // data 
    5151            #define DTdata _DU._DI.DTdata_ 
    5252        }_DI; 
    5353        char DTonebyte_;                // DT1byte 
    5454        #define DTonebyte _DU.DTonebyte_ 
    5555        targ_size_t DTazeros_;          // DTazeros,DTcommon,DTsymsize 
    5656        #define DTazeros _DU.DTazeros_ 
    5757        struct                          // DTabytes 
    5858        { 
    5959            char *DTpbytes_;            // pointer to the bytes 
    6060            #define DTpbytes _DU._DN.DTpbytes_ 
    6161            unsigned DTnbytes_;         // # of bytes 
    6262            #define DTnbytes _DU._DN.DTnbytes_ 
    6363#if TX86 
    6464            int DTseg_;                 // segment it went into 
    6565            #define DTseg _DU._DN.DTseg_ 
    6666#endif 
    6767            targ_size_t DTabytes_;              // offset of abytes for DTabytes 
    6868            #define DTabytes _DU._DN.DTabytes_ 
    6969        }_DN; 
    7070        struct                          // DTxoff 
     
    8585    DT_1byte, 
    8686    DT_nbytes, 
    8787    DT_common, 
    8888    DT_symsize, 
    8989    DT_coff, 
    9090    DT_ibytes, // 8 
    9191}; 
    9292 
    9393#if TX86 
    9494dt_t *dt_calloc(char dtx); 
    9595void dt_free(dt_t *); 
    9696void dt_term(void); 
    9797#elif TARGET_MAC 
    9898dt_t *dt_calloc(void); 
    9999void dt_free(dt_t *); 
    100100#endif 
    101101 
    102102dt_t **dtnbytes(dt_t **,targ_size_t,const char *); 
    103103dt_t **dtabytes(dt_t **pdtend,tym_t ty, targ_size_t offset, targ_size_t size, const char *ptr); 
    104104dt_t **dtdword(dt_t **, int value); 
     105dt_t **dtsize_t(dt_t **, targ_size_t value); 
    105106dt_t **dtnzeros(dt_t **pdtend,targ_size_t size); 
    106107dt_t **dtxoff(dt_t **pdtend,symbol *s,targ_size_t offset,tym_t ty); 
    107108dt_t **dtselfoff(dt_t **pdtend,targ_size_t offset,tym_t ty); 
    108109dt_t **dtcoff(dt_t **pdtend,targ_size_t offset); 
    109110dt_t ** dtcat(dt_t **pdtend,dt_t *dt); 
    110111void dt_optimize(dt_t *dt); 
    111112void dtsymsize(symbol *); 
    112113void init_common(symbol *); 
    113114unsigned dt_size(dt_t *dtstart); 
    114115 
    115116#endif /* DT_H */ 
    116117 
  • trunk/src/backend/el.c

    r581 r618  
    29442944        case TYcldouble: 
    29452945        case TYcdouble: 
    29462946        case TYcfloat: 
    29472947#if !DDRT 
    29482948            result = (targ_llong)el_toldouble(e); 
    29492949#else 
    29502950            result = Xxtoi(el_toldouble(e)); 
    29512951#endif 
    29522952            break; 
    29532953 
    29542954#if SCPP 
    29552955        case TYmemptr: 
    29562956            ty = tybasic(tym_conv(e->ET)); 
    29572957            goto L1; 
    29582958#endif 
    29592959        default: 
    29602960#if SCPP 
    29612961            // Can happen as result of syntax errors 
    29622962            assert(errcnt); 
    29632963#else 
     2964#ifdef DEBUG 
     2965            elem_print(e); 
     2966            *(char*)0=0; 
     2967#endif 
    29642968            assert(0); 
    29652969#endif 
    29662970    } 
    29672971    return result; 
    29682972} 
    29692973 
    29702974/*********************************** 
    29712975 * Determine if constant e is all ones or all zeros. 
    29722976 * Input: 
    29732977 *      bit 0:  all zeros 
    29742978 *          1:  1 
    29752979 *         -1:  all ones 
    29762980 */ 
    29772981 
    29782982int el_allbits(elem *e,int bit) 
    29792983{   targ_llong value; 
    29802984 
    29812985    elem_debug(e); 
    29822986    assert(e->Eoper == OPconst); 
    29832987    value = e->EV.Vullong; 
     
    32723276                    case TYulong: 
    32733277                    case TYdchar: 
    32743278                    case TYfptr: 
    32753279#if TX86 
    32763280                    case TYvptr: 
    32773281                    case TYhptr: 
    32783282#endif 
    32793283                    L1: 
    32803284                        dbg_printf("%dL ",e->EV.Vlong); 
    32813285                        break; 
    32823286 
    32833287                    case TYllong: 
    32843288                    L2: 
    32853289                        dbg_printf("%lldLL ",e->EV.Vllong); 
    32863290                        break; 
    32873291 
    32883292                    case TYullong: 
    32893293                        dbg_printf("%lluLL ",e->EV.Vullong); 
    32903294                        break; 
    32913295 
     3296                    case TYcent: 
     3297                    case TYucent: 
     3298                        dbg_printf("%lluLL+%lluLL ", e->EV.Vcent.msw, e->EV.Vcent.lsw); 
     3299                        break; 
     3300 
    32923301                    case TYfloat: 
    32933302                        dbg_printf("%gf ",(double)e->EV.Vfloat); 
    32943303                        break; 
    32953304                    case TYdouble: 
    32963305                    case TYdouble_alias: 
    32973306                        dbg_printf("%g ",(double)e->EV.Vdouble); 
    32983307                        break; 
    32993308                    case TYldouble: 
    33003309#if TARGET_MAC 
    33013310#if (TARGET_POWERPC) 
    33023311                        if (config.flags & CFGldblisdbl) 
    33033312                            dbg_printf("%gL ",e->EV.Vdouble); 
    33043313                        else 
    33053314#endif 
    33063315#if !DDRT 
    33073316                            dbg_printf("%LgL ",e->EV.Vldouble); 
    33083317#else /* DDRT */ 
    33093318                        { 
    33103319                            static char buffer[75]; 
    33113320                            __g_fmt(buffer, (DD)e->EV.Vldouble); 
  • trunk/src/backend/evalu8.c

    r569 r618  
    565565{   elem *e1,*e2; 
    566566    tym_t tym,tym2,uns; 
    567567    unsigned op; 
    568568#if TARGET_MAC 
    569569    targ_short i1,i2; 
    570570    targ_char c1,c2; 
    571571#else 
    572572    targ_int i1,i2; 
    573573#endif 
    574574    int i; 
    575575    targ_llong l1,l2; 
    576576    targ_ldouble d1,d2; 
    577577    elem esave; 
    578578 
    579579//    assert((_status87() & 0x3800) == 0); 
    580580    assert(e && EOP(e)); 
    581581    op = e->Eoper; 
    582582    elem_debug(e); 
    583583    e1 = e->E1; 
    584584 
    585     //printf("evalu8(): "); //elem_print(e); 
     585    //printf("evalu8(): "); elem_print(e); 
    586586    elem_debug(e1); 
    587587    if (e1->Eoper == OPconst) 
    588588    { 
    589589        tym2 = 0; 
    590590        e2 = NULL; 
    591591        if (EBIN(e)) 
    592592        {   e2 = e->E2; 
    593593            elem_debug(e2); 
    594594            if (e2->Eoper == OPconst) 
    595595            { 
    596596                T68000(c2 =) i2 = l2 = el_tolong(e2); 
    597597                d2 = el_toldouble(e2); 
    598598            } 
    599599            else 
    600600                return e; 
    601601            tym2 = tybasic(typemask(e2)); 
    602602        } 
    603603        T68000(c1 =) i1 = l1 = el_tolong(e1); 
    604604        d1 = el_toldouble(e1); 
    605605        tym = tybasic(typemask(e1));    /* type of op is type of left child */ 
     
    11831183                case TYcldouble: 
    11841184                    switch (tym2) 
    11851185                    { 
    11861186                        case TYldouble: 
    11871187                            e->EV.Vcldouble.re = e1->EV.Vcldouble.re * d2; 
    11881188                            e->EV.Vcldouble.im = e1->EV.Vcldouble.im * d2; 
    11891189                            break; 
    11901190                        case TYildouble: 
    11911191                            e->EV.Vcldouble.re = -e1->EV.Vcldouble.im * d2; 
    11921192                            e->EV.Vcldouble.im =  e1->EV.Vcldouble.re * d2; 
    11931193                            break; 
    11941194                        case TYcldouble: 
    11951195                            e->EV.Vcldouble = Complex_ld::mul(e1->EV.Vcldouble, e2->EV.Vcldouble); 
    11961196                            break; 
    11971197                        default: 
    11981198                            assert(0); 
    11991199                    } 
    12001200                    break; 
    12011201                default: 
    12021202#ifdef DEBUG 
    1203                     dbg_printf("tym = x%lx\n",tym); 
     1203                    dbg_printf("tym = x%x\n",tym); 
    12041204                    elem_print(e); 
    12051205#endif 
    12061206                    assert(0); 
    12071207            } 
    12081208        } 
    12091209        break; 
    12101210    case OPdiv: 
    12111211        if (!boolres(e2))                       // divide by 0 
    12121212        { 
    12131213#if SCPP 
    12141214            if (!tyfloating(tym)) 
    12151215#endif 
    12161216                goto div0; 
    12171217        } 
    12181218        if (uns) 
    12191219            e->EV.Vullong = ((targ_ullong) l1) / ((targ_ullong) l2); 
    12201220        else 
    12211221        {   switch (tym) 
    12221222            { 
    12231223                case TYfloat: 
     
    20302030#endif 
    20312031        e->EV.Vint = l1; 
    20322032        break; 
    20332033    case OP64_32: 
    20342034        e->EV.Vlong = l1; 
    20352035        break; 
    20362036    case OPlngllng: 
    20372037        e->EV.Vllong = (targ_long) l1; 
    20382038        break; 
    20392039    case OPulngllng: 
    20402040        e->EV.Vllong = (targ_ulong) l1; 
    20412041        break; 
    20422042    case OPmsw: 
    20432043        switch (tysize(tym)) 
    20442044        { 
    20452045            case 4: 
    20462046                e->EV.Vllong = (l1 >> 16) & 0xFFFF; 
    20472047                break; 
    20482048            case 8: 
    20492049                e->EV.Vllong = (l1 >> 32) & 0xFFFFFFFF; 
     2050                break; 
     2051            case 16: 
     2052                e->EV.Vllong = e1->EV.Vcent.msw; 
    20502053                break; 
    20512054            default: 
    20522055                assert(0); 
    20532056        } 
    20542057        break; 
    20552058    case OPb_8: 
    20562059        e->EV.Vlong = i1 & 1; 
    20572060        break; 
    20582061    case OPbswap: 
    20592062        e->EV.Vint = ((i1 >> 24) & 0x000000FF) | 
    20602063                     ((i1 >>  8) & 0x0000FF00) | 
    20612064                     ((i1 <<  8) & 0x00FF0000) | 
    20622065                     ((i1 << 24) & 0xFF000000); 
    20632066        break; 
    20642067    case OPind: 
    20652068#if 0 && MARS 
    20662069        /* The problem with this is that although the only reaching definition 
    20672070         * of the variable is null, it still may never get executed, as in: 
    20682071         *   int* p = null; if (p) *p = 3; 
    20692072         * and the error will be spurious. 
  • trunk/src/backend/ptrntab.c

    r605 r618  
    11// Copyright (C) 1985-1998 by Symantec 
    2 // Copyright (C) 2000-2009 by Digital Mars 
     2// Copyright (C) 2000-2010 by Digital Mars 
    33// All Rights Reserved 
    44// http://www.digitalmars.com 
    55/* 
    66 * This source file is made available for personal use 
    77 * only. The license is in /dmd/src/dmd/backendlicense.txt 
    88 * or /dm/src/dmd/backendlicense.txt 
    99 * For any other uses, please contact Digital Mars. 
    1010 */ 
    1111 
    1212#if !DEMO && !SPP 
    1313 
    1414#include        <stdio.h> 
    1515#include        <stdlib.h> 
    1616#include        <string.h> 
    1717#include        <time.h> 
    1818 
    1919#include        "cc.h" 
    2020#include        "code.h" 
    2121#include        "iasm.h" 
    2222 
     
    3535PTRNTAB0 aptb0AAA[] = /* AAA */ { 
    3636        { 0x37, _modax }, 
    3737}; 
    3838 
    3939PTRNTAB0 aptb0AAD[] = /* AAD */ { 
    4040        { 0xd50a, _modax } 
    4141}; 
    4242 
    4343PTRNTAB0 aptb0AAM[] = /* AAM */ { 
    4444        { 0xd40a, _modax } 
    4545}; 
    4646PTRNTAB0 aptb0AAS[] = /* AAS */ { 
    4747        { 0x3f, _modax } 
    4848}; 
    4949PTRNTAB0 aptb0CBW[] = /* CBW */ { 
    5050        { 0x98, _16_bit | _modax } 
    5151}; 
    5252PTRNTAB0 aptb0CWDE[] = /* CWDE */ { 
    5353        { 0x98, _32_bit | _I386 | _modax } 
    5454}; 
     55PTRNTAB0 aptb0CDQE[] = /* CDQE */ { 
     56        { 0x98, _64_bit | _modax } 
     57}; 
    5558PTRNTAB0 aptb0CLC[] =  /* CLC */ { 
    5659        { 0xf8, 0 } 
    5760}; 
    5861 
    5962PTRNTAB0 aptb0CLD[] = /* CLD */ { 
    6063        { 0xfc, 0 } 
    6164}; 
    6265PTRNTAB0 aptb0CLI[] =  /* CLI */ { 
    6366        { 0xfa, 0 } 
    6467}; 
    6568 
    6669PTRNTAB0 aptb0CLTS[] =  /* CLTS */ { 
    6770        { 0x0f06, 0 } 
    6871}; 
    6972 
    7073PTRNTAB0 aptb0CMC[] =  /* CMC */ { 
    7174        { 0xf5, 0 } 
    7275}; 
    7376 
    7477PTRNTAB0 aptb0CMPSB[] =  /* CMPSB */ { 
    7578        { 0xa6, _modsidi } 
    7679}; 
    7780 
    7881PTRNTAB0 aptb0CMPSW[] =  /* CMPSW */ { 
    7982        { 0xa7, _16_bit | _modsidi } 
    8083}; 
    8184 
    8285#if 0 
    8386PTRNTAB0 aptb0CMPSD[] =  /* CMPSD */ { 
    8487        { 0xa7, _32_bit | _I386 | _modsidi } 
    8588}; 
    8689#endif 
    8790 
    8891PTRNTAB0 aptb0CWD[] =  /* CWD */ { 
    8992        { 0x99, _16_bit | _modaxdx } 
    9093}; 
    9194 
    9295PTRNTAB0 aptb0CDQ[] =  /* CDQ */ { 
    9396        { 0x99, _32_bit | _I386 | _modaxdx } 
     97}; 
     98 
     99PTRNTAB0 aptb0CQO[] =  /* CQO */ { 
     100        { 0x99, _64_bit | _modaxdx } 
    94101}; 
    95102 
    96103PTRNTAB0 aptb0DAA[] =  /* DAA */ { 
    97104        { 0x27, _modax } 
    98105}; 
    99106 
    100107PTRNTAB0 aptb0DAS[] =  /* DAS */ { 
    101108        { 0x2f, _modax } 
    102109}; 
    103110 
    104111PTRNTAB0 aptb0HLT[] =  /* HLT */ { 
    105112        { 0xf4, 0 } 
    106113}; 
    107114 
    108115PTRNTAB0 aptb0INSB[] =  /* INSB */ { 
    109116        { 0x6c,  _I386 | _modsi } 
    110117}; 
    111118 
    112119PTRNTAB0 aptb0INSW[] =  /* INSW */ { 
    113120        { 0x6d, _16_bit | _I386 | _modsi } 
     
    31413148        X("addss",      2,              (P) aptb2ADDSS ) \ 
    31423149        X("addsubpd",   2,              (P) aptb2ADDSUBPD ) \ 
    31433150        X("addsubps",   2,              (P) aptb2ADDSUBPS ) \ 
    31443151        X("and",        2,              (P) aptb2AND ) \ 
    31453152        X("andnpd",     2,              (P) aptb2ANDNPD ) \ 
    31463153        X("andnps",     2,              (P) aptb2ANDNPS ) \ 
    31473154        X("andpd",      2,              (P) aptb2ANDPD ) \ 
    31483155        X("andps",      2,              (P) aptb2ANDPS ) \ 
    31493156        X("arpl",       2,              (P) aptb2ARPL ) \ 
    31503157        X("bound",      2,              (P) aptb2BOUND ) \ 
    31513158        X("bsf",        2,              (P) aptb2BSF ) \ 
    31523159        X("bsr",        2,              (P) aptb2BSR ) \ 
    31533160        X("bswap",      1,              (P) aptb1BSWAP ) \ 
    31543161        X("bt",         2,              (P) aptb2BT ) \ 
    31553162        X("btc",        2,              (P) aptb2BTC ) \ 
    31563163        X("btr",        2,              (P) aptb2BTR ) \ 
    31573164        X("bts",        2,              (P) aptb2BTS ) \ 
    31583165        X("call",       ITjump | 1,     (P) aptb1CALL ) \ 
    31593166        X("cbw",        0,              aptb0CBW ) \ 
    31603167        X("cdq",        0,              aptb0CDQ ) \ 
     3168        X("cdqe",       0,              aptb0CDQE ) \ 
    31613169        X("clc",        0,              aptb0CLC ) \ 
    31623170        X("cld",        0,              aptb0CLD ) \ 
    31633171        X("clflush",    1,              (P) aptb1CLFLUSH ) \ 
    31643172        X("cli",        0,              aptb0CLI ) \ 
    31653173        X("clts",       0,              aptb0CLTS ) \ 
    31663174        X("cmc",        0,              aptb0CMC ) \ 
    31673175        X("cmova",      2,              (P) aptb2CMOVNBE ) \ 
    31683176        X("cmovae",     2,              (P) aptb2CMOVNB ) \ 
    31693177        X("cmovb",      2,              (P) aptb2CMOVB ) \ 
    31703178        X("cmovbe",     2,              (P) aptb2CMOVBE ) \ 
    31713179        X("cmovc",      2,              (P) aptb2CMOVB ) \ 
    31723180        X("cmove",      2,              (P) aptb2CMOVZ ) \ 
    31733181        X("cmovg",      2,              (P) aptb2CMOVNLE ) \ 
    31743182        X("cmovge",     2,              (P) aptb2CMOVNL ) \ 
    31753183        X("cmovl",      2,              (P) aptb2CMOVL ) \ 
    31763184        X("cmovle",     2,              (P) aptb2CMOVLE ) \ 
    31773185        X("cmovna",     2,              (P) aptb2CMOVBE ) \ 
    31783186        X("cmovnae",    2,              (P) aptb2CMOVB ) \ 
    31793187        X("cmovnb",     2,              (P) aptb2CMOVNB ) \ 
    31803188        X("cmovnbe",    2,              (P) aptb2CMOVNBE ) \ 
     
    31913199        X("cmovo",      2,              (P) aptb2CMOVO ) \ 
    31923200        X("cmovp",      2,              (P) aptb2CMOVP ) \ 
    31933201        X("cmovpe",     2,              (P) aptb2CMOVP ) \ 
    31943202        X("cmovpo",     2,              (P) aptb2CMOVNP ) \ 
    31953203        X("cmovs",      2,              (P) aptb2CMOVS ) \ 
    31963204        X("cmovz",      2,              (P) aptb2CMOVZ ) \ 
    31973205        X("cmp",        2,              (P) aptb2CMP ) \ 
    31983206        X("cmppd",      3,              (P) aptb3CMPPD ) \ 
    31993207        X("cmpps",      3,              (P) aptb3CMPPS ) \ 
    32003208        X("cmps",       2,              (P) aptb2CMPS ) \ 
    32013209        X("cmpsb",      0,              aptb0CMPSB ) \ 
    32023210        /*X("cmpsd",    0,              aptb0CMPSD )*/ \ 
    32033211        X("cmpsd",      ITopt|3,        (P) aptb3CMPSD ) \ 
    32043212        X("cmpss",      3,              (P) aptb3CMPSS ) \ 
    32053213        X("cmpsw",      0,              aptb0CMPSW ) \ 
    32063214        X("cmpxch8b",   1,              (P) aptb1CMPXCH8B ) \ 
    32073215        X("cmpxchg",    2,              (P) aptb2CMPXCHG ) \ 
    32083216        X("comisd",     2,              (P) aptb2COMISD ) \ 
    32093217        X("comiss",     2,              (P) aptb2COMISS ) \ 
    32103218        X("cpuid",      0,              aptb0CPUID ) \ 
     3219        X("cqo",        0,              aptb0CQO ) \ 
    32113220        X("cvtdq2pd",   2,              (P) aptb2CVTDQ2PD ) \ 
    32123221        X("cvtdq2ps",   2,              (P) aptb2CVTDQ2PS ) \ 
    32133222        X("cvtpd2dq",   2,              (P) aptb2CVTPD2DQ ) \ 
    32143223        X("cvtpd2pi",   2,              (P) aptb2CVTPD2PI ) \ 
    32153224        X("cvtpd2ps",   2,              (P) aptb2CVTPD2PS ) \ 
    32163225        X("cvtpi2pd",   2,              (P) aptb2CVTPI2PD ) \ 
    32173226        X("cvtpi2ps",   2,              (P) aptb2CVTPI2PS ) \ 
    32183227        X("cvtps2dq",   2,              (P) aptb2CVTPS2DQ ) \ 
    32193228        X("cvtps2pd",   2,              (P) aptb2CVTPS2PD ) \ 
    32203229        X("cvtps2pi",   2,              (P) aptb2CVTPS2PI ) \ 
    32213230        X("cvtsd2si",   2,              (P) aptb2CVTSD2SI ) \ 
    32223231        X("cvtsd2ss",   2,              (P) aptb2CVTSD2SS ) \ 
    32233232        X("cvtsi2sd",   2,              (P) aptb2CVTSI2SD ) \ 
    32243233        X("cvtsi2ss",   2,              (P) aptb2CVTSI2SS ) \ 
    32253234        X("cvtss2sd",   2,              (P) aptb2CVTSS2SD ) \ 
    32263235        X("cvtss2si",   2,              (P) aptb2CVTSS2SI ) \ 
    32273236        X("cvttpd2dq",  2,              (P) aptb2CVTTPD2DQ ) \ 
    32283237        X("cvttpd2pi",  2,              (P) aptb2CVTTPD2PI ) \ 
    32293238        X("cvttps2dq",  2,              (P) aptb2CVTTPS2DQ ) \ 
    32303239        X("cvttps2pi",  2,              (P) aptb2CVTTPS2PI ) \ 
  • trunk/src/backend/ty.h

    r605 r618  
    9090    TYident             = 0x30, // type-argument 
    9191    TYtemplate          = 0x31, // unexpanded class template 
    9292    TYvtshape           = 0x32, // virtual function table 
    9393    TYptr               = 0x33, // generic pointer type 
    9494    TYf16func           = 0x34, // _far16 _pascal function 
    9595    TYnsysfunc          = 0x35, // near __syscall func 
    9696    TYfsysfunc          = 0x36, // far __syscall func 
    9797    TYmfunc             = 0x37, // NT C++ member func 
    9898    TYjfunc             = 0x38, // LINKd D function 
    9999    TYhfunc             = 0x39, // C function with hidden parameter 
    100100    TYnref              = 0x3A, // near reference 
    101101    TYfref              = 0x3B, // far reference 
    102102 
    103103    TYcent              = 0x3C, // 128 bit signed integer 
    104104    TYucent             = 0x3D, // 128 bit unsigned integer 
    105105 
    106106    TYMAX               = 0x3E, 
    107107 
    108108#if MARS 
    109109#define TYaarray        TYnptr 
    110 #define TYdelegate      TYllong 
    111 #define TYdarray        TYullong 
     110#define TYdelegate      (I64 ? TYcent : TYllong) 
     111#define TYdarray        (I64 ? TYucent : TYullong) 
    112112#endif 
    113113}; 
    114114 
    115115// These change depending on memory model 
    116116extern int TYptrdiff, TYsize, TYsize_t; 
    117117 
    118118/* Linkage type                 */ 
    119119#define mTYnear         0x100 
    120120#define mTYfar          0x200 
    121121#define mTYcs           0x400           // in code segment 
    122122#define mTYthread       0x800 
    123123#define mTYLINK         0xF00           // all linkage bits 
    124124 
    125125#define mTYloadds       0x1000 
    126126#define mTYexport       0x2000 
    127127#define mTYweak         0x0000 
    128128#define mTYimport       0x4000 
    129129#define mTYnaked        0x8000 
    130130#define mTYMOD          0xF000          // all modifier bits 
    131131 
     
    181181 
    182182/* Groupings of types   */ 
    183183 
    184184#define tyintegral(ty)  (tytab[(ty) & 0xFF] & TYFLintegral) 
    185185 
    186186#define tyarithmetic(ty) (tytab[(ty) & 0xFF] & (TYFLintegral | TYFLreal | TYFLimaginary | TYFLcomplex)) 
    187187 
    188188#define tyaggregate(ty) (tytab[(ty) & 0xFF] & TYFLaggregate) 
    189189 
    190190#define tyscalar(ty)    (tytab[(ty) & 0xFF] & (TYFLintegral | TYFLreal | TYFLimaginary | TYFLcomplex | TYFLptr | TYFLmptr | TYFLnullptr)) 
    191191 
    192192#define tyfloating(ty)  (tytab[(ty) & 0xFF] & (TYFLreal | TYFLimaginary | TYFLcomplex)) 
    193193 
    194194#define tyimaginary(ty) (tytab[(ty) & 0xFF] & TYFLimaginary) 
    195195 
    196196#define tycomplex(ty)   (tytab[(ty) & 0xFF] & TYFLcomplex) 
    197197 
    198198#define tyreal(ty)      (tytab[(ty) & 0xFF] & TYFLreal) 
    199199 
    200200// Fits into 64 bit register 
    201 #define ty64reg(ty)     (tytab[(ty) & 0xFF] & (TYFLintegral | TYFLptr)
     201#define ty64reg(ty)     (tytab[(ty) & 0xFF] & (TYFLintegral | TYFLptr) && tysize(ty) <= NPTRSIZE
    202202 
    203203#ifndef tyshort 
    204204/* Types that are chars or shorts       */ 
    205205#define tyshort(ty)     (tytab[(ty) & 0xFF] & TYFLshort) 
    206206#endif 
    207207 
    208208/* Detect TYlong or TYulong     */ 
    209209#ifndef tylong 
    210210#define tylong(ty)      (tybasic(ty) == TYlong || tybasic(ty) == TYulong) 
    211211#endif 
    212212 
    213213/* Use to detect a pointer type */ 
    214214#ifndef typtr 
    215215#define typtr(ty)       (tytab[(ty) & 0xFF] & TYFLptr) 
    216216#endif 
    217217 
    218218/* Use to detect a reference type */ 
    219219#ifndef tyref 
    220220#define tyref(ty)       (tytab[(ty) & 0xFF] & TYFLref) 
    221221#endif 
  • trunk/src/backend/var.c

    r558 r618  
    222222unsigned 
    223223         maxblks = 0,   /* array max for all block stuff                */ 
    224224                        /* dfoblks <= numblks <= maxblks                */ 
    225225         numcse,        /* number of common subexpressions              */ 
    226226         deftop = 0,    /* # of entries in defnod[]                     */ 
    227227         exptop = 0;    /* top of expnod[]                              */ 
    228228 
    229229vec_t   defkill = NULL,         /* vector of AEs killed by an ambiguous */ 
    230230                                /* definition                           */ 
    231231        starkill = NULL,        /* vector of AEs killed by a definition */ 
    232232                                /* of something that somebody could be  */ 
    233233                                /* pointing to                          */ 
    234234        vptrkill = NULL;        /* vector of AEs killed by an access    */ 
    235235                                /* to a vptr                            */ 
    236236 
    237237/* From debug.c */ 
    238238#if DEBUG 
    239239const char *regstring[32] = {"AX","CX","DX","BX","SP","BP","SI","DI", 
    240240                             "R8","R9","R10","R11","R12","R13","R14","R15", 
    241241                             "XMM0","XMM1","XMM2","XMM3","XMM4","XMM5","XMM6","XMM7", 
    242                              "ES","PSW","STACK","ST0", "ST01"}; 
     242                             "ES","PSW","STACK","ST0","ST01","NOREG","RMload","RMstore"}; 
    243243#endif 
    244244 
    245245/* From nwc.c */ 
    246246 
    247247type *chartype;                 /* default 'char' type                  */ 
    248248 
  • trunk/src/e2ir.c

    r612 r618  
    420420 * Convert array to a dynamic array. 
    421421 */ 
    422422 
    423423elem *array_toDarray(Type *t, elem *e) 
    424424{ 
    425425    unsigned dim; 
    426426    elem *ef = NULL; 
    427427    elem *ex; 
    428428 
    429429    //printf("array_toDarray(t = %s)\n", t->toChars()); 
    430430    //elem_print(e); 
    431431    t = t->toBasetype(); 
    432432    switch (t->ty) 
    433433    { 
    434434        case Tarray: 
    435435            break; 
    436436 
    437437        case Tsarray: 
    438438            e = addressElem(e, t); 
    439439            dim = ((TypeSArray *)t)->dim->toInteger(); 
    440             e = el_pair(TYullong, el_long(TYint, dim), e); 
     440            e = el_pair(TYdarray, el_long(TYint, dim), e); 
    441441            break; 
    442442 
    443443        default: 
    444444        L1: 
    445445            switch (e->Eoper) 
    446446            { 
    447447                case OPconst: 
    448448                { 
    449449                    size_t len = tysize[tybasic(e->Ety)]; 
    450450                    elem *es = el_calloc(); 
    451451                    es->Eoper = OPstring; 
    452452 
    453453                    // Match MEM_PH_FREE for OPstring in ztc\el.c 
    454454                    es->EV.ss.Vstring = (char *)mem_malloc(len); 
    455455                    memcpy(es->EV.ss.Vstring, &e->EV, len); 
    456456 
    457457                    es->EV.ss.Vstrlen = len; 
    458458                    es->Ety = TYnptr; 
    459459                    e = es; 
    460460                    break; 
     
    486486                    // Copy expression to a variable and take the 
    487487                    // address of that variable. 
    488488                    Symbol *stmp; 
    489489                    tym_t ty = tybasic(e->Ety); 
    490490 
    491491                    if (ty == TYstruct) 
    492492                    { 
    493493                        if (e->Enumbytes == 4) 
    494494                            ty = TYint; 
    495495                        else if (e->Enumbytes == 8) 
    496496                            ty = TYllong; 
    497497                    } 
    498498                    e->Ety = ty; 
    499499                    stmp = symbol_genauto(type_fake(ty)); 
    500500                    e = el_bin(OPeq, e->Ety, el_var(stmp), e); 
    501501                    e = el_bin(OPcomma, TYnptr, e, el_una(OPaddr, TYnptr, el_var(stmp))); 
    502502                    break; 
    503503                } 
    504504            } 
    505505            dim = 1; 
    506             e = el_pair(TYullong, el_long(TYint, dim), e); 
     506            e = el_pair(TYdarray, el_long(TYint, dim), e); 
    507507            break; 
    508508    } 
    509509    return el_combine(ef, e); 
    510510} 
    511511 
    512512/***************************************** 
    513513 * Evaluate elem and convert to dynamic array. 
    514514 */ 
    515515 
    516516elem *eval_Darray(IRState *irs, Expression *e) 
    517517{ 
    518518    elem *ex; 
    519519 
    520520    ex = e->toElem(irs); 
    521521    return array_toDarray(e->type, ex); 
    522522} 
    523523 
    524524/************************************ 
    525525 */ 
    526526 
     
    529529    //printf("sarray_toDarray()\n"); 
    530530    //elem_print(e); 
    531531 
    532532    unsigned dim = ((TypeSArray *)tfrom)->dim->toInteger(); 
    533533 
    534534    if (tto) 
    535535    { 
    536536        unsigned fsize = tfrom->nextOf()->size(); 
    537537        unsigned tsize = tto->nextOf()->size(); 
    538538 
    539539        if ((dim * fsize) % tsize != 0) 
    540540        { 
    541541          Lerr: 
    542542            error(loc, "cannot cast %s to %s since sizes don't line up", tfrom->toChars(), tto->toChars()); 
    543543        } 
    544544        dim = (dim * fsize) / tsize; 
    545545    } 
    546546  L1: 
    547547    elem *elen = el_long(TYint, dim); 
    548548    e = addressElem(e, tfrom); 
    549     e = el_pair(TYullong, elen, e); 
     549    e = el_pair(TYdarray, elen, e); 
    550550    return e; 
    551551} 
    552552 
    553553/******************************************** 
    554554 * Determine if t is an array of structs that need a postblit. 
    555555 */ 
    556556 
    557557StructDeclaration *needsPostblit(Type *t) 
    558558{ 
    559559    t = t->toBasetype(); 
    560560    while (t->ty == Tsarray) 
    561561        t = t->nextOf()->toBasetype(); 
    562562    if (t->ty == Tstruct) 
    563563    {   StructDeclaration *sd = ((TypeStruct *)t)->sym; 
    564564        if (sd->postblit) 
    565565            return sd; 
    566566    } 
    567567    return NULL; 
    568568} 
    569569 
     
    579579 
    580580elem *setArray(elem *eptr, elem *edim, Type *tb, elem *evalue, IRState *irs, int op) 
    581581{   int r; 
    582582    elem *e; 
    583583    int sz = tb->size(); 
    584584 
    585585    if (tb->ty == Tfloat80 || tb->ty == Timaginary80) 
    586586        r = RTLSYM_MEMSET80; 
    587587    else if (tb->ty == Tcomplex80) 
    588588        r = RTLSYM_MEMSET160; 
    589589    else if (tb->ty == Tcomplex64) 
    590590        r = RTLSYM_MEMSET128; 
    591591    else 
    592592    { 
    593593        switch (sz) 
    594594        { 
    595595            case 1:      r = RTLSYM_MEMSET8;    break; 
    596596            case 2:      r = RTLSYM_MEMSET16;   break; 
    597597            case 4:      r = RTLSYM_MEMSET32;   break; 
    598598            case 8:      r = RTLSYM_MEMSET64;   break; 
     599            case 16:     r = RTLSYM_MEMSET128;  break; 
    599600            default:     r = RTLSYM_MEMSETN;    break; 
    600601        } 
    601602 
    602603        /* Determine if we need to do postblit 
    603604         */ 
    604605        if (op != TOKblit) 
    605606        { 
    606607            StructDeclaration *sd = needsPostblit(tb); 
    607608            if (sd) 
    608609            {   /* Need to do postblit. 
    609610                 *   void *_d_arraysetassign(void *p, void *value, int dim, TypeInfo ti); 
    610611                 */ 
    611612                r = (op == TOKconstruct) ? RTLSYM_ARRAYSETCTOR : RTLSYM_ARRAYSETASSIGN; 
    612613                evalue = el_una(OPaddr, TYnptr, evalue); 
    613614                Expression *ti = tb->getTypeInfo(NULL); 
    614615                elem *eti = ti->toElem(irs); 
    615616                e = el_params(eti, edim, evalue, eptr, NULL); 
    616617                e = el_bin(OPcall,TYnptr,el_var(rtlsym[r]),e); 
    617618                return e; 
    618619            } 
     
    10531054L1: 
    10541055    el_setLoc(e,loc); 
    10551056    return e; 
    10561057} 
    10571058#endif 
    10581059 
    10591060/************************************** 
    10601061 */ 
    10611062 
    10621063elem *FuncExp::toElem(IRState *irs) 
    10631064{ 
    10641065    elem *e; 
    10651066    Symbol *s; 
    10661067 
    10671068    //printf("FuncExp::toElem() %s\n", toChars()); 
    10681069    s = fd->toSymbol(); 
    10691070    e = el_ptr(s); 
    10701071    if (fd->isNested()) 
    10711072    { 
    10721073        elem *ethis = getEthis(loc, irs, fd); 
    1073         e = el_pair(TYullong, ethis, e); 
     1074        e = el_pair(TYdelegate, ethis, e); 
    10741075    } 
    10751076 
    10761077    irs->deferToObj->push(fd); 
    10771078    el_setLoc(e,loc); 
    10781079    return e; 
    10791080} 
    10801081 
    10811082/************************************** 
    10821083 */ 
    10831084 
    10841085elem *Dsymbol_toElem(Dsymbol *s, IRState *irs) 
    10851086{ 
    10861087    elem *e = NULL; 
    10871088    Symbol *sp; 
    10881089    AttribDeclaration *ad; 
    10891090    VarDeclaration *vd; 
    10901091    ClassDeclaration *cd; 
    10911092    StructDeclaration *sd; 
    10921093    FuncDeclaration *fd; 
    10931094    TemplateMixin *tm; 
     
    26432644                sassert = irs->blx->module->toModuleArray(); 
    26442645                ea = el_bin(OPcall,TYvoid,el_var(sassert), el_long(TYint, loc.linnum)); 
    26452646                eb = el_bin(OPoror,TYvoid,c1,ea); 
    26462647                einit = el_combine(einit, eb); 
    26472648            } 
    26482649 
    26492650            if (elwr) 
    26502651            {   elem *elwr2; 
    26512652 
    26522653                el_free(enbytes); 
    26532654                elwr2 = el_copytree(elwr); 
    26542655                elwr2 = el_bin(OPmul, TYint, elwr2, el_long(TYint, sz)); 
    26552656                n1 = el_bin(OPadd, TYnptr, n1, elwr2); 
    26562657                enbytes = el_bin(OPmin, TYint, eupr, elwr); 
    26572658                elength = el_copytree(enbytes); 
    26582659            } 
    26592660            else 
    26602661                elength = el_copytree(enbytes); 
    26612662            e = setArray(n1, enbytes, tb, evalue, irs, op); 
    26622663        Lpair: 
    2663             e = el_pair(TYullong, elength, e); 
     2664            e = el_pair(TYdarray, elength, e); 
    26642665        Lret2: 
    26652666            e = el_combine(einit, e); 
    26662667            //elem_print(e); 
    26672668            goto Lret; 
    26682669        } 
    26692670#if 0 
    26702671        else if (e2->op == TOKadd || e2->op == TOKmin) 
    26712672        { 
    26722673            /* It's ea[] = eb[] +- ec[] 
    26732674             */ 
    26742675            BinExp *e2a = (BinExp *)e2; 
    26752676            Type *t = e2->type->toBasetype()->nextOf()->toBasetype(); 
    26762677            if (t->ty != Tfloat32 && t->ty != Tfloat64 && t->ty != Tfloat80) 
    26772678            { 
    26782679                e2->error("array add/min for %s not supported", t->toChars()); 
    26792680                return el_long(TYint, 0); 
    26802681            } 
    26812682            elem *ea = e1->toElem(irs); 
    26822683            ea = array_toDarray(e1->type, ea); 
    26832684            elem *eb = e2a->e1->toElem(irs); 
     
    32983299        else 
    32993300        { 
    33003301            // Get pointer to function out of virtual table 
    33013302            unsigned vindex; 
    33023303 
    33033304            assert(ethis); 
    33043305            ep = el_same(&ethis); 
    33053306            ep = el_una(OPind, TYnptr, ep); 
    33063307            vindex = func->vtblIndex; 
    33073308 
    33083309            // Build *(ep + vindex * 4) 
    33093310            ep = el_bin(OPadd,TYnptr,ep,el_long(TYint, vindex * 4)); 
    33103311            ep = el_una(OPind,TYnptr,ep); 
    33113312        } 
    33123313 
    33133314//      if (func->tintro) 
    33143315//          func->error(loc, "cannot form delegate due to covariant return type"); 
    33153316    } 
    33163317    if (ethis->Eoper == OPcomma) 
    33173318    { 
    3318         ethis->E2 = el_pair(TYullong, ethis->E2, ep); 
    3319         ethis->Ety = TYullong
     3319        ethis->E2 = el_pair(TYdelegate, ethis->E2, ep); 
     3320        ethis->Ety = TYdelegate
    33203321        e = ethis; 
    33213322    } 
    33223323    else 
    3323         e = el_pair(TYullong, ethis, ep); 
     3324        e = el_pair(TYdelegate, ethis, ep); 
    33243325    el_setLoc(e,loc); 
    33253326    return e; 
    33263327} 
    33273328 
    33283329elem *DotTypeExp::toElem(IRState *irs) 
    33293330{ 
    33303331    // Just a pass-thru to e1 
    33313332    elem *e; 
    33323333 
    33333334    //printf("DotTypeExp::toElem() %s\n", toChars()); 
    33343335    e = e1->toElem(irs); 
    33353336    el_setLoc(e,loc); 
    33363337    return e; 
    33373338} 
    33383339 
    33393340elem *CallExp::toElem(IRState *irs) 
    33403341{ 
    33413342    //printf("CallExp::toElem('%s')\n", toChars()); 
    33423343    assert(e1->type); 
    33433344    elem *ec; 
     
    43534354 
    43544355            L2: 
    43554356                // Construct: (c1 || ModuleArray(line)) 
    43564357                Symbol *sassert; 
    43574358 
    43584359                sassert = irs->blx->module->toModuleArray(); 
    43594360                ea = el_bin(OPcall,TYvoid,el_var(sassert), el_long(TYint, loc.linnum)); 
    43604361                eb = el_bin(OPoror,TYvoid,c1,ea); 
    43614362                elwr = el_combine(elwr, eb); 
    43624363 
    43634364                elwr2 = el_copytree(elwr2); 
    43644365                eupr = el_copytree(eupr2); 
    43654366            } 
    43664367        } 
    43674368 
    43684369        elem *eptr = array_toPtr(e1->type, e); 
    43694370 
    43704371        elem *elength = el_bin(OPmin, TYint, eupr, elwr2); 
    43714372        eptr = el_bin(OPadd, TYnptr, eptr, el_bin(OPmul, TYint, el_copytree(elwr2), el_long(TYint, sz))); 
    43724373 
    4373         e = el_pair(TYullong, elength, eptr); 
     4374        e = el_pair(TYdarray, elength, eptr); 
    43744375        e = el_combine(elwr, e); 
    43754376        e = el_combine(einit, e); 
    43764377    } 
    43774378    else if (t1->ty == Tsarray) 
    43784379    { 
    43794380        e = sarray_toDarray(loc, t1, NULL, e); 
    43804381    } 
    43814382    el_setLoc(e,loc); 
    43824383    return e; 
    43834384} 
    43844385 
    43854386elem *IndexExp::toElem(IRState *irs) 
    43864387{   elem *e; 
    43874388    elem *n1 = e1->toElem(irs); 
    43884389    elem *eb = NULL; 
    43894390 
    43904391    //printf("IndexExp::toElem() %s\n", toChars()); 
    43914392    Type *t1 = e1->type->toBasetype(); 
    43924393    if (t1->ty == Taarray) 
    43934394    { 
     
    45664567    else 
    45674568    {   dim = 0; 
    45684569        e = el_long(TYint, 0); 
    45694570    } 
    45704571    Type *tb = type->toBasetype(); 
    45714572#if 1 
    45724573    e = el_param(e, type->getTypeInfo(NULL)->toElem(irs)); 
    45734574 
    45744575    // call _d_arrayliteralT(ti, dim, ...) 
    45754576    e = el_bin(OPcall,TYnptr,el_var(rtlsym[RTLSYM_ARRAYLITERALT]),e); 
    45764577    e->Eflags |= EFLAGS_variadic; 
    45774578#else 
    45784579    e = el_param(e, el_long(TYint, tb->next->size())); 
    45794580 
    45804581    // call _d_arrayliteral(size, dim, ...) 
    45814582    e = el_bin(OPcall,TYnptr,el_var(rtlsym[RTLSYM_ARRAYLITERAL]),e); 
    45824583    e->Eflags |= EFLAGS_variadic; 
    45834584#endif 
    45844585    if (tb->ty == Tarray) 
    45854586    { 
    4586         e = el_pair(TYullong, el_long(TYint, dim), e); 
     4587        e = el_pair(TYdarray, el_long(TYint, dim), e); 
    45874588    } 
    45884589    else if (tb->ty == Tpointer) 
    45894590    { 
    45904591    } 
    45914592    else 
    45924593    { 
    45934594        e = el_una(OPind,TYstruct,e); 
    45944595        e->Enumbytes = type->size(); 
    45954596    } 
    45964597 
    45974598    el_setLoc(e,loc); 
    45984599    return e; 
    45994600} 
    46004601 
    46014602 
    46024603elem *AssocArrayLiteralExp::toElem(IRState *irs) 
    46034604{   elem *e; 
    46044605    size_t dim; 
    46054606 
    46064607    //printf("AssocArrayLiteralExp::toElem() %s\n", toChars()); 
  • trunk/src/iasm.c

    r605 r618  
    12311231L386_WARNING2: 
    12321232                        if (config.target_cpu < TARGET_80386) 
    12331233                        {   // Reference to %s caused a 386 instruction to be generated 
    12341234                            //warerr(WM_386_op, id->toChars()); 
    12351235                        } 
    12361236                    } 
    12371237                    break; 
    12381238                case 2: 
    12391239                case 3:     // The third operand is always an _imm 
    12401240                    if (popnd1 && popnd1->s) 
    12411241                        goto L386_WARNING; 
    12421242                    if (popnd2 && popnd2->s) 
    12431243                    { 
    12441244                        id = popnd2->s->ident; 
    12451245                        goto L386_WARNING2; 
    12461246                    } 
    12471247                    break; 
    12481248            } 
    12491249        } 
    12501250 
     1251        if (ptb.pptb0->usFlags & _64_bit && !I64) 
     1252            error(asmstate.loc, "use -m64 to compile 64 bit instructions"); 
     1253 
    12511254        switch (usNumops) 
    12521255        { 
    12531256            case 0: 
    1254                 if ((I32 && (ptb.pptb0->usFlags & _16_bit)) || 
     1257                if (((I32 | I64) && (ptb.pptb0->usFlags & _16_bit)) || 
    12551258                        (I16 && (ptb.pptb0->usFlags & _32_bit))) 
    12561259                { 
    12571260                        emit(0x66); 
    12581261                        pc->Iflags |= CFopsize; 
     1262                } 
     1263                else if (I64 && (ptb.pptb0->usFlags & _64_bit)) 
     1264                { 
     1265                        emit(REX | REX_W); 
     1266                        pc->Irex |= REX_W; 
    12591267                } 
    12601268                break; 
    12611269 
    12621270            // 3 and 2 are the same because the third operand is always 
    12631271            // an immediate and does not affect operation size 
    12641272            case 3: 
    12651273            case 2: 
    12661274                if ((I32 && 
    12671275                      (amod2 == _addr16 || 
    12681276                       (uSizemaskTable2 & _16 && aoptyTable2 == _rel) || 
    12691277                       (uSizemaskTable2 & _32 && aoptyTable2 == _mnoi) || 
    12701278                       (ptb.pptb2->usFlags & _16_bit_addr) 
    12711279                     ) 
    12721280                    ) || 
    12731281                     (I16 && 
    12741282                       (amod2 == _addr32 || 
    12751283                        (uSizemaskTable2 & _32 && aoptyTable2 == _rel) || 
    12761284                        (uSizemaskTable2 & _48 && aoptyTable2 == _mnoi) || 
    12771285                        (ptb.pptb2->usFlags & _32_bit_addr))) 
    12781286                  ) 
  • trunk/src/s2ir.c

    r567 r618  
    967967         */ 
    968968        block_goto(blx, BCgoto, mystate.breakBlock); 
    969969        return; 
    970970    } 
    971971#endif 
    972972 
    973973    if (condition->type->isString()) 
    974974    { 
    975975        // Number the cases so we can unscramble things after the sort() 
    976976        for (int i = 0; i < numcases; i++) 
    977977        {   CaseStatement *cs = (CaseStatement *)cases->data[i]; 
    978978            cs->index = i; 
    979979        } 
    980980 
    981981        cases->sort(); 
    982982 
    983983        /* Create a sorted array of the case strings, and si 
    984984         * will be the symbol for it. 
    985985         */ 
    986986        dt_t *dt = NULL; 
    987         Symbol *si = symbol_generate(SCstatic,type_fake(TYullong)); 
     987        Symbol *si = symbol_generate(SCstatic,type_fake(TYdarray)); 
    988988#if MACHOBJ 
    989989        si->Sseg = DATA; 
    990990#endif 
    991         dtdword(&dt, numcases); 
    992         dtxoff(&dt, si, 8, TYnptr); 
     991        dtsize_t(&dt, numcases); 
     992        dtxoff(&dt, si, PTRSIZE * 2, TYnptr); 
    993993 
    994994        for (int i = 0; i < numcases; i++) 
    995995        {   CaseStatement *cs = (CaseStatement *)cases->data[i]; 
    996996 
    997997            if (cs->exp->op != TOKstring) 
    998998            {   error("case '%s' is not a string", cs->exp->toChars()); // BUG: this should be an assert 
    999999            } 
    10001000            else 
    10011001            { 
    10021002                StringExp *se = (StringExp *)(cs->exp); 
    10031003                unsigned len = se->len; 
    10041004                dtdword(&dt, len); 
    10051005                dtabytes(&dt, TYnptr, 0, se->len * se->sz, (char *)se->string); 
    10061006            } 
    10071007        } 
    10081008 
    10091009        si->Sdt = dt; 
    10101010        si->Sfl = FLdata; 
    10111011        outdata(si); 
    10121012 
  • trunk/src/toobj.c

    r428 r618  
    466466    /* The layout is: 
    467467       { 
    468468            void **vptr; 
    469469            monitor_t monitor; 
    470470            byte[] initializer;         // static initialization data 
    471471            char[] name;                // class name 
    472472            void *[] vtbl; 
    473473            Interface[] interfaces; 
    474474            ClassInfo *base;            // base class 
    475475            void *destructor; 
    476476            void *invariant;            // class invariant 
    477477            uint flags; 
    478478            void *deallocator; 
    479479            OffsetTypeInfo[] offTi; 
    480480            void *defaultConstructor; 
    481481            const(MemberInfo[]) function(string) xgetMembers;   // module getMembers() function 
    482482            //TypeInfo typeinfo; 
    483483       } 
    484484     */ 
    485485    dt_t *dt = NULL; 
    486     offset = CLASSINFO_SIZE;                    // must be ClassInfo.size 
     486    unsigned classinfo_size = global.params.isX86_64 ? CLASSINFO_SIZE_64 : CLASSINFO_SIZE;    // must be ClassInfo.size 
     487    offset = classinfo_size; 
    487488    if (classinfo) 
    488489    { 
    489         if (classinfo->structsize != CLASSINFO_SIZE) 
    490         { 
     490        if (classinfo->structsize != classinfo_size) 
     491        { 
     492#ifdef DEBUG 
     493            printf("CLASSINFO_SIZE = x%x, classinfo->structsize = x%x\n", offset, classinfo->structsize); 
     494#endif 
    491495            error("mismatch between dmd and object.d or object.di found. Check installation and import paths with -v compiler switch."); 
    492496            fatal(); 
    493497        } 
    494498    } 
    495499 
    496500    if (classinfo) 
    497501        dtxoff(&dt, classinfo->toVtblSymbol(), 0, TYnptr); // vtbl for ClassInfo 
    498502    else 
    499503        dtdword(&dt, 0);                // BUG: should be an assert() 
    500504    dtdword(&dt, 0);                    // monitor 
    501505 
    502506    // initializer[] 
    503507    assert(structsize >= 8); 
    504508    dtdword(&dt, structsize);           // size 
    505509    dtxoff(&dt, sinit, 0, TYnptr);      // initializer 
    506510 
    507511    // name[] 
    508512    const char *name = ident->toChars(); 
    509513    size_t namelen = strlen(name); 
    510514    if (!(namelen > 9 && memcmp(name, "TypeInfo_", 9) == 0)) 
     
    829833#endif 
    830834#if MACHOBJ 
    831835    vtblsym->Sseg = DATA; 
    832836#endif 
    833837    outdata(vtblsym); 
    834838    if (isExport()) 
    835839        obj_export(vtblsym,0); 
    836840} 
    837841 
    838842/****************************************** 
    839843 * Get offset of base class's vtbl[] initializer from start of csym. 
    840844 * Returns ~0 if not this csym. 
    841845 */ 
    842846 
    843847unsigned ClassDeclaration::baseVtblOffset(BaseClass *bc) 
    844848{ 
    845849    unsigned csymoffset; 
    846850    int i; 
    847851 
    848852    //printf("ClassDeclaration::baseVtblOffset('%s', bc = %p)\n", toChars(), bc); 
    849     csymoffset = CLASSINFO_SIZE; 
     853    csymoffset = global.params.isX86_64 ? CLASSINFO_SIZE_64 : CLASSINFO_SIZE;    // must be ClassInfo.size 
    850854    csymoffset += vtblInterfaces->dim * (4 * PTRSIZE); 
    851855 
    852856    for (i = 0; i < vtblInterfaces->dim; i++) 
    853857    { 
    854858        BaseClass *b = (BaseClass *)vtblInterfaces->data[i]; 
    855859 
    856860        if (b == bc) 
    857861            return csymoffset; 
    858862        csymoffset += b->base->vtbl.dim * PTRSIZE; 
    859863    } 
    860864 
    861865#if 1 
    862866    // Put out the overriding interface vtbl[]s. 
    863867    // This must be mirrored with ClassDeclaration::baseVtblOffset() 
    864868    //printf("putting out overriding interface vtbl[]s for '%s' at offset x%x\n", toChars(), offset); 
    865869    ClassDeclaration *cd; 
    866870    Array bvtbl; 
    867871 
    868872    for (cd = this->baseClass; cd; cd = cd->baseClass) 
    869873    { 
     
    978982    dtdword(&dt, 0);                    // monitor 
    979983 
    980984    // initializer[] 
    981985    dtdword(&dt, 0);                    // size 
    982986    dtdword(&dt, 0);                    // initializer 
    983987 
    984988    // name[] 
    985989    const char *name = toPrettyChars(); 
    986990    size_t namelen = strlen(name); 
    987991    dtdword(&dt, namelen); 
    988992    dtabytes(&dt, TYnptr, 0, namelen + 1, name); 
    989993 
    990994    // vtbl[] 
    991995    dtdword(&dt, 0); 
    992996    dtdword(&dt, 0); 
    993997 
    994998    // vtblInterfaces->data[] 
    995999    dtdword(&dt, vtblInterfaces->dim); 
    9961000    if (vtblInterfaces->dim) 
    9971001    { 
     1002        offset = global.params.isX86_64 ? CLASSINFO_SIZE_64 : CLASSINFO_SIZE;    // must be ClassInfo.size 
    9981003        if (classinfo) 
    9991004        { 
    1000             if (classinfo->structsize != CLASSINFO_SIZE
     1005            if (classinfo->structsize != offset
    10011006            { 
    10021007                error("mismatch between dmd and object.d or object.di found. Check installation and import paths with -v compiler switch."); 
    10031008                fatal(); 
    10041009            } 
    10051010        } 
    1006         offset = CLASSINFO_SIZE; 
    10071011        dtxoff(&dt, csym, offset, TYnptr);      // (*) 
    10081012    } 
    10091013    else 
    10101014        dtdword(&dt, 0); 
    10111015 
    10121016    // base 
    10131017    assert(!baseClass); 
    10141018    dtdword(&dt, 0); 
    10151019 
    10161020    // dtor 
    10171021    dtdword(&dt, 0); 
    10181022 
    10191023    // invariant 
    10201024    dtdword(&dt, 0); 
    10211025 
    10221026    // flags 
    10231027    dtdword(&dt, 4 | isCOMinterface() | 32); 
    10241028 
    10251029    // deallocator 
    10261030    dtdword(&dt, 0);