translate-all.c revision 9b898ee3642a830a4d4af4d0a485a49d157b5551
/*
* Host code generation
*
* Copyright (c) 2003 Fabrice Bellard
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "config.h"
#define NO_CPU_IO_DEFS
#include "cpu.h"
#include "exec-all.h"
#include "disas.h"
enum {
#include "opc.h"
};
long gen_labels[OPC_BUF_SIZE];
int nb_gen_labels;
#if defined(TARGET_I386)
#elif defined(TARGET_SPARC)
#elif defined(TARGET_MIPS)
#endif
int code_copy_enabled = 1;
#ifdef DEBUG_DISAS
static const char *op_str[] = {
#include "opc.h"
};
static uint8_t op_nb_args[] = {
#include "opc.h"
};
#endif /* bird: opc_copy_size is used ouside DEBUG_DISAS and VBOX isn't necessarily defining DEBUG_DISAS presently. */
static const unsigned short opc_copy_size[] = {
#include "opc.h"
};
#ifdef DEBUG_DISAS /* bird: see previous bird comment. */
{
const uint32_t *opparam_ptr;
int c, n, i;
for(;;) {
c = *opc_ptr++;
n = op_nb_args[c];
for(i = 0; i < n; i++) {
}
if (c == INDEX_op_end)
break;
opparam_ptr += n;
}
}
#endif
/* compute label info */
{
int c, i;
unsigned long gen_code_addr[OPC_BUF_SIZE];
if (nb_gen_labels == 0)
return;
/* compute the address of each op code */
i = 0;
for(;;) {
c = opc_buf[i];
gen_code_addr[i] =(unsigned long)gen_code_ptr;
if (c == INDEX_op_end)
break;
gen_code_ptr += opc_copy_size[c];
i++;
}
/* compute the address of each label */
for(i = 0; i < nb_gen_labels; i++) {
}
}
/* return non zero if the very first instruction is invalid so that
the virtual CPU can trigger an exception.
'*gen_code_size_ptr' contains the size of the generated code (host
code).
*/
int max_code_size, int *gen_code_size_ptr)
{
int gen_code_size;
#ifdef USE_CODE_COPY
if (code_copy_enabled &&
/* nothing more to do */
} else
#endif
{
#ifdef VBOX
{
return -1;
}
#else /* !VBOX */
return -1;
#endif /* !VBOX */
/* generate machine code */
#ifdef USE_DIRECT_JUMP
/* the following two entries are optional (only used for string ops) */
#endif
#ifdef USE_DIRECT_JUMP
#else
NULL,
#endif
#ifdef VBOX
#endif
}
#ifdef DEBUG_DISAS
if (loglevel & CPU_LOG_TB_OUT_ASM) {
}
#endif
return 0;
}
/* The cpu state corresponding to 'searched_pc' is restored.
*/
void *puc)
{
int j, c;
unsigned long tc_ptr;
#ifdef USE_CODE_COPY
}
#endif
return -1;
/* find opc index corresponding to search_pc */
if (searched_pc < tc_ptr)
return -1;
j = 0;
for(;;) {
c = *opc_ptr;
if (c == INDEX_op_end)
return -1;
tc_ptr += opc_copy_size[c];
if (searched_pc < tc_ptr)
break;
opc_ptr++;
}
j = opc_ptr - gen_opc_buf;
/* now find start of instruction before */
while (gen_opc_instr_start[j] == 0)
j--;
#if defined(TARGET_I386)
{
int cc_op;
#ifdef DEBUG_DISAS
if (loglevel & CPU_LOG_TB_OP) {
int i;
for(i=0;i<=j; i++) {
if (gen_opc_instr_start[i]) {
}
}
}
#endif
cc_op = gen_opc_cc_op[j];
if (cc_op != CC_OP_DYNAMIC)
}
#elif defined(TARGET_ARM)
#elif defined(TARGET_SPARC)
{
npc = gen_opc_npc[j];
if (npc == 1) {
/* dynamic NPC: already stored */
} else if (npc == 2) {
/* jump PC: use T2 and the jump targets of the translation */
if (t2)
else
} else {
}
}
#elif defined(TARGET_PPC)
{
int type;
/* for PPC, we need to look at the micro operation to get the
access type */
switch(c) {
#if defined(CONFIG_USER_ONLY)
#else
#endif
type = ACCESS_FLOAT;
break;
type = ACCESS_RES;
break;
type = ACCESS_RES;
break;
type = ACCESS_EXT;
break;
default:
type = ACCESS_INT;
break;
}
}
#elif defined(TARGET_M68K)
#elif defined(TARGET_MIPS)
#endif
return 0;
}