[Infra] Fix version-check workflow (#100090)
[llvm-project.git] / mlir / tools / mlir-tblgen / OpGenHelpers.h
blob1b43d5d3ce3a7df326bd469e11bc662a631b3db9
1 //===- OpGenHelpers.h - MLIR operation generator helpers --------*- C++ -*-===//
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 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"
18 #include <vector>
20 namespace mlir {
21 namespace tblgen {
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);
36 } // namespace tblgen
37 } // namespace mlir
39 #endif // MLIR_TOOLS_MLIRTBLGEN_OPGENHELPERS_H_