From 038988e2624b5174cc5af71896fa79a6466f7820 Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 12 Apr 2022 01:55:24 +0000 Subject: [PATCH 1/2] initialize issueTypes_ --- lib/Scheduler/machine_model.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/Scheduler/machine_model.cpp b/lib/Scheduler/machine_model.cpp index 6fd89ae3..52d59230 100644 --- a/lib/Scheduler/machine_model.cpp +++ b/lib/Scheduler/machine_model.cpp @@ -17,6 +17,31 @@ using std::vector; MachineModel::MachineModel(const std::string &modelFile) { SpecsBuffer buf; buf.Load(modelFile.c_str()); + + char buffer[MAX_NAMESIZE]; + + buf.ReadSpec("MODEL_NAME:", buffer); + mdlName_ = buffer; + + issueRate_ = buf.ReadIntSpec("ISSUE_RATE:"); + + int numIssueTypes = buf.ReadIntSpec("ISSUE_TYPE_COUNT:"); + + issueTypes_.resize(numIssueTypes > 0 ? numIssueTypes : 1); + if (numIssueTypes > 0) { + for (size_t j = 0; j < issueTypes_.size(); j++) { + int pieceCnt; + char *strngs[INBUF_MAX_PIECES_PERLINE]; + int lngths[INBUF_MAX_PIECES_PERLINE]; + buf.GetNxtVldLine(pieceCnt, strngs, lngths); + + if (pieceCnt != 2) + llvm::report_fatal_error("Invalid issue type spec", false); + + issueTypes_[j].name = strngs[0]; + issueTypes_[j].slotsCount = atoi(strngs[1]); + } + } } MachineModel::MachineModel(SpecsBuffer &buf) { From 7bb44c9e1a77855ff6529c251c2d7879e2565309 Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 12 May 2022 09:34:39 -0700 Subject: [PATCH 2/2] Refactor of MachineModel construction --- include/opt-sched/Scheduler/machine_model.h | 2 ++ lib/Scheduler/machine_model.cpp | 40 +++++---------------- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/include/opt-sched/Scheduler/machine_model.h b/include/opt-sched/Scheduler/machine_model.h index 95905749..b4c9753f 100644 --- a/include/opt-sched/Scheduler/machine_model.h +++ b/include/opt-sched/Scheduler/machine_model.h @@ -189,6 +189,8 @@ class MachineModel { std::vector registerTypes_; // A vector of issue types with their names and slot counts. std::vector issueTypes_; + + void parseBuffer(SpecsBuffer &buf); }; } // namespace opt_sched diff --git a/lib/Scheduler/machine_model.cpp b/lib/Scheduler/machine_model.cpp index 52d59230..e8029df7 100644 --- a/lib/Scheduler/machine_model.cpp +++ b/lib/Scheduler/machine_model.cpp @@ -14,37 +14,7 @@ using namespace llvm::opt_sched; using std::string; using std::vector; -MachineModel::MachineModel(const std::string &modelFile) { - SpecsBuffer buf; - buf.Load(modelFile.c_str()); - - char buffer[MAX_NAMESIZE]; - - buf.ReadSpec("MODEL_NAME:", buffer); - mdlName_ = buffer; - - issueRate_ = buf.ReadIntSpec("ISSUE_RATE:"); - - int numIssueTypes = buf.ReadIntSpec("ISSUE_TYPE_COUNT:"); - - issueTypes_.resize(numIssueTypes > 0 ? numIssueTypes : 1); - if (numIssueTypes > 0) { - for (size_t j = 0; j < issueTypes_.size(); j++) { - int pieceCnt; - char *strngs[INBUF_MAX_PIECES_PERLINE]; - int lngths[INBUF_MAX_PIECES_PERLINE]; - buf.GetNxtVldLine(pieceCnt, strngs, lngths); - - if (pieceCnt != 2) - llvm::report_fatal_error("Invalid issue type spec", false); - - issueTypes_[j].name = strngs[0]; - issueTypes_[j].slotsCount = atoi(strngs[1]); - } - } -} - -MachineModel::MachineModel(SpecsBuffer &buf) { +void MachineModel::parseBuffer(SpecsBuffer &buf) { char buffer[MAX_NAMESIZE]; buf.ReadSpec("MODEL_NAME:", buffer); @@ -116,6 +86,14 @@ MachineModel::MachineModel(SpecsBuffer &buf) { } } +MachineModel::MachineModel(const std::string &modelFile) { + SpecsBuffer buf; + buf.Load(modelFile.c_str()); + parseBuffer(buf); +} + +MachineModel::MachineModel(SpecsBuffer &buf) { parseBuffer(buf); } + InstType MachineModel::GetInstTypeByName(const string &typeName, const string &prevName) const { string composite = prevName.size() ? typeName + "_after_" + prevName : "";