1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-23 06:28:59 +00:00

Evicted manual memory management.

This commit is contained in:
Thomas Harte 2017-05-29 21:44:33 -04:00
parent 35f535b9a3
commit 9d29cefe75

View File

@ -12,6 +12,7 @@
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <cstdio> #include <cstdio>
#include <vector>
#include "../MicroOpScheduler.hpp" #include "../MicroOpScheduler.hpp"
#include "../RegisterSizes.hpp" #include "../RegisterSizes.hpp"
@ -184,21 +185,10 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
uint8_t temp8_; uint8_t temp8_;
struct InstructionPage { struct InstructionPage {
MicroOp *instructions[256]; std::vector<MicroOp *> instructions;
MicroOp *all_operations; std::vector<MicroOp> all_operations;
MicroOp *fetch_decode_execute; std::vector<MicroOp> fetch_decode_execute;
bool increments_r; bool increments_r;
InstructionPage() : all_operations(nullptr), increments_r(true), fetch_decode_execute(nullptr) {
for(int c = 0; c < 256; c++) {
instructions[c] = nullptr;
}
}
~InstructionPage() {
delete[] all_operations;
delete[] fetch_decode_execute;
}
}; };
InstructionPage *current_instruction_page_; InstructionPage *current_instruction_page_;
@ -315,7 +305,8 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
} }
// Allocate a landing area. // Allocate a landing area.
target.all_operations = new MicroOp[number_of_micro_ops]; target.all_operations.resize(number_of_micro_ops);
target.instructions.resize(256, nullptr);
// Copy in all programs and set pointers. // Copy in all programs and set pointers.
size_t destination = 0; size_t destination = 0;
@ -627,7 +618,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
{ MicroOp::DecodeOperation }, { MicroOp::DecodeOperation },
{ MicroOp::MoveToNextProgram } { MicroOp::MoveToNextProgram }
}; };
target.fetch_decode_execute = new MicroOp[3]; target.fetch_decode_execute.resize(3);
target.fetch_decode_execute[0] = fetch_decode_execute[0]; target.fetch_decode_execute[0] = fetch_decode_execute[0];
target.fetch_decode_execute[1] = fetch_decode_execute[1]; target.fetch_decode_execute[1] = fetch_decode_execute[1];
target.fetch_decode_execute[2] = fetch_decode_execute[2]; target.fetch_decode_execute[2] = fetch_decode_execute[2];
@ -680,7 +671,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
#define checkSchedule() \ #define checkSchedule() \
if(!scheduled_programs_[schedule_programs_read_pointer_]) {\ if(!scheduled_programs_[schedule_programs_read_pointer_]) {\
current_instruction_page_ = &base_page_;\ current_instruction_page_ = &base_page_;\
schedule_program(base_page_.fetch_decode_execute);\ schedule_program(base_page_.fetch_decode_execute.data());\
} }
number_of_cycles_ += number_of_cycles; number_of_cycles_ += number_of_cycles;
@ -1392,7 +1383,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
case MicroOp::SetInstructionPage: case MicroOp::SetInstructionPage:
current_instruction_page_ = (InstructionPage *)operation->source; current_instruction_page_ = (InstructionPage *)operation->source;
schedule_program(current_instruction_page_->fetch_decode_execute); schedule_program(current_instruction_page_->fetch_decode_execute.data());
break; break;
case MicroOp::CalculateIndexAddress: case MicroOp::CalculateIndexAddress: