41 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8//9// This file defines helpers used in the op generators.10//11//===----------------------------------------------------------------------===//12 13#ifndef MLIR_TOOLS_MLIRTBLGEN_OPGENHELPERS_H_14#define MLIR_TOOLS_MLIRTBLGEN_OPGENHELPERS_H_15 16#include "mlir/Support/LLVM.h"17#include "llvm/TableGen/Record.h"18#include <vector>19 20namespace mlir {21namespace tblgen {22 23/// Returns all the op definitions filtered by the user. The filtering is via24/// command-line option "op-include-regex" and "op-exclude-regex".25std::vector<const llvm::Record *>26getRequestedOpDefinitions(const llvm::RecordKeeper &records);27 28/// Checks whether `str` is a Python keyword or would shadow builtin function.29/// Regenerate using python -c"print(set(sorted(__import__('keyword').kwlist)))"30bool isPythonReserved(llvm::StringRef str);31 32/// Shard the op defintions into the number of shards set by "op-shard-count".33void shardOpDefinitions(34 ArrayRef<const llvm::Record *> defs,35 SmallVectorImpl<ArrayRef<const llvm::Record *>> &shardedDefs);36 37} // namespace tblgen38} // namespace mlir39 40#endif // MLIR_TOOLS_MLIRTBLGEN_OPGENHELPERS_H_41