1616#include " mlir/Interfaces/ViewLikeInterface.h"
1717#include " llvm/ADT/APSInt.h"
1818#include " llvm/Support/Debug.h"
19+ #include " llvm/Support/DebugLog.h"
1920
2021#define DEBUG_TYPE " value-bounds-op-interface"
2122
@@ -195,7 +196,7 @@ void ValueBoundsConstraintSet::addBound(BoundType type, int64_t pos,
195196 // Even without this bound, there may be enough information in the
196197 // constraint system to compute the requested bound. In case this bound is
197198 // actually needed, `computeBound` will return `failure`.
198- LLVM_DEBUG ( llvm::dbgs ( ) << " Failed to add bound: " << expr << " \n " ) ;
199+ LDBG ( ) << " Failed to add bound: " << expr << " \n " ;
199200 }
200201}
201202
@@ -271,20 +272,18 @@ int64_t ValueBoundsConstraintSet::insert(Value value,
271272 assert (!valueDimToPosition.contains (valueDim) && " already mapped" );
272273 int64_t pos = isSymbol ? cstr.appendVar (VarKind::Symbol)
273274 : cstr.appendVar (VarKind::SetDim);
274- LLVM_DEBUG (llvm::dbgs () << " Inserting constraint set column " << pos
275- << " for: " << value
276- << " (dim: " << dim.value_or (kIndexValue )
277- << " , owner: " << getOwnerOfValue (value)->getName ()
278- << " )\n " );
275+ LDBG () << " Inserting constraint set column " << pos << " for: " << value
276+ << " (dim: " << dim.value_or (kIndexValue )
277+ << " , owner: " << getOwnerOfValue (value)->getName () << " )" ;
279278 positionToValueDim.insert (positionToValueDim.begin () + pos, valueDim);
280279 // Update reverse mapping.
281280 for (int64_t i = pos, e = positionToValueDim.size (); i < e; ++i)
282281 if (positionToValueDim[i].has_value ())
283282 valueDimToPosition[*positionToValueDim[i]] = i;
284283
285284 if (addToWorklist) {
286- LLVM_DEBUG ( llvm::dbgs () << " Push to worklist: " << value
287- << " (dim: " << dim.value_or (kIndexValue ) << " )\n " ) ;
285+ LDBG () << " Push to worklist: " << value
286+ << " (dim: " << dim.value_or (kIndexValue ) << " )" ;
288287 worklist.push (pos);
289288 }
290289
@@ -294,8 +293,7 @@ int64_t ValueBoundsConstraintSet::insert(Value value,
294293int64_t ValueBoundsConstraintSet::insert (bool isSymbol) {
295294 int64_t pos = isSymbol ? cstr.appendVar (VarKind::Symbol)
296295 : cstr.appendVar (VarKind::SetDim);
297- LLVM_DEBUG (llvm::dbgs () << " Inserting anonymous constraint set column " << pos
298- << " \n " );
296+ LDBG () << " Inserting anonymous constraint set column " << pos;
299297 positionToValueDim.insert (positionToValueDim.begin () + pos, std::nullopt );
300298 // Update reverse mapping.
301299 for (int64_t i = pos, e = positionToValueDim.size (); i < e; ++i)
@@ -339,10 +337,9 @@ int64_t ValueBoundsConstraintSet::getPos(Value value,
339337 cast<BlockArgument>(value).getOwner ()->isEntryBlock ()) &&
340338 " unstructured control flow is not supported" );
341339#endif // NDEBUG
342- LLVM_DEBUG (llvm::dbgs () << " Getting pos for: " << value
343- << " (dim: " << dim.value_or (kIndexValue )
344- << " , owner: " << getOwnerOfValue (value)->getName ()
345- << " )\n " );
340+ LDBG () << " Getting pos for: " << value
341+ << " (dim: " << dim.value_or (kIndexValue )
342+ << " , owner: " << getOwnerOfValue (value)->getName () << " )" ;
346343 auto it =
347344 valueDimToPosition.find (std::make_pair (value, dim.value_or (kIndexValue )));
348345 assert (it != valueDimToPosition.end () && " expected mapped entry" );
@@ -364,7 +361,7 @@ bool ValueBoundsConstraintSet::isMapped(Value value,
364361}
365362
366363void ValueBoundsConstraintSet::processWorklist () {
367- LLVM_DEBUG ( llvm::dbgs ( ) << " Processing value bounds worklist...\n " ) ;
364+ LDBG ( ) << " Processing value bounds worklist..." ;
368365 while (!worklist.empty ()) {
369366 int64_t pos = worklist.front ();
370367 worklist.pop ();
@@ -386,18 +383,17 @@ void ValueBoundsConstraintSet::processWorklist() {
386383 // Do not process any further if the stop condition is met.
387384 auto maybeDim = dim == kIndexValue ? std::nullopt : std::make_optional (dim);
388385 if (stopCondition (value, maybeDim, *this )) {
389- LLVM_DEBUG ( llvm::dbgs ( ) << " Stop condition met for: " << value
390- << " (dim: " << maybeDim << " ) \n " ) ;
386+ LDBG ( ) << " Stop condition met for: " << value << " (dim: " << maybeDim
387+ << " ) " ;
391388 continue ;
392389 }
393390
394391 // Query `ValueBoundsOpInterface` for constraints. New items may be added to
395392 // the worklist.
396393 auto valueBoundsOp =
397394 dyn_cast<ValueBoundsOpInterface>(getOwnerOfValue (value));
398- LLVM_DEBUG (llvm::dbgs ()
399- << " Query value bounds for: " << value
400- << " (owner: " << getOwnerOfValue (value)->getName () << " )\n " );
395+ LDBG () << " Query value bounds for: " << value
396+ << " (owner: " << getOwnerOfValue (value)->getName () << " )" ;
401397 if (valueBoundsOp) {
402398 if (dim == kIndexValue ) {
403399 valueBoundsOp.populateBoundsForIndexValue (value, *this );
@@ -406,7 +402,7 @@ void ValueBoundsConstraintSet::processWorklist() {
406402 }
407403 continue ;
408404 }
409- LLVM_DEBUG ( llvm::dbgs ( ) << " --> ValueBoundsOpInterface not implemented\n " ) ;
405+ LDBG ( ) << " --> ValueBoundsOpInterface not implemented" ;
410406
411407 // If the op does not implement `ValueBoundsOpInterface`, check if it
412408 // implements the `DestinationStyleOpInterface`. OpResults of such ops are
@@ -705,9 +701,7 @@ bool ValueBoundsConstraintSet::comparePos(int64_t lhsPos,
705701
706702 // We cannot prove anything if the constraint set is already empty.
707703 if (cstr.isEmpty ()) {
708- LLVM_DEBUG (
709- llvm::dbgs ()
710- << " cannot compare value/dims: constraint system is already empty" );
704+ LDBG () << " cannot compare value/dims: constraint system is already empty" ;
711705 return false ;
712706 }
713707
0 commit comments