OSDN Git Service

b6ee194f9d0b60b065e47180d0d7599dbeece0a9
[pf3gnuchains/pf3gnuchains3x.git] / sid / component / cgen-cpu / sh / sh5-media-defs.h
1 /* CPU family header for sh5 / sh5_media.
2
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
4
5 Copyright (C) 2000-2009 Red Hat, Inc.
6
7 This file is part of the Red Hat simulators.
8
9
10 */
11
12 #ifndef DEFS_SH5_MEDIA_H
13 #define DEFS_SH5_MEDIA_H
14
15 #include <stack>
16 #include "cgen-types.h"
17
18 // forward declaration
19
20   
21 namespace sh5 {
22 struct sh5_cpu;
23 }
24
25 namespace sh5_media {
26
27 using namespace cgen;
28
29   static const int max_delay = 0;
30   static const int pipe_sz = 1; // max_delay + 1
31
32   template <typename ELT> 
33   struct write_stack 
34   {
35     int t;
36     const int sz;
37     ELT buf[WRITE_BUF_SZ];
38
39     write_stack       ()             : t(-1), sz(WRITE_BUF_SZ) {}
40     inline bool empty ()             { return (t == -1); }
41     inline void clear ()             { t = -1; }
42     inline void pop   ()             { if (t > -1) t--;}
43     inline void push  (const ELT &e) { if (t+1 < sz) buf [++t] = e;}
44     inline ELT &top   ()             { return buf [t>0 ? ( t<sz ? t : sz-1) : 0];}
45   };
46
47   // look ahead for latest write with index = idx, where time of write is
48   // <= dist steps from base (present) in write_stack array st.
49   // returning def if no scheduled write is found.
50
51   template <typename STKS, typename VAL>
52   inline VAL lookahead (int dist, int base, STKS &st, VAL def, int idx=0)
53   {
54     for (; dist > 0; --dist)
55     {
56       write_stack <VAL> &v = st [(base + dist) % pipe_sz];
57       for (int i = v.t; i > 0; --i) 
58           if (v.buf [i].idx0 == idx) return v.buf [i];
59     }
60     return def;
61   }
62
63
64
65   template <typename MODE>
66   struct write
67   {
68     USI pc;
69     MODE val;
70     USI idx0;
71     write (PCADDR _pc, MODE _val, USI _idx0=0) : pc(_pc), val(_val), idx0(_idx0) {} 
72     write() {}
73   };
74
75
76 // write stacks used in parallel execution
77
78   struct write_stacks
79   {
80   // types of stacks
81
82
83
84   // unified writeback function (defined in sh5_media-write.cc)
85   void writeback (int tick, sh5::sh5_cpu* current_cpu);
86   // unified write-stack clearing function (defined in sh5_media-write.cc)
87   void reset ();
88
89   }; // end struct sh5_media::write_stacks 
90
91 } // end sh5_media namespace
92
93 #endif /* DEFS_SH5_MEDIA_H */