home *** CD-ROM | disk | FTP | other *** search
- #include "register.h"
- #include "symtab.h"
- #include "diblock.h"
- #include "instrn.h"
- #include "process.h"
-
- dinstrn *
- i_bc1f(dipc, offset)
- dinstrn *dipc;
- short offset;
- {
- unsigned long c;
-
- procsget(CP1CS, c);
-
- if (Test_Cond(c) == 0)
- dipc = do_delayed_branch(dipc, (unsigned long)(dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2)));
-
- return dipc;
- }
-
- dinstrn *
- i_bc1t(dipc, offset)
- dinstrn *dipc;
- short offset;
- {
- unsigned long c;
-
- procsget(CP1CS, c);
-
- if (Test_Cond(c) == 1)
- dipc = do_delayed_branch(dipc, (unsigned long)(dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2)));
-
- return dipc;
- }
-
- static
- dinstrn *
- c_beq0(dipc)
- dinstrn *dipc;
- {
- if (*dipc->di_0 == 0)
- do_known_delayed_branch;
-
- return dipc;
- }
-
- static
- dinstrn *
- c_beq0_up(dipc)
- dinstrn *dipc;
- {
- if (*dipc->di_0 == 0)
- do_known_delayed_upbranch;
-
- return dipc;
- }
-
- static
- dinstrn *
- c_beq(dipc)
- dinstrn *dipc;
- {
- if (*dipc->di_0 == *dipc->di_1)
- do_known_delayed_branch;
-
- return dipc;
- }
-
- static
- dinstrn *
- c_beq_up(dipc)
- dinstrn *dipc;
- {
- if (*dipc->di_0 == *dipc->di_1)
- do_known_delayed_upbranch;
-
- return dipc;
- }
-
- dinstrn *
- i_beq(dipc, rs, rt, offset)
- dinstrn *dipc;
- int rs;
- int rt;
- short offset;
- {
- unsigned long s;
- unsigned long t;
- unsigned long target;
-
- target = dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2);
-
- if (compile_ok)
- {
- if (rt == R_0)
- dipc->di_handler = (target > dipc->di_addr) ? c_beq0 : c_beq0_up;
- else
- dipc->di_handler = (target > dipc->di_addr) ? c_beq : c_beq_up;
-
- dipc->di_0 = &P.p_state[rs];
- dipc->di_1 = &P.p_state[rt];
-
- (void)compile_known_delayed_branch(dipc, target);
-
- return (*dipc->di_handler)(dipc);
- }
-
- procsget(rs, s);
-
- procsget(rt, t);
-
- if (s == t)
- dipc = do_delayed_branch(dipc, target);
-
- return dipc;
- }
-
- static
- dinstrn *
- c_bgez(dipc)
- dinstrn *dipc;
- {
- if ((long)*dipc->di_0 >= 0)
- do_known_delayed_branch;
-
- return dipc;
- }
-
- static
- dinstrn *
- c_bgez_up(dipc)
- dinstrn *dipc;
- {
- if ((long)*dipc->di_0 >= 0)
- do_known_delayed_upbranch;
-
- return dipc;
- }
-
- dinstrn *
- i_bgez(dipc, rs, rt, offset)
- dinstrn *dipc;
- int rs;
- int rt;
- short offset;
- {
- unsigned long target;
- long s;
-
- target = dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2);
-
- if (compile_ok)
- {
- dipc->di_handler = c_bgez;
- dipc->di_handler = (target > dipc->di_addr) ? c_bgez : c_bgez_up;
- dipc->di_0 = &P.p_state[rs];
- (void)compile_known_delayed_branch(dipc, target);
-
- return (*dipc->di_handler)(dipc);
- }
-
- procsget(rs, *(unsigned long *)&s);
-
- if (s >= 0)
- dipc = do_delayed_branch(dipc, target);
-
- return dipc;
- }
-
- static
- dinstrn *
- c_bgtz(dipc)
- dinstrn *dipc;
- {
- if ((long)*dipc->di_0 > 0)
- do_known_delayed_branch;
-
- return dipc;
- }
-
- static
- dinstrn *
- c_bgtz_up(dipc)
- dinstrn *dipc;
- {
- if ((long)*dipc->di_0 > 0)
- do_known_delayed_upbranch;
-
- return dipc;
- }
-
- dinstrn *
- i_bgtz(dipc, rs, rt, offset)
- dinstrn *dipc;
- int rs;
- int rt;
- short offset;
- {
- unsigned long target;
- long s;
-
- target = dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2);
-
- if (compile_ok)
- {
- dipc->di_handler = (target > dipc->di_addr) ? c_bgtz : c_bgtz_up;
- dipc->di_0 = &P.p_state[rs];
- (void)compile_known_delayed_branch(dipc, target);
-
- return (*dipc->di_handler)(dipc);
- }
-
- procsget(rs, *(unsigned long *)&s);
-
- if (s > 0)
- dipc = do_delayed_branch(dipc, target);
-
- return dipc;
- }
-
- dinstrn *
- i_blez(dipc, rs, rt, offset)
- dinstrn *dipc;
- int rs;
- int rt;
- short offset;
- {
- long s;
-
- procsget(rs, *(unsigned long *)&s);
-
- if (s <= 0)
- dipc = do_delayed_branch(dipc, (unsigned long)(dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2)));
-
- return dipc;
- }
-
- dinstrn *
- i_bltz(dipc, rs, rt, offset)
- dinstrn *dipc;
- int rs;
- int rt;
- short offset;
- {
- long s;
-
- procsget(rs, *(unsigned long *)&s);
-
- if (s < 0)
- dipc = do_delayed_branch(dipc, (unsigned long)(dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2)));
-
- return dipc;
- }
-
- static
- dinstrn *
- c_bne0(dipc)
- dinstrn *dipc;
- {
- if (*dipc->di_0 != 0)
- do_known_delayed_branch;
-
- return dipc;
- }
-
- static
- dinstrn *
- c_bne0_up(dipc)
- dinstrn *dipc;
- {
- if (*dipc->di_0 != 0)
- do_known_delayed_upbranch;
-
- return dipc;
- }
-
- static
- dinstrn *
- c_bne(dipc)
- dinstrn *dipc;
- {
- if (*dipc->di_0 != *dipc->di_1)
- do_known_delayed_branch;
-
- return dipc;
- }
-
- static
- dinstrn *
- c_bne_up(dipc)
- dinstrn *dipc;
- {
- if (*dipc->di_0 != *dipc->di_1)
- do_known_delayed_upbranch;
-
- return dipc;
- }
-
- dinstrn *
- i_bne(dipc, rs, rt, offset)
- dinstrn *dipc;
- int rs;
- int rt;
- short offset;
- {
- unsigned long target;
- unsigned long s;
- unsigned long t;
-
- target = dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2);
-
- if (compile_ok)
- {
- if (rt == R_0)
- dipc->di_handler = (target > dipc->di_addr) ? c_bne0 : c_bne0_up;
- else
- dipc->di_handler = (target > dipc->di_addr) ? c_bne : c_bne_up;
-
- dipc->di_0 = &P.p_state[rs];
- dipc->di_1 = &P.p_state[rt];
- (void)compile_known_delayed_branch(dipc, target);
-
- return (*dipc->di_handler)(dipc);
- }
-
- procsget(rs, s);
-
- procsget(rt, t);
-
- if (s != t)
- dipc = do_delayed_branch(dipc, target);
-
- return dipc;
- }
-