MLIR  20.0.0git
Macros | Functions
FlatLinearValueConstraints.cpp File Reference
#include "mlir/Analysis//FlatLinearValueConstraints.h"
#include "mlir/Analysis/Presburger/LinearTransform.h"
#include "mlir/Analysis/Presburger/PresburgerSpace.h"
#include "mlir/Analysis/Presburger/Simplex.h"
#include "mlir/Analysis/Presburger/Utils.h"
#include "mlir/IR/AffineExprVisitor.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/IntegerSet.h"
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "flat-value-constraints"
 

Functions

static LogicalResult getFlattenedAffineExprs (ArrayRef< AffineExpr > exprs, unsigned numDims, unsigned numSymbols, std::vector< SmallVector< int64_t, 8 >> *flattenedExprs, FlatLinearConstraints *localVarCst, bool addConservativeSemiAffineBounds=false)
 
static bool detectAsMod (const FlatLinearConstraints &cst, unsigned pos, unsigned offset, unsigned num, int64_t lbConst, int64_t ubConst, MLIRContext *context, SmallVectorImpl< AffineExpr > &memo)
 
static bool detectAsFloorDiv (const FlatLinearConstraints &cst, unsigned pos, MLIRContext *context, SmallVectorImpl< AffineExpr > &exprs)
 Check if the pos^th variable can be expressed as a floordiv of an affine function of other variables (where the divisor is a positive constant) given the initial set of expressions in exprs. More...
 
static bool areVarsAligned (const FlatLinearValueConstraints &a, const FlatLinearValueConstraints &b)
 Checks if two constraint systems are in the same space, i.e., if they are associated with the same set of variables, appearing in the same order. More...
 
static bool LLVM_ATTRIBUTE_UNUSED areVarsUnique (const FlatLinearValueConstraints &cst, unsigned start, unsigned end)
 Checks if the SSA values associated with cst's variables in range [start, end) are unique. More...
 
static bool LLVM_ATTRIBUTE_UNUSED areVarsUnique (const FlatLinearValueConstraints &cst)
 Checks if the SSA values associated with cst's variables are unique. More...
 
static bool LLVM_ATTRIBUTE_UNUSED areVarsUnique (const FlatLinearValueConstraints &cst, VarKind kind)
 Checks if the SSA values associated with cst's variables of kind kind are unique. More...
 
static void mergeAndAlignVars (unsigned offset, FlatLinearValueConstraints *a, FlatLinearValueConstraints *b)
 Merge and align the variables of A and B starting at 'offset', so that both constraint systems get the union of the contained variables that is dimension-wise and symbol-wise unique; both constraint systems are updated so that they have the union of all variables, with A's original variables appearing first followed by any of B's variables that didn't appear in A. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "flat-value-constraints"

Definition at line 26 of file FlatLinearValueConstraints.cpp.

Function Documentation

◆ areVarsAligned()

static bool areVarsAligned ( const FlatLinearValueConstraints a,
const FlatLinearValueConstraints b 
)
static

◆ areVarsUnique() [1/3]

static bool LLVM_ATTRIBUTE_UNUSED areVarsUnique ( const FlatLinearValueConstraints cst)
static

Checks if the SSA values associated with cst's variables are unique.

Definition at line 1015 of file FlatLinearValueConstraints.cpp.

References areVarsUnique(), and mlir::presburger::IntegerRelation::getNumDimAndSymbolVars().

◆ areVarsUnique() [2/3]

static bool LLVM_ATTRIBUTE_UNUSED areVarsUnique ( const FlatLinearValueConstraints cst,
unsigned  start,
unsigned  end 
)
static

Checks if the SSA values associated with cst's variables in range [start, end) are unique.

Definition at line 991 of file FlatLinearValueConstraints.cpp.

References mlir::FlatLinearValueConstraints::getMaybeValues(), and mlir::presburger::IntegerRelation::getNumDimAndSymbolVars().

Referenced by areVarsUnique().

◆ areVarsUnique() [3/3]

static bool LLVM_ATTRIBUTE_UNUSED areVarsUnique ( const FlatLinearValueConstraints cst,
VarKind  kind 
)
static

Checks if the SSA values associated with cst's variables of kind kind are unique.

Definition at line 1022 of file FlatLinearValueConstraints.cpp.

References areVarsUnique(), mlir::presburger::IntegerRelation::getNumDimAndSymbolVars(), and mlir::presburger::IntegerRelation::getNumDimVars().

◆ detectAsFloorDiv()

static bool detectAsFloorDiv ( const FlatLinearConstraints cst,
unsigned  pos,
MLIRContext context,
SmallVectorImpl< AffineExpr > &  exprs 
)
static

Check if the pos^th variable can be expressed as a floordiv of an affine function of other variables (where the divisor is a positive constant) given the initial set of expressions in exprs.

If it can be, the corresponding position in exprs is set as the detected affine expr. For eg: 4q <= i + j <= 4q + 3 <=> q = (i + j) floordiv 4. An equality can also yield a floordiv: eg. 4q = i + j <=> q = (i + j) floordiv 4. 32q + 28 <= i <= 32q + 31 => q = i floordiv 32.

Definition at line 418 of file FlatLinearValueConstraints.cpp.

References mlir::presburger::computeSingleVarRepr(), mlir::presburger::Equality, mlir::getAffineConstantExpr(), mlir::presburger::IntegerRelation::getNumCols(), mlir::presburger::IntegerRelation::getNumVars(), and mlir::presburger::None.

Referenced by mlir::FlatLinearConstraints::computeLocalVars(), and mlir::FlatLinearConstraints::getSliceBounds().

◆ detectAsMod()

static bool detectAsMod ( const FlatLinearConstraints cst,
unsigned  pos,
unsigned  offset,
unsigned  num,
int64_t  lbConst,
int64_t  ubConst,
MLIRContext context,
SmallVectorImpl< AffineExpr > &  memo 
)
static

◆ getFlattenedAffineExprs()

static LogicalResult getFlattenedAffineExprs ( ArrayRef< AffineExpr exprs,
unsigned  numDims,
unsigned  numSymbols,
std::vector< SmallVector< int64_t, 8 >> *  flattenedExprs,
FlatLinearConstraints localVarCst,
bool  addConservativeSemiAffineBounds = false 
)
static

◆ mergeAndAlignVars()

static void mergeAndAlignVars ( unsigned  offset,
FlatLinearValueConstraints a,
FlatLinearValueConstraints b 
)
static

Merge and align the variables of A and B starting at 'offset', so that both constraint systems get the union of the contained variables that is dimension-wise and symbol-wise unique; both constraint systems are updated so that they have the union of all variables, with A's original variables appearing first followed by any of B's variables that didn't appear in A.

Local variables in B that have the same division representation as local variables in A are merged into one. We allow A and B to have non-unique values for their variables; in such cases, they are still aligned with the variables appearing first aligned with those appearing first in the other system from left to right.

Definition at line 1044 of file FlatLinearValueConstraints.cpp.

References mlir::FlatLinearValueConstraints::appendDimVar(), areVarsAligned(), mlir::FlatLinearValueConstraints::findVar(), mlir::FlatLinearValueConstraints::getMaybeValues(), mlir::presburger::IntegerRelation::getNumDimVars(), mlir::FlatLinearValueConstraints::getValue(), mlir::FlatLinearValueConstraints::getValues(), mlir::FlatLinearValueConstraints::insertDimVar(), mlir::presburger::IntegerRelation::mergeLocalVars(), mlir::FlatLinearValueConstraints::mergeSymbolVars(), and mlir::presburger::IntegerRelation::swapVar().

Referenced by mlir::FlatLinearValueConstraints::mergeAndAlignVarsWithOther(), and mlir::FlatLinearValueConstraints::unionBoundingBox().