OpenASIP 2.2
Loading...
Searching...
No Matches
GPRGuardEncoding.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 GPRGuardEncoding.cc
26 *
27 * Implementation of GPRGuardEncoding class.
28 *
29 * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include <string>
34
35#include "GPRGuardEncoding.hh"
36#include "GuardField.hh"
37#include "ObjectState.hh"
38
39using std::string;
40
42 "gpr_guard_enc";
43const std::string GPRGuardEncoding::OSKEY_RF_NAME = "rf_name";
44const std::string GPRGuardEncoding::OSKEY_REGISTER_INDEX = "reg_index";
45
46/**
47 * The constructor.
48 *
49 * Creates a guard encoding and Registers it into the given guard field
50 * automatically. The guard expression is identified by the name of register
51 * file, the index of the GPR and the "invert" flag, all given as parameters.
52 *
53 * @param regFile Name of the register file.
54 * @param index The index the GPR.
55 * @param inverted The "invert" flag.
56 * @param encoding The control code of the guard expression.
57 * @param parent The parent guard field.
58 * @exception ObjectAlreadyExists If the guard expression is already encoded
59 * in the parent field, or if the given control
60 * code is already assigned to another guard
61 * expression.
62 */
64 const std::string& regFile, int index, bool inverted, unsigned int encoding,
65 GuardField& parent)
66 : GuardEncoding(inverted, encoding), regFile_(regFile), index_(index) {
69}
70
71/**
72 * The constructor.
73 *
74 * Loads the state of the object from the given ObjectState instance.
75 *
76 * @param state The ObjectState instance.
77 * @param parent The parent guard field.
78 * @exception ObjectStateLoadingException If an error occurs while loading the
79 * state.
80 * @exception ObjectAlreadyExists If the guard expression is already encoded
81 * in the parent field, or if the given control
82 * code is already assigned to another guard
83 * expression.
84 */
86 : GuardEncoding(state), regFile_(""), index_(0) {
87 const string procName = "GPRGuardEncoding::GPRGuardEncoding";
88
89 if (state->name() != OSNAME_GPR_GUARD_ENCODING) {
90 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
91 }
92
93 try {
96 } catch (const Exception& exception) {
98 __FILE__, __LINE__, procName, exception.errorMessage());
99 }
100
103}
104
105/**
106 * The destructor.
107 */
113
114
115/**
116 * Returns the name of the register file that contains the GPR of this guard
117 * expression.
118 *
119 * @return The name of the register file.
120 */
121std::string
123 return regFile_;
124}
125
126
127/**
128 * Returns the index of the GPR of this guard expression.
129 *
130 * @return The index of the GPR.
131 */
132int
134 return index_;
135}
136
137
138/**
139 * Saves the state of the object to an ObjectState instance.
140 *
141 * @return The newly created ObjectState instance.
142 */
std::string errorMessage() const
Definition Exception.cc:123
std::string regFile_
Name of the register file.
static const std::string OSNAME_GPR_GUARD_ENCODING
ObjectState name for GPR guard encoding.
int index_
Register index.
static const std::string OSKEY_RF_NAME
ObjectState attribute key for the name of the register file.
virtual ObjectState * saveState() const
GPRGuardEncoding(const std::string &regFile, int index, bool inverted, unsigned int encoding, GuardField &parent)
int registerIndex() const
static const std::string OSKEY_REGISTER_INDEX
ObjectState attribute key for register index.
std::string registerFile() const
GuardField * parent() const
virtual ObjectState * saveState() const
void setParent(GuardField *parent)
void addGuardEncoding(GPRGuardEncoding &encoding)
void removeGuardEncoding(GPRGuardEncoding &encoding)
void setName(const std::string &name)
void setAttribute(const std::string &name, const std::string &value)
std::string stringAttribute(const std::string &name) const
int intAttribute(const std::string &name) const
std::string name() const