Skip to content

Commit 78844b3

Browse files
committed
Simplify creating DataDepGraph for tests
Allow it to be made from a string.
1 parent 3138e2d commit 78844b3

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

include/opt-sched/Scheduler/data_dep.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class DataDepGraph : public llvm::opt_sched::OptSchedDDGWrapperBase,
178178

179179
// Reads the data dependence graph from a text file.
180180
FUNC_RESULT ReadFrmFile(SpecsBuffer *buf, bool &endOfFileReached);
181+
FUNC_RESULT ReadFromString(const std::string &Str);
181182
// Continues reading until the end of the current graph definition,
182183
// discarding the data.
183184
FUNC_RESULT SkipGraph(SpecsBuffer *buf, bool &endOfFileReached);

lib/Scheduler/data_dep.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,16 @@ void DataDepGraph::SetDynmcLwrBounds() {
337337
}
338338
}
339339

340+
FUNC_RESULT DataDepGraph::ReadFromString(const std::string &Str) {
341+
char *BufData = new char[Str.size() + 1];
342+
std::copy_n(Str.data(), Str.size() + 1, BufData);
343+
SpecsBuffer Buf;
344+
Buf.SetBuf(BufData, Str.size() + 1);
345+
346+
bool EndReached = false;
347+
return ReadFrmFile(&Buf, EndReached);
348+
}
349+
340350
FUNC_RESULT DataDepGraph::ReadFrmFile(SpecsBuffer *buf,
341351
bool &endOfFileReached) {
342352
int pieceCnt;

0 commit comments

Comments
 (0)