OpenCores
URL https://opencores.org/ocsvn/thor/thor/trunk

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64v5/] [software/] [AS64/] [source/] [FT64.cpp] - Diff between revs 54 and 55

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 54 Rev 55
Line 31... Line 31...
 
 
extern char *pif1;
extern char *pif1;
extern int first_rodata;
extern int first_rodata;
extern int first_data;
extern int first_data;
extern int first_bss;
extern int first_bss;
extern int htable[100000];
 
extern int htblcnt[100000];
 
extern int htblmax;
extern int htblmax;
extern int pass;
extern int pass;
extern int num_cinsns;
extern int num_cinsns;
 
 
static int64_t ca;
static int64_t ca;
Line 1055... Line 1053...
 
 
static void emit_insn(int64_t oc, int can_compress, int sz)
static void emit_insn(int64_t oc, int can_compress, int sz)
{
{
    int ndx;
    int ndx;
 
 
 
        switch (sz) {
 
        case 6: oc = oc & 0xffffffffffffLL;     break;// 48-bits max
 
        case 4: oc = oc & 0xffffffffLL; break;
 
        default: oc = oc & 0xffffLL; break;
 
        }
 
        if (sz > 2) {
    if (pass==3 && can_compress && gCanCompress) {
    if (pass==3 && can_compress && gCanCompress) {
       for (ndx = 0; ndx < htblmax; ndx++) {
       for (ndx = 0; ndx < htblmax; ndx++) {
         if ((int)oc == hTable[ndx].opcode) {
                                if (oc == hTable[ndx].opcode) {
           hTable[ndx].count++;
           hTable[ndx].count++;
           return;
           return;
         }
         }
       }
       }
       if (htblmax < 100000) {
       if (htblmax < 100000) {
          hTable[htblmax].opcode = (int)oc;
                                hTable[htblmax].opcode = oc;
          hTable[htblmax].count = 1;
          hTable[htblmax].count = 1;
          htblmax++;
          htblmax++;
          return;
          return;
       }
       }
       error("Too many instructions");
       error("Too many instructions");
       return;
       return;
    }
    }
 
        }
    if (pass > 3) {
    if (pass > 3) {
     if (can_compress && gCanCompress) {
                if (can_compress && gCanCompress && sz > 2) {
       for (ndx = 0; ndx < min(128,htblmax); ndx++) {
                        for (ndx = 0; ndx < min(256, htblmax); ndx++) {
         if ((int)oc == hTable[ndx].opcode) {
                                if (oc == hTable[ndx].opcode) {
           emitCode(((ndx << 6)|0x3F) & 0xff);
                                        emitCode(0x2D);
           emitCode(((ndx << 6)|0x3F) >> 8);
                                        emitCode(ndx);
                   num_bytes += 2;
                   num_bytes += 2;
                   num_insns += 1;
                   num_insns += 1;
 
                                        num_cinsns += 1;
           return;
           return;
         }
         }
       }
       }
     }
     }
         if (sz==2) {
         if (sz==2) {
Line 1107... Line 1113...
         emitCode((oc >> 16) & 255);
         emitCode((oc >> 16) & 255);
         emitCode((oc >> 24) & 255);
         emitCode((oc >> 24) & 255);
         emitCode((oc >> 32LL) & 255);
         emitCode((oc >> 32LL) & 255);
         emitCode((oc >> 40LL) & 255);
         emitCode((oc >> 40LL) & 255);
         num_bytes += 6;
         num_bytes += 6;
        //if (sz==3) {
 
        //      emitCode((int)(oc >> 16));
 
 //         num_bytes += 2;
 
        //      emitCode(oc >> 32);
 
 //         num_bytes += 2;
 
        //}
 
        num_insns += 1;
        num_insns += 1;
    /*
 
    if (processOpt==2) {
 
       for (ndx = 0; ndx < htblmax; ndx++) {
 
         if (oc == hTable[ndx].opcode) {
 
           printf("found opcode\n");
 
           emitAlignedCode(((ndx & 8) << 4)|0x50|(ndx & 0x7));
 
           emitCode(ndx >> 4);
 
           return;
 
         }
 
       }
 
     emitAlignedCode(oc & 255);
 
     emitCode((oc >> 8) & 255);
 
     emitCode((oc >> 16) & 255);
 
     emitCode((oc >> 24) & 255);
 
    }
 
    else {
 
     emitAlignedCode(oc & 255);
 
     emitCode((oc >> 8) & 255);
 
     emitCode((oc >> 16) & 255);
 
     emitCode((oc >> 24) & 255);
 
    */
 
    }
    }
}
}
 
 
void LoadConstant(int64_t val, int rg)
void LoadConstant(int64_t val, int rg)
{
{
Line 1157... Line 1136...
                        0x09, !expand_flag, 6);
                        0x09, !expand_flag, 6);
                return;
                return;
        }
        }
        if (IsNBit(val, 49)) {
        if (IsNBit(val, 49)) {
                emit_insn(
                emit_insn(
                        ((val >> 30) << 13LL) |
                        ((val >> 30LL) << 13LL) |
                        (rg << 8) |
                        (rg << 8) |
                        0x27, !expand_flag, 4); // LUI
                        0x27, !expand_flag, 4); // LUI
                if (((val >> 20) & 0xfffffLL) != 0)
                if (((val >> 20LL) & 0xfffffLL) != 0)
                        emit_insn(
                        emit_insn(
                        (val << 18LL) |
                        (val << 18LL) |
                        (rg << 13) |
                        (rg << 13) |
 
                        (rg << 8) |
                        (1 << 6) |
                        (1 << 6) |
                        0x09, !expand_flag, 6);
                        0x09, !expand_flag, 6);
                return;
                return;
        }
        }
        // Won't fit into 49 bits, assume 64 bit constant
        // Won't fit into 49 bits, assume 64 bit constant
Line 1177... Line 1157...
                0x27, !expand_flag, 6); // LUI
                0x27, !expand_flag, 6); // LUI
        if (((val >> 20) & 0xfffffLL) != 0)
        if (((val >> 20) & 0xfffffLL) != 0)
                emit_insn(
                emit_insn(
                (val << 18LL) |
                (val << 18LL) |
                        (rg << 13) |
                        (rg << 13) |
 
                        (rg << 8) |
                        (1 << 6) |
                        (1 << 6) |
                        0x09, !expand_flag, 6); // ORI
                        0x09, !expand_flag, 6); // ORI
        return;
        return;
}
}
 
 
Line 3096... Line 3077...
                        (opcode6 << 26LL) |
                        (opcode6 << 26LL) |
                        (0 << 23) |              // Sc
                        (0 << 23) |              // Sc
                        (Rs << 18) |
                        (Rs << 18) |
                        (23 << 13) |
                        (23 << 13) |
                        (Ra << 8) |
                        (Ra << 8) |
                        0x02,!expand_flag,4);
                        0x16,!expand_flag,4);
                ScanToEOL();
                ScanToEOL();
                return;
                return;
        }
        }
        if (!IsNBit(val, 14)) {
        if (!IsNBit(val, 14)) {
                emit_insn(
                emit_insn(
Line 3412... Line 3393...
                        (opcode6 << 26LL) |
                        (opcode6 << 26LL) |
                        (0 << 23) |              // Sc = 0
                        (0 << 23) |              // Sc = 0
                        (Rt << 18) |
                        (Rt << 18) |
                        (23 << 13) |
                        (23 << 13) |
                        (Ra << 8) |
                        (Ra << 8) |
                        0x02,!expand_flag,4);
                        0x16,!expand_flag,4);
                ScanToEOL();
                ScanToEOL();
                return;
                return;
        }
        }
        if (!IsNBit(val, 14)) {
        if (!IsNBit(val, 14)) {
                emit_insn(
                emit_insn(
Line 4449... Line 4430...
    first_org = 1;
    first_org = 1;
    first_rodata = 1;
    first_rodata = 1;
    first_data = 1;
    first_data = 1;
    first_bss = 1;
    first_bss = 1;
        expandedBlock = 0;
        expandedBlock = 0;
    if (pass<3) {
    if (pass==3) {
    htblmax = 0;
    htblmax = 0;
    for (nn = 0; nn < 100000; nn++) {
    for (nn = 0; nn < 100000; nn++) {
      hTable[nn].count = 0;
      hTable[nn].count = 0;
      hTable[nn].opcode = 0;
      hTable[nn].opcode = 0;
    }
    }
Line 4523... Line 4504...
            }
            }
            segment = bssseg;
            segment = bssseg;
            break;
            break;
                case tk_cache: process_cache(0x1E); break;
                case tk_cache: process_cache(0x1E); break;
                case tk_call:  process_call(0x19); break;
                case tk_call:  process_call(0x19); break;
        case tk_cli: emit_insn(0xC0000002,0,4); break;
        case tk_cli: emit_insn(0xC0000002,!expand_flag,4); break;
                case tk_chk:  process_chk(0x34); break;
                case tk_chk:  process_chk(0x34); break;
                case tk_cmovenz: process_cmove(0x29); break;
                case tk_cmovenz: process_cmove(0x29); break;
                //case tk_cmp:  process_rrop(0x06); break;
                //case tk_cmp:  process_rrop(0x06); break;
                //case tk_cmpi:  process_riop(0x06); break;
                //case tk_cmpi:  process_riop(0x06); break;
                //case tk_cmpu:  process_rrop(0x07); break;
                //case tk_cmpu:  process_rrop(0x07); break;
Line 4617... Line 4598...
                case tk_lvhu: ProcessLoadVolatile(0x3B,-4); break;
                case tk_lvhu: ProcessLoadVolatile(0x3B,-4); break;
                case tk_lvw: ProcessLoadVolatile(0x3B,8); break;
                case tk_lvw: ProcessLoadVolatile(0x3B,8); break;
        case tk_lw:  process_load(0x20,4); break;
        case tk_lw:  process_load(0x20,4); break;
        case tk_lwr:  process_load(0x1D,0); break;
        case tk_lwr:  process_load(0x1D,0); break;
                                case tk_macro:  process_macro(); break;
                                case tk_macro:  process_macro(); break;
                case tk_memdb: emit_insn(0x04400002,0,4); break;
                case tk_memdb: emit_insn(0x04400002,!expand_flag,4); break;
                case tk_memsb: emit_insn(0x04440002,0,4); break;
                case tk_memsb: emit_insn(0x04440002,!expand_flag,4); break;
                case tk_message: process_message(); break;
                case tk_message: process_message(); break;
                case tk_mod: process_rrop(0x16,0x2E); break;
                case tk_mod: process_rrop(0x16,0x2E); break;
                case tk_modu: process_rrop(0x14,-1); break;
                case tk_modu: process_rrop(0x14,-1); break;
        case tk_mov: process_mov(0x02, 0x22); break;
        case tk_mov: process_mov(0x02, 0x22); break;
                case tk_mul: process_rrop(0x3A,0x3A); break;
                case tk_mul: process_rrop(0x3A,0x3A); break;
                //case tk_mulh: process_rrop(0x26, 0x3A); break;
                //case tk_mulh: process_rrop(0x26, 0x3A); break;
                case tk_mulu: process_rrop(0x38,0x38); break;
                case tk_mulu: process_rrop(0x38,0x38); break;
                //case tk_muluh: process_rrop(0x24, 0x38); break;
                //case tk_muluh: process_rrop(0x24, 0x38); break;
                case tk_neg: process_neg(); break;
                case tk_neg: process_neg(); break;
        case tk_nop: emit_insn(0x1C,0,4); break;
        case tk_nop: emit_insn(0x1C,!expand_flag,4); break;
                case tk_not: process_rop(0x05); break;
                case tk_not: process_rop(0x05); break;
//        case tk_not: process_rop(0x07); break;
//        case tk_not: process_rop(0x07); break;
        case tk_or:  process_rrop(0x09,0x09); break;
        case tk_or:  process_rrop(0x09,0x09); break;
        case tk_ori: process_riop(0x09); break;
        case tk_ori: process_riop(0x09); break;
        case tk_org: process_org(); break;
        case tk_org: process_org(); break;
        case tk_plus: expand_flag = 1; break;
                                case tk_plus: compress_flag = 0;  expand_flag = 1; break;
        case tk_public: process_public(); break;
        case tk_public: process_public(); break;
        case tk_rodata:
        case tk_rodata:
            if (first_rodata) {
            if (first_rodata) {
                while(sections[segment].address & 4095)
                while(sections[segment].address & 4095)
                    emitByte(0x00);
                    emitByte(0x00);
Line 4693... Line 4674...
        case tk_swap: process_rop(0x03); break;
        case tk_swap: process_rop(0x03); break;
                //case tk_swp:  process_storepair(0x27); break;
                //case tk_swp:  process_storepair(0x27); break;
                case tk_sxb: process_rop(0x1A); break;
                case tk_sxb: process_rop(0x1A); break;
                case tk_sxc: process_rop(0x19); break;
                case tk_sxc: process_rop(0x19); break;
                case tk_sxh: process_rop(0x18); break;
                case tk_sxh: process_rop(0x18); break;
                case tk_sync: emit_insn(0x04480002,0,4); break;
                case tk_sync: emit_insn(0x04480002,!expand_flag,4); break;
                //case tk_unlink: emit_insn((0x1B << 26) | (0x1F << 16) | (30 << 11) | (0x1F << 6) | 0x02,0,4); break;
                //case tk_unlink: emit_insn((0x1B << 26) | (0x1F << 16) | (30 << 11) | (0x1F << 6) | 0x02,0,4); break;
                case tk_vadd: process_vrrop(0x04); break;
                case tk_vadd: process_vrrop(0x04); break;
                case tk_vadds: process_vsrrop(0x14); break;
                case tk_vadds: process_vsrrop(0x14); break;
                case tk_vand: process_vrrop(0x08); break;
                case tk_vand: process_vrrop(0x08); break;
                case tk_vands: process_vsrrop(0x18); break;
                case tk_vands: process_vsrrop(0x18); break;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.