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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [or1ksim/] [or1ksim-0.3.0/] [cpu/] [or32/] [common-i386.h] - Diff between revs 19 and 21

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 19 Rev 21
/* common-i386.h -- Assembler routines used in rec_i386.h and op_i386.h
/* common-i386.h -- Assembler routines used in rec_i386.h and op_i386.h
   Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
   Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
 
 
This file is part of OpenRISC 1000 Architectural Simulator.
This file is part of OpenRISC 1000 Architectural Simulator.
 
 
This program is free software; you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
(at your option) any later version.
 
 
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
 
/* This is needed because we can't move an mmx register to a general purpose
/* This is needed because we can't move an mmx register to a general purpose
 * register. */
 * register. */
static union {
static union {
  struct {
  struct {
    uint32_t low32;
    uint32_t low32;
    uint32_t high32;
    uint32_t high32;
  } val3232;
  } val3232;
  uint64_t val64;
  uint64_t val64;
} useless_x86;
} useless_x86;
 
 
/* Sets the PC with a specified value */
/* Sets the PC with a specified value */
static void set_pc(oraddr_t pc)
static void set_pc(oraddr_t pc)
{
{
  /* I could just use pc as a memory argument, but if I do that then gcc may put
  /* I could just use pc as a memory argument, but if I do that then gcc may put
   * the value of pc onto the stack, in which case gcc would also shift the
   * the value of pc onto the stack, in which case gcc would also shift the
   * stack twice, which would result in two add 4, %esp instructions and a
   * stack twice, which would result in two add 4, %esp instructions and a
   * mov %eax, *%esp, which would not only be slow but it would take up more
   * mov %eax, *%esp, which would not only be slow but it would take up more
   * space. */
   * space. */
  asm("movq %%mm0, %0\n"
  asm("movq %%mm0, %0\n"
      "\tmovl %2, %1\n"
      "\tmovl %2, %1\n"
      "\tmovq %3, %%mm0"
      "\tmovq %3, %%mm0"
      : "=m" (useless_x86.val64),
      : "=m" (useless_x86.val64),
        "=m" (useless_x86.val3232.high32)
        "=m" (useless_x86.val3232.high32)
      : "r" (pc),
      : "r" (pc),
        "m" (useless_x86.val64));
        "m" (useless_x86.val64));
}
}
 
 
/* Returns the current value of the pc */
/* Returns the current value of the pc */
static oraddr_t get_pc(void)
static oraddr_t get_pc(void)
{
{
  asm("movq %%mm0, %0" : "=m" (useless_x86.val64));
  asm("movq %%mm0, %0" : "=m" (useless_x86.val64));
  return useless_x86.val3232.high32;
  return useless_x86.val3232.high32;
}
}
 
 
/* Updates the runtime.sim.cycles counter */
/* Updates the runtime.sim.cycles counter */
static void upd_sim_cycles(void)
static void upd_sim_cycles(void)
{
{
  asm volatile ("movq %%mm0, %0\n" : "=m" (useless_x86.val64));
  asm volatile ("movq %%mm0, %0\n" : "=m" (useless_x86.val64));
  runtime.sim.cycles += scheduler.job_queue->time - useless_x86.val3232.low32;
  runtime.sim.cycles += scheduler.job_queue->time - useless_x86.val3232.low32;
  scheduler.job_queue->time = useless_x86.val3232.low32;
  scheduler.job_queue->time = useless_x86.val3232.low32;
  cpu_state.pc = useless_x86.val3232.high32;
  cpu_state.pc = useless_x86.val3232.high32;
}
}
 
 
 
 

powered by: WebSVN 2.1.0

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