14 #ifndef MLIR_EDSC_BUILDERS_H_ 15 #define MLIR_EDSC_BUILDERS_H_ 29 explicit operator int64_t() {
return v; }
99 other.bodyScope =
nullptr;
104 std::swap(bodyScope, other.bodyScope);
120 bodyScope->nestedBuilder =
this;
127 bodyScope->nestedBuilder =
nullptr;
137 "Illegal use of NestedBuilder; must have called exit()");
172 void operator()(
function_ref<
void(
void)> fun =
nullptr);
211 void operator()(
function_ref<
void(
void)> fun =
nullptr);
224 void operator()(std::function<
void(
void)> fun =
nullptr);
257 void operator()(
function_ref<
void(
void)> fun =
nullptr);
326 std::swap(t, other.
t);
327 std::swap(
v, other.
v);
331 operator Value()
const {
return getValue(); }
332 operator bool()
const {
return hasValue(); }
336 template <
typename Op,
typename... Args>
344 template <
typename Op,
typename... Args>
359 assert(hasValue() &&
"Unexpected null value;");
368 return v->getDefiningOp();
394 template <
typename Op,
typename... Args>
396 template <
typename Op,
typename... Args>
static Op createOp(Args... args);
413 static_assert(std::is_same<HandleType, ValueHandle>() ||
414 std::is_same<HandleType, OperationHandle>(),
415 "Only CustomOperation<ValueHandle> or " 416 "CustomOperation<OperationHandle> can be constructed.");
421 return HandleType::create(name, operands, resultTypes, attributes);
453 operator bool() {
return block !=
nullptr; }
461 template <
typename Op,
typename... Args>
468 template <
typename Op,
typename... Args>
477 template <
typename Op,
typename... Args>
485 if (
auto f = dyn_cast<AffineForOp>(op)) {
489 llvm_unreachable(
"unsupported operation, use an OperationHandle instead");
492 template <
typename Op,
typename... Args>
526 template <
typename Container>
529 res.reserve(values.size());
530 for (
auto v : values)
538 #endif // MLIR_EDSC_BUILDERS_H_ Definition: InferTypeOpInterface.cpp:20
BlockHandle()
Definition: Builders.h:437
Definition: Builders.h:201
Definition: Operation.h:27
~NestedBuilder()
Definition: Builders.h:135
void create(OpBuilder &builder, SmallVectorImpl< Value > &results, Location location, Args &&... args)
Definition: FoldUtils.h:76
Definition: Attributes.h:139
Value getValue() const
Definition: Builders.h:358
ValueHandle operator%(ValueHandle lhs, ValueHandle rhs)
Definition: Builders.cpp:390
Block represents an ordered list of Operations.
Definition: Block.h:21
Definition: Builders.h:431
ValueHandle operator>=(ValueHandle lhs, ValueHandle rhs)
Definition: Builders.cpp:482
static OperationHandle create(Args... args)
Definition: Builders.h:462
Definition: Builders.h:290
ValueHandle(Type t)
Definition: Builders.h:300
ValueHandle operator^(ValueHandle lhs, ValueHandle rhs)
Operation * getOperation() const
Definition: Builders.h:404
bool operator!=(IntInfty lhs, IntInfty rhs)
Definition: SDBM.h:94
IntInfty operator+(IntInfty lhs, IntInfty rhs)
Definition: SDBM.h:57
CustomOperation(StringRef name)
Definition: Builders.h:412
static ValueHandle null()
A ValueHandle in a null state can never be captured;.
Definition: Builders.h:293
ValueHandle operator!(ValueHandle value)
Definition: Builders.cpp:405
ValueHandle operator &&(ValueHandle lhs, ValueHandle rhs)
Simple wrapper to build a generic operation without successor blocks.
Definition: Builders.h:411
ValueHandle()
Definition: Builders.h:372
ValueHandle(Value v)
Definition: Builders.h:306
int64_t v
Definition: Builders.h:30
static ValueHandle create(Args... args)
Definition: Builders.h:478
Type getType() const
Definition: Builders.h:363
Definition: Location.h:52
index_t(int64_t v)
Definition: Builders.h:28
unsigned getNumResults()
Return the number of results held by this operation.
Definition: Operation.cpp:548
OperationHandle(Operation *op)
Definition: Builders.h:387
int64_t floorDiv(int64_t lhs, int64_t rhs)
Definition: MathExtras.h:31
OpTy create(Location location, Args &&... args)
Create an operation of specific op type at the current insertion point.
Definition: Builders.h:294
OperationHandle()
Definition: Builders.h:386
Definition: Builders.h:220
NestedBuilder & operator=(NestedBuilder &&other)
Definition: Builders.h:103
iterator end()
Definition: Block.h:111
int64_t ceilDiv(int64_t lhs, int64_t rhs)
Definition: MathExtras.h:23
auto map(Fn fun, IterType begin, IterType end) -> SmallVector< typename std::result_of< Fn(decltype(*begin))>::type, 8 >
Map with iterators.
Definition: Functional.h:28
bool hasType() const
Definition: Builders.h:362
Definition: Builders.h:94
ValueHandle operator/(ValueHandle lhs, ValueHandle rhs)
Definition: Builders.cpp:383
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
Definition: Operation.h:246
Definition: Builders.h:27
ValueHandle operator>(ValueHandle lhs, ValueHandle rhs)
Definition: Builders.cpp:476
bool hasValue() const
Definition: Builders.h:357
static Op createOp(Args... args)
Definition: Builders.h:469
Definition: AffineMap.h:37
void exit()
Definition: Builders.h:125
Definition: Builders.h:232
std::string name
Definition: Builders.h:423
Definition: Builders.h:150
bool operator==(IntInfty lhs, IntInfty rhs)
Definition: SDBM.h:90
Definition: Builders.h:385
bool operator<(IntInfty lhs, IntInfty rhs)
Definition: SDBM.h:82
Definition: Builders.h:266
Definition: FoldUtils.h:50
ValueHandle operator||(ValueHandle lhs, ValueHandle rhs)
Definition: Builders.cpp:416
Value v
Definition: Builders.h:375
static Location getLocation()
Definition: Builders.cpp:58
NestedPattern Op(FilterFunctionType filter)
Definition: NestedMatcher.cpp:111
Definition: Builders.h:43
Type t
Definition: Builders.h:374
This class represents a saved insertion point.
Definition: Builders.h:186
Definition: MLIRContext.h:34
void swap(ValueHandle &other)
Provide a swap operator.
Definition: Builders.h:323
Operation * getOperation() const
Definition: Builders.h:365
AffineExpr operator-(int64_t val, AffineExpr expr)
Definition: AffineExpr.h:207
Definition: OpDefinition.h:949
static OpBuilder & getBuilder()
Definition: Builders.cpp:52
void enter(mlir::Block *block, int prev=0)
Definition: Builders.h:115
Definition: Builders.h:239
AffineExpr operator*(int64_t val, AffineExpr expr)
Definition: AffineExpr.h:206
BlockHandle(mlir::Block *block)
Definition: Builders.h:443
Definition: Builders.h:158
NestedBuilder(NestedBuilder &&other)
Definition: Builders.h:98
bool operator<=(IntInfty lhs, IntInfty rhs)
Definition: SDBM.h:86
HandleType operator()(ArrayRef< ValueHandle > operands={}, ArrayRef< Type > resultTypes={}, ArrayRef< NamedAttribute > attributes={})
Definition: Builders.h:418
mlir::Block * getBlock()
Definition: Builders.h:455
SmallVector< ValueHandle, 8 > makeValueHandles(Container values)
Definition: Builders.h:527