72 changes: 36 additions & 36 deletions mlir/include/mlir/Analysis/AffineStructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,17 @@ class AffineValueMap {
// Creates an empty AffineValueMap (users should call 'reset' to reset map
// and operands).
AffineValueMap() {}
AffineValueMap(AffineMap map, ArrayRef<Value *> operands,
ArrayRef<Value *> results = llvm::None);
AffineValueMap(AffineMap map, ArrayRef<ValuePtr> operands,
ArrayRef<ValuePtr> results = llvm::None);

explicit AffineValueMap(AffineApplyOp applyOp);
explicit AffineValueMap(AffineBound bound);

~AffineValueMap();

// Resets this AffineValueMap with 'map', 'operands', and 'results'.
void reset(AffineMap map, ArrayRef<Value *> operands,
ArrayRef<Value *> results = llvm::None);
void reset(AffineMap map, ArrayRef<ValuePtr> operands,
ArrayRef<ValuePtr> results = llvm::None);

/// Return the value map that is the difference of value maps 'a' and 'b',
/// represented as an affine map and its operands. The output map + operands
Expand All @@ -146,7 +146,7 @@ class AffineValueMap {
inline bool isMultipleOf(unsigned idx, int64_t factor) const;

/// Return true if the idx^th result depends on 'value', false otherwise.
bool isFunctionOf(unsigned idx, Value *value) const;
bool isFunctionOf(unsigned idx, ValuePtr value) const;

/// Return true if the result at 'idx' is a constant, false
/// otherwise.
Expand All @@ -162,8 +162,8 @@ class AffineValueMap {
inline unsigned getNumSymbols() const { return map.getNumSymbols(); }
inline unsigned getNumResults() const { return map.getNumResults(); }

Value *getOperand(unsigned i) const;
ArrayRef<Value *> getOperands() const;
ValuePtr getOperand(unsigned i) const;
ArrayRef<ValuePtr> getOperands() const;
AffineMap getAffineMap() const;

private:
Expand All @@ -172,9 +172,9 @@ class AffineValueMap {

// TODO: make these trailing objects?
/// The SSA operands binding to the dim's and symbols of 'map'.
SmallVector<Value *, 4> operands;
SmallVector<ValuePtr, 4> operands;
/// The SSA results binding to the results of 'map'.
SmallVector<Value *, 4> results;
SmallVector<ValuePtr, 4> results;
};

/// An IntegerValueSet is an integer set plus its operands.
Expand Down Expand Up @@ -207,7 +207,7 @@ class IntegerValueSet {
// 'AffineCondition'.
MutableIntegerSet set;
/// The SSA operands binding to the dim's and symbols of 'set'.
SmallVector<Value *, 4> operands;
SmallVector<ValuePtr, 4> operands;
};

/// A flat list of affine equalities and inequalities in the form.
Expand Down Expand Up @@ -245,7 +245,7 @@ class FlatAffineConstraints {
unsigned numReservedEqualities,
unsigned numReservedCols, unsigned numDims = 0,
unsigned numSymbols = 0, unsigned numLocals = 0,
ArrayRef<Optional<Value *>> idArgs = {})
ArrayRef<Optional<ValuePtr>> idArgs = {})
: numReservedCols(numReservedCols), numDims(numDims),
numSymbols(numSymbols) {
assert(numReservedCols >= numDims + numSymbols + 1);
Expand All @@ -264,7 +264,7 @@ class FlatAffineConstraints {
/// dimensions and symbols.
FlatAffineConstraints(unsigned numDims = 0, unsigned numSymbols = 0,
unsigned numLocals = 0,
ArrayRef<Optional<Value *>> idArgs = {})
ArrayRef<Optional<ValuePtr>> idArgs = {})
: numReservedCols(numDims + numSymbols + numLocals + 1), numDims(numDims),
numSymbols(numSymbols) {
assert(numReservedCols >= numDims + numSymbols + 1);
Expand Down Expand Up @@ -304,10 +304,10 @@ class FlatAffineConstraints {
// Clears any existing data and reserves memory for the specified constraints.
void reset(unsigned numReservedInequalities, unsigned numReservedEqualities,
unsigned numReservedCols, unsigned numDims, unsigned numSymbols,
unsigned numLocals = 0, ArrayRef<Value *> idArgs = {});
unsigned numLocals = 0, ArrayRef<ValuePtr> idArgs = {});

void reset(unsigned numDims = 0, unsigned numSymbols = 0,
unsigned numLocals = 0, ArrayRef<Value *> idArgs = {});
unsigned numLocals = 0, ArrayRef<ValuePtr> idArgs = {});

/// Appends constraints from 'other' into this. This is equivalent to an
/// intersection with no simplification of any sort attempted.
Expand Down Expand Up @@ -396,7 +396,7 @@ class FlatAffineConstraints {
/// operands. If `eq` is true, add a single equality equal to the bound map's
/// first result expr.
LogicalResult addLowerOrUpperBound(unsigned pos, AffineMap boundMap,
ArrayRef<Value *> operands, bool eq,
ArrayRef<ValuePtr> operands, bool eq,
bool lower = true);

/// Computes the lower and upper bounds of the first 'num' dimensional
Expand All @@ -415,10 +415,10 @@ class FlatAffineConstraints {
/// operand list 'operands'.
/// This function assumes 'values.size' == 'lbMaps.size' == 'ubMaps.size'.
/// Note that both lower/upper bounds use operands from 'operands'.
LogicalResult addSliceBounds(ArrayRef<Value *> values,
LogicalResult addSliceBounds(ArrayRef<ValuePtr> values,
ArrayRef<AffineMap> lbMaps,
ArrayRef<AffineMap> ubMaps,
ArrayRef<Value *> operands);
ArrayRef<ValuePtr> operands);

// Adds an inequality (>= 0) from the coefficients specified in inEq.
void addInequality(ArrayRef<int64_t> inEq);
Expand Down Expand Up @@ -447,33 +447,33 @@ class FlatAffineConstraints {

/// Sets the identifier corresponding to the specified Value id to a
/// constant. Asserts if the 'id' is not found.
void setIdToConstant(Value &id, int64_t val);
void setIdToConstant(ValueRef id, int64_t val);

/// Looks up the position of the identifier with the specified Value. Returns
/// true if found (false otherwise). `pos' is set to the (column) position of
/// the identifier.
bool findId(Value &id, unsigned *pos) const;
bool findId(ValueRef id, unsigned *pos) const;

/// Returns true if an identifier with the specified Value exists, false
/// otherwise.
bool containsId(Value &id) const;
bool containsId(ValueRef id) const;

// Add identifiers of the specified kind - specified positions are relative to
// the kind of identifier. The coefficient column corresponding to the added
// identifier is initialized to zero. 'id' is the Value corresponding to the
// identifier that can optionally be provided.
void addDimId(unsigned pos, Value *id = nullptr);
void addSymbolId(unsigned pos, Value *id = nullptr);
void addDimId(unsigned pos, ValuePtr id = nullptr);
void addSymbolId(unsigned pos, ValuePtr id = nullptr);
void addLocalId(unsigned pos);
void addId(IdKind kind, unsigned pos, Value *id = nullptr);
void addId(IdKind kind, unsigned pos, ValuePtr id = nullptr);

/// Add the specified values as a dim or symbol id depending on its nature, if
/// it already doesn't exist in the system. `id' has to be either a terminal
/// symbol or a loop IV, i.e., it cannot be the result affine.apply of any
/// symbols or loop IVs. The identifier is added to the end of the existing
/// dims or symbols. Additional information on the identifier is extracted
/// from the IR and added to the constraint system.
void addInductionVarOrTerminalSymbol(Value *id);
void addInductionVarOrTerminalSymbol(ValuePtr id);

/// Composes the affine value map with this FlatAffineConstrains, adding the
/// results of the map as dimensions at the front [0, vMap->getNumResults())
Expand All @@ -500,8 +500,8 @@ class FlatAffineConstraints {
void projectOut(unsigned pos, unsigned num);
inline void projectOut(unsigned pos) { return projectOut(pos, 1); }

/// Projects out the identifier that is associate with Value *.
void projectOut(Value *id);
/// Projects out the identifier that is associate with ValuePtr .
void projectOut(ValuePtr id);

void removeId(IdKind idKind, unsigned pos);
void removeId(unsigned pos);
Expand Down Expand Up @@ -577,28 +577,28 @@ class FlatAffineConstraints {
return numIds - numDims - numSymbols;
}

inline ArrayRef<Optional<Value *>> getIds() const {
inline ArrayRef<Optional<ValuePtr>> getIds() const {
return {ids.data(), ids.size()};
}
inline MutableArrayRef<Optional<Value *>> getIds() {
inline MutableArrayRef<Optional<ValuePtr>> getIds() {
return {ids.data(), ids.size()};
}

/// Returns the optional Value corresponding to the pos^th identifier.
inline Optional<Value *> getId(unsigned pos) const { return ids[pos]; }
inline Optional<Value *> &getId(unsigned pos) { return ids[pos]; }
inline Optional<ValuePtr> getId(unsigned pos) const { return ids[pos]; }
inline Optional<ValuePtr> &getId(unsigned pos) { return ids[pos]; }

/// Returns the Value associated with the pos^th identifier. Asserts if
/// no Value identifier was associated.
inline Value *getIdValue(unsigned pos) const {
inline ValuePtr getIdValue(unsigned pos) const {
assert(ids[pos].hasValue() && "identifier's Value not set");
return ids[pos].getValue();
}

/// Returns the Values associated with identifiers in range [start, end).
/// Asserts if no Value was associated with one of these identifiers.
void getIdValues(unsigned start, unsigned end,
SmallVectorImpl<Value *> *values) const {
SmallVectorImpl<ValuePtr> *values) const {
assert((start < numIds || start == end) && "invalid start position");
assert(end <= numIds && "invalid end position");
values->clear();
Expand All @@ -607,17 +607,17 @@ class FlatAffineConstraints {
values->push_back(getIdValue(i));
}
}
inline void getAllIdValues(SmallVectorImpl<Value *> *values) const {
inline void getAllIdValues(SmallVectorImpl<ValuePtr> *values) const {
getIdValues(0, numIds, values);
}

/// Sets Value associated with the pos^th identifier.
inline void setIdValue(unsigned pos, Value *val) {
inline void setIdValue(unsigned pos, ValuePtr val) {
assert(pos < numIds && "invalid id position");
ids[pos] = val;
}
/// Sets Values associated with identifiers in the range [start, end).
void setIdValues(unsigned start, unsigned end, ArrayRef<Value *> values) {
void setIdValues(unsigned start, unsigned end, ArrayRef<ValuePtr> values) {
assert((start < numIds || end == start) && "invalid start position");
assert(end <= numIds && "invalid end position");
assert(values.size() == end - start);
Expand Down Expand Up @@ -766,7 +766,7 @@ class FlatAffineConstraints {
/// system appearing in the order the identifiers correspond to columns.
/// Temporary ones or those that aren't associated to any Value are set to
/// None.
SmallVector<Optional<Value *>, 8> ids;
SmallVector<Optional<ValuePtr>, 8> ids;

/// A parameter that controls detection of an unrealistic number of
/// constraints. If the number of constraints is this many times the number of
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Analysis/CallInterfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ namespace mlir {

/// A callable is either a symbol, or an SSA value, that is referenced by a
/// call-like operation. This represents the destination of the call.
struct CallInterfaceCallable : public PointerUnion<SymbolRefAttr, Value *> {
using PointerUnion<SymbolRefAttr, Value *>::PointerUnion;
struct CallInterfaceCallable : public PointerUnion<SymbolRefAttr, ValuePtr> {
using PointerUnion<SymbolRefAttr, ValuePtr>::PointerUnion;
};

#include "mlir/Analysis/CallInterfaces.h.inc"
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Analysis/Dominance.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ class DominanceInfo : public detail::DominanceInfoBase</*IsPostDom=*/false> {
}

/// Return true if value A properly dominates operation B.
bool properlyDominates(Value *a, Operation *b);
bool properlyDominates(ValuePtr a, Operation *b);

/// Return true if operation A dominates operation B.
bool dominates(Value *a, Operation *b) {
bool dominates(ValuePtr a, Operation *b) {
return (Operation *)a->getDefiningOp() == b || properlyDominates(a, b);
}

Expand Down
17 changes: 10 additions & 7 deletions mlir/include/mlir/Analysis/Liveness.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Operation;
class Region;
class Value;

// TODO(riverriddle) Remove this after Value is value-typed.
using ValuePtr = Value *;

/// Represents an analysis for computing liveness information from a
/// given top-level operation. The analysis iterates over all associated
/// regions that are attached to the given top-level operation. It
Expand All @@ -57,7 +60,7 @@ class Liveness {
public:
using OperationListT = std::vector<Operation *>;
using BlockMapT = DenseMap<Block *, LivenessBlockInfo>;
using ValueSetT = SmallPtrSet<Value *, 16>;
using ValueSetT = SmallPtrSet<ValuePtr, 16>;

public:
/// Creates a new Liveness analysis that computes liveness
Expand All @@ -72,7 +75,7 @@ class Liveness {
/// Note that the operations in this list are not ordered and the current
/// implementation is computationally expensive (as it iterates over all
/// blocks in which the given value is live).
OperationListT resolveLiveness(Value *value) const;
OperationListT resolveLiveness(ValuePtr value) const;

/// Gets liveness info (if any) for the block.
const LivenessBlockInfo *getLiveness(Block *block) const;
Expand All @@ -85,7 +88,7 @@ class Liveness {

/// Returns true if the given operation represent the last use of the
/// given value.
bool isLastUse(Value *value, Operation *operation) const;
bool isLastUse(ValuePtr value, Operation *operation) const;

/// Dumps the liveness information in a human readable format.
void dump() const;
Expand Down Expand Up @@ -124,20 +127,20 @@ class LivenessBlockInfo {
const ValueSetT &out() const { return outValues; }

/// Returns true if the given value is in the live-in set.
bool isLiveIn(Value *value) const;
bool isLiveIn(ValuePtr value) const;

/// Returns true if the given value is in the live-out set.
bool isLiveOut(Value *value) const;
bool isLiveOut(ValuePtr value) const;

/// Gets the start operation for the given value. This is the first operation
/// the given value is considered to be live. This could either be the start
/// operation of the current block (in case the value is live-in) or the
/// operation that defines the given value (must be referenced in this block).
Operation *getStartOperation(Value *value) const;
Operation *getStartOperation(ValuePtr value) const;

/// Gets the end operation for the given value using the start operation
/// provided (must be referenced in this block).
Operation *getEndOperation(Value *value, Operation *startOperation) const;
Operation *getEndOperation(ValuePtr value, Operation *startOperation) const;

private:
/// The underlying block.
Expand Down
9 changes: 6 additions & 3 deletions mlir/include/mlir/Analysis/LoopAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class NestedPattern;
class Operation;
class Value;

// TODO(riverriddle) Remove this after Value is value-typed.
using ValuePtr = Value *;

/// Returns the trip count of the loop as an affine map with its corresponding
/// operands if the latter is expressible as an affine expression, and nullptr
/// otherwise. This method always succeeds as long as the lower bound is not a
Expand All @@ -45,7 +48,7 @@ class Value;
// TODO(mlir-team): this should be moved into 'Transforms/' and be replaced by a
// pure analysis method relying on FlatAffineConstraints
void buildTripCountMapAndOperands(AffineForOp forOp, AffineMap *map,
SmallVectorImpl<Value *> *operands);
SmallVectorImpl<ValuePtr> *operands);

/// Returns the trip count of the loop if it's a constant, None otherwise. This
/// uses affine expression analysis and is able to determine constant trip count
Expand All @@ -66,8 +69,8 @@ uint64_t getLargestDivisorOfTripCount(AffineForOp forOp);
///
/// Emits a note if it encounters a chain of affine.apply and conservatively
/// those cases.
DenseSet<Value *, DenseMapInfo<Value *>>
getInvariantAccesses(Value *iv, ArrayRef<Value *> indices);
DenseSet<ValuePtr, DenseMapInfo<ValuePtr>>
getInvariantAccesses(ValuePtr iv, ArrayRef<ValuePtr> indices);

using VectorizableLoopFun = std::function<bool(AffineForOp)>;

Expand Down
10 changes: 5 additions & 5 deletions mlir/include/mlir/Analysis/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ unsigned getNestingDepth(Operation &op);
/// Returns in 'sequentialLoops' all sequential loops in loop nest rooted
/// at 'forOp'.
void getSequentialLoops(AffineForOp forOp,
llvm::SmallDenseSet<Value *, 8> *sequentialLoops);
llvm::SmallDenseSet<ValuePtr, 8> *sequentialLoops);

/// ComputationSliceState aggregates loop IVs, loop bound AffineMaps and their
/// associated operands for a set of loops within a loop nest (typically the
Expand All @@ -64,15 +64,15 @@ void getSequentialLoops(AffineForOp forOp,
struct ComputationSliceState {
// List of sliced loop IVs (ordered from outermost to innermost).
// EX: 'ivs[i]' has lower bound 'lbs[i]' and upper bound 'ubs[i]'.
SmallVector<Value *, 4> ivs;
SmallVector<ValuePtr, 4> ivs;
// List of lower bound AffineMaps.
SmallVector<AffineMap, 4> lbs;
// List of upper bound AffineMaps.
SmallVector<AffineMap, 4> ubs;
// List of lower bound operands (lbOperands[i] are used by 'lbs[i]').
std::vector<SmallVector<Value *, 4>> lbOperands;
std::vector<SmallVector<ValuePtr, 4>> lbOperands;
// List of upper bound operands (ubOperands[i] are used by 'ubs[i]').
std::vector<SmallVector<Value *, 4>> ubOperands;
std::vector<SmallVector<ValuePtr, 4>> ubOperands;
// Slice loop nest insertion point in target loop nest.
Block::iterator insertPoint;
// Adds to 'cst' with constraints which represent the slice bounds on 'ivs'
Expand Down Expand Up @@ -257,7 +257,7 @@ struct MemRefRegion {
unsigned getRank() const;

/// Memref that this region corresponds to.
Value *memref;
ValuePtr memref;

/// Read or write.
bool write;
Expand Down
13 changes: 8 additions & 5 deletions mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ class OpBuilder;
class RewritePattern;
class Value;

// TODO(riverriddle) Remove this after Value is value-typed.
using ValuePtr = Value *;

// Owning list of rewriting patterns.
class OwningRewritePatternList;

/// Emit code that computes the given affine expression using standard
/// arithmetic operations applied to the provided dimension and symbol values.
Value *expandAffineExpr(OpBuilder &builder, Location loc, AffineExpr expr,
ArrayRef<Value *> dimValues,
ArrayRef<Value *> symbolValues);
ValuePtr expandAffineExpr(OpBuilder &builder, Location loc, AffineExpr expr,
ArrayRef<ValuePtr> dimValues,
ArrayRef<ValuePtr> symbolValues);

/// Collect a set of patterns to convert from the Affine dialect to the Standard
/// dialect, in particular convert structured affine control flow into CFG
Expand All @@ -47,11 +50,11 @@ void populateAffineToStdConversionPatterns(OwningRewritePatternList &patterns,

/// Emit code that computes the lower bound of the given affine loop using
/// standard arithmetic operations.
Value *lowerAffineLowerBound(AffineForOp op, OpBuilder &builder);
ValuePtr lowerAffineLowerBound(AffineForOp op, OpBuilder &builder);

/// Emit code that computes the upper bound of the given affine loop using
/// standard arithmetic operations.
Value *lowerAffineUpperBound(AffineForOp op, OpBuilder &builder);
ValuePtr lowerAffineUpperBound(AffineForOp op, OpBuilder &builder);
} // namespace mlir

#endif // MLIR_CONVERSION_AFFINETOSTANDARD_AFFINETOSTANDARD_H
7 changes: 5 additions & 2 deletions mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class AffineForOp;
struct LogicalResult;
class Value;

// TODO(riverriddle) Remove this after Value is value-typed.
using ValuePtr = Value *;

namespace loop {
class ForOp;
} // end namespace loop
Expand Down Expand Up @@ -78,8 +81,8 @@ LogicalResult convertLoopNestToGPULaunch(loop::ForOp forOp,
/// The above conditions are assumed to be satisfied by the computation rooted
/// at `forOp`.
LogicalResult convertLoopToGPULaunch(loop::ForOp forOp,
ArrayRef<Value *> numWorkGroups,
ArrayRef<Value *> workGroupSizes);
ArrayRef<ValuePtr> numWorkGroups,
ArrayRef<ValuePtr> workGroupSizes);

} // namespace mlir

Expand Down
57 changes: 29 additions & 28 deletions mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ class LLVMTypeConverter : public TypeConverter {
/// Promote the LLVM struct representation of all MemRef descriptors to stack
/// and use pointers to struct to avoid the complexity of the
/// platform-specific C/C++ ABI lowering related to struct argument passing.
SmallVector<Value *, 4> promoteMemRefDescriptors(Location loc,
ValueRange opOperands,
ValueRange operands,
OpBuilder &builder);
SmallVector<ValuePtr, 4> promoteMemRefDescriptors(Location loc,
ValueRange opOperands,
ValueRange operands,
OpBuilder &builder);

/// Promote the LLVM struct representation of one MemRef descriptor to stack
/// and use pointer to struct to avoid the complexity of the platform-specific
/// C/C++ ABI lowering related to struct argument passing.
Value *promoteOneMemRefDescriptor(Location loc, Value *operand,
OpBuilder &builder);
ValuePtr promoteOneMemRefDescriptor(Location loc, ValuePtr operand,
OpBuilder &builder);

protected:
/// LLVM IR module used to parse/create types.
Expand Down Expand Up @@ -139,32 +139,32 @@ class LLVMTypeConverter : public TypeConverter {
class StructBuilder {
public:
/// Construct a helper for the given value.
explicit StructBuilder(Value *v);
explicit StructBuilder(ValuePtr v);
/// Builds IR creating an `undef` value of the descriptor type.
static StructBuilder undef(OpBuilder &builder, Location loc,
Type descriptorType);

/*implicit*/ operator Value *() { return value; }
/*implicit*/ operator ValuePtr() { return value; }

protected:
// LLVM value
Value *value;
ValuePtr value;
// Cached struct type.
Type structType;

protected:
/// Builds IR to extract a value from the struct at position pos
Value *extractPtr(OpBuilder &builder, Location loc, unsigned pos);
ValuePtr extractPtr(OpBuilder &builder, Location loc, unsigned pos);
/// Builds IR to set a value in the struct at position pos
void setPtr(OpBuilder &builder, Location loc, unsigned pos, Value *ptr);
void setPtr(OpBuilder &builder, Location loc, unsigned pos, ValuePtr ptr);
};
/// Helper class to produce LLVM dialect operations extracting or inserting
/// elements of a MemRef descriptor. Wraps a Value pointing to the descriptor.
/// The Value may be null, in which case none of the operations are valid.
class MemRefDescriptor : public StructBuilder {
public:
/// Construct a helper for the given descriptor value.
explicit MemRefDescriptor(Value *descriptor);
explicit MemRefDescriptor(ValuePtr descriptor);
/// Builds IR creating an `undef` value of the descriptor type.
static MemRefDescriptor undef(OpBuilder &builder, Location loc,
Type descriptorType);
Expand All @@ -173,39 +173,40 @@ class MemRefDescriptor : public StructBuilder {
/// type.
static MemRefDescriptor fromStaticShape(OpBuilder &builder, Location loc,
LLVMTypeConverter &typeConverter,
MemRefType type, Value *memory);
MemRefType type, ValuePtr memory);

/// Builds IR extracting the allocated pointer from the descriptor.
Value *allocatedPtr(OpBuilder &builder, Location loc);
ValuePtr allocatedPtr(OpBuilder &builder, Location loc);
/// Builds IR inserting the allocated pointer into the descriptor.
void setAllocatedPtr(OpBuilder &builder, Location loc, Value *ptr);
void setAllocatedPtr(OpBuilder &builder, Location loc, ValuePtr ptr);

/// Builds IR extracting the aligned pointer from the descriptor.
Value *alignedPtr(OpBuilder &builder, Location loc);
ValuePtr alignedPtr(OpBuilder &builder, Location loc);

/// Builds IR inserting the aligned pointer into the descriptor.
void setAlignedPtr(OpBuilder &builder, Location loc, Value *ptr);
void setAlignedPtr(OpBuilder &builder, Location loc, ValuePtr ptr);

/// Builds IR extracting the offset from the descriptor.
Value *offset(OpBuilder &builder, Location loc);
ValuePtr offset(OpBuilder &builder, Location loc);

/// Builds IR inserting the offset into the descriptor.
void setOffset(OpBuilder &builder, Location loc, Value *offset);
void setOffset(OpBuilder &builder, Location loc, ValuePtr offset);
void setConstantOffset(OpBuilder &builder, Location loc, uint64_t offset);

/// Builds IR extracting the pos-th size from the descriptor.
Value *size(OpBuilder &builder, Location loc, unsigned pos);
ValuePtr size(OpBuilder &builder, Location loc, unsigned pos);

/// Builds IR inserting the pos-th size into the descriptor
void setSize(OpBuilder &builder, Location loc, unsigned pos, Value *size);
void setSize(OpBuilder &builder, Location loc, unsigned pos, ValuePtr size);
void setConstantSize(OpBuilder &builder, Location loc, unsigned pos,
uint64_t size);

/// Builds IR extracting the pos-th size from the descriptor.
Value *stride(OpBuilder &builder, Location loc, unsigned pos);
ValuePtr stride(OpBuilder &builder, Location loc, unsigned pos);

/// Builds IR inserting the pos-th stride into the descriptor
void setStride(OpBuilder &builder, Location loc, unsigned pos, Value *stride);
void setStride(OpBuilder &builder, Location loc, unsigned pos,
ValuePtr stride);
void setConstantStride(OpBuilder &builder, Location loc, unsigned pos,
uint64_t stride);

Expand All @@ -220,19 +221,19 @@ class MemRefDescriptor : public StructBuilder {
class UnrankedMemRefDescriptor : public StructBuilder {
public:
/// Construct a helper for the given descriptor value.
explicit UnrankedMemRefDescriptor(Value *descriptor);
explicit UnrankedMemRefDescriptor(ValuePtr descriptor);
/// Builds IR creating an `undef` value of the descriptor type.
static UnrankedMemRefDescriptor undef(OpBuilder &builder, Location loc,
Type descriptorType);

/// Builds IR extracting the rank from the descriptor
Value *rank(OpBuilder &builder, Location loc);
ValuePtr rank(OpBuilder &builder, Location loc);
/// Builds IR setting the rank in the descriptor
void setRank(OpBuilder &builder, Location loc, Value *value);
void setRank(OpBuilder &builder, Location loc, ValuePtr value);
/// Builds IR extracting ranked memref descriptor ptr
Value *memRefDescPtr(OpBuilder &builder, Location loc);
ValuePtr memRefDescPtr(OpBuilder &builder, Location loc);
/// Builds IR setting ranked memref descriptor ptr
void setMemRefDescPtr(OpBuilder &builder, Location loc, Value *value);
void setMemRefDescPtr(OpBuilder &builder, Location loc, ValuePtr value);
};
/// Base class for operation conversions targeting the LLVM IR dialect. Provides
/// conversion patterns with an access to the containing LLVMLowering for the
Expand Down
105 changes: 54 additions & 51 deletions mlir/include/mlir/Dialect/AffineOps/AffineOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class OpBuilder;
/// A utility function to check if a value is defined at the top level of a
/// function. A value of index type defined at the top level is always a valid
/// symbol.
bool isTopLevelValue(Value *value);
bool isTopLevelValue(ValuePtr value);

class AffineOpsDialect : public Dialect {
public:
Expand Down Expand Up @@ -148,18 +148,19 @@ class AffineDmaStartOp : public Op<AffineDmaStartOp, OpTrait::VariadicOperands,
public:
using Op::Op;

static void build(Builder *builder, OperationState &result, Value *srcMemRef,
AffineMap srcMap, ValueRange srcIndices, Value *destMemRef,
AffineMap dstMap, ValueRange destIndices, Value *tagMemRef,
AffineMap tagMap, ValueRange tagIndices, Value *numElements,
Value *stride = nullptr,
Value *elementsPerStride = nullptr);
static void build(Builder *builder, OperationState &result,
ValuePtr srcMemRef, AffineMap srcMap, ValueRange srcIndices,
ValuePtr destMemRef, AffineMap dstMap,
ValueRange destIndices, ValuePtr tagMemRef,
AffineMap tagMap, ValueRange tagIndices,
ValuePtr numElements, ValuePtr stride = nullptr,
ValuePtr elementsPerStride = nullptr);

/// Returns the operand index of the src memref.
unsigned getSrcMemRefOperandIndex() { return 0; }

/// Returns the source MemRefType for this DMA operation.
Value *getSrcMemRef() { return getOperand(getSrcMemRefOperandIndex()); }
ValuePtr getSrcMemRef() { return getOperand(getSrcMemRefOperandIndex()); }
MemRefType getSrcMemRefType() {
return getSrcMemRef()->getType().cast<MemRefType>();
}
Expand Down Expand Up @@ -191,7 +192,7 @@ class AffineDmaStartOp : public Op<AffineDmaStartOp, OpTrait::VariadicOperands,
}

/// Returns the destination MemRefType for this DMA operations.
Value *getDstMemRef() { return getOperand(getDstMemRefOperandIndex()); }
ValuePtr getDstMemRef() { return getOperand(getDstMemRefOperandIndex()); }
MemRefType getDstMemRefType() {
return getDstMemRef()->getType().cast<MemRefType>();
}
Expand Down Expand Up @@ -225,7 +226,7 @@ class AffineDmaStartOp : public Op<AffineDmaStartOp, OpTrait::VariadicOperands,
}

/// Returns the Tag MemRef for this DMA operation.
Value *getTagMemRef() { return getOperand(getTagMemRefOperandIndex()); }
ValuePtr getTagMemRef() { return getOperand(getTagMemRefOperandIndex()); }
MemRefType getTagMemRefType() {
return getTagMemRef()->getType().cast<MemRefType>();
}
Expand All @@ -249,13 +250,13 @@ class AffineDmaStartOp : public Op<AffineDmaStartOp, OpTrait::VariadicOperands,
}

/// Returns the number of elements being transferred by this DMA operation.
Value *getNumElements() {
ValuePtr getNumElements() {
return getOperand(getTagMemRefOperandIndex() + 1 +
getTagMap().getNumInputs());
}

/// Returns the AffineMapAttr associated with 'memref'.
NamedAttribute getAffineMapAttrForMemRef(Value *memref) {
NamedAttribute getAffineMapAttrForMemRef(ValuePtr memref) {
if (memref == getSrcMemRef())
return {Identifier::get(getSrcMapAttrName(), getContext()),
getSrcMapAttr()};
Expand Down Expand Up @@ -305,14 +306,14 @@ class AffineDmaStartOp : public Op<AffineDmaStartOp, OpTrait::VariadicOperands,
}

/// Returns the stride value for this DMA operation.
Value *getStride() {
ValuePtr getStride() {
if (!isStrided())
return nullptr;
return getOperand(getNumOperands() - 1 - 1);
}

/// Returns the number of elements to transfer per stride for this DMA op.
Value *getNumElementsPerStride() {
ValuePtr getNumElementsPerStride() {
if (!isStrided())
return nullptr;
return getOperand(getNumOperands() - 1);
Expand All @@ -337,14 +338,14 @@ class AffineDmaWaitOp : public Op<AffineDmaWaitOp, OpTrait::VariadicOperands,
public:
using Op::Op;

static void build(Builder *builder, OperationState &result, Value *tagMemRef,
AffineMap tagMap, ValueRange tagIndices,
Value *numElements);
static void build(Builder *builder, OperationState &result,
ValuePtr tagMemRef, AffineMap tagMap, ValueRange tagIndices,
ValuePtr numElements);

static StringRef getOperationName() { return "affine.dma_wait"; }

// Returns the Tag MemRef associated with the DMA operation being waited on.
Value *getTagMemRef() { return getOperand(0); }
ValuePtr getTagMemRef() { return getOperand(0); }
MemRefType getTagMemRefType() {
return getTagMemRef()->getType().cast<MemRefType>();
}
Expand All @@ -367,14 +368,16 @@ class AffineDmaWaitOp : public Op<AffineDmaWaitOp, OpTrait::VariadicOperands,
}

/// Returns the AffineMapAttr associated with 'memref'.
NamedAttribute getAffineMapAttrForMemRef(Value *memref) {
NamedAttribute getAffineMapAttrForMemRef(ValuePtr memref) {
assert(memref == getTagMemRef());
return {Identifier::get(getTagMapAttrName(), getContext()),
getTagMapAttr()};
}

/// Returns the number of elements transferred in the associated DMA op.
Value *getNumElements() { return getOperand(1 + getTagMap().getNumInputs()); }
ValuePtr getNumElements() {
return getOperand(1 + getTagMap().getNumInputs());
}

static StringRef getTagMapAttrName() { return "tag_map"; }
static ParseResult parse(OpAsmParser &parser, OperationState &result);
Expand Down Expand Up @@ -409,18 +412,18 @@ class AffineLoadOp : public Op<AffineLoadOp, OpTrait::OneResult,
static void build(Builder *builder, OperationState &result, AffineMap map,
ValueRange operands);
/// Builds an affine load op with an identity map and operands.
static void build(Builder *builder, OperationState &result, Value *memref,
static void build(Builder *builder, OperationState &result, ValuePtr memref,
ValueRange indices = {});
/// Builds an affine load op with the specified map and its operands.
static void build(Builder *builder, OperationState &result, Value *memref,
static void build(Builder *builder, OperationState &result, ValuePtr memref,
AffineMap map, ValueRange mapOperands);

/// Returns the operand index of the memref.
unsigned getMemRefOperandIndex() { return 0; }

/// Get memref operand.
Value *getMemRef() { return getOperand(getMemRefOperandIndex()); }
void setMemRef(Value *value) { setOperand(getMemRefOperandIndex(), value); }
ValuePtr getMemRef() { return getOperand(getMemRefOperandIndex()); }
void setMemRef(ValuePtr value) { setOperand(getMemRefOperandIndex(), value); }
MemRefType getMemRefType() {
return getMemRef()->getType().cast<MemRefType>();
}
Expand All @@ -435,7 +438,7 @@ class AffineLoadOp : public Op<AffineLoadOp, OpTrait::OneResult,
}

/// Returns the AffineMapAttr associated with 'memref'.
NamedAttribute getAffineMapAttrForMemRef(Value *memref) {
NamedAttribute getAffineMapAttrForMemRef(ValuePtr memref) {
assert(memref == getMemRef());
return {Identifier::get(getMapAttrName(), getContext()),
getAffineMapAttr()};
Expand Down Expand Up @@ -476,21 +479,21 @@ class AffineStoreOp : public Op<AffineStoreOp, OpTrait::ZeroResult,

/// Builds an affine store operation with the provided indices (identity map).
static void build(Builder *builder, OperationState &result,
Value *valueToStore, Value *memref, ValueRange indices);
ValuePtr valueToStore, ValuePtr memref, ValueRange indices);
/// Builds an affine store operation with the specified map and its operands.
static void build(Builder *builder, OperationState &result,
Value *valueToStore, Value *memref, AffineMap map,
ValuePtr valueToStore, ValuePtr memref, AffineMap map,
ValueRange mapOperands);

/// Get value to be stored by store operation.
Value *getValueToStore() { return getOperand(0); }
ValuePtr getValueToStore() { return getOperand(0); }

/// Returns the operand index of the memref.
unsigned getMemRefOperandIndex() { return 1; }

/// Get memref operand.
Value *getMemRef() { return getOperand(getMemRefOperandIndex()); }
void setMemRef(Value *value) { setOperand(getMemRefOperandIndex(), value); }
ValuePtr getMemRef() { return getOperand(getMemRefOperandIndex()); }
void setMemRef(ValuePtr value) { setOperand(getMemRefOperandIndex(), value); }

MemRefType getMemRefType() {
return getMemRef()->getType().cast<MemRefType>();
Expand All @@ -506,7 +509,7 @@ class AffineStoreOp : public Op<AffineStoreOp, OpTrait::ZeroResult,
}

/// Returns the AffineMapAttr associated with 'memref'.
NamedAttribute getAffineMapAttrForMemRef(Value *memref) {
NamedAttribute getAffineMapAttrForMemRef(ValuePtr memref) {
assert(memref == getMemRef());
return {Identifier::get(getMapAttrName(), getContext()),
getAffineMapAttr()};
Expand All @@ -526,10 +529,10 @@ class AffineStoreOp : public Op<AffineStoreOp, OpTrait::ZeroResult,
};

/// Returns true if the given Value can be used as a dimension id.
bool isValidDim(Value *value);
bool isValidDim(ValuePtr value);

/// Returns true if the given Value can be used as a symbol.
bool isValidSymbol(Value *value);
bool isValidSymbol(ValuePtr value);

/// Modifies both `map` and `operands` in-place so as to:
/// 1. drop duplicate operands
Expand All @@ -538,17 +541,17 @@ bool isValidSymbol(Value *value);
/// dimensional operands
/// 4. propagate constant operands and drop them
void canonicalizeMapAndOperands(AffineMap *map,
SmallVectorImpl<Value *> *operands);
SmallVectorImpl<ValuePtr> *operands);
/// Canonicalizes an integer set the same way canonicalizeMapAndOperands does
/// for affine maps.
void canonicalizeSetAndOperands(IntegerSet *set,
SmallVectorImpl<Value *> *operands);
SmallVectorImpl<ValuePtr> *operands);

/// Returns a composed AffineApplyOp by composing `map` and `operands` with
/// other AffineApplyOps supplying those operands. The operands of the resulting
/// AffineApplyOp do not change the length of AffineApplyOp chains.
AffineApplyOp makeComposedAffineApply(OpBuilder &b, Location loc, AffineMap map,
ArrayRef<Value *> operands);
ArrayRef<ValuePtr> operands);

/// Given an affine map `map` and its input `operands`, this method composes
/// into `map`, maps of AffineApplyOps whose results are the values in
Expand All @@ -558,22 +561,22 @@ AffineApplyOp makeComposedAffineApply(OpBuilder &b, Location loc, AffineMap map,
/// terminal symbol, i.e., a symbol defined at the top level or a block/function
/// argument.
void fullyComposeAffineMapAndOperands(AffineMap *map,
SmallVectorImpl<Value *> *operands);
SmallVectorImpl<ValuePtr> *operands);

#define GET_OP_CLASSES
#include "mlir/Dialect/AffineOps/AffineOps.h.inc"

/// Returns if the provided value is the induction variable of a AffineForOp.
bool isForInductionVar(Value *val);
bool isForInductionVar(ValuePtr val);

/// Returns the loop parent of an induction variable. If the provided value is
/// not an induction variable, then return nullptr.
AffineForOp getForInductionVarOwner(Value *val);
AffineForOp getForInductionVarOwner(ValuePtr val);

/// Extracts the induction variables from a list of AffineForOps and places them
/// in the output argument `ivs`.
void extractForInductionVars(ArrayRef<AffineForOp> forInsts,
SmallVectorImpl<Value *> *ivs);
SmallVectorImpl<ValuePtr> *ivs);

/// AffineBound represents a lower or upper bound in the for operation.
/// This class does not own the underlying operands. Instead, it refers
Expand All @@ -588,7 +591,7 @@ class AffineBound {
AffineValueMap getAsAffineValueMap();

unsigned getNumOperands() { return opEnd - opStart; }
Value *getOperand(unsigned idx) { return op.getOperand(opStart + idx); }
ValuePtr getOperand(unsigned idx) { return op.getOperand(opStart + idx); }

using operand_iterator = AffineForOp::operand_iterator;
using operand_range = AffineForOp::operand_range;
Expand All @@ -613,7 +616,7 @@ class AffineBound {
};

/// An `AffineApplyNormalizer` is a helper class that supports renumbering
/// operands of AffineApplyOp. This acts as a reindexing map of Value* to
/// operands of AffineApplyOp. This acts as a reindexing map of Value to
/// positional dims or symbols and allows simplifications such as:
///
/// ```mlir
Expand All @@ -626,13 +629,13 @@ class AffineBound {
/// %1 = affine.apply () -> (0)
/// ```
struct AffineApplyNormalizer {
AffineApplyNormalizer(AffineMap map, ArrayRef<Value *> operands);
AffineApplyNormalizer(AffineMap map, ArrayRef<ValuePtr> operands);

/// Returns the AffineMap resulting from normalization.
AffineMap getAffineMap() { return affineMap; }

SmallVector<Value *, 8> getOperands() {
SmallVector<Value *, 8> res(reorderedDims);
SmallVector<ValuePtr, 8> getOperands() {
SmallVector<ValuePtr, 8> res(reorderedDims);
res.append(concatenatedSymbols.begin(), concatenatedSymbols.end());
return res;
}
Expand All @@ -642,27 +645,27 @@ struct AffineApplyNormalizer {

/// Normalizes 'otherMap' and its operands 'otherOperands' to map to this
/// normalizer's coordinate space.
void normalize(AffineMap *otherMap, SmallVectorImpl<Value *> *otherOperands);
void normalize(AffineMap *otherMap, SmallVectorImpl<ValuePtr> *otherOperands);

private:
/// Helper function to insert `v` into the coordinate system of the current
/// AffineApplyNormalizer. Returns the AffineDimExpr with the corresponding
/// renumbered position.
AffineDimExpr renumberOneDim(Value *v);
AffineDimExpr renumberOneDim(ValuePtr v);

/// Given an `other` normalizer, this rewrites `other.affineMap` in the
/// coordinate system of the current AffineApplyNormalizer.
/// Returns the rewritten AffineMap and updates the dims and symbols of
/// `this`.
AffineMap renumber(const AffineApplyNormalizer &other);

/// Maps of Value* to position in `affineMap`.
DenseMap<Value *, unsigned> dimValueToPosition;
/// Maps of Value to position in `affineMap`.
DenseMap<ValuePtr, unsigned> dimValueToPosition;

/// Ordered dims and symbols matching positional dims and symbols in
/// `affineMap`.
SmallVector<Value *, 8> reorderedDims;
SmallVector<Value *, 8> concatenatedSymbols;
SmallVector<ValuePtr, 8> reorderedDims;
SmallVector<ValuePtr, 8> concatenatedSymbols;

AffineMap affineMap;

Expand Down
8 changes: 4 additions & 4 deletions mlir/include/mlir/Dialect/AffineOps/AffineOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def AffineForOp : Affine_Op<"for",
static StringRef getUpperBoundAttrName() { return "upper_bound"; }

Block *getBody() { return &region().front(); }
Value *getInductionVar() { return getBody()->getArgument(0); }
ValuePtr getInductionVar() { return getBody()->getArgument(0); }
OpBuilder getBodyBuilder() {
return OpBuilder(getBody(), std::prev(getBody()->end()));
}
Expand Down Expand Up @@ -286,8 +286,8 @@ def AffinePrefetchOp : Affine_Op<"prefetch"> {
BoolAttr:$isDataCache);

let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *memref,"
"AffineMap map, ArrayRef<Value *> mapOperands, bool isWrite,"
"Builder *builder, OperationState &result, ValuePtr memref,"
"AffineMap map, ArrayRef<ValuePtr> mapOperands, bool isWrite,"
"unsigned localityHint, bool isDataCache",
[{
assert(map.getNumInputs() == mapOperands.size()
Expand Down Expand Up @@ -315,7 +315,7 @@ def AffinePrefetchOp : Affine_Op<"prefetch"> {
}

/// Returns the AffineMapAttr associated with 'memref'.
NamedAttribute getAffineMapAttrForMemRef(Value *mref) {
NamedAttribute getAffineMapAttrForMemRef(ValuePtr mref) {
assert(mref == memref());
return {Identifier::get(getMapAttrName(), getContext()),
getAffineMapAttr()};
Expand Down
6 changes: 3 additions & 3 deletions mlir/include/mlir/Dialect/GPU/GPUDialect.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ class GPUDialect : public Dialect {
/// Utility class for the GPU dialect to represent triples of `Value`s
/// accessible through `.x`, `.y`, and `.z` similarly to CUDA notation.
struct KernelDim3 {
Value *x;
Value *y;
Value *z;
ValuePtr x;
ValuePtr y;
ValuePtr z;
};

#define GET_OP_CLASSES
Expand Down
16 changes: 8 additions & 8 deletions mlir/include/mlir/Dialect/GPU/GPUOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [FunctionLike, IsolatedFromAbove, Symbol]> {

/// Returns a list of block arguments that correspond to buffers located in
/// the workgroup memory
ArrayRef<BlockArgument *> getWorkgroupAttributions() {
ArrayRef<BlockArgumentPtr> getWorkgroupAttributions() {
auto begin =
std::next(getBody().front().args_begin(), getType().getNumInputs());
auto end = std::next(begin, getNumWorkgroupAttributions());
Expand All @@ -166,7 +166,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [FunctionLike, IsolatedFromAbove, Symbol]> {

/// Returns a list of block arguments that correspond to buffers located in
/// the private memory.
ArrayRef<BlockArgument *> getPrivateAttributions() {
ArrayRef<BlockArgumentPtr> getPrivateAttributions() {
auto begin =
std::next(getBody().front().args_begin(),
getType().getNumInputs() + getNumWorkgroupAttributions());
Expand Down Expand Up @@ -282,8 +282,8 @@ def GPU_LaunchFuncOp : GPU_Op<"launch_func">,

let builders = [
OpBuilder<"Builder *builder, OperationState &result, GPUFuncOp kernelFunc, "
"Value *gridSizeX, Value *gridSizeY, Value *gridSizeZ, "
"Value *blockSizeX, Value *blockSizeY, Value *blockSizeZ, "
"ValuePtr gridSizeX, ValuePtr gridSizeY, ValuePtr gridSizeZ, "
"ValuePtr blockSizeX, ValuePtr blockSizeY, ValuePtr blockSizeZ, "
"ValueRange kernelOperands">,
OpBuilder<"Builder *builder, OperationState &result, GPUFuncOp kernelFunc, "
"KernelDim3 gridSize, KernelDim3 blockSize, "
Expand All @@ -302,7 +302,7 @@ def GPU_LaunchFuncOp : GPU_Op<"launch_func">,
StringRef getKernelModuleName();

/// The i-th operand passed to the kernel function.
Value *getKernelOperand(unsigned i);
ValuePtr getKernelOperand(unsigned i);

/// Get the SSA values passed as operands to specify the grid size.
KernelDim3 getGridSizeOperandValues();
Expand Down Expand Up @@ -415,9 +415,9 @@ def GPU_LaunchOp : GPU_Op<"launch", [IsolatedFromAbove]>,
let skipDefaultBuilders = 1;

let builders = [
OpBuilder<"Builder *builder, OperationState &result, Value *gridSizeX,"
"Value *gridSizeY, Value *gridSizeZ, Value *blockSizeX,"
"Value *blockSizeY, Value *blockSizeZ,"
OpBuilder<"Builder *builder, OperationState &result, ValuePtr gridSizeX,"
"ValuePtr gridSizeY, ValuePtr gridSizeZ, ValuePtr blockSizeX,"
"ValuePtr blockSizeY, ValuePtr blockSizeZ,"
"ValueRange operands">
];

Expand Down
6 changes: 3 additions & 3 deletions mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ class LLVMDialect : public Dialect {
/// surrounding the insertion point of builder. Obtain the address of that
/// global and use it to compute the address of the first character in the
/// string (operations inserted at the builder insertion point).
Value *createGlobalString(Location loc, OpBuilder &builder, StringRef name,
StringRef value, LLVM::Linkage linkage,
LLVM::LLVMDialect *llvmDialect);
ValuePtr createGlobalString(Location loc, OpBuilder &builder, StringRef name,
StringRef value, LLVM::Linkage linkage,
LLVM::LLVMDialect *llvmDialect);

/// LLVM requires some operations to be inside of a Module operation. This
/// function confirms that the Operation has the desired properties.
Expand Down
22 changes: 11 additions & 11 deletions mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ def LLVM_ICmpOp : LLVM_OneResultOp<"icmp", [NoSideEffect]>,
$res = builder.CreateICmp(getLLVMCmpPredicate($predicate), $lhs, $rhs);
}];
let builders = [OpBuilder<
"Builder *b, OperationState &result, ICmpPredicate predicate, Value *lhs, "
"Value *rhs", [{
"Builder *b, OperationState &result, ICmpPredicate predicate, ValuePtr lhs, "
"ValuePtr rhs", [{
LLVMDialect *dialect = &lhs->getType().cast<LLVMType>().getDialect();
build(b, result, LLVMType::getInt1Ty(dialect),
b->getI64IntegerAttr(static_cast<int64_t>(predicate)), lhs, rhs);
Expand Down Expand Up @@ -232,8 +232,8 @@ def LLVM_FCmpOp : LLVM_OneResultOp<"fcmp", [NoSideEffect]>,
$res = builder.CreateFCmp(getLLVMCmpPredicate($predicate), $lhs, $rhs);
}];
let builders = [OpBuilder<
"Builder *b, OperationState &result, FCmpPredicate predicate, Value *lhs, "
"Value *rhs", [{
"Builder *b, OperationState &result, FCmpPredicate predicate, ValuePtr lhs, "
"ValuePtr rhs", [{
LLVMDialect *dialect = &lhs->getType().cast<LLVMType>().getDialect();
build(b, result, LLVMType::getInt1Ty(dialect),
b->getI64IntegerAttr(static_cast<int64_t>(predicate)), lhs, rhs);
Expand Down Expand Up @@ -265,7 +265,7 @@ def LLVM_AllocaOp :
$res = alloca;
}];
let builders = [OpBuilder<
"Builder *b, OperationState &result, Type resultType, Value *arraySize, "
"Builder *b, OperationState &result, Type resultType, ValuePtr arraySize, "
"unsigned alignment",
[{
if (alignment == 0)
Expand All @@ -292,7 +292,7 @@ def LLVM_GEPOp : LLVM_OneResultOp<"getelementptr", [NoSideEffect]>,
def LLVM_LoadOp : LLVM_OneResultOp<"load">, Arguments<(ins LLVM_Type:$addr)>,
LLVM_Builder<"$res = builder.CreateLoad($addr);"> {
let builders = [OpBuilder<
"Builder *b, OperationState &result, Value *addr",
"Builder *b, OperationState &result, ValuePtr addr",
[{
auto type = addr->getType().cast<LLVM::LLVMType>().getPointerElementTy();
build(b, result, type, addr);
Expand Down Expand Up @@ -353,7 +353,7 @@ def LLVM_ExtractElementOp : LLVM_OneResultOp<"extractelement", [NoSideEffect]>,
$res = builder.CreateExtractElement($vector, $position);
}];
let builders = [OpBuilder<
"Builder *b, OperationState &result, Value *vector, Value *position,"
"Builder *b, OperationState &result, ValuePtr vector, ValuePtr position,"
"ArrayRef<NamedAttribute> attrs = {}">];
let parser = [{ return parseExtractElementOp(parser, result); }];
let printer = [{ printExtractElementOp(p, *this); }];
Expand Down Expand Up @@ -384,7 +384,7 @@ def LLVM_InsertValueOp : LLVM_OneResultOp<"insertvalue", [NoSideEffect]>,
extractPosition($position));
}];
let builders = [OpBuilder<
"Builder *b, OperationState &result, Value *container, Value *value, "
"Builder *b, OperationState &result, ValuePtr container, ValuePtr value, "
"ArrayAttr position",
[{
build(b, result, container->getType(), container, value, position);
Expand All @@ -398,7 +398,7 @@ def LLVM_ShuffleVectorOp
LLVM_Builder<
"$res = builder.CreateShuffleVector($v1, $v2, extractPosition($mask));"> {
let builders = [OpBuilder<
"Builder *b, OperationState &result, Value *v1, Value *v2, "
"Builder *b, OperationState &result, ValuePtr v1, ValuePtr v2, "
"ArrayAttr mask, ArrayRef<NamedAttribute> attrs = {}">];
let verifier = [{
auto wrappedVectorType1 = v1()->getType().cast<LLVM::LLVMType>();
Expand All @@ -422,8 +422,8 @@ def LLVM_SelectOp
LLVM_Builder<
"$res = builder.CreateSelect($condition, $trueValue, $falseValue);"> {
let builders = [OpBuilder<
"Builder *b, OperationState &result, Value *condition, Value *lhs, "
"Value *rhs", [{
"Builder *b, OperationState &result, ValuePtr condition, ValuePtr lhs, "
"ValuePtr rhs", [{
build(b, result, lhs->getType(), condition, lhs, rhs);
}]>];
let parser = [{ return parseSelectOp(parser, result); }];
Expand Down
16 changes: 8 additions & 8 deletions mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class LinalgOp;
class Aliases {
public:
/// Returns true if v1 and v2 alias.
bool alias(Value *v1, Value *v2) { return find(v1) == find(v2); }
bool alias(ValuePtr v1, ValuePtr v2) { return find(v1) == find(v2); }

private:
/// Returns the base buffer or block argument into which the view `v` aliases.
/// This lazily records the new aliases discovered while walking back the
/// use-def chain.
Value *find(Value *v);
ValuePtr find(ValuePtr v);

DenseMap<Value *, Value *> aliases;
DenseMap<ValuePtr, ValuePtr> aliases;
};

/// Data structure for holding a dependence graph that operates on LinalgOp and
Expand All @@ -54,7 +54,7 @@ class LinalgDependenceGraph {
public:
struct LinalgOpView {
Operation *op;
Value *view;
ValuePtr view;
};
struct LinalgDependenceGraphElem {
// dependentOpView may be either:
Expand All @@ -64,7 +64,7 @@ class LinalgDependenceGraph {
// View in the op that is used to index in the graph:
// 1. src in the case of dependencesFromDstGraphs.
// 2. dst in the case of dependencesIntoGraphs.
Value *indexingView;
ValuePtr indexingView;
};
using LinalgDependences = SmallVector<LinalgDependenceGraphElem, 8>;
using DependenceGraph = DenseMap<Operation *, LinalgDependences>;
Expand Down Expand Up @@ -97,14 +97,14 @@ class LinalgDependenceGraph {
/// Dependences are restricted to views aliasing `view`.
SmallVector<Operation *, 8> findCoveringReads(LinalgOp srcLinalgOp,
LinalgOp dstLinalgOp,
Value *view) const;
ValuePtr view) const;

/// Returns the operations that are interleaved between `srcLinalgOp` and
/// `dstLinalgOp` and that are involved in a WAR or WAW with `srcLinalgOp`.
/// Dependences are restricted to views aliasing `view`.
SmallVector<Operation *, 8> findCoveringWrites(LinalgOp srcLinalgOp,
LinalgOp dstLinalgOp,
Value *view) const;
ValuePtr view) const;

private:
// Keep dependences in both directions, this is not just a performance gain
Expand All @@ -130,7 +130,7 @@ class LinalgDependenceGraph {
/// Implementation detail for findCoveringxxx.
SmallVector<Operation *, 8>
findOperationsWithCoveringDependences(LinalgOp srcLinalgOp,
LinalgOp dstLinalgOp, Value *view,
LinalgOp dstLinalgOp, ValuePtr view,
ArrayRef<DependenceType> types) const;

Aliases &aliases;
Expand Down
20 changes: 10 additions & 10 deletions mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,34 @@ inline StringRef toString(IterType t) {
/// makeLinalgGenericOp({A({m, n}), B({k, n})}, {C({m, n})}, ... );
/// ```
struct StructuredIndexed {
StructuredIndexed(Value *v) : value(v) {}
StructuredIndexed(ValuePtr v) : value(v) {}
StructuredIndexed operator()(ArrayRef<AffineExpr> indexings) {
return StructuredIndexed(value, indexings);
}

operator Value *() const /* implicit */ { return value; }
operator ValuePtr() const /* implicit */ { return value; }
ArrayRef<AffineExpr> getExprs() { return exprs; }

private:
StructuredIndexed(Value *v, ArrayRef<AffineExpr> indexings)
StructuredIndexed(ValuePtr v, ArrayRef<AffineExpr> indexings)
: value(v), exprs(indexings.begin(), indexings.end()) {
assert(v->getType().isa<MemRefType>() && "MemRefType expected");
}
StructuredIndexed(ValueHandle v, ArrayRef<AffineExpr> indexings)
: StructuredIndexed(v.getValue(), indexings) {}

Value *value;
ValuePtr value;
SmallVector<AffineExpr, 4> exprs;
};

inline void defaultRegionBuilder(ArrayRef<BlockArgument *> args) {}
inline void defaultRegionBuilder(ArrayRef<BlockArgumentPtr> args) {}

Operation *makeLinalgGenericOp(ArrayRef<IterType> iteratorTypes,
ArrayRef<StructuredIndexed> inputs,
ArrayRef<StructuredIndexed> outputs,
function_ref<void(ArrayRef<BlockArgument *>)>
function_ref<void(ArrayRef<BlockArgumentPtr>)>
regionBuilder = defaultRegionBuilder,
ArrayRef<Value *> otherValues = {},
ArrayRef<ValuePtr> otherValues = {},
ArrayRef<Attribute> otherAttributes = {});

namespace ops {
Expand All @@ -96,7 +96,7 @@ using edsc::intrinsics::linalg_yield;

/// Build the body of a region to compute a multiply-accumulate, under the
/// current ScopedContext, at the current insert point.
void macRegionBuilder(ArrayRef<BlockArgument *> args);
void macRegionBuilder(ArrayRef<BlockArgumentPtr> args);

/// TODO(ntv): In the future we should tie these implementations to something in
/// Tablegen that generates the proper interfaces and the proper sugared named
Expand All @@ -120,7 +120,7 @@ void macRegionBuilder(ArrayRef<BlockArgument *> args);
/// with in-place semantics and parallelism.

/// Unary pointwise operation (with broadcast) entry point.
using UnaryPointwiseOpBuilder = function_ref<Value *(ValueHandle)>;
using UnaryPointwiseOpBuilder = function_ref<ValuePtr(ValueHandle)>;
Operation *linalg_pointwise(UnaryPointwiseOpBuilder unaryOp,
StructuredIndexed I, StructuredIndexed O);

Expand All @@ -131,7 +131,7 @@ Operation *linalg_pointwise_tanh(StructuredIndexed I, StructuredIndexed O);

/// Binary pointwise operation (with broadcast) entry point.
using BinaryPointwiseOpBuilder =
function_ref<Value *(ValueHandle, ValueHandle)>;
function_ref<ValuePtr(ValueHandle, ValueHandle)>;
Operation *linalg_pointwise(BinaryPointwiseOpBuilder binaryOp,
StructuredIndexed I1, StructuredIndexed I2,
StructuredIndexed O);
Expand Down
10 changes: 5 additions & 5 deletions mlir/include/mlir/Dialect/Linalg/IR/LinalgLibraryOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,22 @@ def LinalgLibraryInterface : OpInterface<"LinalgOp"> {
"Query the number of loops within the current operation.",
"unsigned", "getNumLoops">,
InterfaceMethod<"Query the input view at the given index.",
"Value *", "getInput", (ins "unsigned":$i)
"ValuePtr ", "getInput", (ins "unsigned":$i)
>,
InterfaceMethod<"Query the output view at the given index.",
"Value *", "getOutput", (ins "unsigned":$i)
"ValuePtr ", "getOutput", (ins "unsigned":$i)
>,
InterfaceMethod<[{
Query the index of the given input value, or `None` if the value is not
an input.
}],
"Optional<unsigned>", "getIndexOfInput", (ins "Value *":$view)
"Optional<unsigned>", "getIndexOfInput", (ins "ValuePtr ":$view)
>,
InterfaceMethod<[{
Query the index of the given view value, or `None` if the value is not
an view.
}],
"Optional<unsigned>", "getIndexOfOutput", (ins "Value *":$view)
"Optional<unsigned>", "getIndexOfOutput", (ins "ValuePtr ":$view)
>,
InterfaceMethod<[{
Query the type of the input view at the given index.
Expand Down Expand Up @@ -228,7 +228,7 @@ def CopyOp : LinalgLibrary_Op<"copy", [NInputs<1>, NOutputs<1>]> {
// TODO(ntv) this should go away once the usage of OptionalAttr triggers
// emission of builders with default arguments left unspecified.
let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *input, Value *output", [{
"Builder *builder, OperationState &result, ValuePtr input, ValuePtr output", [{
return build(
builder, result, input, output, AffineMapAttr(), AffineMapAttr());
}]>];
Expand Down
16 changes: 8 additions & 8 deletions mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def Linalg_RangeOp :
````
}];
let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *min, Value *max, "
"Value *step",
"Builder *builder, OperationState &result, ValuePtr min, ValuePtr max, "
"ValuePtr step",
[{
auto rangeType = RangeType::get(builder->getContext());
build(builder, result, rangeType, min, max, step);
Expand Down Expand Up @@ -112,7 +112,7 @@ def Linalg_SliceOp : Linalg_Op<"slice", [NoSideEffect]>,
}];

let builders = [OpBuilder<
"Builder *b, OperationState &result, Value *base, "
"Builder *b, OperationState &result, ValuePtr base, "
"ValueRange indexings">];

let extraClassDeclaration = [{
Expand All @@ -124,12 +124,12 @@ def Linalg_SliceOp : Linalg_Op<"slice", [NoSideEffect]>,
MemRefType getBaseViewType() { return view()->getType().cast<MemRefType>(); }

// Get the underlying indexing at a given rank.
Value *indexing(unsigned rank) { return *(indexings().begin() + rank); }
ValuePtr indexing(unsigned rank) { return *(indexings().begin() + rank); }

// Get the subset of indexings that are of RangeType.
SmallVector<Value *, 8> getRanges() {
SmallVector<Value *, 8> res;
for (auto *operand : indexings())
SmallVector<ValuePtr, 8> getRanges() {
SmallVector<ValuePtr, 8> res;
for (auto operand : indexings())
if (!operand->getType().isa<IndexType>())
res.push_back(operand);
return res;
Expand All @@ -154,7 +154,7 @@ def Linalg_TransposeOp : Linalg_Op<"transpose", [NoSideEffect]>,
}];

let builders = [OpBuilder<
"Builder *b, OperationState &result, Value *view, "
"Builder *b, OperationState &result, ValuePtr view, "
"AffineMapAttr permutation, ArrayRef<NamedAttribute> attrs = {}">];

let verifier = [{
Expand Down
10 changes: 5 additions & 5 deletions mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,22 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
"Query the number of loops within the current operation.",
"unsigned", "getNumLoops">,
InterfaceMethod<"Query the input view at the given index.",
"Value *", "getInput", (ins "unsigned":$i)
"ValuePtr ", "getInput", (ins "unsigned":$i)
>,
InterfaceMethod<"Query the output view at the given index.",
"Value *", "getOutput", (ins "unsigned":$i)
"ValuePtr ", "getOutput", (ins "unsigned":$i)
>,
InterfaceMethod<[{
Query the index of the given input value, or `None` if the value is not
an input.
}],
"llvm::Optional<unsigned>", "getIndexOfInput", (ins "Value *":$view)
"llvm::Optional<unsigned>", "getIndexOfInput", (ins "ValuePtr ":$view)
>,
InterfaceMethod<[{
Query the index of the given view value, or `None` if the value is not
an view.
}],
"llvm::Optional<unsigned>", "getIndexOfOutput", (ins "Value *":$view)
"llvm::Optional<unsigned>", "getIndexOfOutput", (ins "ValuePtr ":$view)
>,
InterfaceMethod<[{
Query the type of the input view at the given index.
Expand Down Expand Up @@ -228,7 +228,7 @@ def CopyOp : LinalgStructured_Op<"copy", [NInputs<1>, NOutputs<1>]> {
// TODO(ntv) this should go away once the usage of OptionalAttr triggers
// emission of builders with default arguments left unspecified.
let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *input, Value *output", [{
"Builder *builder, OperationState &result, ValuePtr input, ValuePtr output", [{
return build(
builder, result, input, output, AffineMapAttr(), AffineMapAttr());
}]>];
Expand Down
8 changes: 4 additions & 4 deletions mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ class ViewTraits : public OpTrait::TraitBase<ConcreteType, ViewTraits> {

public:
/// Return the `i`-th input view.
Value *getInput(unsigned i) {
ValuePtr getInput(unsigned i) {
assert(i < nInputs());
return this->getOperation()->getOperand(i);
}
/// Return the index of `view` in the list of input views if found, llvm::None
/// otherwise.
Optional<unsigned> getIndexOfInput(Value *view) {
Optional<unsigned> getIndexOfInput(ValuePtr view) {
auto it = llvm::find(getInputs(), view);
if (it != getInputs().end())
return it - getInputs().begin();
Expand All @@ -99,12 +99,12 @@ class ViewTraits : public OpTrait::TraitBase<ConcreteType, ViewTraits> {
return {range.begin(), range.begin() + nInputs()};
}
/// Return the `i`-th output view.
Value *getOutput(unsigned i) {
ValuePtr getOutput(unsigned i) {
return this->getOperation()->getOperand(nInputs() + i);
}
/// Return the index of `view` in the list of output views if found,
/// llvm::None otherwise.
Optional<unsigned> getIndexOfOutput(Value *view) {
Optional<unsigned> getIndexOfOutput(ValuePtr view) {
auto it = llvm::find(getOutputs(), view);
if (it != getOutputs().end())
return it - getOutputs().begin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AffineMapDomainHasDim<int n> : CPred<[{

class HasOperandsOfType<string type>: CPred<[{
llvm::any_of($0.getOperands(),
[](Value* v) {
[](ValuePtr v) {
return dyn_cast_or_null<}] # type # [{>(v->getDefiningOp());
})
}]>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ struct LinalgTransforms {
namespace detail {
// Implementation detail of isProducedByOpOfType avoids the need for explicit
// template instantiations.
bool isProducedByOpOfTypeImpl(Operation *consumerOp, Value *consumedView,
bool isProducedByOpOfTypeImpl(Operation *consumerOp, ValuePtr consumedView,
function_ref<bool(Operation *)> isaOpType);
} // namespace detail

// Returns true if the `consumedView` value use in `consumerOp` is produced by
// an op of type `OpTy`. This is used to implement use-def type information on
// buffers.
template <typename OpTy>
bool isProducedByOpOfType(Operation *consumerOp, Value *consumedView) {
bool isProducedByOpOfType(Operation *consumerOp, ValuePtr consumedView) {
return detail::isProducedByOpOfTypeImpl(
consumerOp, consumedView, [](Operation *op) { return isa<OpTy>(op); });
}
Expand Down
36 changes: 18 additions & 18 deletions mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ namespace edsc {

/// A LoopRangeBuilder is a generic NestedBuilder for loop.for operations.
/// More specifically it is meant to be used as a temporary object for
/// representing any nested MLIR construct that is "related to" an mlir::Value*
/// representing any nested MLIR construct that is "related to" an mlir::Value
/// (for now an induction variable).
class LoopRangeBuilder : public NestedBuilder {
public:
/// Constructs a new loop.for and captures the associated induction
/// variable. A ValueHandle pointer is passed as the first argument and is the
/// *only* way to capture the loop induction variable.
LoopRangeBuilder(ValueHandle *iv, ValueHandle range);
LoopRangeBuilder(ValueHandle *iv, Value *range);
LoopRangeBuilder(ValueHandle *iv, ValuePtr range);
LoopRangeBuilder(ValueHandle *iv, SubViewOp::Range range);

LoopRangeBuilder(const LoopRangeBuilder &) = delete;
Expand All @@ -65,7 +65,7 @@ class LoopNestRangeBuilder {
LoopNestRangeBuilder(ArrayRef<edsc::ValueHandle *> ivs,
ArrayRef<edsc::ValueHandle> ranges);
LoopNestRangeBuilder(ArrayRef<edsc::ValueHandle *> ivs,
ArrayRef<Value *> ranges);
ArrayRef<ValuePtr> ranges);
LoopNestRangeBuilder(ArrayRef<edsc::ValueHandle *> ivs,
ArrayRef<SubViewOp::Range> ranges);
edsc::ValueHandle operator()(std::function<void(void)> fun = nullptr);
Expand All @@ -88,14 +88,14 @@ struct FusionInfo {
/// whole `consumedView`. This checks structural dominance, that the dependence
/// is a RAW without any interleaved write to any piece of `consumedView`.
bool isProducerLastWriteOfView(const LinalgDependenceGraph &graph,
LinalgOp consumer, Value *consumedView,
LinalgOp consumer, ValuePtr consumedView,
LinalgOp producer);

/// Checks whether fusing the specific `producer` of the `consumedView` is
/// feasible. This checks `producer` is the last write of `consumedView` and
/// that no interleaved dependence would be violated (RAW, WAR or WAW).
bool isFusableInto(const LinalgDependenceGraph &graph, LinalgOp consumer,
Value *consumedView, LinalgOp producer);
ValuePtr consumedView, LinalgOp producer);

/// Fuses producer into consumer if the producer is structurally feasible and
/// the fusion would not violate dependencies.
Expand All @@ -111,8 +111,8 @@ Optional<FusionInfo> fuseProducerOf(OpBuilder &b, LinalgOp consumer,
/// the inverse, concatenated loopToOperandRangeMaps to this list allows the
/// derivation of loop ranges for any linalgOp.
template <typename ConcreteOp>
SmallVector<Value *, 8> getViewSizes(ConcreteOp linalgOp) {
SmallVector<Value *, 8> res;
SmallVector<ValuePtr, 8> getViewSizes(ConcreteOp linalgOp) {
SmallVector<ValuePtr, 8> res;
for (auto v : linalgOp.getInputsAndOutputs()) {
MemRefType t = v->getType().template cast<MemRefType>();
for (unsigned i = 0; i < t.getRank(); ++i)
Expand All @@ -125,10 +125,10 @@ SmallVector<Value *, 8> getViewSizes(ConcreteOp linalgOp) {
/// When non-null, the optional pointer `folder` is used to call into the
/// `createAndFold` builder method. If `folder` is null, the regular `create`
/// method is called.
SmallVector<Value *, 4> applyMapToValues(OpBuilder &b, Location loc,
AffineMap map,
ArrayRef<Value *> values,
OperationFolder *folder = nullptr);
SmallVector<ValuePtr, 4> applyMapToValues(OpBuilder &b, Location loc,
AffineMap map,
ArrayRef<ValuePtr> values,
OperationFolder *folder = nullptr);

struct TiledLinalgOp {
LinalgOp op;
Expand All @@ -151,7 +151,7 @@ struct TiledLinalgOp {
/// `createAndFold` builder method. If `folder` is null, the regular `create`
/// method is called.
Optional<TiledLinalgOp> tileLinalgOp(OpBuilder &b, LinalgOp op,
ArrayRef<Value *> tileSizes,
ArrayRef<ValuePtr> tileSizes,
ArrayRef<unsigned> permutation = {},
OperationFolder *folder = nullptr);

Expand Down Expand Up @@ -182,9 +182,9 @@ Optional<TiledLinalgOp> tileLinalgOperation(OpBuilder &b, Operation *op,
}

struct PromotionInfo {
Value *buffer;
Value *fullLocalView;
Value *partialLocalView;
ValuePtr buffer;
ValuePtr fullLocalView;
ValuePtr partialLocalView;
};

/// Promotes the `subViews` into a new buffer allocated at the insertion point
Expand All @@ -199,13 +199,13 @@ struct PromotionInfo {
/// Returns a list of PromotionInfo which hold the promoted buffer and the
/// full and partial views indexing into the buffer.
SmallVector<PromotionInfo, 8>
promoteSubViews(OpBuilder &b, Location loc, ArrayRef<Value *> subViews,
promoteSubViews(OpBuilder &b, Location loc, ArrayRef<ValuePtr> subViews,
bool dynamicBuffers = false, OperationFolder *folder = nullptr);

/// Returns all the operands of `linalgOp` that are not views.
/// Asserts that these operands are value types to allow transformations like
/// tiling to just use the values when cloning `linalgOp`.
SmallVector<Value *, 4> getAssumedNonViewOperands(LinalgOp linalgOp);
SmallVector<ValuePtr, 4> getAssumedNonViewOperands(LinalgOp linalgOp);

/// Apply the permutation defined by `permutation` to `inVec`.
/// Element `i` in `inVec` is mapped to location `j = permutation[i]`.
Expand All @@ -226,7 +226,7 @@ void applyPermutationToVector(SmallVector<T, N> &inVec,
/// It is the entry point for declarative transformation
/// Returns the cloned `LinalgOp` with the new operands
LinalgOp promoteSubViewOperands(OpBuilder &b, LinalgOp op,
llvm::SetVector<Value *> subViews,
llvm::SetVector<ValuePtr> subViews,
bool dynamicBuffers = false,
OperationFolder *folder = nullptr);

Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/LoopOps/LoopOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void ensureLoopTerminator(Region &region, Builder &builder, Location loc);

/// Returns the loop parent of an induction variable. If the provided value is
/// not an induction variable, then return nullptr.
ForOp getForInductionVarOwner(Value *val);
ForOp getForInductionVarOwner(ValuePtr val);

} // end namespace loop
} // end namespace mlir
Expand Down
12 changes: 6 additions & 6 deletions mlir/include/mlir/Dialect/LoopOps/LoopOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,18 @@ def ForOp : Loop_Op<"for",
let skipDefaultBuilders = 1;
let builders = [
OpBuilder<"Builder *builder, OperationState &result, "
"Value *lowerBound, Value *upperBound, Value *step">
"ValuePtr lowerBound, ValuePtr upperBound, ValuePtr step">
];

let extraClassDeclaration = [{
Block *getBody() { return &region().front(); }
Value *getInductionVar() { return getBody()->getArgument(0); }
ValuePtr getInductionVar() { return getBody()->getArgument(0); }
OpBuilder getBodyBuilder() {
return OpBuilder(getBody(), std::prev(getBody()->end()));
}
void setLowerBound(Value *bound) { getOperation()->setOperand(0, bound); }
void setUpperBound(Value *bound) { getOperation()->setOperand(1, bound); }
void setStep(Value *step) { getOperation()->setOperand(2, step); }
void setLowerBound(ValuePtr bound) { getOperation()->setOperand(0, bound); }
void setUpperBound(ValuePtr bound) { getOperation()->setOperand(1, bound); }
void setStep(ValuePtr step) { getOperation()->setOperand(2, step); }
}];
}

Expand Down Expand Up @@ -116,7 +116,7 @@ def IfOp : Loop_Op<"if",
let skipDefaultBuilders = 1;
let builders = [
OpBuilder<"Builder *builder, OperationState &result, "
"Value *cond, bool withElseRegion">
"ValuePtr cond, bool withElseRegion">
];

let extraClassDeclaration = [{
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def SPV_CompositeExtractOp : SPV_Op<"CompositeExtract", [NoSideEffect]> {

let builders = [
OpBuilder<[{Builder *builder, OperationState &state,
Value *composite, ArrayRef<int32_t> indices}]>
ValuePtr composite, ArrayRef<int32_t> indices}]>
];

let hasFolder = 1;
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def SPV_BranchConditionalOp : SPV_Op<"BranchConditional",

let builders = [
OpBuilder<
"Builder *builder, OperationState &state, Value *condition, "
"Builder *builder, OperationState &state, ValuePtr condition, "
"Block *trueBlock, ValueRange trueArguments, "
"Block *falseBlock, ValueRange falseArguments, "
"Optional<std::pair<uint32_t, uint32_t>> weights = {}",
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,8 @@ def SPV_SelectOp : SPV_Op<"Select", [NoSideEffect]> {
);

let builders = [OpBuilder<[{Builder *builder, OperationState &state,
Value *cond, Value *trueValue,
Value *falseValue}]>];
ValuePtr cond, ValuePtr trueValue,
ValuePtr falseValue}]>];
}

// -----
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class SPIRVOpLowering : public OpConversionPattern<SourceOp> {
namespace spirv {
/// Returns a value that represents a builtin variable value within the SPIR-V
/// module.
Value *getBuiltinVariableValue(Operation *op, spirv::BuiltIn builtin,
OpBuilder &builder);
ValuePtr getBuiltinVariableValue(Operation *op, spirv::BuiltIn builtin,
OpBuilder &builder);

/// Attribute name for specifying argument ABI information.
StringRef getInterfaceVarABIAttrName();
Expand Down
6 changes: 3 additions & 3 deletions mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def SPV_AccessChainOp : SPV_Op<"AccessChain", [NoSideEffect]> {
);

let builders = [OpBuilder<[{Builder *builder, OperationState &state,
Value *basePtr, ValueRange indices}]>];
ValuePtr basePtr, ValueRange indices}]>];

let hasCanonicalizer = 1;
}
Expand Down Expand Up @@ -272,7 +272,7 @@ def SPV_LoadOp : SPV_Op<"Load", []> {
);

let builders = [OpBuilder<[{Builder *builder, OperationState &state,
Value *basePtr, /*optional*/IntegerAttr memory_access,
ValuePtr basePtr, /*optional*/IntegerAttr memory_access,
/*optional*/IntegerAttr alignment}]>];
}

Expand Down Expand Up @@ -367,7 +367,7 @@ def SPV_StoreOp : SPV_Op<"Store", []> {

let builders = [
OpBuilder<"Builder *builder, OperationState &state, "
"Value *ptr, Value *value, ArrayRef<NamedAttribute> namedAttrs", [{
"ValuePtr ptr, ValuePtr value, ArrayRef<NamedAttribute> namedAttrs", [{
state.addOperands(ptr);
state.addOperands(value);
state.addAttributes(namedAttrs);
Expand Down
35 changes: 18 additions & 17 deletions mlir/include/mlir/Dialect/StandardOps/Ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ class DmaStartOp
public:
using Op::Op;

static void build(Builder *builder, OperationState &result, Value *srcMemRef,
ValueRange srcIndices, Value *destMemRef,
ValueRange destIndices, Value *numElements,
Value *tagMemRef, ValueRange tagIndices,
Value *stride = nullptr,
Value *elementsPerStride = nullptr);
static void build(Builder *builder, OperationState &result,
ValuePtr srcMemRef, ValueRange srcIndices,
ValuePtr destMemRef, ValueRange destIndices,
ValuePtr numElements, ValuePtr tagMemRef,
ValueRange tagIndices, ValuePtr stride = nullptr,
ValuePtr elementsPerStride = nullptr);

// Returns the source MemRefType for this DMA operation.
Value *getSrcMemRef() { return getOperand(0); }
ValuePtr getSrcMemRef() { return getOperand(0); }
// Returns the rank (number of indices) of the source MemRefType.
unsigned getSrcMemRefRank() {
return getSrcMemRef()->getType().cast<MemRefType>().getRank();
Expand All @@ -202,7 +202,7 @@ class DmaStartOp
}

// Returns the destination MemRefType for this DMA operations.
Value *getDstMemRef() { return getOperand(1 + getSrcMemRefRank()); }
ValuePtr getDstMemRef() { return getOperand(1 + getSrcMemRefRank()); }
// Returns the rank (number of indices) of the destination MemRefType.
unsigned getDstMemRefRank() {
return getDstMemRef()->getType().cast<MemRefType>().getRank();
Expand All @@ -222,12 +222,12 @@ class DmaStartOp
}

// Returns the number of elements being transferred by this DMA operation.
Value *getNumElements() {
ValuePtr getNumElements() {
return getOperand(1 + getSrcMemRefRank() + 1 + getDstMemRefRank());
}

// Returns the Tag MemRef for this DMA operation.
Value *getTagMemRef() {
ValuePtr getTagMemRef() {
return getOperand(1 + getSrcMemRefRank() + 1 + getDstMemRefRank() + 1);
}
// Returns the rank (number of indices) of the tag MemRefType.
Expand Down Expand Up @@ -276,13 +276,13 @@ class DmaStartOp
1 + 1 + getTagMemRefRank();
}

Value *getStride() {
ValuePtr getStride() {
if (!isStrided())
return nullptr;
return getOperand(getNumOperands() - 1 - 1);
}

Value *getNumElementsPerStride() {
ValuePtr getNumElementsPerStride() {
if (!isStrided())
return nullptr;
return getOperand(getNumOperands() - 1);
Expand All @@ -307,13 +307,14 @@ class DmaWaitOp
public:
using Op::Op;

static void build(Builder *builder, OperationState &result, Value *tagMemRef,
ValueRange tagIndices, Value *numElements);
static void build(Builder *builder, OperationState &result,
ValuePtr tagMemRef, ValueRange tagIndices,
ValuePtr numElements);

static StringRef getOperationName() { return "std.dma_wait"; }

// Returns the Tag MemRef associated with the DMA operation being waited on.
Value *getTagMemRef() { return getOperand(0); }
ValuePtr getTagMemRef() { return getOperand(0); }

// Returns the tag memref index for this DMA operation.
operand_range getTagIndices() {
Expand All @@ -327,7 +328,7 @@ class DmaWaitOp
}

// Returns the number of elements transferred in the associated DMA operation.
Value *getNumElements() { return getOperand(1 + getTagMemRefRank()); }
ValuePtr getNumElements() { return getOperand(1 + getTagMemRefRank()); }

static ParseResult parse(OpAsmParser &parser, OperationState &result);
void print(OpAsmPrinter &p);
Expand All @@ -342,7 +343,7 @@ void printDimAndSymbolList(Operation::operand_iterator begin,

/// Parses dimension and symbol list and returns true if parsing failed.
ParseResult parseDimAndSymbolList(OpAsmParser &parser,
SmallVectorImpl<Value *> &operands,
SmallVectorImpl<ValuePtr> &operands,
unsigned &numDims);

raw_ostream &operator<<(raw_ostream &os, SubViewOp::Range &range);
Expand Down
78 changes: 39 additions & 39 deletions mlir/include/mlir/Dialect/StandardOps/Ops.td
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class CastOp<string mnemonic, list<OpTrait> traits = []> :
let results = (outs AnyType);

let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *source, Type destType", [{
"Builder *builder, OperationState &result, ValuePtr source, Type destType", [{
impl::buildCastOp(builder, result, source, destType);
}]>];

Expand Down Expand Up @@ -191,7 +191,7 @@ def AllocOp : Std_Op<"alloc"> {
}]>,
OpBuilder<
"Builder *builder, OperationState &result, MemRefType memrefType, " #
"ArrayRef<Value*> operands, IntegerAttr alignment = IntegerAttr()", [{
"ArrayRef<ValuePtr> operands, IntegerAttr alignment = IntegerAttr()", [{
result.addOperands(operands);
result.types.push_back(memrefType);
if (alignment)
Expand Down Expand Up @@ -330,15 +330,15 @@ def CallIndirectOp : Std_Op<"call_indirect", [CallOpInterface]> {
let results = (outs Variadic<AnyType>);

let builders = [OpBuilder<
"Builder *, OperationState &result, Value *callee,"
"Builder *, OperationState &result, ValuePtr callee,"
"ValueRange operands = {}", [{
result.operands.push_back(callee);
result.addOperands(operands);
result.addTypes(callee->getType().cast<FunctionType>().getResults());
}]>];

let extraClassDeclaration = [{
Value *getCallee() { return getOperand(0); }
ValuePtr getCallee() { return getOperand(0); }

/// Get the argument operands to the called function.
operand_range getArgOperands() {
Expand Down Expand Up @@ -395,7 +395,7 @@ def CmpFOp : Std_Op<"cmpf",

let builders = [OpBuilder<
"Builder *builder, OperationState &result, CmpFPredicate predicate,"
"Value *lhs, Value *rhs", [{
"ValuePtr lhs, ValuePtr rhs", [{
::buildCmpFOp(builder, result, predicate, lhs, rhs);
}]>];

Expand Down Expand Up @@ -463,7 +463,7 @@ def CmpIOp : Std_Op<"cmpi",

let builders = [OpBuilder<
"Builder *builder, OperationState &result, CmpIPredicate predicate,"
"Value *lhs, Value *rhs", [{
"ValuePtr lhs, ValuePtr rhs", [{
::buildCmpIOp(builder, result, predicate, lhs, rhs);
}]>];

Expand Down Expand Up @@ -502,7 +502,7 @@ def CondBranchOp : Std_Op<"cond_br", [Terminator]> {
let arguments = (ins I1:$condition, Variadic<AnyType>:$branchOperands);

let builders = [OpBuilder<
"Builder *, OperationState &result, Value *condition,"
"Builder *, OperationState &result, ValuePtr condition,"
"Block *trueDest, ValueRange trueOperands,"
"Block *falseDest, ValueRange falseOperands", [{
result.addOperands(condition);
Expand All @@ -518,7 +518,7 @@ def CondBranchOp : Std_Op<"cond_br", [Terminator]> {
enum { trueIndex = 0, falseIndex = 1 };

// The condition operand is the first operand in the list.
Value *getCondition() { return getOperand(0); }
ValuePtr getCondition() { return getOperand(0); }

/// Return the destination if the condition is true.
Block *getTrueDest() {
Expand All @@ -531,12 +531,12 @@ def CondBranchOp : Std_Op<"cond_br", [Terminator]> {
}

// Accessors for operands to the 'true' destination.
Value *getTrueOperand(unsigned idx) {
ValuePtr getTrueOperand(unsigned idx) {
assert(idx < getNumTrueOperands());
return getOperand(getTrueDestOperandIndex() + idx);
}

void setTrueOperand(unsigned idx, Value *value) {
void setTrueOperand(unsigned idx, ValuePtr value) {
assert(idx < getNumTrueOperands());
setOperand(getTrueDestOperandIndex() + idx, value);
}
Expand All @@ -561,11 +561,11 @@ def CondBranchOp : Std_Op<"cond_br", [Terminator]> {
}

// Accessors for operands to the 'false' destination.
Value *getFalseOperand(unsigned idx) {
ValuePtr getFalseOperand(unsigned idx) {
assert(idx < getNumFalseOperands());
return getOperand(getFalseDestOperandIndex() + idx);
}
void setFalseOperand(unsigned idx, Value *value) {
void setFalseOperand(unsigned idx, ValuePtr value) {
assert(idx < getNumFalseOperands());
setOperand(getFalseDestOperandIndex() + idx, value);
}
Expand Down Expand Up @@ -678,7 +678,7 @@ def DimOp : Std_Op<"dim", [NoSideEffect]> {
let results = (outs Index);

let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *memrefOrTensor,"
"Builder *builder, OperationState &result, ValuePtr memrefOrTensor,"
"unsigned index", [{
auto indexType = builder->getIndexType();
auto indexAttr = builder->getIntegerAttr(indexType, index);
Expand Down Expand Up @@ -730,15 +730,15 @@ def ExtractElementOp : Std_Op<"extract_element", [NoSideEffect]> {
let results = (outs AnyType);

let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *aggregate,"
"Builder *builder, OperationState &result, ValuePtr aggregate,"
"ValueRange indices = {}", [{
auto resType = aggregate->getType().cast<ShapedType>()
.getElementType();
build(builder, result, resType, aggregate, indices);
}]>];

let extraClassDeclaration = [{
Value *getAggregate() { return getOperand(0); }
ValuePtr getAggregate() { return getOperand(0); }

operand_range getIndices() {
return {operand_begin() + 1, operand_end()};
Expand Down Expand Up @@ -816,7 +816,7 @@ def LoadOp : Std_Op<"load"> {
let results = (outs AnyType);

let builders = [OpBuilder<
"Builder *, OperationState &result, Value *memref,"
"Builder *, OperationState &result, ValuePtr memref,"
"ValueRange indices = {}", [{
auto memrefType = memref->getType().cast<MemRefType>();
result.addOperands(memref);
Expand All @@ -825,8 +825,8 @@ def LoadOp : Std_Op<"load"> {
}]>];

let extraClassDeclaration = [{
Value *getMemRef() { return getOperand(0); }
void setMemRef(Value *value) { setOperand(0, value); }
ValuePtr getMemRef() { return getOperand(0); }
void setMemRef(ValuePtr value) { setOperand(0, value); }
MemRefType getMemRefType() {
return getMemRef()->getType().cast<MemRefType>();
}
Expand Down Expand Up @@ -952,8 +952,8 @@ def PrefetchOp : Std_Op<"prefetch"> {
BoolAttr:$isDataCache);

let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *memref,"
"ArrayRef<Value *> indices, bool isWrite, unsigned hint, bool isData",
"Builder *builder, OperationState &result, ValuePtr memref,"
"ArrayRef<ValuePtr> indices, bool isWrite, unsigned hint, bool isData",
[{
auto hintAttr = builder->getI32IntegerAttr(hint);
auto isWriteAttr = builder->getBoolAttr(isWrite);
Expand Down Expand Up @@ -990,7 +990,7 @@ def RankOp : Std_Op<"rank", [NoSideEffect]> {
let verifier = ?;

let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *tensor", [{
"Builder *builder, OperationState &result, ValuePtr tensor", [{
auto indexType = builder->getIndexType();
build(builder, result, indexType, tensor);
}]>];
Expand Down Expand Up @@ -1052,16 +1052,16 @@ def SelectOp : Std_Op<"select", [NoSideEffect, SameOperandsAndResultShape]> {
let results = (outs AnyType);

let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *condition,"
"Value *trueValue, Value *falseValue", [{
"Builder *builder, OperationState &result, ValuePtr condition,"
"ValuePtr trueValue, ValuePtr falseValue", [{
result.addOperands({condition, trueValue, falseValue});
result.addTypes(trueValue->getType());
}]>];

let extraClassDeclaration = [{
Value *getCondition() { return condition(); }
Value *getTrueValue() { return true_value(); }
Value *getFalseValue() { return false_value(); }
ValuePtr getCondition() { return condition(); }
ValuePtr getTrueValue() { return true_value(); }
ValuePtr getFalseValue() { return false_value(); }
}];

let hasFolder = 1;
Expand Down Expand Up @@ -1089,7 +1089,7 @@ def SignExtendIOp : Std_Op<"sexti",
let results = (outs IntegerLike);

let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *value, Type destType", [{
"Builder *builder, OperationState &result, ValuePtr value, Type destType", [{
result.addOperands(value);
result.addTypes(destType);
}]>];
Expand Down Expand Up @@ -1189,7 +1189,7 @@ def SplatOp : Std_Op<"splat", [NoSideEffect]> {
let results = (outs AnyTypeOf<[AnyVector, AnyStaticShapeTensor]>:$aggregate);

let builders =
[OpBuilder<"Builder *builder, OperationState &result, Value *element, "
[OpBuilder<"Builder *builder, OperationState &result, ValuePtr element, "
"Type aggregateType",
[{ build(builder, result, aggregateType, element); }]>];

Expand All @@ -1213,16 +1213,16 @@ def StoreOp : Std_Op<"store"> {
Variadic<Index>:$indices);

let builders = [OpBuilder<
"Builder *, OperationState &result, Value *valueToStore, Value *memref", [{
"Builder *, OperationState &result, ValuePtr valueToStore, ValuePtr memref", [{
result.addOperands(valueToStore);
result.addOperands(memref);
}]>];

let extraClassDeclaration = [{
Value *getValueToStore() { return getOperand(0); }
ValuePtr getValueToStore() { return getOperand(0); }

Value *getMemRef() { return getOperand(1); }
void setMemRef(Value *value) { setOperand(1, value); }
ValuePtr getMemRef() { return getOperand(1); }
void setMemRef(ValuePtr value) { setOperand(1, value); }
MemRefType getMemRefType() {
return getMemRef()->getType().cast<MemRefType>();
}
Expand Down Expand Up @@ -1364,13 +1364,13 @@ def SubViewOp : Std_Op<"subview", [AttrSizedOperandSegments, NoSideEffect]> {

let builders = [
OpBuilder<
"Builder *b, OperationState &result, Value *source, "
"Builder *b, OperationState &result, ValuePtr source, "
"ValueRange offsets, ValueRange sizes, "
"ValueRange strides, Type resultType = Type(), "
"ArrayRef<NamedAttribute> attrs = {}">,
OpBuilder<
"Builder *builder, OperationState &result, "
"Type resultType, Value *source">
"Type resultType, ValuePtr source">
];

let extraClassDeclaration = [{
Expand Down Expand Up @@ -1403,7 +1403,7 @@ def SubViewOp : Std_Op<"subview", [AttrSizedOperandSegments, NoSideEffect]> {
// offset, size and stride operands of the SubViewOp into a list of triples.
// Such a list of triple is sometimes more convenient to manipulate.
struct Range {
Value *offset, *size, *stride;
ValuePtr offset, size, stride;
};
SmallVector<Range, 8> getRanges();
}];
Expand Down Expand Up @@ -1465,7 +1465,7 @@ def TensorLoadOp : Std_Op<"tensor_load",
let verifier = ?;

let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *memref", [{
"Builder *builder, OperationState &result, ValuePtr memref", [{
auto memrefType = memref->getType().cast<MemRefType>();
auto resultType = RankedTensorType::get(memrefType.getShape(),
memrefType.getElementType());
Expand Down Expand Up @@ -1519,7 +1519,7 @@ def TruncateIOp : Std_Op<"trunci", [NoSideEffect, SameOperandsAndResultShape]> {
let results = (outs IntegerLike);

let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *value, Type destType", [{
"Builder *builder, OperationState &result, ValuePtr value, Type destType", [{
result.addOperands(value);
result.addTypes(destType);
}]>];
Expand Down Expand Up @@ -1578,7 +1578,7 @@ def ViewOp : Std_Op<"view", [NoSideEffect]> {

/// Returns the dynamic offset for this view operation if specified.
/// Returns nullptr if no dynamic offset was specified.
Value *getDynamicOffset();
ValuePtr getDynamicOffset();

/// Returns the starting operand list position of the dynamic size operands.
unsigned getDynamicSizesOperandStart() {
Expand Down Expand Up @@ -1619,7 +1619,7 @@ def ZeroExtendIOp : Std_Op<"zexti", [NoSideEffect, SameOperandsAndResultShape]>
let results = (outs IntegerLike);

let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *value, Type destType", [{
"Builder *builder, OperationState &result, ValuePtr value, Type destType", [{
result.addOperands(value);
result.addTypes(destType);
}]>];
Expand Down
5 changes: 4 additions & 1 deletion mlir/include/mlir/Dialect/VectorOps/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class Operation;
class Value;
class VectorType;

// TODO(riverriddle) Remove this after Value is value-typed.
using ValuePtr = Value *;

/// Computes and returns the multi-dimensional ratio of `superShape` to
/// `subShape`. This is calculated by performing a traversal from minor to major
/// dimensions (i.e. in reverse shape order). If integral division is not
Expand Down Expand Up @@ -122,7 +125,7 @@ Optional<SmallVector<int64_t, 4>> shapeRatio(VectorType superVectorType,
/// `%arg0[%c0, %c0]` into vector<128xf32> which needs a 1-D vector broadcast.
///
AffineMap
makePermutationMap(Operation *op, ArrayRef<Value *> indices,
makePermutationMap(Operation *op, ArrayRef<ValuePtr> indices,
const DenseMap<Operation *, unsigned> &loopToVectorDim);

namespace matcher {
Expand Down
22 changes: 12 additions & 10 deletions mlir/include/mlir/Dialect/VectorOps/VectorOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def Vector_ContractionOp :
: vector<7x8x16x15xf32>, vector<8x16x7x5xf32> into vector<8x15x8x5xf32>
}];
let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *lhs, Value *rhs, "
"Value *acc, ArrayAttr indexingMaps, ArrayAttr iteratorTypes">];
"Builder *builder, OperationState &result, ValuePtr lhs, ValuePtr rhs, "
"ValuePtr acc, ArrayAttr indexingMaps, ArrayAttr iteratorTypes">];
let extraClassDeclaration = [{
VectorType getLhsType() {
return lhs()->getType().cast<VectorType>();
Expand Down Expand Up @@ -252,7 +252,8 @@ def Vector_ShuffleOp :

```
}];
let builders = [OpBuilder<"Builder *builder, OperationState &result, Value *v1, Value *v2, ArrayRef<int64_t>">];
let builders = [OpBuilder<"Builder *builder, OperationState &result,"
"ValuePtr v1, ValuePtr v2, ArrayRef<int64_t>">];
let extraClassDeclaration = [{
static StringRef getMaskAttrName() { return "mask"; }
VectorType getV1VectorType() {
Expand Down Expand Up @@ -312,7 +313,8 @@ def Vector_ExtractOp :
```
}];
let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *source, ArrayRef<int64_t>">];
"Builder *builder, OperationState &result, ValuePtr source,"
"ArrayRef<int64_t>">];
let extraClassDeclaration = [{
static StringRef getPositionAttrName() { return "position"; }
VectorType getVectorType() {
Expand Down Expand Up @@ -357,7 +359,7 @@ def Vector_ExtractSlicesOp :
}];
let builders = [OpBuilder<
"Builder *builder, OperationState &result, TupleType tupleType, " #
"Value *vector, ArrayRef<int64_t> sizes, " #
"ValuePtr vector, ArrayRef<int64_t> sizes, " #
"ArrayRef<int64_t> strides">];
let extraClassDeclaration = [{
VectorType getSourceVectorType() {
Expand Down Expand Up @@ -428,8 +430,8 @@ def Vector_InsertOp :
```
}];
let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *source, " #
"Value *dest, ArrayRef<int64_t>">];
"Builder *builder, OperationState &result, ValuePtr source, " #
"ValuePtr dest, ArrayRef<int64_t>">];
let extraClassDeclaration = [{
static StringRef getPositionAttrName() { return "position"; }
Type getSourceType() { return source()->getType(); }
Expand Down Expand Up @@ -521,7 +523,7 @@ def Vector_InsertStridedSliceOp :
```
}];
let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *source, Value *dest, " #
"Builder *builder, OperationState &result, ValuePtr source, ValuePtr dest, " #
"ArrayRef<int64_t> offsets, ArrayRef<int64_t> strides">];
let extraClassDeclaration = [{
static StringRef getOffsetsAttrName() { return "offsets"; }
Expand Down Expand Up @@ -723,7 +725,7 @@ def Vector_StridedSliceOp :
vector<4x8x16xf32> to vector<2x4x16xf32>
}];
let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *source, " #
"Builder *builder, OperationState &result, ValuePtr source, " #
"ArrayRef<int64_t> offsets, ArrayRef<int64_t> sizes, " #
"ArrayRef<int64_t> strides">];
let extraClassDeclaration = [{
Expand Down Expand Up @@ -975,7 +977,7 @@ def Vector_TypeCastOp :
}];

let builders = [OpBuilder<
"Builder *builder, OperationState &result, Value *source">];
"Builder *builder, OperationState &result, ValuePtr source">];

let parser = [{
return impl::parseCastOp(parser, result);
Expand Down
5 changes: 3 additions & 2 deletions mlir/include/mlir/Dialect/VectorOps/VectorTransforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ namespace vector {
//
// This will be extended in the future to support more advanced use cases than
// simple pointwise ops.
Value *unrollSingleResultOpMatchingType(PatternRewriter &builder, Operation *op,
ArrayRef<int64_t> targetShape);
ValuePtr unrollSingleResultOpMatchingType(PatternRewriter &builder,
Operation *op,
ArrayRef<int64_t> targetShape);

} // namespace vector
} // namespace mlir
Expand Down
Loading