summaryrefslogtreecommitdiff
path: root/src/stage.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/stage.cc')
-rw-r--r--src/stage.cc43
1 files changed, 16 insertions, 27 deletions
diff --git a/src/stage.cc b/src/stage.cc
index 4efe2fe..ac688d8 100644
--- a/src/stage.cc
+++ b/src/stage.cc
@@ -16,6 +16,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "stage.h"
+#include "pipe_spec.h"
#include <array>
#include <deque>
@@ -29,7 +30,7 @@ Stage::Stage(Stage *next)
Stage::~Stage() { delete this->next; };
std::array<int, GPR_NUM> Stage::gprs;
-std::array<int, V_NUM> Stage::vrs;
+std::array<std::array<signed int, V_R_LIMIT>, V_NUM> Stage::vrs;
std::deque<signed int> Stage::checked_out;
unsigned int Stage::pc;
Storage *Stage::storage;
@@ -65,40 +66,28 @@ InstrDTO *Stage::advance(Response p)
return r;
}
-InstrDTO *Stage::get_instr() { return this->curr_instr; }
-
-void Stage::set_condition(CC c, bool v)
+bool Stage::is_vector_type(Mnemonic m)
{
- if (v)
- this->gprs[3] = this->gprs[3] | 1 << c;
- else
- this->gprs[3] = this->gprs[3] & ~(1 << c);
+ return (
+ m == ADDV || m == SUBV || m == MULV || m == DIVV || m == CEV ||
+ m == LOADV || m == STOREV);
}
-signed int Stage::dereference_register(signed int v)
+bool Stage::is_logical(Mnemonic m)
{
- signed int r;
-
- if (v < 0 || v >= GPR_NUM + V_NUM) {
- throw std::out_of_range(
- "instruction tried to access register which does not exist");
- }
-
- r = (v >= GPR_NUM) ? this->vrs[v % GPR_NUM] : this->gprs[v];
- return r;
+ return (
+ m == ANDI || m == ORI || m == XORI || m == AND || m == OR || m == XOR ||
+ m == NOT);
}
-void Stage::store_register(signed int v, signed int d)
-{
- if (v < 0 || v >= GPR_NUM + V_NUM) {
- throw std::out_of_range(
- "instruction tried to access register which does not exist");
- }
+InstrDTO *Stage::get_instr() { return this->curr_instr; }
- if (v >= GPR_NUM)
- this->vrs[v % GPR_NUM] = d;
+void Stage::set_condition(CC c, bool v)
+{
+ if (v)
+ this->gprs[3] = this->gprs[3] | 1 << c;
else
- this->gprs[v] = d;
+ this->gprs[3] = this->gprs[3] & ~(1 << c);
}
bool Stage::is_checked_out(signed int r)