1 //===- OpGenHelpers.h - MLIR operation generator helpers --------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines helpers used in the op generators.
11 //===----------------------------------------------------------------------===//
13 #ifndef MLIR_TOOLS_MLIRTBLGEN_OPGENHELPERS_H_
14 #define MLIR_TOOLS_MLIRTBLGEN_OPGENHELPERS_H_
16 #include "mlir/Support/LLVM.h"
17 #include "llvm/TableGen/Record.h"
23 /// Returns all the op definitions filtered by the user. The filtering is via
24 /// command-line option "op-include-regex" and "op-exclude-regex".
25 std::vector
<llvm::Record
*>
26 getRequestedOpDefinitions(const llvm::RecordKeeper
&recordKeeper
);
28 /// Checks whether `str` is a Python keyword or would shadow builtin function.
29 /// Regenerate using python -c"print(set(sorted(__import__('keyword').kwlist)))"
30 bool isPythonReserved(llvm::StringRef str
);
32 /// Shard the op defintions into the number of shards set by "op-shard-count".
33 void shardOpDefinitions(ArrayRef
<llvm::Record
*> defs
,
34 SmallVectorImpl
<ArrayRef
<llvm::Record
*>> &shardedDefs
);
39 #endif // MLIR_TOOLS_MLIRTBLGEN_OPGENHELPERS_H_