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 : "";