21#include "llvm/ADT/STLExtras.h"
31 if (attr.
getName() ==
"fastmathFlags") {
50 if (!operands.empty()) {
53 llvm::interleaveComma(operandTypes, p);
62 std::optional<ArrayAttr> opBundleTags) {
63 if (opBundleOperands.empty())
65 assert(opBundleTags &&
"expect operand bundle tags");
68 llvm::interleaveComma(
69 llvm::zip(opBundleOperands, opBundleOperandTypes, *opBundleTags), p,
71 auto bundleTag = cast<StringAttr>(std::get<2>(bundle)).getValue();
89 return p.
emitError(currentParserLoc,
"expect operand bundle tag");
100 opBundleOperands.push_back(std::move(operands));
101 opBundleOperandTypes.push_back(std::move(types));
102 opBundleTags.push_back(StringAttr::get(p.
getContext(), tag));
119 auto bundleParser = [&] {
129 opBundleTags = ArrayAttr::get(p.
getContext(), opBundleTagAttrs);
141 Type resultType = calleeType.getReturnType();
142 if (!isa<LLVM::LLVMVoidType>(resultType))
143 results.push_back(resultType);
149 return calleeType.isVarArg() ? TypeAttr::get(calleeType) :
nullptr;
157 resultType = LLVMVoidType::get(context);
159 resultType = results.front();
160 return LLVMFunctionType::get(resultType, llvm::to_vector(args.
getTypes()),
166 build(builder, state, results, builder.
getStringAttr(callee), args);
171 build(builder, state, results, SymbolRefAttr::get(callee), args);
176 assert(callee &&
"expected non-null callee in direct call builder");
177 build(builder, state, results,
178 nullptr, callee, args,
nullptr,
181 nullptr,
nullptr,
nullptr,
182 nullptr,
nullptr,
nullptr,
186 nullptr,
nullptr,
nullptr,
201 LLVMFunctionType calleeType, StringRef callee,
203 build(builder, state, calleeType, builder.
getStringAttr(callee), args);
207 LLVMFunctionType calleeType, StringAttr callee,
209 build(builder, state, calleeType, SymbolRefAttr::get(callee), args);
227 nullptr,
nullptr,
nullptr,
236 nullptr,
nullptr,
nullptr,
242 LLVMFunctionType calleeType,
ValueRange args) {
247 nullptr,
nullptr,
nullptr,
248 nullptr,
nullptr,
nullptr,
254 nullptr,
nullptr,
nullptr,
270 auto calleeType =
func.getFunctionType();
274 nullptr,
nullptr,
nullptr,
275 nullptr,
nullptr,
nullptr,
281 nullptr,
nullptr,
nullptr,
300 return getOperand(0);
306 auto symRef = cast<SymbolRefAttr>(callee);
307 return setCalleeAttr(cast<FlatSymbolRefAttr>(symRef));
310 return setOperand(0, cast<Value>(callee));
315template <
typename OpTy>
318 if (callOp.getCallee().has_value())
325template <
typename OpTy>
327 return callOp.getCalleeOperands().drop_front(
339template <
typename OpTy>
342 if (std::optional<LLVMFunctionType> varCalleeType = callOp.getVarCalleeType())
343 return operands.take_front(varCalleeType->getNumParams());
361template <
typename OpTy>
363 if (callee.isExternal())
365 auto parentFunc = callOp->template getParentOfType<FunctionOpInterface>();
374 if (!hasSubprogram(parentFunc) || !hasSubprogram(callee))
376 bool containsLoc = !isa<UnknownLoc>(callOp->getLoc());
378 return callOp.emitError()
379 <<
"inlinable function call in a function with a DISubprogram "
380 "location must have a debug location";
386template <
typename OpTy>
389 if (!callOp.getCallee().has_value() && callOp.getCalleeOperands().empty())
390 return callOp.emitOpError(
391 "must have either a `callee` attribute or at least an operand");
393 std::optional<LLVMFunctionType> varCalleeType = callOp.getVarCalleeType();
398 if (!varCalleeType->isVarArg())
399 return callOp.emitOpError(
400 "expected var_callee_type to be a variadic function type");
408 if (varCalleeType->getNumParams() > passedOperands.size())
409 return callOp.emitOpError(
"expected var_callee_type to have at most ")
410 << passedOperands.size() <<
" parameters";
413 for (
auto [paramType, operand] :
414 llvm::zip(varCalleeType->getParams(), passedOperands))
415 if (paramType != operand.getType())
416 return callOp.emitOpError()
417 <<
"var_callee_type parameter type mismatch: " << paramType
418 <<
" != " << operand.getType();
421 if (!callOp.getNumResults()) {
422 if (!isa<LLVMVoidType>(varCalleeType->getReturnType()))
423 return callOp.emitOpError(
"expected var_callee_type to return void");
425 if (callOp.getResult().getType() != varCalleeType->getReturnType())
426 return callOp.emitOpError(
"var_callee_type return type mismatch: ")
427 << varCalleeType->getReturnType()
428 <<
" != " << callOp.getResult().getType();
435template <
typename OpTy>
450 llvm::dyn_cast<LLVMPointerType>(callOp.getOperand(0).getType());
452 return callOp.emitOpError(
"indirect call expects a pointer as callee: ")
453 << callOp.getOperand(0).getType();
461 return callOp.emitOpError()
463 <<
"' does not reference a symbol in the current scope";
464 if (
auto fn = dyn_cast<LLVMFuncOp>(callee)) {
467 fnType = fn.getFunctionType();
468 }
else if (
auto ifunc = dyn_cast<IFuncOp>(callee)) {
469 fnType = ifunc.getIFuncType();
470 }
else if (isa<AliasOp>(callee)) {
474 fnType = callOp.getCalleeFunctionType();
476 return callOp.emitOpError()
478 <<
"' does not reference a valid LLVM function, IFunc, or alias";
482 LLVMFunctionType funcType = llvm::dyn_cast<LLVMFunctionType>(fnType);
484 return callOp.emitOpError(
"callee does not have a functional type: ")
487 if (funcType.isVarArg() && !callOp.getVarCalleeType())
488 return callOp.emitOpError()
489 <<
"missing var_callee_type attribute for vararg call";
493 if (callOp.getNumResults() == 0 &&
494 !llvm::isa<LLVM::LLVMVoidType>(funcType.getReturnType()))
495 return callOp.emitOpError() <<
"expected function call to produce a value";
497 if (callOp.getNumResults() != 0 &&
498 llvm::isa<LLVM::LLVMVoidType>(funcType.getReturnType()))
499 return callOp.emitOpError()
500 <<
"calling function with void result must not produce values";
502 if (callOp.getNumResults() > 1)
503 return callOp.emitOpError()
504 <<
"expected LLVM function call to produce 0 or 1 result";
506 if (callOp.getNumResults() &&
507 callOp.getResult().getType() != funcType.getReturnType())
508 return callOp.emitOpError()
509 <<
"result type mismatch: " << callOp.getResult().getType()
510 <<
" != " << funcType.getReturnType();
516 if (!llvm::isa<LLVM::LLVMVoidType>(funcType.getReturnType()))
517 calleeResultTypes.push_back(funcType.getReturnType());
519 callOp, funcType.getParams(), calleeResultTypes);
527 auto callee = getCallee();
528 bool isDirect = callee.has_value();
533 if (getCConv() != LLVM::CConv::C)
534 p << stringifyCConv(getCConv()) <<
' ';
536 if (getTailCallKind() != LLVM::TailCallKind::None)
537 p << tailcallkind::stringifyTailCallKind(getTailCallKind()) <<
' ';
546 auto args = getCalleeOperands().drop_front(isDirect ? 0 : 1);
547 p <<
'(' << args <<
')';
550 if (std::optional<LLVMFunctionType> varCalleeType = getVarCalleeType())
551 p <<
" vararg(" << *varCalleeType <<
")";
553 if (!getOpBundleOperands().empty()) {
556 getOpBundleOperands().getTypes(), getOpBundleTags());
560 {getCalleeAttrName(), getTailCallKindAttrName(),
561 getVarCalleeTypeAttrName(), getCConvAttrName(),
562 getOperandSegmentSizesAttrName(),
563 getOpBundleSizesAttrName(),
564 getOpBundleTagsAttrName(), getArgAttrsAttrName(),
565 getResAttrsAttrName()});
569 p << getOperand(0).getType() <<
", ";
573 p, args.getTypes(), getArgAttrsAttr(),
574 false, getResultTypes(), getResAttrsAttr());
589 types.emplace_back();
594 trailingTypesLoc,
"expected indirect call to have 2 trailing types");
599 resTypes, resultAttrs)) {
601 return parser.
emitError(trailingTypesLoc,
602 "expected direct call to have 1 trailing types");
603 return parser.
emitError(trailingTypesLoc,
604 "expected trailing function type");
607 if (resTypes.size() > 1)
608 return parser.
emitError(trailingTypesLoc,
609 "expected function with 0 or 1 result");
610 if (resTypes.size() == 1 && llvm::isa<LLVM::LLVMVoidType>(resTypes[0]))
611 return parser.
emitError(trailingTypesLoc,
612 "expected a non-void result type");
618 llvm::append_range(types, argTypes);
622 if (!resTypes.empty())
623 result.addTypes(resTypes);
636 if (failed(*parseResult))
638 operands.push_back(funcPtrOperand);
647 StringAttr opBundleSizesAttrName) {
648 unsigned opBundleIndex = 0;
649 for (
const auto &[operands, types] :
650 llvm::zip_equal(opBundleOperands, opBundleOperandTypes)) {
651 if (operands.size() != types.size())
652 return parser.
emitError(loc,
"expected ")
654 <<
" types for operand bundle operands for operand bundle #"
655 << opBundleIndex <<
", but actually got " << types.size();
661 opBundleSizes.reserve(opBundleOperands.size());
662 for (
const auto &operands : opBundleOperands)
663 opBundleSizes.push_back(operands.size());
666 opBundleSizesAttrName,
678 SymbolRefAttr funcAttr;
679 TypeAttr varCalleeType;
687 getCConvAttrName(
result.name),
692 getTailCallKindAttrName(
result.name),
695 parser, LLVM::TailCallKind::None)));
700 bool isDirect = operands.empty();
713 StringAttr varCalleeTypeAttrName =
714 CallOp::getVarCalleeTypeAttrName(
result.name);
726 parser, opBundleOperands, opBundleOperandTypes, opBundleTags);
729 if (opBundleTags && !opBundleTags.empty())
730 result.addAttribute(CallOp::getOpBundleTagsAttrName(
result.name).getValue(),
740 argAttrs, resultAttrs))
744 getArgAttrsAttrName(
result.name), getResAttrsAttrName(
result.name));
746 opBundleOperandTypes,
747 getOpBundleSizesAttrName(
result.name)))
750 int32_t numOpBundleOperands = 0;
751 for (
const auto &operands : opBundleOperands)
752 numOpBundleOperands += operands.size();
755 CallOp::getOperandSegmentSizeAttr(),
757 {static_cast<int32_t>(operands.size()), numOpBundleOperands}));
761LLVMFunctionType CallOp::getCalleeFunctionType() {
762 if (std::optional<LLVMFunctionType> varCalleeType = getVarCalleeType())
763 return *varCalleeType;
774 auto calleeType =
func.getFunctionType();
777 nullptr,
nullptr, normalOps, unwindOps,
778 nullptr,
nullptr,
nullptr,
779 nullptr, {}, {}, normal, unwind);
786 build(builder, state, tys,
787 nullptr, callee, ops,
nullptr,
788 nullptr, normalOps, unwindOps,
nullptr,
nullptr,
790 nullptr, {}, {}, normal, unwind);
799 nullptr,
nullptr, normalOps, unwindOps,
800 nullptr,
nullptr,
nullptr,
801 nullptr, {}, {}, normal, unwind);
805 assert(
index < getNumSuccessors() &&
"invalid successor index");
807 : getUnwindDestOperandsMutable());
815 return getOperand(0);
821 auto symRef = cast<SymbolRefAttr>(callee);
822 return setCalleeAttr(cast<FlatSymbolRefAttr>(symRef));
825 return setOperand(0, cast<Value>(callee));
843LogicalResult InvokeOp::verify() {
844 Block *unwindDest = getUnwindDest();
845 if (unwindDest->
empty())
846 return emitError(
"must have at least one operation in unwind destination");
849 if (!isa<LandingpadOp>(unwindDest->
front()))
850 return emitError(
"first operation in unwind destination should be a "
851 "llvm.landingpad operation");
860 auto callee = getCallee();
861 bool isDirect = callee.has_value();
866 if (getCConv() != LLVM::CConv::C)
867 p << stringifyCConv(getCConv()) <<
' ';
875 p <<
'(' << getCalleeOperands().drop_front(isDirect ? 0 : 1) <<
')';
882 if (std::optional<LLVMFunctionType> varCalleeType = getVarCalleeType())
883 p <<
" vararg(" << *varCalleeType <<
")";
885 if (!getOpBundleOperands().empty()) {
888 getOpBundleOperands().getTypes(), getOpBundleTags());
892 {getCalleeAttrName(), getOperandSegmentSizeAttr(),
893 getCConvAttrName(), getVarCalleeTypeAttrName(),
894 getOpBundleSizesAttrName(),
895 getOpBundleTagsAttrName(), getArgAttrsAttrName(),
896 getResAttrsAttrName()});
900 p << getOperand(0).getType() <<
", ";
902 p, getCalleeOperands().drop_front(isDirect ? 0 : 1).getTypes(),
904 false, getResultTypes(), getResAttrsAttr());
917 SymbolRefAttr funcAttr;
918 TypeAttr varCalleeType;
922 Block *normalDest, *unwindDest;
928 getCConvAttrName(
result.name),
935 bool isDirect = operands.empty();
951 StringAttr varCalleeTypeAttrName =
952 InvokeOp::getVarCalleeTypeAttrName(
result.name);
964 parser, opBundleOperands, opBundleOperandTypes, opBundleTags);
967 if (opBundleTags && !opBundleTags.empty())
969 InvokeOp::getOpBundleTagsAttrName(
result.name).getValue(),
979 argAttrs, resultAttrs))
983 getArgAttrsAttrName(
result.name), getResAttrsAttrName(
result.name));
985 result.addSuccessors({normalDest, unwindDest});
986 result.addOperands(normalOperands);
987 result.addOperands(unwindOperands);
990 opBundleOperandTypes,
991 getOpBundleSizesAttrName(
result.name)))
994 int32_t numOpBundleOperands = 0;
995 for (
const auto &operands : opBundleOperands)
996 numOpBundleOperands += operands.size();
999 InvokeOp::getOperandSegmentSizeAttr(),
1001 static_cast<int32_t>(normalOperands.size()),
1002 static_cast<int32_t>(unwindOperands.size()),
1003 numOpBundleOperands}));
1007LLVMFunctionType InvokeOp::getCalleeFunctionType() {
1008 if (std::optional<LLVMFunctionType> varCalleeType = getVarCalleeType())
1009 return *varCalleeType;
1017LogicalResult LandingpadOp::verify() {
1019 if (LLVMFuncOp
func = (*this)->getParentOfType<LLVMFuncOp>()) {
1020 if (!
func.getPersonality())
1022 "llvm.landingpad needs to be in a function with a personality");
1028 if (!getCleanup() && getOperands().empty())
1029 return emitError(
"landingpad instruction expects at least one clause or "
1030 "cleanup attribute");
1033 value = getOperand(idx);
1034 bool isFilter = llvm::isa<LLVMArrayType>(value.
getType());
1041 if (
auto addrOp = bcOp.getArg().getDefiningOp<AddressOfOp>())
1044 <<
"global addresses expected as operand to "
1045 "bitcast used in clauses for landingpad";
1053 << idx <<
" is not a known constant - null, addressof, bitcast";
1060 p << (getCleanup() ?
" cleanup " :
" ");
1063 for (
auto value : getOperands()) {
1066 bool isArrayTy = llvm::isa<LLVMArrayType>(value.
getType());
1067 p <<
'(' << (isArrayTy ?
"filter " :
"catch ") << value <<
" : "
1108LogicalResult CallIntrinsicOp::verify() {
1109 if (!getIntrin().starts_with(
"llvm."))
1110 return emitOpError() <<
"intrinsic name must start with 'llvm.'";
1118 build(builder, state,
TypeRange{}, intrin, args,
1119 FastmathFlagsAttr{},
1126 mlir::LLVM::FastmathFlagsAttr fastMathFlags) {
1127 build(builder, state,
TypeRange{}, intrin, args,
1134 mlir::Type resultType, mlir::StringAttr intrin,
1136 build(builder, state, {resultType}, intrin, args, FastmathFlagsAttr{},
1144 mlir::LLVM::FastmathFlagsAttr fastMathFlags) {
1145 build(builder, state, resultTypes, intrin, args, fastMathFlags,
1150ParseResult CallIntrinsicOp::parse(
OpAsmParser &parser,
1152 StringAttr intrinAttr;
1162 result.addAttribute(CallIntrinsicOp::getIntrinAttrName(
result.name),
1170 return mlir::failure();
1173 return mlir::failure();
1178 parser, opBundleOperands, opBundleOperandTypes, opBundleTags);
1181 if (opBundleTags && !opBundleTags.empty())
1183 CallIntrinsicOp::getOpBundleTagsAttrName(
result.name).getValue(),
1187 return mlir::failure();
1192 operands, argAttrs, resultAttrs))
1196 getArgAttrsAttrName(
result.name), getResAttrsAttrName(
result.name));
1199 opBundleOperandTypes,
1200 getOpBundleSizesAttrName(
result.name)))
1203 int32_t numOpBundleOperands = 0;
1204 for (
const auto &operands : opBundleOperands)
1205 numOpBundleOperands += operands.size();
1208 CallIntrinsicOp::getOperandSegmentSizeAttr(),
1210 {static_cast<int32_t>(operands.size()), numOpBundleOperands}));
1212 return mlir::success();
1220 p <<
"(" << args <<
")";
1223 if (!getOpBundleOperands().empty()) {
1226 getOpBundleOperands().getTypes(), getOpBundleTagsAttr());
1230 {getOperandSegmentSizesAttrName(),
1231 getOpBundleSizesAttrName(), getIntrinAttrName(),
1232 getOpBundleTagsAttrName(), getArgAttrsAttrName(),
1233 getResAttrsAttrName()});
1239 p, args.
getTypes(), getArgAttrsAttr(),
1240 false, getResultTypes(), getResAttrsAttr());
1247void InlineAsmOp::getEffects(
1250 if (getHasSideEffects()) {
1260LogicalResult InlineAsmOp::verify() {
1261 if (!getTailCallKindAttr())
1264 if (getTailCallKindAttr().getTailCallKind() == TailCallKind::MustTail)
1266 "tail call kind 'musttail' is not supported by this operation");
1277 if (!getCallee().has_value() && !operands.empty())
1278 operands = operands.drop_front();
1279 return llvm::filter_to_vector(
1280 operands, [](
Value arg) {
return isa<LLVMPointerType>(arg.
getType()); });
1283#define GET_OP_CLASSES
1284#include "mlir/Dialect/LLVMIR/LLVMCallOps.cpp.inc"
getNumOperands() - 1))) return failure()
Given a list of lists of parsed operands, populates uniqueOperands with unique operands.
static LogicalResult verifyCallOpSymbolUses(OpTy callOp, SymbolTableCollection &symbolTable)
static void printOneOpBundle(OpAsmPrinter &p, OperandRange operands, TypeRange operandTypes, StringRef tag)
static unsigned getNumConsumedCalleeOperands(OpTy callOp)
Return the number of leading callee operands of callOp that the operation consumes instead of passing...
static LLVMFunctionType getLLVMFuncType(MLIRContext *context, TypeRange results, ValueRange args)
Constructs a LLVMFunctionType from MLIR results and args.
static LogicalResult verifyCallOpVarCalleeType(OpTy callOp)
Verify that the parameter and return types of the variadic callee type match the callOp argument and ...
static ParseResult parseOptionalCallFuncPtr(OpAsmParser &parser, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &operands)
Parses an optional function pointer operand before the call argument list for indirect calls,...
static Operation::operand_range getOperandsPassedToCallee(OpTy callOp)
Return the operands of callOp that are passed to the callee, including the variadic arguments in case...
static LogicalResult verifyCallOpDebugInfo(OpTy callOp, LLVMFuncOp callee)
Verify that an inlinable callsite of a debug-info-bearing function in a debug-info-bearing function h...
static auto processFMFAttr(ArrayRef< NamedAttribute > attrs)
static TypeAttr getCallOpVarCalleeType(LLVMFunctionType calleeType)
Gets the variadic callee type for a LLVMFunctionType.
static ParseResult parseOneOpBundle(OpAsmParser &p, SmallVector< SmallVector< OpAsmParser::UnresolvedOperand > > &opBundleOperands, SmallVector< SmallVector< Type > > &opBundleOperandTypes, SmallVector< Attribute > &opBundleTags)
static ParseResult resolveOpBundleOperands(OpAsmParser &parser, SMLoc loc, OperationState &state, ArrayRef< SmallVector< OpAsmParser::UnresolvedOperand > > opBundleOperands, ArrayRef< SmallVector< Type > > opBundleOperandTypes, StringAttr opBundleSizesAttrName)
static ParseResult parseCallTypeAndResolveOperands(OpAsmParser &parser, OperationState &result, bool isDirect, ArrayRef< OpAsmParser::UnresolvedOperand > operands, SmallVectorImpl< DictionaryAttr > &argAttrs, SmallVectorImpl< DictionaryAttr > &resultAttrs)
Parses the type of a call operation and resolves the operands if the parsing succeeds.
static SmallVector< Type, 1 > getCallOpResultTypes(LLVMFunctionType calleeType)
Gets the MLIR Op-like result types of a LLVMFunctionType.
static Operation::operand_range getArgOperandsImpl(OpTy callOp)
Return the operands of callOp that correspond to the declared parameters of the callee,...
@ Paren
Parens surrounding zero or more operands.
virtual Builder & getBuilder() const =0
Return a builder which provides useful access to MLIRContext, global objects like types and attribute...
virtual ParseResult parseCommaSeparatedList(Delimiter delimiter, function_ref< ParseResult()> parseElementFn, StringRef contextMessage=StringRef())=0
Parse a list of comma-separated items with an optional delimiter.
virtual ParseResult parseOptionalAttrDict(NamedAttrList &result)=0
Parse a named dictionary into 'result' if it is present.
virtual ParseResult parseOptionalKeyword(StringRef keyword)=0
Parse the given keyword if present.
MLIRContext * getContext() const
virtual ParseResult parseRParen()=0
Parse a ) token.
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
virtual ParseResult parseRSquare()=0
Parse a ] token.
virtual ParseResult parseOptionalRParen()=0
Parse a ) token if present.
virtual ParseResult parseCustomAttributeWithFallback(Attribute &result, Type type, function_ref< ParseResult(Attribute &result, Type type)> parseAttribute)=0
Parse a custom attribute with the provided callback, unless the next token is #, in which case the ge...
ParseResult parseString(std::string *string)
Parse a quoted string token.
virtual SMLoc getCurrentLocation()=0
Get the location of the next token and store it into the argument.
virtual ParseResult parseOptionalComma()=0
Parse a , token if present.
virtual ParseResult parseColon()=0
Parse a : token.
virtual SMLoc getNameLoc() const =0
Return the location of the original name token.
virtual ParseResult parseOptionalRSquare()=0
Parse a ] token if present.
virtual ParseResult parseLParen()=0
Parse a ( token.
virtual ParseResult parseType(Type &result)=0
Parse a type.
virtual ParseResult parseOptionalLParen()=0
Parse a ( token if present.
ParseResult parseTypeList(SmallVectorImpl< Type > &result)
Parse a type list.
ParseResult parseKeyword(StringRef keyword)
Parse a given keyword.
virtual ParseResult parseOptionalLSquare()=0
Parse a [ token if present.
virtual ParseResult parseAttribute(Attribute &result, Type type={})=0
Parse an arbitrary attribute of a given type and return it in result.
virtual void printAttributeWithoutType(Attribute attr)
Print the given attribute without its type.
virtual void printSymbolName(StringRef symbolRef)
Print the given string as a symbol reference, i.e.
virtual void printString(StringRef string)
Print the given string as a quoted string, escaping any special or non-printable characters in it.
MLIRContext * getContext() const
Return the context this attribute belongs to.
Block represents an ordered list of Operations.
This class is a general helper class for creating context-global objects like types,...
DenseI32ArrayAttr getDenseI32ArrayAttr(ArrayRef< int32_t > values)
Ty getType(Args &&...args)
Get or construct an instance of the type Ty with provided arguments.
StringAttr getStringAttr(const Twine &bytes)
A symbol reference with a reference path containing a single element.
StringRef getValue() const
Returns the name of the held symbol reference.
StringAttr getAttr() const
Returns the name of the held symbol reference as a StringAttr.
This class represents a fused location whose metadata is known to be an instance of the given type.
Diagnostic & attachNote(std::optional< Location > noteLoc=std::nullopt)
Attaches a note to this diagnostic.
T findInstanceOf()
Return an instance of the given location type if one is nested under the current location.
MLIRContext is the top-level object for a collection of MLIR operations.
This class provides a mutable adaptor for a range of operands.
MutableOperandRange slice(unsigned subStart, unsigned subLen, std::optional< OperandSegment > segment=std::nullopt) const
Slice this range into a sub range, with the additional operand segment.
ArrayRef< NamedAttribute > getAttrs() const
Return all of the attributes on this operation.
NamedAttribute represents a combination of a name and an Attribute value.
StringAttr getName() const
Return the name of the attribute.
Attribute getValue() const
Return the value of the attribute.
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
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 OptionalParseResult parseOptionalOperand(UnresolvedOperand &result, bool allowResultNumber=true)=0
Parse a single operand if present.
virtual ParseResult parseSuccessorAndUseList(Block *&dest, SmallVectorImpl< Value > &operands)=0
Parse a single operation successor and its operand list.
ParseResult resolveOperands(Operands &&operands, Type type, SmallVectorImpl< Value > &result)
Resolve a list of operands to SSA values, emitting an error on failure, or appending the results to t...
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.
virtual ParseResult parseOperandList(SmallVectorImpl< UnresolvedOperand > &result, Delimiter delimiter=Delimiter::None, bool allowResultNumber=true, int requiredOperandCount=-1)=0
Parse zero or more SSA comma-separated operand references with a specified surrounding delimiter,...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
virtual void printSuccessorAndUseList(Block *successor, ValueRange succOperands)=0
Print the successor and its operands.
void printOperands(OperandRange operands)
Print a comma separated range of operation operands out of line to avoid instantiating the range iter...
virtual void printOptionalAttrDict(ArrayRef< NamedAttribute > attrs, ArrayRef< StringRef > elidedAttrs={})=0
If the specified operation has attributes, print out an attribute dictionary with their values.
This class helps build Operations.
This class represents a contiguous range of operand ranges, e.g.
This class implements the operand iterators for the Operation class.
type_range getTypes() const
Operation is the basic unit of execution within MLIR.
Location getLoc()
The source location the operation was defined or derived from.
OperandRange operand_range
This class implements Optional functionality for ParseResult.
bool has_value() const
Returns true if we contain a valid ParseResult value.
This class represents a specific instance of an effect.
static DerivedEffect * get()
This class models how operands are forwarded to block arguments in control flow.
This class represents a collection of SymbolTables.
virtual Operation * lookupNearestSymbolFrom(Operation *from, StringAttr symbol)
Returns the operation registered with the given symbol name within the closest parent operation of,...
This class provides an abstraction for a range of TypeRange.
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 provides an abstraction over the different types of ranges over Values.
type_range getTypes() const
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.
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
static DenseArrayAttrImpl get(MLIRContext *context, ArrayRef< int32_t > content)
NamedAttrList getAttrsForPrinting(Operation *op)
Returns the attributes of op to print: its discardable attributes and all its inherent attributes.
void printOpBundles(mlir::OpAsmPrinter &p, mlir::Operation *op, mlir::OperandRangeRange opBundleOperands, mlir::TypeRangeRange opBundleOperandTypes, std::optional< mlir::ArrayAttr > opBundleTags)
RetTy parseOptionalLLVMKeyword(OpAsmParser &parser, EnumTy defaultValue)
Parse an enum from the keyword, or default to the provided default value.
LogicalResult verifyOperandBundles(OpType &op)
Verifies the operand bundles of op.
std::optional< mlir::ParseResult > parseOpBundles(mlir::OpAsmParser &p, mlir::SmallVector< mlir::SmallVector< mlir::OpAsmParser::UnresolvedOperand > > &opBundleOperands, mlir::SmallVector< mlir::SmallVector< mlir::Type > > &opBundleOperandTypes, mlir::ArrayAttr &opBundleTags)
void printFunctionSignature(OpAsmPrinter &p, TypeRange argTypes, ArrayAttr argAttrs, bool isVariadic, TypeRange resultTypes, ArrayAttr resultAttrs, Region *body=nullptr, bool printEmptyResult=true)
Print a function signature for a call or callable operation.
ParseResult parseFunctionSignature(OpAsmParser &parser, SmallVectorImpl< Type > &argTypes, SmallVectorImpl< DictionaryAttr > &argAttrs, SmallVectorImpl< Type > &resultTypes, SmallVectorImpl< DictionaryAttr > &resultAttrs, bool mustParseEmptyResult=true)
Parses a function signature using parser.
LogicalResult verifyCallOpInterface(CallOpInterface call, TypeRange argumentTypes, TypeRange resultTypes)
Verify that the forwarded operands and results of call are in a 1:1 relationship with the given argum...
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,...
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.
A callable is either a symbol, or an SSA value, that is referenced by a call-like operation.
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 addAttribute(StringRef name, Attribute attr)
Add an attribute with the specified name.