Line 27... |
Line 27... |
#include <string.h>
|
#include <string.h>
|
#include <ctype.h>
|
#include <ctype.h>
|
|
|
#include "config.h"
|
#include "config.h"
|
#include "arch.h"
|
#include "arch.h"
|
#include "opcode/or32.h"
|
|
#include "branch_predict.h"
|
#include "branch_predict.h"
|
#include "abstract.h"
|
#include "abstract.h"
|
#include "labels.h"
|
#include "labels.h"
|
#include "parse.h"
|
#include "parse.h"
|
#include "execute.h"
|
#include "execute.h"
|
Line 42... |
Line 41... |
#include "debug_unit.h"
|
#include "debug_unit.h"
|
#include "opcode/or32.h"
|
#include "opcode/or32.h"
|
#include "immu.h"
|
#include "immu.h"
|
#include "dmmu.h"
|
#include "dmmu.h"
|
#include "debug.h"
|
#include "debug.h"
|
|
#include "opcode/or32.h"
|
|
|
/* General purpose registers. */
|
/* General purpose registers. */
|
machword reg[MAX_GPRS];
|
machword reg[MAX_GPRS];
|
|
|
/* Instruction queue */
|
/* Instruction queue */
|
Line 609... |
Line 609... |
update_pc();
|
update_pc();
|
return 0;
|
return 0;
|
}
|
}
|
|
|
/* If decoding cannot be found, call this function */
|
/* If decoding cannot be found, call this function */
|
|
#if SIMPLE_EXECUTION
|
|
void l_invalid (struct iqueue_entry *current) {
|
|
#else
|
void l_invalid () {
|
void l_invalid () {
|
|
#endif
|
/* It would be hard to handle this case for statistics; we skip it
|
/* It would be hard to handle this case for statistics; we skip it
|
since it should not occur anyway:
|
since it should not occur anyway:
|
IFF (config.cpu.dependstats) current->func_unit = it_unknown; */
|
IFF (config.cpu.dependstats) current->func_unit = it_unknown; */
|
except_handle(EXCEPT_ILLEGAL, iqueue[0].insn_addr);
|
except_handle(EXCEPT_ILLEGAL, iqueue[0].insn_addr);
|
}
|
}
|
Line 624... |
Line 628... |
#include "execgen.c"
|
#include "execgen.c"
|
|
|
#else /* SIMPLE_EXECUTION */
|
#else /* SIMPLE_EXECUTION */
|
|
|
|
|
#define INSTRUCTION(name) void name ()
|
#define INSTRUCTION(name) void name (struct iqueue_entry *current)
|
#define get_operand (op_no) op[(op_no)]
|
|
|
|
/* Implementation specific.
|
/* Implementation specific.
|
Parses and returns operands. */
|
Parses and returns operands. */
|
|
|
static void
|
static void
|
Line 684... |
Line 687... |
}
|
}
|
|
|
/* Implementation specific.
|
/* Implementation specific.
|
Evaluates source operand op_no. */
|
Evaluates source operand op_no. */
|
|
|
inline static unsigned long eval_operand32 (int op_no, int *breakpoint)
|
static unsigned long eval_operand (int op_no)
|
{
|
|
if (op[op_no + MAX_OPERANDS] & OPTYPE_DIS)
|
|
/* memory accesses are not cached */
|
|
return eval_mem32 (op[op_no], breakpoint);
|
|
else if (op[op_no + MAX_OPERANDS] & OPTYPE_REG) {
|
|
return eval_reg32 (op[op_no]);
|
|
} else {
|
|
return op[op_no];
|
|
}
|
|
}
|
|
|
|
/* Implementation specific.
|
|
Evaluates source operand op_no. */
|
|
|
|
static unsigned long eval_operand16 (int op_no, int *breakpoint)
|
|
{
|
{
|
if (op[op_no + MAX_OPERANDS] & OPTYPE_DIS) {
|
if (op[op_no + MAX_OPERANDS] & OPTYPE_DIS) {
|
return eval_mem16 (op[op_no], breakpoint);
|
return op[op_no];
|
}
|
|
else {
|
|
fprintf (stderr, "Invalid operand type.\n");
|
|
exit (1);
|
|
}
|
|
}
|
|
|
|
/* Implementation specific.
|
|
Evaluates source operand op_no. */
|
|
|
|
static unsigned long eval_operand8 (int op_no, int *breakpoint)
|
|
{
|
|
if (op[op_no + MAX_OPERANDS] & OPTYPE_DIS)
|
|
return eval_mem8 (op[op_no], breakpoint);
|
|
else {
|
|
fprintf (stderr, "Invalid operand type.\n");
|
|
exit (1);
|
|
}
|
|
}
|
|
|
|
/* Implementation specific.
|
|
Set destination operand (register direct, register indirect
|
|
(with displacement) with value. */
|
|
|
|
inline static void set_operand32(int op_no, unsigned long value, int* breakpoint)
|
|
{
|
|
/* Mark this as destination operand. */
|
|
IFF (config.cpu.dependstats) op[op_no + MAX_OPERANDS] |= OPTYPE_DST;
|
|
if (op[op_no + MAX_OPERANDS] & OPTYPE_DIS) {
|
|
set_mem32(op[op_no], value, breakpoint);
|
|
} else if (op[op_no + MAX_OPERANDS] & OPTYPE_REG) {
|
} else if (op[op_no + MAX_OPERANDS] & OPTYPE_REG) {
|
set_reg32(op[op_no], value);
|
return eval_reg32 (op[op_no]);
|
} else {
|
} else {
|
fprintf (stderr, "Invalid operand type.\n");
|
return op[op_no];
|
exit (1);
|
|
}
|
|
}
|
|
|
|
/* Implementation specific.
|
|
Set destination operand (register direct, register indirect
|
|
(with displacement) with value. */
|
|
|
|
void set_operand16(int op_no, unsigned long value, int* breakpoint)
|
|
{
|
|
/* Mark this as destination operand. */
|
|
op[op_no + MAX_OPERANDS] |= OPTYPE_DST;
|
|
if (op[op_no + MAX_OPERANDS] & OPTYPE_DIS) {
|
|
set_mem16(op[op_no], value, breakpoint);
|
|
}
|
|
else
|
|
{
|
|
fprintf (stderr, "Invalid operand type.\n");
|
|
exit (1);
|
|
}
|
}
|
}
|
}
|
|
|
/* Implementation specific.
|
/* Implementation specific.
|
Set destination operand (register direct, register indirect
|
Set destination operand (reister direct) with value. */
|
(with displacement) with value. */
|
|
|
|
void set_operand8(int op_no, unsigned long value, int* breakpoint)
|
inline static void set_operand(int op_no, unsigned long value)
|
{
|
{
|
/* Mark this as destination operand. */
|
/* Mark this as destination operand. */
|
op[op_no + MAX_OPERANDS] |= OPTYPE_DST;
|
if (!(op[op_no + MAX_OPERANDS] & OPTYPE_REG)) {
|
if (op[op_no + MAX_OPERANDS] & OPTYPE_DIS)
|
fprintf (stderr, "Trying to set a non-register operand\n");
|
set_mem8(op[op_no], value, breakpoint);
|
|
else
|
|
{
|
|
fprintf (stderr, "Invalid operand type.\n");
|
|
exit (1);
|
exit (1);
|
}
|
}
|
|
set_reg32(op[op_no], value);
|
}
|
}
|
|
|
/* Simple and rather slow decoding function based on built automata. */
|
/* Simple and rather slow decoding function based on built automata. */
|
static inline void decode_execute (struct iqueue_entry *current)
|
static inline void decode_execute (struct iqueue_entry *current)
|
{
|
{
|
int insn_index;
|
int insn_index;
|
|
|
current->insn_index = insn_index = insn_decode(current->insn);
|
current->insn_index = insn_index = insn_decode(current->insn);
|
|
|
if (insn_index < 0)
|
if (insn_index < 0)
|
l_invalid();
|
l_invalid(current);
|
else {
|
else {
|
op = ¤t->op[0];
|
op = ¤t->op[0];
|
eval_operands (current->insn, insn_index, &breakpoint);
|
eval_operands (current->insn, insn_index, &breakpoint);
|
or32_opcodes[insn_index].exec();
|
or32_opcodes[insn_index].exec(current);
|
}
|
}
|
if (do_stats) analysis(&iqueue[0]);
|
if (do_stats) analysis(&iqueue[0]);
|
}
|
}
|
|
|
|
#define SET_PARAM0(val) set_operand(0, val)
|
|
|
|
#define PARAM0 eval_operand(0)
|
|
#define PARAM1 eval_operand(1)
|
|
#define PARAM2 eval_operand(2)
|
|
|
#include "insnset.c"
|
#include "insnset.c"
|
|
|
#endif /* !SIMPLE_EXECUTION */
|
#endif /* !SIMPLE_EXECUTION */
|
|
|
No newline at end of file
|
No newline at end of file
|