summaryrefslogtreecommitdiff
path: root/src/mem/slicc/slicc_global.hh
blob: 40a00c9d20917c7b84634f0ace9a66a976c02c9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

/*
 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met: redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer;
 * redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution;
 * neither the name of the copyright holders nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef SLICC_GLOBAL_H
#define SLICC_GLOBAL_H

#include <cassert>

#include "mem/gems_common/std-includes.hh"
#include "mem/gems_common/Map.hh"

typedef unsigned char uint8;
typedef unsigned int uint32;
typedef unsigned long long uint64;

typedef signed char int8;
typedef int int32;
typedef long long int64;

typedef long long integer_t;
typedef unsigned long long uinteger_t;

const bool ASSERT_FLAG = true;

// when CHECK_RESOURCE_DEADLOCK is enabled, slicc will generate additional code
// that works in conjuction with the resources rank value specified in the protocol
// to detect invalid resource stalls as soon as they occur.
const bool CHECK_INVALID_RESOURCE_STALLS = false;

#undef assert
#define assert(EXPR) ASSERT(EXPR)

#define ASSERT(EXPR)\
{\
  if (ASSERT_FLAG) {\
    if (!(EXPR)) {\
      cerr << "failed assertion '"\
           << #EXPR << "' at fn "\
           << __PRETTY_FUNCTION__ << " in "\
           << __FILE__ << ":"\
           << __LINE__ << endl;\
      if(isatty(STDERR_FILENO)) {\
        cerr << "At this point you might want to attach a debug to ";\
        cerr << "the running and get to the" << endl;\
        cerr << "crash site; otherwise press enter to continue" << endl;\
        cerr << "PID: " << getpid();\
        cerr << endl << flush; \
        char c; \
        cin.get(c); \
      }\
      abort();\
    }\
  }\
}

class State;
class Event;
class Symbol;
class Var;

namespace __gnu_cxx {
  template <> struct hash<State*>
  {
    size_t operator()(State* s) const { return (size_t) s; }
  };
  template <> struct hash<Event*>
  {
    size_t operator()(Event* s) const { return (size_t) s; }
  };
  template <> struct hash<Symbol*>
  {
    size_t operator()(Symbol* s) const { return (size_t) s; }
  };
  template <> struct hash<Var*>
  {
    size_t operator()(Var* s) const { return (size_t) s; }
  };
} // namespace __gnu_cxx

namespace std {
  template <> struct equal_to<Event*>
  {
    bool operator()(Event* s1, Event* s2) const { return s1 == s2; }
  };
  template <> struct equal_to<State*>
  {
    bool operator()(State* s1, State* s2) const { return s1 == s2; }
  };
  template <> struct equal_to<Symbol*>
  {
    bool operator()(Symbol* s1, Symbol* s2) const { return s1 == s2; }
  };
  template <> struct equal_to<Var*>
  {
    bool operator()(Var* s1, Var* s2) const { return s1 == s2; }
  };
} // namespace std

#endif //SLICC_GLOBAL_H