MLIR 24.0.0git
GPUBase.cpp
Go to the documentation of this file.
1//===- GPUBase.cpp - GPU types and attributes -----------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements GPU types, attributes, and enums.
10//
11//===----------------------------------------------------------------------===//
12
14
15#include "mlir/IR/Builders.h"
17#include "llvm/ADT/TypeSwitch.h"
18#include "llvm/Support/CommandLine.h"
19#include "llvm/Support/StringSaver.h"
20
21using namespace mlir;
22using namespace mlir::gpu;
23
24//===----------------------------------------------------------------------===//
25// GPU Device Mapping Attributes
26//===----------------------------------------------------------------------===//
27
28int64_t GPUBlockMappingAttr::getMappingId() const {
29 return static_cast<int64_t>(getBlock());
30}
31
32bool GPUBlockMappingAttr::isLinearMapping() const {
33 return getMappingId() >= static_cast<int64_t>(MappingId::LinearDim0);
34}
35
36int64_t GPUBlockMappingAttr::getRelativeIndex() const {
37 return isLinearMapping()
38 ? getMappingId() - static_cast<int64_t>(MappingId::LinearDim0)
39 : getMappingId();
40}
41
42int64_t GPUWarpgroupMappingAttr::getMappingId() const {
43 return static_cast<int64_t>(getWarpgroup());
44}
45
46bool GPUWarpgroupMappingAttr::isLinearMapping() const {
47 return getMappingId() >= static_cast<int64_t>(MappingId::LinearDim0);
48}
49
50int64_t GPUWarpgroupMappingAttr::getRelativeIndex() const {
51 return isLinearMapping()
52 ? getMappingId() - static_cast<int64_t>(MappingId::LinearDim0)
53 : getMappingId();
54}
55
56int64_t GPUWarpMappingAttr::getMappingId() const {
57 return static_cast<int64_t>(getWarp());
58}
59
60bool GPUWarpMappingAttr::isLinearMapping() const {
61 return getMappingId() >= static_cast<int64_t>(MappingId::LinearDim0);
62}
63
64int64_t GPUWarpMappingAttr::getRelativeIndex() const {
65 return isLinearMapping()
66 ? getMappingId() - static_cast<int64_t>(MappingId::LinearDim0)
67 : getMappingId();
68}
69
70int64_t GPUThreadMappingAttr::getMappingId() const {
71 return static_cast<int64_t>(getThread());
72}
73
74bool GPUThreadMappingAttr::isLinearMapping() const {
75 return getMappingId() >= static_cast<int64_t>(MappingId::LinearDim0);
76}
77
78int64_t GPUThreadMappingAttr::getRelativeIndex() const {
79 return isLinearMapping()
80 ? getMappingId() - static_cast<int64_t>(MappingId::LinearDim0)
81 : getMappingId();
82}
83
84int64_t GPULaneMappingAttr::getMappingId() const {
85 return static_cast<int64_t>(getLane());
86}
87
88bool GPULaneMappingAttr::isLinearMapping() const {
89 return getMappingId() >= static_cast<int64_t>(MappingId::LinearDim0);
90}
91
92int64_t GPULaneMappingAttr::getRelativeIndex() const {
93 return isLinearMapping()
94 ? getMappingId() - static_cast<int64_t>(MappingId::LinearDim0)
95 : getMappingId();
96}
97
98int64_t GPUMemorySpaceMappingAttr::getMappingId() const {
99 return static_cast<int64_t>(getAddressSpace());
100}
101
102bool GPUMemorySpaceMappingAttr::isLinearMapping() const {
103 llvm_unreachable("GPUMemorySpaceMappingAttr does not support linear mapping");
104}
105
106int64_t GPUMemorySpaceMappingAttr::getRelativeIndex() const {
107 llvm_unreachable("GPUMemorySpaceMappingAttr does not support relative index");
108}
109
110//===----------------------------------------------------------------------===//
111// MMAMatrixType
112//===----------------------------------------------------------------------===//
113
115 StringRef operand) {
116 return Base::get(elementType.getContext(), shape, elementType, operand);
117}
118
121 ArrayRef<int64_t> shape, Type elementType,
122 StringRef operand) {
123 return Base::getChecked(emitError, elementType.getContext(), shape,
124 elementType, operand);
125}
126
127unsigned MMAMatrixType::getNumDims() const { return getImpl()->numDims; }
128
130 return getImpl()->getShape();
131}
132
133Type MMAMatrixType::getElementType() const { return getImpl()->elementType; }
134
135StringRef MMAMatrixType::getOperand() const { return getImpl()->getOperand(); }
136
138 return elementType.isF16() || elementType.isF32() || elementType.isF64() ||
139 elementType.isUnsignedInteger(8) || elementType.isSignedInteger(8) ||
140 elementType.isInteger(32);
141}
142
143LogicalResult
145 ArrayRef<int64_t> shape, Type elementType,
146 StringRef operand) {
147 if (operand != "AOp" && operand != "BOp" && operand != "COp")
148 return emitError() << "operand expected to be one of AOp, BOp or COp";
149
150 if (shape.size() != 2)
151 return emitError() << "MMAMatrixType must have exactly two dimensions";
152
153 if (!MMAMatrixType::isValidElementType(elementType))
154 return emitError()
155 << "MMAMatrixType elements must be SI8, UI8, I32, F16, F32, or F64";
156
157 return success();
158}
159
160//===----------------------------------------------------------------------===//
161// GPUDialect
162//===----------------------------------------------------------------------===//
163
164bool GPUDialect::isWorkgroupMemoryAddressSpace(Attribute memorySpace) {
165 if (!memorySpace)
166 return false;
167 if (auto gpuAttr = llvm::dyn_cast<gpu::AddressSpaceAttr>(memorySpace))
168 return gpuAttr.getValue() == getWorkgroupAddressSpace();
169 return false;
170}
171
172bool GPUDialect::hasWorkgroupMemoryAddressSpace(MemRefType type) {
173 Attribute memorySpace = type.getMemorySpace();
174 return isWorkgroupMemoryAddressSpace(memorySpace);
175}
176
177bool GPUDialect::isConstantMemoryAddressSpace(Attribute memorySpace) {
178 if (!memorySpace)
179 return false;
180 if (auto gpuAttr = llvm::dyn_cast<gpu::AddressSpaceAttr>(memorySpace))
181 return gpuAttr.getValue() == getConstantAddressSpace();
182 return false;
183}
184
185bool GPUDialect::hasConstantMemoryAddressSpace(MemRefType type) {
186 Attribute memorySpace = type.getMemorySpace();
187 return isConstantMemoryAddressSpace(memorySpace);
188}
189
190//===----------------------------------------------------------------------===//
191// GPU object attribute
192//===----------------------------------------------------------------------===//
193
194LogicalResult ObjectAttr::verify(function_ref<InFlightDiagnostic()> emitError,
195 Attribute target, CompilationTarget format,
196 StringAttr object, DictionaryAttr properties,
197 KernelTableAttr kernels) {
198 if (!target)
199 return emitError() << "the target attribute cannot be null";
200 if (target.hasPromiseOrImplementsInterface<TargetAttrInterface>())
201 return success();
202 return emitError() << "the target attribute must implement or promise the "
203 "`gpu::TargetAttrInterface`";
204}
205
206namespace {
207ParseResult parseObject(AsmParser &odsParser, CompilationTarget &format,
208 StringAttr &object) {
209 std::optional<CompilationTarget> formatResult;
210 StringRef enumKeyword;
211 auto loc = odsParser.getCurrentLocation();
212 if (failed(odsParser.parseOptionalKeyword(&enumKeyword)))
213 formatResult = CompilationTarget::Fatbin;
214 if (!formatResult &&
215 (formatResult =
216 gpu::symbolizeEnum<gpu::CompilationTarget>(enumKeyword)) &&
217 odsParser.parseEqual())
218 return odsParser.emitError(loc, "expected an equal sign");
219 if (!formatResult)
220 return odsParser.emitError(loc, "expected keyword for GPU object format");
221 FailureOr<StringAttr> objectResult =
222 FieldParser<StringAttr>::parse(odsParser);
223 if (failed(objectResult))
224 return odsParser.emitError(odsParser.getCurrentLocation(),
225 "failed to parse GPU_ObjectAttr parameter "
226 "'object' which is to be a `StringAttr`");
227 format = *formatResult;
228 object = *objectResult;
229 return success();
230}
231
232void printObject(AsmPrinter &odsParser, CompilationTarget format,
233 StringAttr object) {
234 if (format != CompilationTarget::Fatbin)
235 odsParser << stringifyEnum(format) << " = ";
236 odsParser << object;
237}
238} // namespace
239
240//===----------------------------------------------------------------------===//
241// GPU select object attribute
242//===----------------------------------------------------------------------===//
243
244LogicalResult
245gpu::SelectObjectAttr::verify(function_ref<InFlightDiagnostic()> emitError,
246 Attribute target, uint16_t priority) {
247 if (!target && priority != kDefaultPriority)
248 return emitError() << "a priority requires a target to be specified";
249 // Check `target`, it can be null, an integer attr or a GPU Target attribute.
250 if (target) {
251 if (auto intAttr = mlir::dyn_cast<IntegerAttr>(target)) {
252 if (intAttr.getInt() < 0) {
253 return emitError() << "the object index must be positive";
254 }
255 } else if (!target.hasPromiseOrImplementsInterface<TargetAttrInterface>()) {
256 return emitError()
257 << "the target attribute must be a GPU Target attribute";
258 }
259 }
260 return success();
261}
262
263//===----------------------------------------------------------------------===//
264// GPU KernelMetadataAttr
265//===----------------------------------------------------------------------===//
266
267KernelMetadataAttr KernelMetadataAttr::get(FunctionOpInterface kernel,
268 DictionaryAttr metadata) {
269 assert(kernel && "invalid kernel");
270 return get(kernel.getNameAttr(), kernel.getFunctionType(),
271 kernel.getAllArgAttrs(), metadata);
272}
273
274KernelMetadataAttr
275KernelMetadataAttr::getChecked(function_ref<InFlightDiagnostic()> emitError,
276 FunctionOpInterface kernel,
277 DictionaryAttr metadata) {
278 assert(kernel && "invalid kernel");
279 return getChecked(emitError, kernel.getNameAttr(), kernel.getFunctionType(),
280 kernel.getAllArgAttrs(), metadata);
281}
282
283KernelMetadataAttr
284KernelMetadataAttr::appendMetadata(ArrayRef<NamedAttribute> attrs) const {
285 if (attrs.empty())
286 return *this;
287 NamedAttrList attrList;
288 if (DictionaryAttr dict = getMetadata())
289 attrList.append(dict);
290 attrList.append(attrs);
291 return KernelMetadataAttr::get(getName(), getFunctionType(), getArgAttrs(),
292 attrList.getDictionary(getContext()));
293}
294
295LogicalResult
296KernelMetadataAttr::verify(function_ref<InFlightDiagnostic()> emitError,
297 StringAttr name, Type functionType,
298 ArrayAttr argAttrs, DictionaryAttr metadata) {
299 if (name.empty())
300 return emitError() << "the kernel name can't be empty";
301 if (argAttrs) {
302 if (llvm::any_of(argAttrs, [](Attribute attr) {
303 return !llvm::isa<DictionaryAttr>(attr);
304 }))
305 return emitError()
306 << "all attributes in the array must be a dictionary attribute";
307 }
308 return success();
309}
310
311//===----------------------------------------------------------------------===//
312// GPU KernelTableAttr
313//===----------------------------------------------------------------------===//
314
315KernelTableAttr KernelTableAttr::get(MLIRContext *context,
316 ArrayRef<KernelMetadataAttr> kernels,
317 bool isSorted) {
318 // Note that `is_sorted` is always only invoked once even with assertions ON.
319 assert((!isSorted || llvm::is_sorted(kernels)) &&
320 "expected a sorted kernel array");
321 // Immediately return the attribute if the array is sorted.
322 if (isSorted || llvm::is_sorted(kernels))
323 return Base::get(context, kernels);
324 // Sort the array.
325 SmallVector<KernelMetadataAttr> kernelsTmp(kernels);
326 llvm::array_pod_sort(kernelsTmp.begin(), kernelsTmp.end());
327 return Base::get(context, kernelsTmp);
328}
329
330KernelTableAttr KernelTableAttr::getChecked(
331 function_ref<InFlightDiagnostic()> emitError, MLIRContext *context,
332 ArrayRef<KernelMetadataAttr> kernels, bool isSorted) {
333 // Note that `is_sorted` is always only invoked once even with assertions ON.
334 assert((!isSorted || llvm::is_sorted(kernels)) &&
335 "expected a sorted kernel array");
336 // Immediately return the attribute if the array is sorted.
337 if (isSorted || llvm::is_sorted(kernels))
338 return Base::getChecked(emitError, context, kernels);
339 // Sort the array.
340 SmallVector<KernelMetadataAttr> kernelsTmp(kernels);
341 llvm::array_pod_sort(kernelsTmp.begin(), kernelsTmp.end());
342 return Base::getChecked(emitError, context, kernelsTmp);
343}
344
345LogicalResult
346KernelTableAttr::verify(function_ref<InFlightDiagnostic()> emitError,
347 ArrayRef<KernelMetadataAttr> kernels) {
348 if (kernels.size() < 2)
349 return success();
350 // Check that the kernels are uniquely named.
351 if (std::adjacent_find(kernels.begin(), kernels.end(),
352 [](KernelMetadataAttr l, KernelMetadataAttr r) {
353 return l.getName() == r.getName();
354 }) != kernels.end()) {
355 return emitError() << "expected all kernels to be uniquely named";
356 }
357 return success();
358}
359
360KernelMetadataAttr KernelTableAttr::lookup(StringRef key) const {
361 auto [iterator, found] = impl::findAttrSorted(begin(), end(), key);
362 return found ? *iterator : KernelMetadataAttr();
363}
364
365KernelMetadataAttr KernelTableAttr::lookup(StringAttr key) const {
366 auto [iterator, found] = impl::findAttrSorted(begin(), end(), key);
367 return found ? *iterator : KernelMetadataAttr();
368}
369
370//===----------------------------------------------------------------------===//
371// GPU target options
372//===----------------------------------------------------------------------===//
373
388
406
407TypeID TargetOptions::getTypeID() const { return typeID; }
408
409StringRef TargetOptions::getToolkitPath() const { return toolkitPath; }
410
414
415StringRef TargetOptions::getCmdOptions() const { return cmdOptions; }
416
417StringRef TargetOptions::getELFSection() const { return elfSection; }
418
422
423function_ref<void(llvm::Module &)>
427
428function_ref<void(llvm::Module &)>
432
433function_ref<void(llvm::Module &)>
437
439 return isaCallback;
440}
441
442CompilationTarget TargetOptions::getCompilationTarget() const {
443 return compilationTarget;
444}
445
447 return CompilationTarget::Fatbin;
448}
449
450std::pair<llvm::BumpPtrAllocator, SmallVector<const char *>>
452 std::pair<llvm::BumpPtrAllocator, SmallVector<const char *>> options;
453 llvm::StringSaver stringSaver(options.first);
454 StringRef opts = cmdOptions;
455 // For a correct tokenization of the command line options `opts` must be
456 // unquoted, otherwise the tokenization function returns a single string: the
457 // unquoted `cmdOptions` -which is not the desired behavior.
458 // Remove any quotes if they are at the beginning and end of the string:
459 if (!opts.empty() && opts.front() == '"' && opts.back() == '"')
460 opts.consume_front("\""), opts.consume_back("\"");
461 if (!opts.empty() && opts.front() == '\'' && opts.back() == '\'')
462 opts.consume_front("'"), opts.consume_back("'");
463#ifdef _WIN32
464 llvm::cl::TokenizeWindowsCommandLine(opts, stringSaver, options.second,
465 /*MarkEOLs=*/false);
466#else
467 llvm::cl::TokenizeGNUCommandLine(opts, stringSaver, options.second,
468 /*MarkEOLs=*/false);
469#endif // _WIN32
470 return options;
471}
472
473std::pair<llvm::BumpPtrAllocator, SmallVector<const char *>>
477
478std::pair<llvm::BumpPtrAllocator, SmallVector<const char *>>
480 size_t startPos = cmdOptions.find(startsWith);
481 if (startPos == std::string::npos)
482 return {llvm::BumpPtrAllocator(), SmallVector<const char *>()};
483
484 auto tokenized =
485 tokenizeCmdOptions(cmdOptions.substr(startPos + startsWith.size()));
486 cmdOptions.resize(startPos);
487 return tokenized;
488}
489
491
492#include "mlir/Dialect/GPU/IR/GPUOpsEnums.cpp.inc"
493
494#define GET_ATTRDEF_CLASSES
495#include "mlir/Dialect/GPU/IR/GPUOpsAttributes.cpp.inc"
496
497namespace {
498template <typename... Attrs>
499void registerAttributeStorageImpl(MLIRContext *context) {
501}
502} // namespace
503
505 registerAttributeStorageImpl<
506#define GET_ATTRDEF_LIST
507#include "mlir/Dialect/GPU/IR/GPUOpsAttributes.cpp.inc"
508 >(context);
509}
510
511#include "mlir/Dialect/GPU/IR/CompilationAttrInterfaces.cpp.inc"
return success()
ArrayAttr()
b getContext())
static llvm::ManagedStatic< PassManagerOptions > options
#define MLIR_DEFINE_EXPLICIT_TYPE_ID(CLASS_NAME)
Definition TypeID.h:323
virtual ParseResult parseOptionalKeyword(StringRef keyword)=0
Parse the given keyword if present.
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
virtual ParseResult parseEqual()=0
Parse a = token.
virtual SMLoc getCurrentLocation()=0
Get the location of the next token and store it into the argument.
Attributes are known-constant values of operations.
Definition Attributes.h:25
This class represents a diagnostic that is inflight and set to be reported.
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:71
DictionaryAttr getDictionary(MLIRContext *context) const
Return a dictionary attribute for the underlying dictionary.
void append(StringRef name, Attribute attr)
Add an attribute with the specified name.
This class allows for representing and managing the symbol table used by operations with the 'SymbolT...
Definition SymbolTable.h:25
This class provides an efficient unique identifier for a specific C++ type.
Definition TypeID.h:107
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition Types.h:74
bool isF64() const
Definition Types.cpp:41
MLIRContext * getContext() const
Return the MLIRContext in which this type was uniqued.
Definition Types.cpp:35
bool isSignedInteger() const
Return true if this is a signed integer type (with the specified width).
Definition Types.cpp:78
bool isF32() const
Definition Types.cpp:40
bool isUnsignedInteger() const
Return true if this is an unsigned integer type (with the specified width).
Definition Types.cpp:90
bool isInteger() const
Return true if this is an integer type (with the specified width).
Definition Types.cpp:58
bool isF16() const
Definition Types.cpp:38
static void registerAttribute(MLIRContext *ctx)
Register an attribute instance T with the uniquer.
MMAMatrix represents a matrix held by a subgroup for matrix-matrix multiply accumulate operations.
Definition GPUBase.h:132
ArrayRef< int64_t > getShape() const
Get shape of the matrix.
Definition GPUBase.cpp:129
static MMAMatrixType get(ArrayRef< int64_t > shape, Type elementType, StringRef operand)
Get MMAMatrixType and verify construction Invariants.
Definition GPUBase.cpp:114
Type getElementType() const
Get elementType of a single element.
Definition GPUBase.cpp:133
static bool isValidElementType(Type elementType)
Check if a type is valid a MMAMatrixType elementType.
Definition GPUBase.cpp:137
static LogicalResult verifyInvariants(function_ref< InFlightDiagnostic()> emitError, ArrayRef< int64_t > shape, Type elementType, StringRef operand)
Verify that shape and elementType are actually allowed for the MMAMatrixType.
Definition GPUBase.cpp:144
StringRef getOperand() const
The general form of operation this type supports is given by the equation C += A*B.
Definition GPUBase.cpp:135
static MMAMatrixType getChecked(function_ref< InFlightDiagnostic()> emitError, ArrayRef< int64_t > shape, Type elementType, StringRef operand)
Get MMAMatrixType at a particular location and verify construction Invariants.
Definition GPUBase.cpp:120
unsigned getNumDims() const
Get number of dims.
Definition GPUBase.cpp:127
This class serves as an opaque interface for passing options to the TargetAttrInterface methods.
function_ref< void(llvm::Module &)> optimizedLlvmIRCallback
Callback invoked with LLVM IR for the device module after LLVM optimizations but before codegen.
function_ref< void(StringRef)> getISACallback() const
Returns the callback invoked with the target ISA for the device, for example PTX assembly.
Definition GPUBase.cpp:438
TypeID getTypeID() const
Returns the typeID.
Definition GPUBase.cpp:407
std::string toolkitPath
Path to the target toolkit.
SymbolTable * getSymbolTable() const
Returns the result of the getSymbolTableCallback callback or a nullptr if no callback was provided.
Definition GPUBase.cpp:419
StringRef getELFSection() const
Returns the ELF section.
Definition GPUBase.cpp:417
StringRef getCmdOptions() const
Returns the command line options.
Definition GPUBase.cpp:415
std::string cmdOptions
An optional set of command line options to be used by the compilation process.
function_ref< void(StringRef)> isaCallback
Callback invoked with the target ISA for the device, for example PTX assembly.
CompilationTarget compilationTarget
Compilation process target format.
std::pair< llvm::BumpPtrAllocator, SmallVector< const char * > > tokenizeCmdOptions() const
Returns a tokenization of the command line options.
Definition GPUBase.cpp:474
function_ref< void(llvm::Module &)> initialLlvmIRCallback
Callback invoked with the initial LLVM IR for the device module.
ArrayRef< Attribute > getLibrariesToLink() const
Returns the LLVM libraries to link to.
Definition GPUBase.cpp:411
TargetOptions(StringRef toolkitPath={}, ArrayRef< Attribute > librariesToLink={}, StringRef cmdOptions={}, StringRef elfSection={}, CompilationTarget compilationTarget=getDefaultCompilationTarget(), function_ref< SymbolTable *()> getSymbolTableCallback={}, function_ref< void(llvm::Module &)> initialLlvmIRCallback={}, function_ref< void(llvm::Module &)> linkedLlvmIRCallback={}, function_ref< void(llvm::Module &)> optimizedLlvmIRCallback={}, function_ref< void(StringRef)> isaCallback={})
Constructor initializing the toolkit path, the list of files to link to, extra command line options,...
Definition GPUBase.cpp:374
function_ref< void(llvm::Module &)> getOptimizedLlvmIRCallback() const
Returns the callback invoked with LLVM IR for the device module after LLVM optimizations but before c...
Definition GPUBase.cpp:434
std::pair< llvm::BumpPtrAllocator, SmallVector< const char * > > tokenizeAndRemoveSuffixCmdOptions(llvm::StringRef startsWith)
Returns a tokenization of the substr of the command line options that starts with startsWith and ends...
Definition GPUBase.cpp:479
StringRef getToolkitPath() const
Returns the toolkit path.
Definition GPUBase.cpp:409
SmallVector< Attribute > librariesToLink
List of files to link with the LLVM module.
function_ref< void(llvm::Module &)> linkedLlvmIRCallback
Callback invoked with LLVM IR for the device module after linking the device libraries.
function_ref< void(llvm::Module &)> getInitialLlvmIRCallback() const
Returns the callback invoked with the initial LLVM IR for the device module.
Definition GPUBase.cpp:424
function_ref< SymbolTable *()> getSymbolTableCallback
Callback for obtaining the parent symbol table of all the GPU modules being serialized.
static CompilationTarget getDefaultCompilationTarget()
Returns the default compilation target: CompilationTarget::Fatbin.
Definition GPUBase.cpp:446
function_ref< void(llvm::Module &)> getLinkedLlvmIRCallback() const
Returns the callback invoked with LLVM IR for the device module after linking the device libraries.
Definition GPUBase.cpp:429
std::string elfSection
ELF Section where the binary needs to be located.
CompilationTarget getCompilationTarget() const
Returns the compilation target.
Definition GPUBase.cpp:442
ArrayRef< NamedAttribute > getArgAttrs(FunctionOpInterface op, unsigned index)
Return all of the attributes for the argument at 'index'.
void registerAttributeStorage(MLIRContext *context)
Register storage whose definitions are private to MLIRGPUBase.
Definition GPUBase.cpp:504
std::pair< IteratorT, bool > findAttrSorted(IteratorT first, IteratorT last, StringRef name)
Using llvm::lower_bound requires an extra string comparison to check whether the returned iterator po...
detail::InFlightRemark failed(Location loc, RemarkOpts opts)
Report an optimization remark that failed.
Definition Remarks.h:886
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
auto getChecked(function_ref< InFlightDiagnostic()> emitError, MLIRContext *context, Ts &&...params)
Helper method analogous to get, but uses getChecked when available to allow graceful failure on inval...
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
llvm::function_ref< Fn > function_ref
Definition LLVM.h:155