translate-all.c revision 3d40f685fa5cdd9cb665ae3cbf5f76113dafcb99
/*
* 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, see <http://www.gnu.org/licenses/>.
*/
/*
* Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Oracle elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#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"
#include "tcg.h"
#include "qemu-timer.h"
/* code generation context */
void cpu_gen_init(void)
{
}
/* 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).
*/
{
TCGContext *s = &tcg_ctx;
int gen_code_size;
#ifdef CONFIG_PROFILER
#endif
#ifdef CONFIG_PROFILER
s->tb_count1++; /* includes aborted translations because of
exceptions */
ti = profile_getclock();
#endif
#ifdef VBOX
#endif
tcg_func_start(s);
/* generate machine code */
#ifdef USE_DIRECT_JUMP
#else
s->tb_jmp_offset = NULL;
#endif
#ifdef CONFIG_PROFILER
s->tb_count++;
s->code_time -= profile_getclock();
#endif
#ifdef CONFIG_PROFILER
s->code_time += profile_getclock();
s->code_out_len += gen_code_size;
#endif
#ifdef VBOX
#endif
#ifdef DEBUG_DISAS
if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) {
qemu_log("\n");
}
#endif
return 0;
}
/* The cpu state corresponding to 'searched_pc' is restored.
*/
void *puc)
{
TCGContext *s = &tcg_ctx;
int j;
#ifdef CONFIG_PROFILER
#endif
#ifdef CONFIG_PROFILER
ti = profile_getclock();
#endif
tcg_func_start(s);
if (use_icount) {
/* Reset the cycle counter to the start of the block. */
/* Clear the IO flag. */
}
/* find opc index corresponding to search_pc */
if (searched_pc < tc_ptr)
return -1;
#ifdef USE_DIRECT_JUMP
#else
s->tb_jmp_offset = NULL;
#endif
if (j < 0)
return -1;
/* now find start of instruction before */
while (gen_opc_instr_start[j] == 0)
j--;
#ifdef CONFIG_PROFILER
s->restore_count++;
#endif
return 0;
}