OpenASIP  2.0
FixedRegisters.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file FixedRegisters.cc
26  *
27  * Definition of FixedRegisters class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include "FixedRegisters.hh"
34 #include "SimValue.hh"
35 
36 /**
37  * Constructor.
38  */
40  stackPointer_(NULL), intReturnValue_(NULL), floatReturnValue_(NULL) {
41 }
42 
43 /**
44  * Destructor.
45  */
47 }
48 
49 /**
50  * Returns the stack pointer value.
51  *
52  * @return Stack pointer value.
53  */
54 SimValue&
56  if (stackPointer_ == NULL) {
57  return NullSimValue::instance();
58  }
59  return *stackPointer_;
60 }
61 
62 /**
63  * Returns integer argument with a given index.
64  *
65  * If index is out of range, returns NullSimValue.
66  *
67  * @return Integer argument with a given index.
68  */
69 SimValue&
71  if (index < 0 || index > static_cast<int>(integerArgs_.size()) - 1) {
72  return NullSimValue::instance();
73  }
74  return *integerArgs_[index];
75 }
76 
77 /**
78  * Returns float argument register with a given index.
79  *
80  * If index is out of range, returns NullSimValue.
81  *
82  * @return Float argument register with a given index.
83  */
84 SimValue&
86  if (index < 0 || index > static_cast<int>(floatArgs_.size()) - 1) {
87  return NullSimValue::instance();
88  }
89  return *floatArgs_[index];
90 }
91 
92 /**
93  * Returns integer return value.
94  *
95  * @return Integer return value.
96  */
97 SimValue&
99  if (intReturnValue_ == NULL) {
100  return NullSimValue::instance();
101  }
102  return *intReturnValue_;
103 }
104 
105 /**
106  * Returns float return value.
107  *
108  * @return Float return value.
109  */
110 SimValue&
112  if (floatReturnValue_ == NULL) {
113  return NullSimValue::instance();
114  }
115  return *floatReturnValue_;
116 }
117 
118 /**
119  * Sets stack pointer to new value.
120  *
121  * @param value New value.
122  */
123 void
125  stackPointer_ = &value;
126 }
127 
128 /**
129  * Adds new integer argument register.
130  *
131  * @param value New integer argument register value.
132  */
133 void
135  integerArgs_.push_back(&value);
136 }
137 
138 /**
139  * Adds new float argument register.
140  *
141  * @param value New float argument register value.
142  */
143 void
145  floatArgs_.push_back(&value);
146 }
147 
148 /**
149  * Sets integer return value to new value.
150  *
151  * @param value New value.
152  */
153 void
155  intReturnValue_ = &value;
156 }
157 
158 /**
159  * Sets float return value to new value.
160  *
161  * @param value New value.
162  */
163 void
165  floatReturnValue_ = &value;
166 }
FixedRegisters::integerArgumentRegister
SimValue & integerArgumentRegister(int index) const
Definition: FixedRegisters.cc:70
FixedRegisters::floatReturnValue
SimValue & floatReturnValue() const
Definition: FixedRegisters.cc:111
FixedRegisters.hh
NullSimValue::instance
static SimValue & instance()
Definition: SimValue.cc:1642
FixedRegisters::stackPointer
SimValue & stackPointer() const
Definition: FixedRegisters.cc:55
FixedRegisters::~FixedRegisters
virtual ~FixedRegisters()
Definition: FixedRegisters.cc:46
SimValue
Definition: SimValue.hh:96
FixedRegisters::setFloatReturnValue
void setFloatReturnValue(SimValue &value)
Definition: FixedRegisters.cc:164
FixedRegisters::addFloatArgumentRegister
void addFloatArgumentRegister(SimValue &value)
Definition: FixedRegisters.cc:144
FixedRegisters::intReturnValue_
SimValue * intReturnValue_
Integer return value.
Definition: FixedRegisters.hh:74
FixedRegisters::floatReturnValue_
SimValue * floatReturnValue_
Floating point return value.
Definition: FixedRegisters.hh:76
FixedRegisters::integerReturnValue
SimValue & integerReturnValue() const
Definition: FixedRegisters.cc:98
FixedRegisters::stackPointer_
SimValue * stackPointer_
Stack pointer.
Definition: FixedRegisters.hh:68
FixedRegisters::FixedRegisters
FixedRegisters()
Definition: FixedRegisters.cc:39
FixedRegisters::addIntegerArgumentRegister
void addIntegerArgumentRegister(SimValue &value)
Definition: FixedRegisters.cc:134
FixedRegisters::integerArgs_
std::vector< SimValue * > integerArgs_
Integer argument registers.
Definition: FixedRegisters.hh:70
FixedRegisters::setStackPointer
void setStackPointer(SimValue &value)
Definition: FixedRegisters.cc:124
FixedRegisters::floatArgumentRegister
SimValue & floatArgumentRegister(int index) const
Definition: FixedRegisters.cc:85
SimValue.hh
FixedRegisters::setIntegerReturnValue
void setIntegerReturnValue(SimValue &value)
Definition: FixedRegisters.cc:154
FixedRegisters::floatArgs_
std::vector< SimValue * > floatArgs_
Floating point argument registers.
Definition: FixedRegisters.hh:72