18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/ADT/StringExtras.h"
20 #include "llvm/ADT/TypeSwitch.h"
21 #include "llvm/Support/Casting.h"
26 #include "mlir/Dialect/EmitC/IR/EmitCDialect.cpp.inc"
32 void EmitCDialect::initialize() {
35 #include "mlir/Dialect/EmitC/IR/EmitC.cpp.inc"
38 #define GET_TYPEDEF_LIST
39 #include "mlir/Dialect/EmitC/IR/EmitCTypes.cpp.inc"
42 #define GET_ATTRDEF_LIST
43 #include "mlir/Dialect/EmitC/IR/EmitCAttributes.cpp.inc"
52 return builder.
create<emitc::ConstantOp>(loc, type, value);
58 builder.
create<emitc::YieldOp>(loc);
62 if (llvm::isa<emitc::OpaqueType>(type))
64 if (
auto ptrType = llvm::dyn_cast<emitc::PointerType>(type))
66 if (
auto arrayType = llvm::dyn_cast<emitc::ArrayType>(type)) {
67 auto elemType = arrayType.getElementType();
68 return !llvm::isa<emitc::ArrayType>(elemType) &&
73 if (llvm::isa<IntegerType>(type))
75 if (llvm::isa<FloatType>(type))
77 if (
auto tensorType = llvm::dyn_cast<TensorType>(type)) {
78 if (!tensorType.hasStaticShape()) {
81 auto elemType = tensorType.getElementType();
82 if (llvm::isa<emitc::ArrayType>(elemType)) {
87 if (
auto tupleType = llvm::dyn_cast<TupleType>(type)) {
88 return llvm::all_of(tupleType.getTypes(), [](
Type type) {
89 return !llvm::isa<emitc::ArrayType>(type) && isSupportedEmitCType(type);
96 if (
auto intType = llvm::dyn_cast<IntegerType>(type)) {
97 switch (intType.getWidth()) {
112 return llvm::isa<IndexType, emitc::OpaqueType>(type) ||
117 if (
auto floatType = llvm::dyn_cast<FloatType>(type)) {
118 switch (floatType.getWidth()) {
130 return isa<emitc::SignedSizeTType, emitc::SizeTType, emitc::PtrDiffTType>(
138 assert(op->
getNumResults() == 1 &&
"operation must have 1 result");
140 if (llvm::isa<emitc::OpaqueAttr>(value))
143 if (llvm::isa<StringAttr>(value))
145 <<
"string attributes are not supported, use #emitc.opaque instead";
148 Type attrType = cast<TypedAttr>(value).getType();
153 if (resultType != attrType)
155 <<
"requires attribute to either be an #emitc.opaque attribute or "
157 << attrType <<
") to match the op's result type (" << resultType
168 Type lhsType = getLhs().getType();
169 Type rhsType = getRhs().getType();
171 if (isa<emitc::PointerType>(lhsType) && isa<emitc::PointerType>(rhsType))
172 return emitOpError(
"requires that at most one operand is a pointer");
174 if ((isa<emitc::PointerType>(lhsType) &&
175 !isa<IntegerType, emitc::OpaqueType>(rhsType)) ||
176 (isa<emitc::PointerType>(rhsType) &&
177 !isa<IntegerType, emitc::OpaqueType>(lhsType)))
178 return emitOpError(
"requires that one operand is an integer or of opaque "
179 "type if the other is a pointer");
189 StringRef applicableOperatorStr = getApplicableOperator();
192 if (applicableOperatorStr.empty())
193 return emitOpError(
"applicable operator must not be empty");
196 if (applicableOperatorStr !=
"&" && applicableOperatorStr !=
"*")
197 return emitOpError(
"applicable operator is illegal");
199 Operation *op = getOperand().getDefiningOp();
200 if (op && dyn_cast<ConstantOp>(op))
201 return emitOpError(
"cannot apply to constant");
213 Value variable = getVar();
216 !llvm::isa<emitc::GetGlobalOp, emitc::MemberOp, emitc::MemberOfPtrOp,
217 emitc::SubscriptOp, emitc::VariableOp>(variableDef))
218 return emitOpError() <<
"requires first operand (" << variable
219 <<
") to be a get_global, member, member of pointer, "
220 "subscript or variable";
222 Value value = getValue();
224 return emitOpError() <<
"requires value's type (" << value.
getType()
225 <<
") to match variable's type (" << variable.
getType()
227 if (isa<ArrayType>(variable.
getType()))
228 return emitOpError() <<
"cannot assign to array type";
237 Type input = inputs.front(), output = outputs.front();
252 if (getCallee().empty())
253 return emitOpError(
"callee must not be empty");
255 if (std::optional<ArrayAttr> argsAttr = getArgs()) {
257 auto intAttr = llvm::dyn_cast<IntegerAttr>(arg);
258 if (intAttr && llvm::isa<IndexType>(intAttr.getType())) {
259 int64_t index = intAttr.getInt();
262 if ((index < 0) || (index >=
static_cast<int64_t
>(getNumOperands())))
263 return emitOpError(
"index argument is out of range");
266 }
else if (llvm::isa<ArrayAttr>(
269 return emitOpError(
"array argument has no type");
274 if (std::optional<ArrayAttr> templateArgsAttr = getTemplateArgs()) {
275 for (
Attribute tArg : *templateArgsAttr) {
276 if (!llvm::isa<TypeAttr, IntegerAttr, FloatAttr, emitc::OpaqueAttr>(tArg))
277 return emitOpError(
"template argument has invalid type");
281 if (llvm::any_of(getResultTypes(), llvm::IsaPred<ArrayType>)) {
282 return emitOpError() <<
"cannot return array type";
296 if (
auto opaqueValue = llvm::dyn_cast<emitc::OpaqueAttr>(value)) {
297 if (opaqueValue.getValue().empty())
298 return emitOpError() <<
"value must not be empty";
303 OpFoldResult emitc::ConstantOp::fold(FoldAdaptor adaptor) {
return getValue(); }
310 auto yieldOp = cast<YieldOp>(getBody()->getTerminator());
311 Value yieldedValue = yieldOp.getResult();
313 assert(rootOp &&
"Yielded value not defined within expression");
318 Type resultType = getResult().getType();
319 Region ®ion = getRegion();
324 return emitOpError(
"must yield a value at termination");
327 Value yieldResult = yield.getResult();
330 return emitOpError(
"must yield a value at termination");
334 if (resultType != yieldType)
335 return emitOpError(
"requires yielded type to match return type");
339 return emitOpError(
"contains an unsupported operation");
341 return emitOpError(
"requires exactly one result for each operation");
343 return emitOpError(
"requires exactly one use for each operation");
354 Value ub,
Value step, BodyBuilderFn bodyBuilder) {
364 ForOp::ensureTerminator(*bodyRegion, builder, result.
location);
392 regionArgs.push_back(inductionVariable);
401 regionArgs.front().type = type;
412 ForOp::ensureTerminator(*body, builder, result.
location);
422 p <<
" " << getInductionVar() <<
" = " <<
getLowerBound() <<
" to "
427 p <<
" : " << t <<
' ';
434 LogicalResult ForOp::verifyRegions() {
439 "expected induction variable to be same type as bounds and step");
452 return emitOpError(
"requires a 'callee' symbol reference attribute");
455 return emitOpError() <<
"'" << fnAttr.getValue()
456 <<
"' does not reference a valid function";
459 auto fnType = fn.getFunctionType();
460 if (fnType.getNumInputs() != getNumOperands())
461 return emitOpError(
"incorrect number of operands for callee");
463 for (
unsigned i = 0, e = fnType.getNumInputs(); i != e; ++i)
464 if (getOperand(i).
getType() != fnType.getInput(i))
465 return emitOpError(
"operand type mismatch: expected operand type ")
466 << fnType.getInput(i) <<
", but provided "
467 << getOperand(i).getType() <<
" for operand number " << i;
469 if (fnType.getNumResults() != getNumResults())
470 return emitOpError(
"incorrect number of results for callee");
472 for (
unsigned i = 0, e = fnType.getNumResults(); i != e; ++i)
473 if (getResult(i).
getType() != fnType.getResult(i)) {
474 auto diag = emitOpError(
"result type mismatch at index ") << i;
475 diag.attachNote() <<
" op result types: " << getResultTypes();
476 diag.attachNote() <<
"function result types: " << fnType.getResults();
483 FunctionType CallOp::getCalleeType() {
494 auto fnAttr = getSymNameAttr();
496 return emitOpError(
"requires a 'sym_name' symbol reference attribute");
499 return emitOpError() <<
"'" << fnAttr.getValue()
500 <<
"' does not reference a valid function";
514 state.addAttribute(getFunctionTypeAttrName(state.name),
TypeAttr::get(type));
515 state.attributes.append(attrs.begin(), attrs.end());
518 if (argAttrs.empty())
520 assert(type.getNumInputs() == argAttrs.size());
522 builder, state, argAttrs, std::nullopt,
523 getArgAttrsAttrName(state.name), getResAttrsAttrName(state.name));
533 parser, result,
false,
534 getFunctionTypeAttrName(result.
name), buildFuncType,
535 getArgAttrsAttrName(result.
name), getResAttrsAttrName(result.
name));
540 p, *
this,
false, getFunctionTypeAttrName(),
541 getArgAttrsAttrName(), getResAttrsAttrName());
545 if (getNumResults() > 1)
546 return emitOpError(
"requires zero or exactly one result, but has ")
549 if (getNumResults() == 1 && isa<ArrayType>(getResultTypes()[0]))
550 return emitOpError(
"cannot return array type");
560 auto function = cast<FuncOp>((*this)->getParentOp());
563 if (getNumOperands() !=
function.getNumResults())
564 return emitOpError(
"has ")
565 << getNumOperands() <<
" operands, but enclosing function (@"
566 <<
function.getName() <<
") returns " <<
function.getNumResults();
568 if (
function.getNumResults() == 1)
569 if (getOperand().
getType() !=
function.getResultTypes()[0])
570 return emitError() <<
"type of the return operand ("
571 << getOperand().getType()
572 <<
") doesn't match function result type ("
573 <<
function.getResultTypes()[0] <<
")"
574 <<
" in function @" <<
function.getName();
583 bool addThenBlock,
bool addElseBlock) {
584 assert((!addElseBlock || addThenBlock) &&
585 "must not create else block w/o then block");
599 bool withElseRegion) {
609 if (withElseRegion) {
617 assert(thenBuilder &&
"the builder callback for 'then' must be present");
624 thenBuilder(builder, result.
location);
630 elseBuilder(builder, result.
location);
665 bool printBlockTerminators =
false;
667 p <<
" " << getCondition();
671 printBlockTerminators);
674 Region &elseRegion = getElseRegion();
675 if (!elseRegion.
empty()) {
679 printBlockTerminators);
701 Region *elseRegion = &this->getElseRegion();
702 if (elseRegion->
empty())
710 FoldAdaptor adaptor(operands, *
this);
711 auto boolAttr = dyn_cast_or_null<BoolAttr>(adaptor.getCondition());
712 if (!boolAttr || boolAttr.getValue())
713 regions.emplace_back(&getThenRegion());
716 if (!boolAttr || !boolAttr.getValue()) {
717 if (!getElseRegion().empty())
718 regions.emplace_back(&getElseRegion());
720 regions.emplace_back();
724 void IfOp::getRegionInvocationBounds(
727 if (
auto cond = llvm::dyn_cast_or_null<BoolAttr>(operands[0])) {
730 invocationBounds.emplace_back(0, cond.getValue() ? 1 : 0);
731 invocationBounds.emplace_back(0, cond.getValue() ? 0 : 1);
734 invocationBounds.assign(2, {0, 1});
743 bool standardInclude = getIsStandardInclude();
748 p <<
"\"" << getInclude() <<
"\"";
764 <<
"expected trailing '>' for standard include";
779 if (getValue().empty())
780 return emitOpError() <<
"value must not be empty";
788 Type lhsType = getLhs().getType();
789 Type rhsType = getRhs().getType();
790 Type resultType = getResult().getType();
792 if (isa<emitc::PointerType>(rhsType) && !isa<emitc::PointerType>(lhsType))
793 return emitOpError(
"rhs can only be a pointer if lhs is a pointer");
795 if (isa<emitc::PointerType>(lhsType) &&
796 !isa<IntegerType, emitc::OpaqueType, emitc::PointerType>(rhsType))
797 return emitOpError(
"requires that rhs is an integer, pointer or of opaque "
798 "type if lhs is a pointer");
800 if (isa<emitc::PointerType>(lhsType) && isa<emitc::PointerType>(rhsType) &&
801 !isa<IntegerType, emitc::OpaqueType>(resultType))
802 return emitOpError(
"requires that the result is an integer or of opaque "
803 "type if lhs and rhs are pointers");
820 Value result = getResult();
824 return emitOpError() <<
"yields a value not returned by parent";
827 return emitOpError() <<
"does not yield a value to be returned by parent";
838 if (
auto arrayType = llvm::dyn_cast<emitc::ArrayType>(getValue().
getType())) {
840 if (
getIndices().size() != (
size_t)arrayType.getRank()) {
841 return emitOpError() <<
"on array operand requires number of indices ("
843 <<
") to match the rank of the array type ("
844 << arrayType.getRank() <<
")";
847 for (
unsigned i = 0, e =
getIndices().size(); i != e; ++i) {
850 return emitOpError() <<
"on array operand requires index operand " << i
851 <<
" to be integer-like, but got " << type;
855 Type elementType = arrayType.getElementType();
856 if (elementType !=
getType()) {
857 return emitOpError() <<
"on array operand requires element type ("
858 << elementType <<
") and result type (" <<
getType()
865 if (
auto pointerType =
866 llvm::dyn_cast<emitc::PointerType>(getValue().
getType())) {
870 <<
"on pointer operand requires one index operand, but got "
876 return emitOpError() <<
"on pointer operand requires index operand to be "
877 "integer-like, but got "
881 Type pointeeType = pointerType.getPointee();
882 if (pointeeType !=
getType()) {
883 return emitOpError() <<
"on pointer operand requires pointee type ("
884 << pointeeType <<
") and result type (" <<
getType()
899 #include "mlir/Dialect/EmitC/IR/EmitCEnums.cpp.inc"
905 #define GET_ATTRDEF_CLASSES
906 #include "mlir/Dialect/EmitC/IR/EmitCAttributes.cpp.inc"
912 #define GET_TYPEDEF_CLASSES
913 #include "mlir/Dialect/EmitC/IR/EmitCTypes.cpp.inc"
934 if (!isValidElementType(elementType))
935 return parser.
emitError(typeLoc,
"invalid array element type"),
Type();
938 return parser.
getChecked<ArrayType>(dimensions, elementType);
944 printer << dim <<
'x';
954 return emitError() <<
"shape must not be empty";
956 for (int64_t dim : shape) {
958 return emitError() <<
"dimensions must have positive size";
962 return emitError() <<
"element type must not be none";
964 if (!isValidElementType(elementType))
965 return emitError() <<
"invalid array element type";
972 Type elementType)
const {
984 llvm::StringRef value) {
986 return emitError() <<
"expected non empty string in !emitc.opaque type";
988 if (value.back() ==
'*') {
989 return emitError() <<
"pointer not allowed as outer type with "
990 "!emitc.opaque, use !emitc.ptr instead";
1009 if (
auto array = llvm::dyn_cast<ArrayType>(type))
1029 if (!llvm::isa<ElementsAttr, IntegerAttr, FloatAttr, emitc::OpaqueAttr>(
1032 <<
"initial value should be a integer, float, elements or opaque "
1039 return emitOpError(
"expected valid emitc type");
1041 if (getInitialValue().has_value()) {
1042 Attribute initValue = getInitialValue().value();
1045 if (
auto elementsAttr = llvm::dyn_cast<ElementsAttr>(initValue)) {
1046 auto arrayType = llvm::dyn_cast<ArrayType>(
getType());
1048 return emitOpError(
"expected array type, but got ") <<
getType();
1050 Type initType = elementsAttr.getType();
1052 if (initType != tensorType) {
1053 return emitOpError(
"initial value expected to be of type ")
1054 <<
getType() <<
", but was of type " << initType;
1056 }
else if (
auto intAttr = dyn_cast<IntegerAttr>(initValue)) {
1057 if (intAttr.getType() !=
getType()) {
1058 return emitOpError(
"initial value expected to be of type ")
1059 <<
getType() <<
", but was of type " << intAttr.getType();
1061 }
else if (
auto floatAttr = dyn_cast<FloatAttr>(initValue)) {
1062 if (floatAttr.getType() !=
getType()) {
1063 return emitOpError(
"initial value expected to be of type ")
1064 <<
getType() <<
", but was of type " << floatAttr.getType();
1066 }
else if (!isa<emitc::OpaqueAttr>(initValue)) {
1067 return emitOpError(
"initial value should be a integer, float, elements "
1068 "or opaque attribute, but got ")
1072 if (getStaticSpecifier() && getExternSpecifier()) {
1073 return emitOpError(
"cannot have both static and extern specifiers");
1088 return emitOpError(
"'")
1089 << getName() <<
"' does not reference a valid emitc.global";
1091 Type resultType = getResult().getType();
1092 if (global.getType() != resultType)
1093 return emitOpError(
"result type ")
1094 << resultType <<
" does not match type " << global.getType()
1095 <<
" of the global @" << getName();
1103 #define GET_OP_CLASSES
1104 #include "mlir/Dialect/EmitC/IR/EmitC.cpp.inc"
static std::optional< int64_t > getUpperBound(Value iv)
Gets the constant upper bound on an affine.for iv.
static std::optional< int64_t > getLowerBound(Value iv)
Gets the constant lower bound on an iv.
static LogicalResult verifyInitializationAttribute(Operation *op, Attribute value)
Check that the type of the initial value is compatible with the operations result type.
static ParseResult parseEmitCGlobalOpTypeAndInitialValue(OpAsmParser &parser, TypeAttr &typeAttr, Attribute &initialValue)
static void printEmitCGlobalOpTypeAndInitialValue(OpAsmPrinter &p, GlobalOp op, TypeAttr type, Attribute initialValue)
static Type getInitializerTypeForGlobal(Type type)
static Operation * materializeConstant(Dialect *dialect, OpBuilder &builder, Attribute value, Type type, Location loc)
A utility function used to materialize a constant for a given attribute and type.
static MLIRContext * getContext(OpFoldResult val)
static std::string diag(const llvm::Value &value)
static void print(spirv::VerCapExtAttr triple, DialectAsmPrinter &printer)
static Type getElementType(Type type, ArrayRef< int32_t > indices, function_ref< InFlightDiagnostic(StringRef)> emitErrorFn)
Walks the given type hierarchy with the given indices, potentially down to component granularity,...
static ArrayRef< int64_t > getShape(Type type)
Returns the shape of the given type.
This base class exposes generic asm parser hooks, usable across the various derived parsers.
virtual Builder & getBuilder() const =0
Return a builder which provides useful access to MLIRContext, global objects like types and attribute...
virtual ParseResult parseOptionalAttrDict(NamedAttrList &result)=0
Parse a named dictionary into 'result' if it is present.
virtual ParseResult parseOptionalEqual()=0
Parse a = token if present.
virtual ParseResult parseOptionalKeyword(StringRef keyword)=0
Parse the given keyword if present.
MLIRContext * getContext() const
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
virtual ParseResult parseOptionalColon()=0
Parse a : token if present.
virtual ParseResult parseLess()=0
Parse a '<' token.
virtual ParseResult parseDimensionList(SmallVectorImpl< int64_t > &dimensions, bool allowDynamic=true, bool withTrailingX=true)=0
Parse a dimension list of a tensor or memref type.
virtual ParseResult parseOptionalGreater()=0
Parse a '>' token if present.
virtual ParseResult parseEqual()=0
Parse a = token.
virtual OptionalParseResult parseOptionalAttribute(Attribute &result, Type type={})=0
Parse an arbitrary optional attribute of a given type and return it in result.
virtual SMLoc getCurrentLocation()=0
Get the location of the next token and store it into the argument.
auto getChecked(SMLoc loc, ParamsT &&...params)
Invoke the getChecked method of the given Attribute or Type class, using the provided location to emi...
virtual SMLoc getNameLoc() const =0
Return the location of the original name token.
virtual ParseResult parseOptionalLess()=0
Parse a '<' token if present.
virtual ParseResult parseGreater()=0
Parse a '>' token.
virtual ParseResult parseType(Type &result)=0
Parse a type.
ParseResult parseKeyword(StringRef keyword)
Parse a given keyword.
virtual ParseResult parseAttribute(Attribute &result, Type type={})=0
Parse an arbitrary attribute of a given type and return it in result.
This base class exposes generic asm printer hooks, usable across the various derived printers.
virtual void printAttributeWithoutType(Attribute attr)
Print the given attribute without its type.
virtual void printType(Type type)
Attributes are known-constant values of operations.
Block represents an ordered list of Operations.
BlockArgument getArgument(unsigned i)
Operation * getTerminator()
Get the terminator operation of this block.
BlockArgument addArgument(Type type, Location loc)
Add one value to the argument list.
bool mightHaveTerminator()
Check whether this block might have a terminator.
iterator_range< iterator > without_terminator()
Return an iterator range over the operation within this block excluding the terminator operation at t...
This class is a general helper class for creating context-global objects like types,...
FunctionType getFunctionType(TypeRange inputs, TypeRange results)
IntegerType getIntegerType(unsigned width)
StringAttr getStringAttr(const Twine &bytes)
A symbol reference with a reference path containing a single element.
This class represents a diagnostic that is inflight and set to be reported.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
MLIRContext is the top-level object for a collection of MLIR operations.
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
virtual ParseResult parseRegion(Region ®ion, ArrayRef< Argument > arguments={}, bool enableNameShadowing=false)=0
Parses a region.
virtual ParseResult resolveOperand(const UnresolvedOperand &operand, Type type, SmallVectorImpl< Value > &result)=0
Resolve an operand to an SSA value, emitting an error on failure.
virtual ParseResult parseOperand(UnresolvedOperand &result, bool allowResultNumber=true)=0
Parse a single SSA value operand name along with a result number if allowResultNumber is true.
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
virtual void printOptionalAttrDict(ArrayRef< NamedAttribute > attrs, ArrayRef< StringRef > elidedAttrs={})=0
If the specified operation has attributes, print out an attribute dictionary with their values.
virtual void printRegion(Region &blocks, bool printEntryBlockArgs=true, bool printBlockTerminators=true, bool printEmptyBlock=false)=0
Prints a region.
RAII guard to reset the insertion point of the builder when destroyed.
This class helps build Operations.
void setInsertionPointToStart(Block *block)
Sets the insertion point to the start of the specified block.
Block * createBlock(Region *parent, Region::iterator insertPt={}, TypeRange argTypes=std::nullopt, ArrayRef< Location > locs=std::nullopt)
Add new block with 'argTypes' arguments and set the insertion point to the end of it.
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
This class represents a single result from folding an operation.
type_range getType() const
Operation is the basic unit of execution within MLIR.
bool hasTrait()
Returns true if the operation was registered with a particular trait, e.g.
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
Operation * getParentOp()
Returns the closest surrounding operation that contains this operation or nullptr if this is a top-le...
InFlightDiagnostic emitOpError(const Twine &message={})
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
unsigned getNumResults()
Return the number of results held by this operation.
This class implements Optional functionality for ParseResult.
bool has_value() const
Returns true if we contain a valid ParseResult value.
This class represents a point being branched from in the methods of the RegionBranchOpInterface.
bool isParent() const
Returns true if branching from the parent op.
This class represents a successor of a region.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
This class represents a collection of SymbolTables.
Operation * lookupNearestSymbolFrom(Operation *from, StringAttr symbol)
Returns the operation registered with the given symbol name within the closest parent operation of,...
static StringRef getSymbolAttrName()
Return the name of the attribute used for symbol names.
This class provides an abstraction over the various different ranges of value types.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
bool hasOneUse() const
Returns true if this value has exactly one use.
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
A named class for passing around the variadic flag.
void buildTerminatedBody(OpBuilder &builder, Location loc)
Default callback for builders of ops carrying a region.
bool isSupportedFloatType(mlir::Type type)
Determines whether type is a valid floating-point type in EmitC.
bool isSupportedEmitCType(mlir::Type type)
Determines whether type is valid in EmitC.
bool isPointerWideType(mlir::Type type)
Determines whether type is a emitc.size_t/ssize_t type.
bool isIntegerIndexOrOpaqueType(Type type)
Determines whether type is integer like, i.e.
bool isSupportedIntegerType(mlir::Type type)
Determines whether type is a valid integer type in EmitC.
void addArgAndResultAttrs(Builder &builder, OperationState &result, ArrayRef< DictionaryAttr > argAttrs, ArrayRef< DictionaryAttr > resultAttrs, StringAttr argAttrsName, StringAttr resAttrsName)
Adds argument and result attributes, provided as argAttrs and resultAttrs arguments,...
void printFunctionOp(OpAsmPrinter &p, FunctionOpInterface op, bool isVariadic, StringRef typeAttrName, StringAttr argAttrsName, StringAttr resAttrsName)
Printer implementation for function-like operations.
ParseResult parseFunctionOp(OpAsmParser &parser, OperationState &result, bool allowVariadic, StringAttr typeAttrName, FuncTypeBuilder funcTypeBuilder, StringAttr argAttrsName, StringAttr resAttrsName)
Parser implementation for function-like operations.
Operation::operand_range getIndices(Operation *op)
Get the indices that the given load/store operation is operating on.
QueryRef parse(llvm::StringRef line, const QuerySession &qs)
Include the generated interface declarations.
Type getType(OpFoldResult ofr)
Returns the int type of the integer in ofr.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...
UnresolvedOperand ssaName
This is the representation of an operand reference.
This represents an operation in an abstracted form, suitable for use with the builder APIs.
SmallVector< Value, 4 > operands
void addOperands(ValueRange newOperands)
void addAttribute(StringRef name, Attribute attr)
Add an attribute with the specified name.
SmallVector< std::unique_ptr< Region >, 1 > regions
Regions that the op will hold.
Region * addRegion()
Create a region that should be attached to the operation.