Skip to content

Commit

Permalink
Refactor of MachineModel construction
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbyrnes committed May 20, 2022
1 parent a3a2662 commit f6b6105
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
2 changes: 2 additions & 0 deletions include/opt-sched/Scheduler/machine_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ class MachineModel {
std::vector<RegTypeInfo> registerTypes_;
// A vector of issue types with their names and slot counts.
std::vector<IssueTypeInfo> issueTypes_;

void parseBuffer(SpecsBuffer &buf);
};

} // namespace opt_sched
Expand Down
40 changes: 9 additions & 31 deletions lib/Scheduler/machine_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 : "";
Expand Down

0 comments on commit f6b6105

Please sign in to comment.