Skip to content

Commit

Permalink
ternaries
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Jul 10, 2024
1 parent 819a47a commit 5520ac2
Showing 1 changed file with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -436,17 +436,12 @@ void createUseLocks(
// search for the correct lock based on the port of the acq/rel
// operation e.g. acq as consumer is the read lock (second)
LockOp lock;
if (lockAction == LockAction::AcquireGreaterEqual) {
if (port == ObjectFifoPort::Produce)
lock = locksPerFifo.at(target)[0];
else
lock = locksPerFifo.at(target)[1];
} else {
if (port == ObjectFifoPort::Produce)
lock = locksPerFifo.at(target)[1];
else
lock = locksPerFifo.at(target)[0];
}
std::vector<LockOp> locks = locksPerFifo.at(target);
if (lockAction == LockAction::AcquireGreaterEqual)
lock = port == ObjectFifoPort::Produce ? locks[0] : locks[1];
else
lock = port == ObjectFifoPort::Produce ? locks[1] : locks[0];

builder.create<UseLockOp>(builder.getUnknownLoc(), lock, lockAction,
numLocks);
std::pair<ObjectFifoCreateOp, int> opPort = {op, static_cast<int>(port)};
Expand Down Expand Up @@ -655,11 +650,7 @@ void replaceObjectAcquireOp(
// acquire locks
size_t numLocks = acquireOp.acqNumber();
size_t alreadyAcq = acquiredIndices.size();
size_t numCreate;
if (numLocks > alreadyAcq)
numCreate = numLocks - alreadyAcq;
else
numCreate = 0;
size_t numCreate = numLocks > alreadyAcq ? numLocks - alreadyAcq : 0;

{
OpBuilder::InsertionGuard gg(builder);
Expand Down

0 comments on commit 5520ac2

Please sign in to comment.