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;
254 class EraseStmt final :
public Node::NodeBase<EraseStmt, OpRewriteStmt> {
268 class ReplaceStmt final :
public Node::NodeBase<ReplaceStmt, OpRewriteStmt>,
269 private llvm::TrailingObjects<ReplaceStmt, Expr *> {
276 return {getTrailingObjects<Expr *>(), numReplExprs};
284 :
Base(loc, rootOp), numReplExprs(numReplExprs) {}
287 unsigned numReplExprs;
299 class RewriteStmt final :
public Node::NodeBase<RewriteStmt, OpRewriteStmt> {
309 :
Base(loc, rootOp), rewriteBody(rewriteBody) {}
312 CompoundStmt *rewriteBody;
321 class ReturnStmt final :
public Node::NodeBase<ReturnStmt, Stmt> {
334 :
Base(loc), resultExpr(resultExpr) {}
389 class CallExpr final :
public Node::NodeBase<CallExpr, Expr>,
390 private llvm::TrailingObjects<CallExpr, Expr *> {
394 bool isNegated =
false);
401 return {getTrailingObjects<Expr *>(), numArgs};
413 :
Base(loc, type), callable(callable), numArgs(numArgs),
414 isNegated(isNegated) {}
423 friend llvm::TrailingObjects<CallExpr, Expr *>;
443 :
Base(loc, type), decl(decl) {}
458 const Expr *parentExpr, StringRef memberName,
470 :
Base(loc, type), parentExpr(parentExpr), memberName(memberName) {}
473 const Expr *parentExpr;
476 StringRef memberName;
490 const Expr *parentExpr,
Type type) {
491 return cast<AllResultsMemberAccessExpr>(
510 :
public Node::NodeBase<OperationExpr, Expr>,
511 private llvm::TrailingObjects<OperationExpr, Expr *,
512 NamedAttributeDecl *> {
522 std::optional<StringRef>
getName()
const;
533 return {getTrailingObjects<Expr *>(), numOperands};
541 return {getTrailingObjects<Expr *>() + numOperands, numResultTypes};
549 return {getTrailingObjects<NamedAttributeDecl *>(), numAttributes};
557 unsigned numOperands,
unsigned numResultTypes,
558 unsigned numAttributes, SMRange nameLoc)
559 :
Base(loc, type), nameDecl(nameDecl), numOperands(numOperands),
560 numResultTypes(numResultTypes), numAttributes(numAttributes),
564 const OpNameDecl *nameDecl;
567 unsigned numOperands, numResultTypes, numAttributes;
573 friend llvm::TrailingObjects<OperationExpr, Expr *, NamedAttributeDecl *>;
574 size_t numTrailingObjects(OverloadToken<Expr *>)
const {
575 return numOperands + numResultTypes;
585 class RangeExpr final :
public Node::NodeBase<RangeExpr, Expr>,
586 private llvm::TrailingObjects<RangeExpr, Expr *> {
593 return {getTrailingObjects<Expr *>(), numElements};
604 :
Base(loc, type), numElements(numElements) {}
607 unsigned numElements;
618 class TupleExpr final :
public Node::NodeBase<TupleExpr, Expr>,
619 private llvm::TrailingObjects<TupleExpr, Expr *> {
626 return {getTrailingObjects<Expr *>(),
getType().
size()};
648 class TypeExpr :
public Node::NodeBase<TypeExpr, Expr> {
686 :
Node(typeID, loc), name(name) {}
695 std::optional<StringRef> docComment;
711 :
Decl(typeID, loc, name) {}
749 :
public Node::NodeBase<AttrConstraintDecl, CoreConstraintDecl> {
772 :
public Node::NodeBase<OpConstraintDecl, CoreConstraintDecl> {
778 std::optional<StringRef>
getName()
const;
797 :
public Node::NodeBase<TypeConstraintDecl, CoreConstraintDecl> {
811 :
public Node::NodeBase<TypeRangeConstraintDecl, CoreConstraintDecl> {
825 :
public Node::NodeBase<ValueConstraintDecl, CoreConstraintDecl> {
847 :
public Node::NodeBase<ValueRangeConstraintDecl, CoreConstraintDecl> {
881 :
public Node::NodeBase<UserConstraintDecl, ConstraintDecl>,
882 llvm::TrailingObjects<UserConstraintDecl, VariableDecl *, StringRef> {
888 std::optional<StringRef> codeBlock,
Type resultType,
890 return createImpl(ctx, name, inputs, nativeInputTypes, results, codeBlock,
891 nullptr, resultType);
900 return createImpl(ctx, name, inputs, std::nullopt,
901 results, std::nullopt, body, resultType);
909 return {getTrailingObjects<VariableDecl *>(), numInputs};
922 return {getTrailingObjects<VariableDecl *>() + numInputs, numResults};
940 bool isExternal()
const {
return !constraintBody && !codeBlock; }
949 std::optional<StringRef> codeBlock,
954 bool hasNativeInputTypes,
unsigned numResults,
955 std::optional<StringRef> codeBlock,
957 :
Base(name.getLoc(), &name), numInputs(numInputs),
958 numResults(numResults), codeBlock(codeBlock), constraintBody(body),
959 resultType(resultType), hasNativeInputTypes(hasNativeInputTypes) {}
968 std::optional<StringRef> codeBlock;
971 const CompoundStmt *constraintBody;
977 bool hasNativeInputTypes;
980 friend llvm::TrailingObjects<UserConstraintDecl, VariableDecl *, StringRef>;
981 size_t numTrailingObjects(OverloadToken<VariableDecl *>)
const {
982 return numInputs + numResults;
1005 :
Base(name.getLoc(), &name), value(value) {}
1024 return name ? std::optional<StringRef>(name->
getName()) : std::nullopt;
1029 explicit OpNameDecl(SMRange loc) :
Base(loc) {}
1040 std::optional<uint16_t> benefit,
1041 bool hasBoundedRecursion,
1055 return cast<OpRewriteStmt>(patternBody->
getChildren().back());
1059 PatternDecl(SMRange loc,
const Name *name, std::optional<uint16_t> benefit,
1061 :
Base(loc, name), benefit(benefit),
1062 hasBoundedRecursion(hasBoundedRecursion), patternBody(body) {}
1066 std::optional<uint16_t> benefit;
1069 bool hasBoundedRecursion;
1072 const CompoundStmt *patternBody;
1091 :
public Node::NodeBase<UserRewriteDecl, Decl>,
1092 llvm::TrailingObjects<UserRewriteDecl, VariableDecl *> {
1098 std::optional<StringRef> codeBlock,
1100 return createImpl(ctx, name, inputs, results, codeBlock,
nullptr,
1110 return createImpl(ctx, name, inputs, results, std::nullopt,
1119 return {getTrailingObjects<VariableDecl *>(), numInputs};
1128 return {getTrailingObjects<VariableDecl *>() + numInputs, numResults};
1154 std::optional<StringRef> codeBlock,
1158 std::optional<StringRef> codeBlock,
const CompoundStmt *body,
1160 :
Base(name.getLoc(), &name), numInputs(numInputs),
1161 numResults(numResults), codeBlock(codeBlock), rewriteBody(body),
1162 resultType(resultType) {}
1168 unsigned numResults;
1171 std::optional<StringRef> codeBlock;
1174 const CompoundStmt *rewriteBody;
1180 friend llvm::TrailingObjects<UserRewriteDecl, VariableDecl *>;
1192 if (isa<UserConstraintDecl>(
this))
1193 return "constraint";
1194 assert(isa<UserRewriteDecl>(
this) &&
"unknown callable type");
1200 if (
const auto *cst = dyn_cast<UserConstraintDecl>(
this))
1201 return cst->getInputs();
1202 return cast<UserRewriteDecl>(
this)->getInputs();
1207 if (
const auto *cst = dyn_cast<UserConstraintDecl>(
this))
1208 return cst->getResultType();
1209 return cast<UserRewriteDecl>(
this)->getResultType();
1216 if (
const auto *cst = dyn_cast<UserConstraintDecl>(
this))
1217 return cst->getResults();
1218 return cast<UserRewriteDecl>(
this)->getResults();
1224 if (
const auto *cst = dyn_cast<UserConstraintDecl>(
this))
1225 return cst->getCodeBlock();
1226 return cast<UserRewriteDecl>(
this)->getCodeBlock();
1231 return isa<UserConstraintDecl, UserRewriteDecl>(decl);
1241 :
public Node::NodeBase<VariableDecl, Decl>,
1242 private llvm::TrailingObjects<VariableDecl, ConstraintRef> {
1250 return {getTrailingObjects<ConstraintRef>(), numConstraints};
1268 unsigned numConstraints)
1269 :
Base(name.getLoc(), &name), type(type), initExpr(initExpr),
1270 numConstraints(numConstraints) {}
1279 unsigned numConstraints;
1282 friend llvm::TrailingObjects<VariableDecl, ConstraintRef>;
1290 class Module final :
public Node::NodeBase<Module, Node>,
1291 private llvm::TrailingObjects<Module, Decl *> {
1297 return {getTrailingObjects<Decl *>(), numChildren};
1304 Module(SMLoc loc,
unsigned numChildren)
1305 :
Base(SMRange{loc, loc}), numChildren(numChildren) {}
1308 unsigned numChildren;
1311 friend llvm::TrailingObjects<Module, Decl *>;
1324 return isa<CoreConstraintDecl, UserConstraintDecl>(node);
1339 return isa<EraseStmt, ReplaceStmt, RewriteStmt>(node);
1343 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)