use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.
the class BranchReordering method run.
@Override
public void run(Program program) {
Preconditions.checkArgument(!program.isUnrolled(), "Reordering should be performed before unrolling.");
for (Thread t : program.getThreads()) {
new ThreadReordering(t).run();
}
logger.info("Branches reordered");
logger.info("{}: {}", DETERMINISTIC_REORDERING, reorderDeterministically);
}
use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.
the class ConstantPropagation method run.
@Override
public void run(Program program) {
Preconditions.checkArgument(program.isUnrolled(), "The program needs to be unrolled before constant propagation.");
Preconditions.checkArgument(!program.isCompiled(), "Constant propagation needs to be run before compilation.");
for (Thread thread : program.getThreads()) {
run(thread);
}
}
use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.
the class DeadAssignmentElimination method run.
@Override
public void run(Program program) {
this.program = program;
logger.info("#Events before DSE: " + program.getEvents().size());
for (Thread t : program.getThreads()) {
eliminateDeadStores(t);
t.clearCache();
}
program.clearCache(false);
logger.info("#Events after DSE: " + program.getEvents().size());
}
use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.
the class DeadAssignmentElimination method eliminateDeadStores.
private void eliminateDeadStores(Thread thread) {
Set<Event> removed = new HashSet<>();
// Registers that are used by other threads or assertions cannot be removed
Set<Register> usedRegs = new HashSet<>();
if (program.getAss() != null) {
usedRegs.addAll(program.getAss().getRegs());
}
program.getCache().getEvents(FilterBasic.get(ASSERTION)).stream().filter(RegWriter.class::isInstance).map(RegWriter.class::cast).map(RegWriter::getResultRegister).forEach(usedRegs::add);
program.getEvents().stream().filter(o -> !o.getThread().equals(thread)).filter(o -> o instanceof RegReaderData).forEach(o -> usedRegs.addAll(((RegReaderData) o).getDataRegs()));
for (Event e : Lists.reverse(thread.getEvents())) {
if (e instanceof RegWriter && !e.is(VISIBLE) && !usedRegs.contains(((RegWriter) e).getResultRegister())) {
// Invisible RegWriters that write to an unused reg can get removed
removed.add(e);
}
// An event that was not removed adds its dependencies to the used registers
if (!removed.contains(e)) {
if (e instanceof RegReaderData) {
// Data & Ctrl dependencies
usedRegs.addAll(((RegReaderData) e).getDataRegs());
}
if (e instanceof MemEvent) {
// Address dependencies
usedRegs.addAll(((MemEvent) e).getAddress().getRegs());
}
}
}
// Here is the actual removal
Event pred = null;
Event cur = thread.getEntry();
while (cur != null) {
if (removed.contains(cur) && !cur.is(Tag.NOOPT)) {
cur.delete();
cur = pred;
}
pred = cur;
cur = cur.getSuccessor();
}
}
use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.
the class DeadCodeElimination method run.
@Override
public void run(Program program) {
Preconditions.checkArgument(!program.isUnrolled(), "Dead code elimination should be performed before unrolling.");
logger.info("#Events before DCE: " + program.getEvents().size());
int id = 0;
for (Thread t : program.getThreads()) {
eliminateDeadCode(t, id);
t.clearCache();
id = t.getExit().getOId() + 1;
}
program.clearCache(false);
logger.info("#Events after DCE: " + program.getEvents().size());
}
Aggregations