9 #ifndef MLIR_TOOLS_PDLL_AST_NODES_H_
10 #define MLIR_TOOLS_PDLL_AST_NODES_H_
14 #include "llvm/ADT/StringMap.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/Support/SMLoc.h"
17 #include "llvm/Support/SourceMgr.h"
18 #include "llvm/Support/TrailingObjects.h"
27 class NamedAttributeDecl;
41 StringRef
getName()
const {
return name; }
44 SMRange
getLoc()
const {
return location; }
49 Name &operator=(
const Name &) =
delete;
50 Name(StringRef name, SMRange location) : name(name), location(location) {}
74 auto getDecls()
const {
return llvm::make_second_range(decls); }
84 return dyn_cast_or_null<T>(
lookup(name));
90 const T *
lookup(StringRef name)
const {
91 return dyn_cast_or_null<T>(
lookup(name));
98 llvm::StringMap<Decl *> decls;
111 template <
typename T,
typename BaseT>
118 return node->
getTypeID() == TypeID::get<T>();
122 template <
typename... Args>
134 void print(raw_ostream &os)
const;
138 template <
typename WalkFnT,
typename ArgT =
typename llvm::function_traits<
139 WalkFnT>::template arg_t<0>>
140 std::enable_if_t<!std::is_convertible<const Node *, ArgT>::value>
143 if (
const ArgT *derivedNode = dyn_cast<ArgT>(node))
149 Node(
TypeID typeID, SMRange loc) : typeID(typeID), loc(loc) {}
179 private llvm::TrailingObjects<CompoundStmt, Stmt *> {
186 return {getTrailingObjects<Stmt *>(), numChildren};
196 :
Base(location), numChildren(numChildren) {}
199 unsigned numChildren;
211 class LetStmt final :
public Node::NodeBase<LetStmt, Stmt> {
222 VariableDecl *varDecl;
255 class EraseStmt final :
public Node::NodeBase<EraseStmt, OpRewriteStmt> {
270 class ReplaceStmt final :
public Node::NodeBase<ReplaceStmt, OpRewriteStmt>,
271 private llvm::TrailingObjects<ReplaceStmt, Expr *> {
278 return {getTrailingObjects<Expr *>(), numReplExprs};
286 :
Base(loc, rootOp), numReplExprs(numReplExprs) {}
289 unsigned numReplExprs;
302 class RewriteStmt final :
public Node::NodeBase<RewriteStmt, OpRewriteStmt> {
312 :
Base(loc, rootOp), rewriteBody(rewriteBody) {}
315 CompoundStmt *rewriteBody;
324 class ReturnStmt final :
public Node::NodeBase<ReturnStmt, Stmt> {
337 :
Base(loc), resultExpr(resultExpr) {}
392 class CallExpr final :
public Node::NodeBase<CallExpr, Expr>,
393 private llvm::TrailingObjects<CallExpr, Expr *> {
397 bool isNegated =
false);
404 return {getTrailingObjects<Expr *>(), numArgs};
416 :
Base(loc, type), callable(callable), numArgs(numArgs),
417 isNegated(isNegated) {}
426 friend llvm::TrailingObjects<CallExpr, Expr *>;
446 :
Base(loc, type), decl(decl) {}
461 const Expr *parentExpr, StringRef memberName,
473 :
Base(loc, type), parentExpr(parentExpr), memberName(memberName) {}
476 const Expr *parentExpr;
479 StringRef memberName;
494 const Expr *parentExpr,
Type type) {
495 return cast<AllResultsMemberAccessExpr>(
514 :
public Node::NodeBase<OperationExpr, Expr>,
515 private llvm::TrailingObjects<OperationExpr, Expr *,
516 NamedAttributeDecl *> {
526 std::optional<StringRef>
getName()
const;
537 return {getTrailingObjects<Expr *>(), numOperands};
545 return {getTrailingObjects<Expr *>() + numOperands, numResultTypes};
553 return {getTrailingObjects<NamedAttributeDecl *>(), numAttributes};
561 unsigned numOperands,
unsigned numResultTypes,
562 unsigned numAttributes, SMRange nameLoc)
563 :
Base(loc, type), nameDecl(nameDecl), numOperands(numOperands),
564 numResultTypes(numResultTypes), numAttributes(numAttributes),
568 const OpNameDecl *nameDecl;
571 unsigned numOperands, numResultTypes, numAttributes;
577 friend llvm::TrailingObjects<OperationExpr, Expr *, NamedAttributeDecl *>;
578 size_t numTrailingObjects(OverloadToken<Expr *>)
const {
579 return numOperands + numResultTypes;
589 class RangeExpr final :
public Node::NodeBase<RangeExpr, Expr>,
590 private llvm::TrailingObjects<RangeExpr, Expr *> {
597 return {getTrailingObjects<Expr *>(), numElements};
608 :
Base(loc, type), numElements(numElements) {}
611 unsigned numElements;
622 class TupleExpr final :
public Node::NodeBase<TupleExpr, Expr>,
623 private llvm::TrailingObjects<TupleExpr, Expr *> {
630 return {getTrailingObjects<Expr *>(),
getType().
size()};
652 class TypeExpr :
public Node::NodeBase<TypeExpr, Expr> {
690 :
Node(typeID, loc), name(name) {}
699 std::optional<StringRef> docComment;
715 :
Decl(typeID, loc, name) {}
754 :
public Node::NodeBase<AttrConstraintDecl, CoreConstraintDecl> {
778 :
public Node::NodeBase<OpConstraintDecl, CoreConstraintDecl> {
784 std::optional<StringRef>
getName()
const;
804 :
public Node::NodeBase<TypeConstraintDecl, CoreConstraintDecl> {
819 :
public Node::NodeBase<TypeRangeConstraintDecl, CoreConstraintDecl> {
834 :
public Node::NodeBase<ValueConstraintDecl, CoreConstraintDecl> {
857 :
public Node::NodeBase<ValueRangeConstraintDecl, CoreConstraintDecl> {
891 :
public Node::NodeBase<UserConstraintDecl, ConstraintDecl>,
892 llvm::TrailingObjects<UserConstraintDecl, VariableDecl *, StringRef> {
898 std::optional<StringRef> codeBlock,
Type resultType,
900 return createImpl(ctx, name, inputs, nativeInputTypes, results, codeBlock,
901 nullptr, resultType);
910 return createImpl(ctx, name, inputs, std::nullopt,
911 results, std::nullopt, body, resultType);
919 return {getTrailingObjects<VariableDecl *>(), numInputs};
932 return {getTrailingObjects<VariableDecl *>() + numInputs, numResults};
950 bool isExternal()
const {
return !constraintBody && !codeBlock; }
959 std::optional<StringRef> codeBlock,
964 bool hasNativeInputTypes,
unsigned numResults,
965 std::optional<StringRef> codeBlock,
967 :
Base(name.getLoc(), &name), numInputs(numInputs),
968 numResults(numResults), codeBlock(codeBlock), constraintBody(body),
969 resultType(resultType), hasNativeInputTypes(hasNativeInputTypes) {}
978 std::optional<StringRef> codeBlock;
981 const CompoundStmt *constraintBody;
987 bool hasNativeInputTypes;
990 friend llvm::TrailingObjects<UserConstraintDecl, VariableDecl *, StringRef>;
991 size_t numTrailingObjects(OverloadToken<VariableDecl *>)
const {
992 return numInputs + numResults;
1015 :
Base(name.getLoc(), &name), value(value) {}
1034 return name ? std::optional<StringRef>(name->
getName()) : std::nullopt;
1039 explicit OpNameDecl(SMRange loc) :
Base(loc) {}
1050 std::optional<uint16_t> benefit,
1051 bool hasBoundedRecursion,
1065 return cast<OpRewriteStmt>(patternBody->
getChildren().back());
1069 PatternDecl(SMRange loc,
const Name *name, std::optional<uint16_t> benefit,
1071 :
Base(loc, name), benefit(benefit),
1072 hasBoundedRecursion(hasBoundedRecursion), patternBody(body) {}
1076 std::optional<uint16_t> benefit;
1079 bool hasBoundedRecursion;
1082 const CompoundStmt *patternBody;
1101 :
public Node::NodeBase<UserRewriteDecl, Decl>,
1102 llvm::TrailingObjects<UserRewriteDecl, VariableDecl *> {
1108 std::optional<StringRef> codeBlock,
1110 return createImpl(ctx, name, inputs, results, codeBlock,
nullptr,
1120 return createImpl(ctx, name, inputs, results, std::nullopt,
1129 return {getTrailingObjects<VariableDecl *>(), numInputs};
1138 return {getTrailingObjects<VariableDecl *>() + numInputs, numResults};
1164 std::optional<StringRef> codeBlock,
1168 std::optional<StringRef> codeBlock,
const CompoundStmt *body,
1170 :
Base(name.getLoc(), &name), numInputs(numInputs),
1171 numResults(numResults), codeBlock(codeBlock), rewriteBody(body),
1172 resultType(resultType) {}
1178 unsigned numResults;
1181 std::optional<StringRef> codeBlock;
1184 const CompoundStmt *rewriteBody;
1190 friend llvm::TrailingObjects<UserRewriteDecl, VariableDecl *>;
1202 if (isa<UserConstraintDecl>(
this))
1203 return "constraint";
1204 assert(isa<UserRewriteDecl>(
this) &&
"unknown callable type");
1210 if (
const auto *cst = dyn_cast<UserConstraintDecl>(
this))
1211 return cst->getInputs();
1212 return cast<UserRewriteDecl>(
this)->getInputs();
1217 if (
const auto *cst = dyn_cast<UserConstraintDecl>(
this))
1218 return cst->getResultType();
1219 return cast<UserRewriteDecl>(
this)->getResultType();
1226 if (
const auto *cst = dyn_cast<UserConstraintDecl>(
this))
1227 return cst->getResults();
1228 return cast<UserRewriteDecl>(
this)->getResults();
1234 if (
const auto *cst = dyn_cast<UserConstraintDecl>(
this))
1235 return cst->getCodeBlock();
1236 return cast<UserRewriteDecl>(
this)->getCodeBlock();
1241 return isa<UserConstraintDecl, UserRewriteDecl>(decl);
1251 :
public Node::NodeBase<VariableDecl, Decl>,
1252 private llvm::TrailingObjects<VariableDecl, ConstraintRef> {
1260 return {getTrailingObjects<ConstraintRef>(), numConstraints};
1278 unsigned numConstraints)
1279 :
Base(name.getLoc(), &name), type(type), initExpr(initExpr),
1280 numConstraints(numConstraints) {}
1289 unsigned numConstraints;
1292 friend llvm::TrailingObjects<VariableDecl, ConstraintRef>;
1300 class Module final :
public Node::NodeBase<Module, Node>,
1301 private llvm::TrailingObjects<Module, Decl *> {
1307 return {getTrailingObjects<Decl *>(), numChildren};
1314 Module(SMLoc loc,
unsigned numChildren)
1315 :
Base(SMRange{loc, loc}), numChildren(numChildren) {}
1318 unsigned numChildren;
1321 friend llvm::TrailingObjects<Module, Decl *>;
1334 return isa<CoreConstraintDecl, UserConstraintDecl>(node);
1349 return isa<EraseStmt, ReplaceStmt, RewriteStmt>(node);
1353 return isa<CompoundStmt, LetStmt, OpRewriteStmt, Expr>(node);
This class provides an efficient unique identifier for a specific C++ type.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class represents an instance of MemberAccessExpr that references all results of an operation.
static StringRef getMemberName()
Return the member name used for the "all-results" access.
static AllResultsMemberAccessExpr * create(Context &ctx, SMRange loc, const Expr *parentExpr, Type type)
static bool classof(const Node *node)
Provide type casting support.
The class represents an Attribute constraint, and constrains a variable to be an Attribute.
Expr * typeExpr
An optional type that the attribute is constrained to.
static AttrConstraintDecl * create(Context &ctx, SMRange loc, Expr *typeExpr=nullptr)
Expr * getTypeExpr()
Return the optional type the attribute is constrained to.
const Expr * getTypeExpr() const
AttrConstraintDecl(SMRange loc, Expr *typeExpr)
This expression represents a literal MLIR Attribute, and contains the textual assembly format of that...
static AttributeExpr * create(Context &ctx, SMRange loc, StringRef value)
StringRef getValue() const
Get the raw value of this expression.
This class represents a PDLL type that corresponds to an mlir::Attribute.
This expression represents a call to a decl, such as a UserConstraintDecl/UserRewriteDecl.
Expr * getCallableExpr() const
Return the callable of this call.
MutableArrayRef< Expr * > getArguments()
Return the arguments of this call.
ArrayRef< Expr * > getArguments() const
static CallExpr * create(Context &ctx, SMRange loc, Expr *callable, ArrayRef< Expr * > arguments, Type resultType, bool isNegated=false)
bool getIsNegated() const
Returns whether the result of this call is to be negated.
This decl represents a shared interface for all callable decls.
std::optional< StringRef > getCodeBlock() const
Return the optional code block of this callable, if this is a native callable with a provided impleme...
Type getResultType() const
Return the result type of this decl.
ArrayRef< VariableDecl * > getInputs() const
Return the inputs of this decl.
StringRef getCallableType() const
Return the callable type of this decl.
ArrayRef< VariableDecl * > getResults() const
Return the explicit results of the declaration.
static bool classof(const Node *decl)
Support LLVM type casting facilities.
This statement represents a compound statement, which contains a collection of other statements.
ArrayRef< Stmt * > getChildren() const
ArrayRef< Stmt * >::iterator begin() const
MutableArrayRef< Stmt * > getChildren()
Return the children of this compound statement.
ArrayRef< Stmt * >::iterator end() const
static CompoundStmt * create(Context &ctx, SMRange location, ArrayRef< Stmt * > children)
This class represents the base of all AST Constraint decls.
static bool classof(const Node *node)
Provide type casting support.
ConstraintDecl(TypeID typeID, SMRange loc, const Name *name=nullptr)
This class represents the main context of the PDLL AST.
This class represents the base of all "core" constraints.
static bool classof(const Node *node)
Provide type casting support.
CoreConstraintDecl(TypeID typeID, SMRange loc, const Name *name=nullptr)
This expression represents a reference to a Decl node.
static DeclRefExpr * create(Context &ctx, SMRange loc, Decl *decl, Type type)
Decl * getDecl() const
Get the decl referenced by this expression.
This class represents a scope for named AST decls.
auto getDecls() const
Return all of the decls within this scope.
const Decl * lookup(StringRef name) const
const DeclScope * getParentScope() const
DeclScope * getParentScope()
Return the parent scope of this scope, or nullptr if there is no parent.
T * lookup(StringRef name)
Decl * lookup(StringRef name)
Lookup a decl with the given name starting from this scope.
void add(Decl *decl)
Add a new decl to the scope.
DeclScope(DeclScope *parent=nullptr)
Create a new scope with an optional parent scope.
const T * lookup(StringRef name) const
This class represents the base Decl node.
std::optional< StringRef > getDocComment() const
Return the documentation comment attached to this decl if it has been set.
const Name * getName() const
Return the name of the decl, or nullptr if it doesn't have one.
Decl(TypeID typeID, SMRange loc, const Name *name=nullptr)
static bool classof(const Node *node)
Provide type casting support.
void setDocComment(Context &ctx, StringRef comment)
Set the documentation comment for this decl.
This statement represents the erase statement in PDLL.
static EraseStmt * create(Context &ctx, SMRange loc, Expr *rootOp)
This class represents a base AST Expression node.
Expr(TypeID typeID, SMRange loc, Type type)
static bool classof(const Node *node)
Provide type casting support.
Type getType() const
Return the type of this expression.
This statement represents a let statement in PDLL.
VariableDecl * getVarDecl() const
Return the variable defined by this statement.
static LetStmt * create(Context &ctx, SMRange loc, VariableDecl *varDecl)
This expression represents a named member or field access of a given parent expression.
static MemberAccessExpr * create(Context &ctx, SMRange loc, const Expr *parentExpr, StringRef memberName, Type type)
const Expr * getParentExpr() const
Get the parent expression of this access.
StringRef getMemberName() const
Return the name of the member being accessed.
This class represents a top-level AST module.
MutableArrayRef< Decl * > getChildren()
Return the children of this module.
static Module * create(Context &ctx, SMLoc loc, ArrayRef< Decl * > children)
ArrayRef< Decl * > getChildren() const
This Decl represents a NamedAttribute, and contains a string name and attribute value.
Expr * getValue() const
Return value of the attribute.
const Name & getName() const
Return the name of the attribute.
static NamedAttributeDecl * create(Context &ctx, const Name &name, Expr *value)
This CRTP class provides several utilies when defining new AST nodes.
static bool classof(const Node *node)
Provide type casting support.
NodeBase< T, BaseT > Base
NodeBase(SMRange loc, Args &&...args)
This class represents a base AST node.
Node(TypeID typeID, SMRange loc)
void walk(function_ref< void(const Node *)> walkFn) const
Walk all of the nodes including, and nested under, this node in pre-order.
SMRange getLoc() const
Return the location of this node.
std::enable_if_t<!std::is_convertible< const Node *, ArgT >::value > walk(WalkFnT &&walkFn) const
void print(raw_ostream &os) const
Print this node to the given stream.
TypeID getTypeID() const
Return the type identifier of this node.
The class represents an Operation constraint, and constrains a variable to be an Operation.
static OpConstraintDecl * create(Context &ctx, SMRange loc, const OpNameDecl *nameDecl=nullptr)
std::optional< StringRef > getName() const
Return the name of the operation, or std::nullopt if there isn't one.
OpConstraintDecl(SMRange loc, const OpNameDecl *nameDecl)
const OpNameDecl * getNameDecl() const
Return the declaration of the operation name.
const OpNameDecl * nameDecl
The operation name of this constraint.
This Decl represents an OperationName.
std::optional< StringRef > getName() const
Return the name of this operation, or std::nullopt if the name is unknown.
static OpNameDecl * create(Context &ctx, const Name &name)
This class represents a base operation rewrite statement.
static bool classof(const Node *node)
Provide type casting support.
OpRewriteStmt(TypeID typeID, SMRange loc, Expr *rootOp)
Expr * rootOp
The root operation being rewritten.
Expr * getRootOpExpr() const
Return the root operation of this rewrite.
This expression represents the structural form of an MLIR Operation.
MutableArrayRef< Expr * > getResultTypes()
Return the result types of this operation.
MutableArrayRef< Expr * > getResultTypes() const
MutableArrayRef< NamedAttributeDecl * > getAttributes()
Return the attributes of this operation.
const OpNameDecl * getNameDecl() const
Return the declaration of the operation name.
SMRange getNameLoc() const
Return the location of the name of the operation expression, or an invalid location if there isn't a ...
MutableArrayRef< Expr * > getOperands()
Return the operands of this operation.
static OperationExpr * create(Context &ctx, SMRange loc, const ods::Operation *odsOp, const OpNameDecl *nameDecl, ArrayRef< Expr * > operands, ArrayRef< Expr * > resultTypes, ArrayRef< NamedAttributeDecl * > attributes)
std::optional< StringRef > getName() const
Return the name of the operation, or std::nullopt if there isn't one.
MutableArrayRef< NamedAttributeDecl * > getAttributes() const
ArrayRef< Expr * > getOperands() const
This Decl represents a single Pattern.
const CompoundStmt * getBody() const
Return the body of this pattern.
static PatternDecl * create(Context &ctx, SMRange location, const Name *name, std::optional< uint16_t > benefit, bool hasBoundedRecursion, const CompoundStmt *body)
const OpRewriteStmt * getRootRewriteStmt() const
Return the root rewrite statement of this pattern.
std::optional< uint16_t > getBenefit() const
Return the benefit of this pattern if specified, or std::nullopt.
bool hasBoundedRewriteRecursion() const
Return if this pattern has bounded rewrite recursion.
This expression builds a range from a set of element values (which may be ranges themselves).
static RangeExpr * create(Context &ctx, SMRange loc, ArrayRef< Expr * > elements, RangeType type)
MutableArrayRef< Expr * > getElements()
Return the element expressions of this range.
ArrayRef< Expr * > getElements() const
RangeType getType() const
Return the range result type of this expression.
This class represents a PDLL type that corresponds to a range of elements with a given element type.
This statement represents the replace statement in PDLL.
ArrayRef< Expr * > getReplExprs() const
MutableArrayRef< Expr * > getReplExprs()
Return the replacement values of this statement.
static ReplaceStmt * create(Context &ctx, SMRange loc, Expr *rootOp, ArrayRef< Expr * > replExprs)
This statement represents a return from a "callable" like decl, e.g.
static ReturnStmt * create(Context &ctx, SMRange loc, Expr *resultExpr)
void setResultExpr(Expr *expr)
Set the result expression of this statement.
Expr * getResultExpr()
Return the result expression of this statement.
const Expr * getResultExpr() const
This statement represents an operation rewrite that contains a block of nested rewrite commands.
static RewriteStmt * create(Context &ctx, SMRange loc, Expr *rootOp, CompoundStmt *rewriteBody)
CompoundStmt * getRewriteBody() const
Return the compound rewrite body.
This class represents a base AST Statement node.
static bool classof(const Node *node)
Provide type casting support.
This expression builds a tuple from a set of element values.
TupleType getType() const
Return the tuple result type of this expression.
MutableArrayRef< Expr * > getElements()
Return the element expressions of this tuple.
ArrayRef< Expr * > getElements() const
static TupleExpr * create(Context &ctx, SMRange loc, ArrayRef< Expr * > elements, ArrayRef< StringRef > elementNames)
This class represents a PDLL tuple type, i.e.
size_t size() const
Return the number of elements within this tuple.
The class represents a Type constraint, and constrains a variable to be a Type.
static TypeConstraintDecl * create(Context &ctx, SMRange loc)
This expression represents a literal MLIR Type, and contains the textual assembly format of that type...
StringRef getValue() const
Get the raw value of this expression.
static TypeExpr * create(Context &ctx, SMRange loc, StringRef value)
The class represents a TypeRange constraint, and constrains a variable to be a TypeRange.
static TypeRangeConstraintDecl * create(Context &ctx, SMRange loc)
This class represents a PDLL type that corresponds to an mlir::Type.
This decl represents a user defined constraint.
ArrayRef< VariableDecl * > getResults() const
bool isExternal() const
Returns true if this constraint is external.
MutableArrayRef< VariableDecl * > getInputs()
Return the input arguments of this constraint.
std::optional< StringRef > getNativeInputType(unsigned index) const
Return the explicit native type to use for the given input.
const Name & getName() const
Return the name of the constraint.
std::optional< StringRef > getCodeBlock() const
Return the optional code block of this constraint, if this is a native constraint with a provided imp...
static UserConstraintDecl * createPDLL(Context &ctx, const Name &name, ArrayRef< VariableDecl * > inputs, ArrayRef< VariableDecl * > results, const CompoundStmt *body, Type resultType)
Create a PDLL constraint with the given body.
Type getResultType() const
Return the result type of this constraint.
MutableArrayRef< VariableDecl * > getResults()
Return the explicit results of the constraint declaration.
ArrayRef< VariableDecl * > getInputs() const
const CompoundStmt * getBody() const
Return the body of this constraint if this constraint is a PDLL constraint, otherwise returns nullptr...
static UserConstraintDecl * createNative(Context &ctx, const Name &name, ArrayRef< VariableDecl * > inputs, ArrayRef< VariableDecl * > results, std::optional< StringRef > codeBlock, Type resultType, ArrayRef< StringRef > nativeInputTypes={})
Create a native constraint with the given optional code block.
This decl represents a user defined rewrite.
std::optional< StringRef > getCodeBlock() const
Return the optional code block of this rewrite, if this is a native rewrite with a provided implement...
Type getResultType() const
Return the result type of this rewrite.
const Name & getName() const
Return the name of the rewrite.
ArrayRef< VariableDecl * > getResults() const
const CompoundStmt * getBody() const
Return the body of this rewrite if this rewrite is a PDLL rewrite, otherwise returns nullptr.
static UserRewriteDecl * createNative(Context &ctx, const Name &name, ArrayRef< VariableDecl * > inputs, ArrayRef< VariableDecl * > results, std::optional< StringRef > codeBlock, Type resultType)
Create a native rewrite with the given optional code block.
static UserRewriteDecl * createPDLL(Context &ctx, const Name &name, ArrayRef< VariableDecl * > inputs, ArrayRef< VariableDecl * > results, const CompoundStmt *body, Type resultType)
Create a PDLL rewrite with the given body.
MutableArrayRef< VariableDecl * > getInputs()
Return the input arguments of this rewrite.
ArrayRef< VariableDecl * > getInputs() const
MutableArrayRef< VariableDecl * > getResults()
Return the explicit results of the rewrite declaration.
bool isExternal() const
Returns true if this rewrite is external.
The class represents a Value constraint, and constrains a variable to be a Value.
static ValueConstraintDecl * create(Context &ctx, SMRange loc, Expr *typeExpr)
Expr * typeExpr
An optional type that the value is constrained to.
const Expr * getTypeExpr() const
ValueConstraintDecl(SMRange loc, Expr *typeExpr)
Expr * getTypeExpr()
Return the optional type the value is constrained to.
The class represents a ValueRange constraint, and constrains a variable to be a ValueRange.
const Expr * getTypeExpr() const
Expr * getTypeExpr()
Return the optional type the value range is constrained to.
static ValueRangeConstraintDecl * create(Context &ctx, SMRange loc, Expr *typeExpr=nullptr)
ValueRangeConstraintDecl(SMRange loc, Expr *typeExpr)
Expr * typeExpr
An optional type that the value range is constrained to.
This Decl represents the definition of a PDLL variable.
const Name & getName() const
Return the name of the decl.
Expr * getInitExpr() const
Return the initializer expression of this statement, or nullptr if there was no initializer.
static VariableDecl * create(Context &ctx, const Name &name, Type type, Expr *initExpr, ArrayRef< ConstraintRef > constraints)
MutableArrayRef< ConstraintRef > getConstraints()
Return the constraints of this variable.
Type getType() const
Return the type of the decl.
ArrayRef< ConstraintRef > getConstraints() const
This class provides an ODS representation of a specific operation.
Include the generated interface declarations.
Type getType(OpFoldResult ofr)
Returns the int type of the integer in ofr.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
This class represents a reference to a constraint, and contains a constraint and the location of the ...
ConstraintRef(const ConstraintDecl *constraint, SMRange refLoc)
const ConstraintDecl * constraint
ConstraintRef(const ConstraintDecl *constraint)
This class provides a convenient API for interacting with source names.
StringRef getName() const
Return the raw string name.
SMRange getLoc() const
Get the location of this name.
static const Name & create(Context &ctx, StringRef name, SMRange location)