9#ifndef MLIR_LIB_DIALECT_LLVMIR_IR_LLVMOPS_H
10#define MLIR_LIB_DIALECT_LLVMIR_IR_LLVMOPS_H
26 mlir::LLVM::ICmpPredicateAttr &predicate);
28 mlir::LLVM::FCmpPredicateAttr &predicate);
30 mlir::LLVM::ICmpPredicateAttr predicate);
32 mlir::LLVM::FCmpPredicateAttr predicate);
35 mlir::LLVM::LinkageAttr val);
37 mlir::LLVM::LinkageAttr &val);
42 std::optional<mlir::ArrayAttr> opBundleTags);
48 mlir::ArrayAttr &opBundleTags);
95 mlir::LLVM::IndirectBrOp op,
127using cconv::getMaxEnumValForCConv;
128using linkage::getMaxEnumValForLinkage;
129using tailcallkind::getMaxEnumValForTailCallKind;
131template <
typename Ty>
134#define REGISTER_ENUM_TYPE(Ty) \
136 struct EnumTraits<Ty> { \
137 static StringRef stringify(Ty value) { return stringify##Ty(value); } \
138 static unsigned getMaxEnumVal() { return getMaxEnumValFor##Ty(); } \
148#undef REGISTER_ENUM_TYPE
154template <
typename EnumTy,
typename RetTy = EnumTy>
164 return static_cast<RetTy
>(defaultValue);
165 return static_cast<RetTy
>(
index);
169template <
typename OpType>
172 std::optional<ArrayAttr> opBundleTags = op.getOpBundleTags();
174 auto isStringAttr = [](
Attribute tagAttr) {
175 return isa<StringAttr>(tagAttr);
177 if (opBundleTags && !llvm::all_of(*opBundleTags, isStringAttr))
178 return op.emitError(
"operand bundle tag must be a StringAttr");
180 size_t numOpBundles = opBundleOperands.size();
181 size_t numOpBundleTags = opBundleTags ? opBundleTags->size() : 0;
182 if (numOpBundles != numOpBundleTags)
183 return op.emitError(
"expected ")
184 << numOpBundles <<
" operand bundle tags, but actually got "
#define REGISTER_ENUM_TYPE(Ty)
This base class exposes generic asm parser hooks, usable across the various derived parsers.
This base class exposes generic asm printer hooks, usable across the various derived printers.
Attributes are known-constant values of operations.
An attribute that represents a reference to a dense integer vector or tensor object.
NamedAttrList is array of NamedAttributes that tracks whether it is sorted and does some basic work t...
The OpAsmParser has methods for interacting with the asm parser: parsing things from it,...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
This class represents a contiguous range of operand ranges, e.g.
This class implements the operand iterators for the Operation class.
Operation is the basic unit of execution within MLIR.
This class implements the successor iterators for Block.
This class provides an abstraction for a range of TypeRange.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
mlir::ParseResult parseCmpPredicate(mlir::OpAsmParser &parser, mlir::LLVM::ICmpPredicateAttr &predicate)
NamedAttrList getAttrsForPrinting(Operation *op)
Returns the attributes of op to print: its discardable attributes and all its inherent attributes.
void printCmpPredicate(mlir::OpAsmPrinter &printer, mlir::Operation *, mlir::LLVM::ICmpPredicateAttr predicate)
Type extractVectorElementType(Type type)
Returns the elemental type of any LLVM-compatible vector type or self.
mlir::ParseResult parseInsertExtractValueElementType(mlir::AsmParser &parser, mlir::Type &valueType, mlir::Type containerType, mlir::DenseI64ArrayAttr position)
Infer the value type from the container type and position.
void printLLVMLinkage(mlir::OpAsmPrinter &p, mlir::Operation *, mlir::LLVM::LinkageAttr val)
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.
bool forwardToUsers(Operation *op, SmallVectorImpl< OpOperand * > &newBlockingUses)
Conditions the deletion of the operation to the removal of all its uses.
mlir::ParseResult parseShuffleType(mlir::AsmParser &parser, mlir::Type v1Type, mlir::Type &resType, mlir::DenseI32ArrayAttr mask)
Build the result type of a shuffle vector operation.
void printShuffleType(mlir::AsmPrinter &printer, mlir::Operation *op, mlir::Type v1Type, mlir::Type resType, mlir::DenseI32ArrayAttr mask)
Nothing to do when the result type is inferred.
mlir::Type getI1SameShape(mlir::Type type)
Returns a boolean type that has the same shape as type.
void printSwitchOpCases(mlir::OpAsmPrinter &p, mlir::LLVM::SwitchOp op, mlir::Type flagType, mlir::DenseIntElementsAttr caseValues, mlir::SuccessorRange caseDestinations, mlir::OperandRangeRange caseOperands, const mlir::TypeRangeRange &caseOperandTypes)
void printIndirectBrOpSucessors(mlir::OpAsmPrinter &p, mlir::LLVM::IndirectBrOp op, mlir::Type flagType, mlir::SuccessorRange succs, mlir::OperandRangeRange succOperands, const mlir::TypeRangeRange &succOperandsTypes)
mlir::ParseResult parseIndirectBrOpSucessors(mlir::OpAsmParser &parser, mlir::Type &flagType, mlir::SmallVectorImpl< mlir::Block * > &succOperandBlocks, mlir::SmallVectorImpl< mlir::SmallVector< mlir::OpAsmParser::UnresolvedOperand > > &succOperands, mlir::SmallVectorImpl< mlir::SmallVector< mlir::Type > > &succOperandsTypes)
mlir::ParseResult parseLLVMLinkage(mlir::OpAsmParser &p, mlir::LLVM::LinkageAttr &val)
mlir::LLVM::LLVMStructType getValAndBoolStructType(mlir::Type valType)
Returns an LLVM struct type that contains a value type and a boolean type.
int parseOptionalKeywordAlternative(OpAsmParser &parser, ArrayRef< StringRef > keywords)
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)
mlir::ParseResult parseGEPIndices(mlir::OpAsmParser &parser, mlir::SmallVectorImpl< mlir::OpAsmParser::UnresolvedOperand > &indices, mlir::DenseI32ArrayAttr &rawConstantIndices)
void printGEPIndices(mlir::OpAsmPrinter &printer, mlir::LLVM::GEPOp gepOp, mlir::OperandRange indices, mlir::DenseI32ArrayAttr rawConstantIndices)
void printInsertExtractValueElementType(mlir::AsmPrinter &printer, mlir::Operation *op, mlir::Type valueType, mlir::Type containerType, mlir::DenseI64ArrayAttr position)
Nothing to print for an inferred type.
mlir::ParseResult parseSwitchOpCases(mlir::OpAsmParser &parser, mlir::Type flagType, mlir::DenseIntElementsAttr &caseValues, mlir::SmallVectorImpl< mlir::Block * > &caseDestinations, mlir::SmallVectorImpl< mlir::SmallVector< mlir::OpAsmParser::UnresolvedOperand > > &caseOperands, mlir::SmallVectorImpl< mlir::SmallVector< mlir::Type > > &caseOperandTypes)
<cases> ::= [ (case (, case )* )?
detail::DenseArrayAttrImpl< int64_t > DenseI64ArrayAttr
detail::DenseArrayAttrImpl< int32_t > DenseI32ArrayAttr