Annotation of lucent/sys/src/alef/k/machdep.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Machine dependant sparc
        !             3:  */
        !             4: 
        !             5: #include "/sys/src/cmd/kc/k.out.h"
        !             6: #define AOUTL  ".k"
        !             7: #define IALEF  "-I/sys/include/alef"
        !             8: 
        !             9: enum
        !            10: {
        !            11:        /* Basic machine type size in bytes */
        !            12:        Machptr                 = 4,
        !            13:        Machint                 = 4,
        !            14:        Machsint                = 2,
        !            15:        Machchar                = 1,
        !            16:        Machchan                = 4,
        !            17:        Machfloat               = 8,
        !            18: 
        !            19:        Autobase                = 4,    /* Automatics start at Autobase(FP) */
        !            20:        Parambase               = 0,    /* Parameters start at Parambase(SP) */
        !            21:        Argbase                 = 4,    /* Space for return pc/frame info */
        !            22: 
        !            23:        Shortfoff               = 2,
        !            24:        Charfoff                = 3,
        !            25: 
        !            26:        /* Type alignments for structs and data */
        !            27:        Align_Machptr           = 4,
        !            28:        Align_Machint           = 4,
        !            29:        Align_Machsint          = 2,
        !            30:        Align_Machchar          = 1,
        !            31:        Align_Machchan          = 4,
        !            32:        Align_Machfloat         = 4,
        !            33:        Align_data              = Align_Machint,
        !            34: 
        !            35:        Sucall                  = 100,  /* Complexity of a function */
        !            36:        Sucompute               = 9,    /* >sun Address needs to be computed */
        !            37: 
        !            38:        /* Size of the PAR rendez structure from the runtime */
        !            39:        SZPAREND                = 4*Machint,
        !            40: };
        !            41: 
        !            42: #define isaddr(nr)     (nr->islval > Sucompute)
        !            43: 
        !            44: typedef struct Adres Adres;
        !            45: typedef struct Inst Inst;
        !            46: typedef struct Glab Glab;
        !            47: typedef        struct Bits Bits;
        !            48: typedef        struct Var Var;
        !            49: typedef        struct Reg Reg;
        !            50: typedef        struct Rgn Rgn;
        !            51: typedef struct Scache Scache;
        !            52: typedef        struct Multab Multab;
        !            53: typedef        struct Hintab Hintab;
        !            54: 
        !            55: enum
        !            56: {
        !            57:        A_NONE  = 0,
        !            58:        A_CONST,
        !            59:        A_FCONST,
        !            60:        A_REG,
        !            61:        A_FREG,
        !            62:        A_INDREG,
        !            63:        A_BRANCH,
        !            64:        A_STRING,
        !            65: };
        !            66: 
        !            67: struct Scache
        !            68: {
        !            69:        Sym *s;
        !            70:        char class;
        !            71: };
        !            72: 
        !            73: struct Glab
        !            74: {
        !            75:        Node    *n;
        !            76:        int     par;
        !            77:        int     crit;
        !            78:        union {
        !            79:                Inst    *i;
        !            80:                ulong   pc;
        !            81:        };
        !            82:        Glab    *next;
        !            83: };
        !            84: 
        !            85: struct Adres
        !            86: {
        !            87:        char    type;
        !            88:        char    class;
        !            89:        char    etype;
        !            90:        char    reg;
        !            91:        Sym     *sym;
        !            92:        union {
        !            93:                long    ival;
        !            94:                float   fval;
        !            95:                char    str[NSNAME];
        !            96:        };
        !            97: };
        !            98: #define A      ((Adres*)0)
        !            99: 
        !           100: struct Inst
        !           101: {
        !           102:        uchar   op;
        !           103:        uchar   fmt;
        !           104:        Adres   src1;
        !           105:        Adres   dst;
        !           106:        int     reg;
        !           107:        Node    *n;
        !           108:        ulong   pc;
        !           109:        int     lineno;
        !           110:        Inst    *next;
        !           111: };
        !           112: #define P      ((Inst*)0)
        !           113: 
        !           114: enum
        !           115: {
        !           116:        Retireg         = 7,            /* Integer return */
        !           117:        Regspass        = 7,            /* Complex ptr */
        !           118:        Ireg            = 8,            /* Base integer registers */
        !           119:        Maxireg         = 20,
        !           120:        Retfreg         = 21,
        !           121:        Freg            = 21,
        !           122:        Maxfreg         = 21+31,
        !           123:        Retfregno       = 0,
        !           124:        Retiregno       = 1,
        !           125:        Nreg            = 55,
        !           126:        RegSP           = 1,
        !           127:        Regtmp          = 14,           /* Loader temporary */
        !           128:        Reglink         = 15,           /* Link register */
        !           129:        Pregs           = 6,            /* Private registers */
        !           130: };
        !           131: 
        !           132: #define        BITS    5
        !           133: #define        NVAR    (BITS*sizeof(ulong)*8)
        !           134: struct Bits
        !           135: {
        !           136:        ulong   b[BITS];
        !           137: };
        !           138: 
        !           139: struct Var
        !           140: {
        !           141:        long    ival;
        !           142:        Sym*    sym;
        !           143:        char    class;
        !           144:        char    etype;
        !           145: };
        !           146: 
        !           147: struct Reg
        !           148: {
        !           149:        long    pc;
        !           150: 
        !           151:        Bits    set;
        !           152:        Bits    use1;
        !           153:        Bits    use2;
        !           154: 
        !           155:        Bits    refbehind;
        !           156:        Bits    refahead;
        !           157:        Bits    calbehind;
        !           158:        Bits    calahead;
        !           159:        Bits    regdiff;
        !           160:        Bits    act;
        !           161: 
        !           162:        long    regu;
        !           163:        long    loop;           /* could be shorter */
        !           164: 
        !           165:        union   {
        !           166:                Reg*    log5;
        !           167:                int     active;
        !           168:        };
        !           169:        Reg*    p1;
        !           170:        Reg*    p2;
        !           171:        Reg*    p2next;
        !           172:        Reg*    s1;
        !           173:        Reg*    s2;
        !           174:        Reg*    next;
        !           175:        Inst*   prog;
        !           176: };
        !           177: #define        R       ((Reg*)0)
        !           178: 
        !           179: #define        NRGN    600
        !           180: struct Rgn
        !           181: {
        !           182:        Reg*    enter;
        !           183:        short   cost;
        !           184:        short   varno;
        !           185:        short   regno;
        !           186: };
        !           187: 
        !           188: #define        BLOAD(r)        band(bnot(r->refbehind), r->refahead)
        !           189: #define        BSTORE(r)       band(bnot(r->calbehind), r->calahead)
        !           190: #define        LOAD(r)         (~r->refbehind.b[z] & r->refahead.b[z])
        !           191: #define        STORE(r)        (~r->calbehind.b[z] & r->calahead.b[z])
        !           192: 
        !           193: #define        bset(a,n)       ((a).b[(n)/32]&(1L<<(n)%32))
        !           194: 
        !           195: #define        CLOAD   5
        !           196: #define        CREF    5
        !           197: #define        CINF    1000
        !           198: #define        LOOP    3
        !           199: 
        !           200: struct Multab
        !           201: {
        !           202:        long    val;
        !           203:        char    code[20];
        !           204: };
        !           205: 
        !           206: struct Hintab
        !           207: {
        !           208:        ushort  val;
        !           209:        char    hint[10];
        !           210: };
        !           211: 
        !           212: extern Hintab  hintab[];
        !           213: Multab multab[20];
        !           214: int    hintabsize;
        !           215: 
        !           216: Tinfo  *tip;
        !           217: Node   ratv;
        !           218: Node   *atv;
        !           219: int    frsize;
        !           220: ulong  args;
        !           221: 
        !           222: Rgn    region[NRGN];
        !           223: Rgn*   rgp;
        !           224: int    nregion;
        !           225: int    nvar;
        !           226: 
        !           227: Bits   externs;
        !           228: Bits   param;
        !           229: Bits   consts;
        !           230: Bits   addrs;
        !           231: Bits   zbits;
        !           232: 
        !           233: long   regbits;
        !           234: long   exregbits;
        !           235: 
        !           236: int    change;
        !           237: 
        !           238: Reg*   firstr;
        !           239: Reg*   lastr;
        !           240: Reg    zreg;
        !           241: Reg*   freer;
        !           242: Var    var[NVAR];
        !           243: 
        !           244: Inst   zprog;
        !           245: ulong  pc;
        !           246: 
        !           247: Scache scache[NSYM];
        !           248: 
        !           249: /* Code generator and machine specific optimisation */
        !           250: Inst           *ai(void);
        !           251: void           mkaddr(Node*, Adres*, int);
        !           252: void           reg(Node*, Type*, Node*);
        !           253: Node           *regtmp(void);
        !           254: Node           *regn(int);
        !           255: void           regfree(Node*);
        !           256: void           preamble(Node*);
        !           257: void           sucalc(Node*);
        !           258: void           scopeis(int);
        !           259: void           regret(Node*, Type*);
        !           260: void           genarg(Node*);
        !           261: void           codmop(Node*, Node*, Node*, Node*);
        !           262: Inst           *instruction(int, Node*, Node*, Node*);
        !           263: void           label(Inst*, ulong);
        !           264: void           gencond(Node*, Node*, int);
        !           265: int            immed(Node*);
        !           266: void           invertcond(Node*);
        !           267: void           codcond(int, Node*, Node*);
        !           268: void           genexp(Node*, Node*);
        !           269: void           ilink(Inst*);
        !           270: int            vconst(Node*);
        !           271: void           assign(Node*, Node*);
        !           272: void           oasgn(Node*, Node*);
        !           273: Node           *argnode(Type*);
        !           274: void           orecv(Node*, Node*);
        !           275: void           switchcode(Node*);
        !           276: void           gencmps(Node**, int, long, Node*);
        !           277: void           regcheck(void);
        !           278: void           setlabel(Node*, ulong);
        !           279: void           setgoto(Node*, Inst*);
        !           280: void           resolvegoto(void);
        !           281: void           gencomplex(Node*, Node*);
        !           282: void           parcode(Node*);
        !           283: Node           *stknode(Type*);
        !           284: void           mkdata(Node*, int, int, Inst*);
        !           285: Reg*           rega(void);
        !           286: int            rcmp(void*, void*);
        !           287: void           regopt(Inst*);
        !           288: void           addmove(Reg*, int, int, int);
        !           289: Bits           mkvar(Adres*, int);
        !           290: void           prop(Reg*, Bits, Bits);
        !           291: int            loopit(Reg*);
        !           292: void           synch(Reg*, Bits);
        !           293: ulong          allreg(ulong, Rgn*);
        !           294: void           paint1(Reg*, int);
        !           295: ulong          paint2(Reg*, int);
        !           296: void           paint3(Reg*, int, long, int);
        !           297: void           addreg(Adres*, int);
        !           298: void           peep(void);
        !           299: void           excise(Reg*);
        !           300: Reg*           uniqp(Reg*);
        !           301: Reg*           uniqs(Reg*);
        !           302: int            regtyp(Adres*);
        !           303: int            regzer(Adres*);
        !           304: int            anyvar(Adres*);
        !           305: int            subprop(Reg*);
        !           306: int            copyprop(Reg*);
        !           307: int            copy1(Adres*, Adres*, Reg*, int);
        !           308: int            copyu(Inst*, Adres*, Adres*);
        !           309: int            copyas(Adres*, Adres*);
        !           310: int            copyau(Adres*, Adres*);
        !           311: int            copyau1(Inst*, Adres*);
        !           312: int            copysub(Adres*, Adres*, Adres*, int);
        !           313: int            copysub1(Inst*, Adres*, Adres*, int);
        !           314: long           RtoB(int);
        !           315: long           FtoB(int);
        !           316: int            BtoR(long);
        !           317: int            BtoF(long);
        !           318: Bits           bor(Bits, Bits);
        !           319: Bits           band(Bits, Bits);
        !           320: Bits           bnot(Bits);
        !           321: int            bany(Bits*);
        !           322: int            bnum(Bits);
        !           323: Bits           blsh(int);
        !           324: int            beq(Bits, Bits);
        !           325: int            bitno(long);
        !           326: int            Bconv(void*, Fconv*);
        !           327: void           ieeedtod(Ieee*, double);
        !           328: int            vcache(Biobuf*, Adres*);
        !           329: char           *vaddr(char*, Adres*, int);
        !           330: void           vname(Biobuf*, char, char*, int);
        !           331: void           cominit(Node*, Type*, Node*, int);
        !           332: Node*          internnode(Type*);
        !           333: void           lblock(Node*);
        !           334: Node*          conf(double);
        !           335: void           evalarg(Node*, int);
        !           336: Node*          atvnode(Type*);
        !           337: Node*          paramnode(Type*);
        !           338: void           genelist(Node*);
        !           339: int            mulcon(Node*, Node*);
        !           340: Multab*                mulcon0(long);

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.