Annotation of GNUtools/cctools/as/sparc-check.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include "sparc-opcode.h"
        !             3: 
        !             4: static void print_rs_reg(char);
        !             5: static void print_cp_reg(void);
        !             6: static void print_f_reg(int);
        !             7: static void print_imm_13(void);
        !             8: static void print_imm_22(void);
        !             9: static void print_asi(void);
        !            10: 
        !            11: 
        !            12: static  char *reg_names[] =
        !            13: { "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",      
        !            14:   "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7",      
        !            15:   "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",      
        !            16:   "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7",      
        !            17:   "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",      
        !            18:   "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",        
        !            19:   "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
        !            20:   "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
        !            21:   "y", "psr", "wim", "tbr", "pc", "npc", "fpsr", "cpsr"
        !            22: };
        !            23: 
        !            24: void
        !            25: main(
        !            26:      int argc,
        !            27:      char *argv[],
        !            28:      char *envp[])
        !            29: {
        !            30:   long i;
        !            31:   const char *arg;
        !            32:   
        !            33:   /* output each instruction */
        !            34:   
        !            35:   for(i = 0; i < NUMOPCODES - 1; i++){
        !            36:     printf("\t%s", sparc_opcodes[i].name);
        !            37:     arg = sparc_opcodes[i].args;
        !            38: 
        !            39:     if (*arg != ',' && *(arg+1) != 'a')  /* handle annul case */
        !            40:       printf("\t");
        !            41:     
        !            42:     /* and every possible combination */
        !            43:     for (arg = sparc_opcodes[i].args; *arg != '\0'; arg++) {
        !            44:       switch (*arg) {
        !            45:       case '\0':
        !            46:        break;          /* done */
        !            47:       case '1':
        !            48:       case '2':
        !            49:       case 'r':
        !            50:       case 'd':
        !            51:        print_rs_reg(*arg);     /* output in a random register */
        !            52:        break;
        !            53:       case 'i':
        !            54:        print_imm_13(); /* output a random immediate value */
        !            55:        break;
        !            56:       case 'n':
        !            57:        print_imm_22(); /* output a random immediate value */
        !            58:        break;
        !            59:       case 'L':
        !            60:       case 'l':
        !            61:        printf("undef");
        !            62:        break;
        !            63:       case 'D':
        !            64:        print_cp_reg();
        !            65:        break;
        !            66:       case 'F':
        !            67:        printf("%%fsr");
        !            68:        break;
        !            69:       case 'p':
        !            70:        printf("%%psr");
        !            71:        break;
        !            72:       case 'C':
        !            73:        printf("%%csr");
        !            74:        break;
        !            75:       case 'A':
        !            76:        print_asi();
        !            77:        break;
        !            78:       case 'q':
        !            79:        printf("%%fq");
        !            80:        break;
        !            81:       case 'Q':
        !            82:        printf("%%cq");
        !            83:        break;
        !            84:       case 'y':
        !            85:        printf("%%y");
        !            86:        break;
        !            87:       case 'w':
        !            88:        printf("%%wim");
        !            89:        break;
        !            90:       case 't':
        !            91:        printf("%%tbr");
        !            92:        break;
        !            93:       case 'h':
        !            94:        printf("%%hi(0xaaaaa)");
        !            95:        break;
        !            96:       case 'e':
        !            97:       case 'f':
        !            98:       case 'g':
        !            99:        print_f_reg(0);
        !           100:        break;
        !           101:       case 'v':
        !           102:       case 'B':
        !           103:       case 'H':
        !           104:        print_f_reg(1);
        !           105:        break;
        !           106:       case 'R':
        !           107:       case 'V':
        !           108:       case 'J':
        !           109:        print_f_reg(3);
        !           110:        break;
        !           111:       case 'm':
        !           112:       case 'M':
        !           113:        printf("%%asr16");
        !           114:        break;
        !           115:       case 'S':
        !           116:        /* special case set insn */
        !           117:        break;
        !           118:       case '+':
        !           119:        putchar('+');
        !           120:        break;
        !           121:       case ']':
        !           122:       case '[':
        !           123:       case ',':
        !           124:       case ' ':
        !           125:        putchar(*arg);
        !           126:        break;
        !           127:       case '#':
        !           128:        printf("0");
        !           129:        break;
        !           130:       case 'a':
        !           131:        printf("a\t");
        !           132:        break;
        !           133:       default:
        !           134:        printf("*** what's this garbage %c 0x%x?\n", *arg, (int) *arg);
        !           135:       }
        !           136:     }
        !           137:     printf("\n");
        !           138:   }
        !           139:   printf("\n");
        !           140: exit(0);
        !           141: }
        !           142: 
        !           143: 
        !           144: #define MAX_RS_REG 32
        !           145: 
        !           146: static
        !           147: void
        !           148: print_rs_reg(char type)
        !           149: {
        !           150:   static int i=0;
        !           151: 
        !           152:   printf("%%%s", reg_names[i++]);
        !           153:   if (i >= MAX_RS_REG)
        !           154:     i = 0;
        !           155: }
        !           156: 
        !           157: #define MAX_FP_REG 64
        !           158: 
        !           159: static
        !           160: void
        !           161: print_f_reg(int align)
        !           162: {
        !           163:   static int i=32;
        !           164: 
        !           165:   printf("%%%s", reg_names[(i++) & ~align]);
        !           166:   if (i >= MAX_FP_REG)
        !           167:     i = 32;
        !           168: }
        !           169: 
        !           170: static
        !           171: void
        !           172: print_imm_13(void)
        !           173: {
        !           174:   static int val = 0;
        !           175: 
        !           176:   val = (val+4) & 0x3ff;
        !           177:   printf("0x%x", val);
        !           178: }
        !           179: 
        !           180: static
        !           181: void
        !           182: print_imm_22(void)
        !           183: {
        !           184:   static int val = 0;
        !           185: 
        !           186:   val = (val + 4) & 0x3fffff;
        !           187:   printf("0x%x", val);
        !           188: }
        !           189: 
        !           190: 
        !           191: #define MAX_ASI 255
        !           192: 
        !           193: static
        !           194: void print_asi(void)
        !           195: {
        !           196:   static int i=0;
        !           197: 
        !           198:   printf("(%d)", i++);
        !           199:   if (i >= MAX_ASI)
        !           200:     i = 0;
        !           201: }
        !           202: 
        !           203: #define MAX_CP_REG 32
        !           204: 
        !           205: static
        !           206: void print_cp_reg(void)
        !           207: {
        !           208:   static int i=0;
        !           209: 
        !           210:   printf("%%c%d", i++);
        !           211:   if (i >= MAX_CP_REG)
        !           212:     i = 0;
        !           213: }

unix.superglobalmegacorp.com

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