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

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc2/] [or1ksim/] [cpu/] [or32/] [rec_i386.h] - Blame information for rev 1611

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1452 nogj
/* rec_i386.h -- i386 specific parts of the recompile engine
2
   Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
3
 
4
This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
 
20
 
21
#include "common_i386.h"
22
 
23
/* Initialises the recompiler (architechture specific). */
24
static inline void init_dyn_rec(void)
25
{
26
  uint64_t add = UINT32_C(-1) | UINT64_C(4) << 32;
27
 
28
  /* Initialises the scheduler handling for future use.  Because the x86 has a
29
   * very low number of registers (8), I have to use MMX registers.  I could do
30
   * load/store combination but that takes up space and is slow.  I use packed
31
   * doublewords to strut my stuff.  The high 32-bits of the first MMX register
32
   * is the PC, the low 32-bits is the number of cycles that are still
33
   * outstanding for the next scheduled job to run.  The second MMX register
34
   * holds the amount that needs to be added to the two values on each cycle.
35
   * The third MMX register only holds the value that we must use to update the
36
   * low 32-bits with */
37
   asm volatile ("movq %0, %%mm1\n"
38
                 : : "m" (add));
39
}
40
 
41
/* Gets the current stack pointer */
42
static inline void *get_sp(void)
43
{
44
  void *stack;
45
  asm("movl %%esp, %0" : "=rm" (stack));
46
  return stack;
47
}
48
 
49
/* Updates the number of cycles that it takes to load 1 instruction */
50
static inline void upd_cycles_dec(int32_t amount)
51
{
52
  useless_x86.val3232.high32 = 4;
53
  useless_x86.val3232.low32 = amount;
54
  asm volatile ("movq %0, %%mm1" : : "m" (useless_x86.val64));
55
}
56
 
57
/* Adds the number of cycles to the next job that would be added anyway */
58
static inline void sched_add_cycles(void)
59
{
60
  asm("movd %%mm1, %%eax\n"
61
      "\tmovd %%eax, %%mm2\n"
62
      "paddd %%mm2, %%mm0"
63
      : : : "eax");
64
}
65
 
66
/* Adds an arbitary amount to the cycle counter */
67
static inline void add_to_cycles(int32_t val)
68
{
69
  val = -val;
70
  asm("movd %0, %%mm2\n"
71
      "paddd %%mm2, %%mm0\n"
72
      : : "rm" (val));
73
}

powered by: WebSVN 2.1.0

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