|
LLZK 0.1.0
Veridise's ZK Language IR
|
#include "CommonCAPIGen.h"#include <llvm/ADT/StringMap.h>#include <clang/Basic/FileManager.h>#include <clang/Basic/LangOptions.h>#include <clang/Basic/SourceManager.h>#include <clang/Lex/Lexer.h>#include <optional>Go to the source code of this file.
Classes | |
| struct | ClangLexerContext::Impl |
Enumerations | |
| enum class | AccessLevel { Public , Private , Protected } |
| Access level tracking for C++ class declarations. More... | |
Functions | |
| llvm::cl::OptionCategory | OpGenCat ("Options for -gen-op-capi-header, -gen-op-capi-impl, and -gen-op-capi-tests") |
| llvm::cl::opt< std::string > | DialectName ("dialect", llvm::cl::desc("The dialect name to use for this group of ops. " "Must match across header, implementation, and test generation."), llvm::cl::cat(OpGenCat)) |
| llvm::cl::opt< std::string > | FunctionPrefix ("prefix", llvm::cl::desc("The prefix to use for generated C API function names. " "Default is 'mlir'. Must match across header, implementation, and test generation."), llvm::cl::init("mlir"), llvm::cl::cat(OpGenCat)) |
| llvm::cl::opt< bool > | GenIsA ("gen-isa", llvm::cl::desc("Generate IsA checks"), llvm::cl::init(true), llvm::cl::cat(OpGenCat)) |
| llvm::cl::opt< bool > | GenOpBuild ("gen-op-build", llvm::cl::desc("Generate operation build(..) functions"), llvm::cl::init(true), llvm::cl::cat(OpGenCat)) |
| llvm::cl::opt< bool > | GenOpOperandGetters ("gen-operand-getters", llvm::cl::desc("Generate operand getters for operations"), llvm::cl::init(true), llvm::cl::cat(OpGenCat)) |
| llvm::cl::opt< bool > | GenOpOperandSetters ("gen-operand-setters", llvm::cl::desc("Generate operand setters for operations"), llvm::cl::init(true), llvm::cl::cat(OpGenCat)) |
| llvm::cl::opt< bool > | GenOpAttributeGetters ("gen-attribute-getters", llvm::cl::desc("Generate attribute getters for operations"), llvm::cl::init(true), llvm::cl::cat(OpGenCat)) |
| llvm::cl::opt< bool > | GenOpAttributeSetters ("gen-attribute-setters", llvm::cl::desc("Generate attribute setters for operations"), llvm::cl::init(true), llvm::cl::cat(OpGenCat)) |
| llvm::cl::opt< bool > | GenOpRegionGetters ("gen-region-getters", llvm::cl::desc("Generate region getters for operations"), llvm::cl::init(true), llvm::cl::cat(OpGenCat)) |
| llvm::cl::opt< bool > | GenOpResultGetters ("gen-result-getters", llvm::cl::desc("Generate result getters for operations"), llvm::cl::init(true), llvm::cl::cat(OpGenCat)) |
| llvm::cl::opt< bool > | GenTypeOrAttrGet ("gen-type-attr-get", llvm::cl::desc("Generate get functions for types and attributes"), llvm::cl::init(true), llvm::cl::cat(OpGenCat)) |
| llvm::cl::opt< bool > | GenTypeOrAttrParamGetters ("gen-parameter-getters", llvm::cl::desc("Generate parameter getters for types and attributes"), llvm::cl::init(true), llvm::cl::cat(OpGenCat)) |
| llvm::cl::opt< bool > | GenExtraClassMethods ("gen-extra-class-methods", llvm::cl::desc("Generate C API wrappers for methods in `extraClassDeclaration`"), llvm::cl::init(true), llvm::cl::cat(OpGenCat)) |
| SmallVector< ExtraMethod > | parseExtraMethods (StringRef extraDecl) |
| Parse method declarations from extraClassDeclaration using Clang's Lexer. | |
| bool | matchesMLIRClass (StringRef cppType, StringRef typeName) |
| Check if a C++ type matches an MLIR type pattern. | |
| std::optional< std::string > | tryCppTypeToCapiType (StringRef cppType) |
| Convert C++ type to MLIR C API type. | |
| std::string | mapCppTypeToCapiType (StringRef cppType) |
|
strong |
Access level tracking for C++ class declarations.
| Enumerator | |
|---|---|
| Public | |
| Private | |
| Protected | |
Definition at line 243 of file CommonCAPIGen.cpp.
| llvm::cl::opt< std::string > DialectName | ( | "dialect" | , |
| llvm::cl::desc("The dialect name to use for this group of ops. " "Must match across header, implementation, and test generation.") | , | ||
| llvm::cl::cat(OpGenCat) | ) |
| llvm::cl::opt< std::string > FunctionPrefix | ( | "prefix" | , |
| llvm::cl::desc("The prefix to use for generated C API function names. " "Default is 'mlir'. Must match across header, implementation, and test generation.") | , | ||
| llvm::cl::init("mlir") | , | ||
| llvm::cl::cat(OpGenCat) | ) |
| llvm::cl::opt< bool > GenExtraClassMethods | ( | "gen-extra-class-methods" | , |
| llvm::cl::desc("Generate C API wrappers for methods in `extraClassDeclaration`") | , | ||
| llvm::cl::init(true) | , | ||
| llvm::cl::cat(OpGenCat) | ) |
| llvm::cl::opt< bool > GenIsA | ( | "gen-isa" | , |
| llvm::cl::desc("Generate IsA checks") | , | ||
| llvm::cl::init(true) | , | ||
| llvm::cl::cat(OpGenCat) | ) |
| llvm::cl::opt< bool > GenOpAttributeGetters | ( | "gen-attribute-getters" | , |
| llvm::cl::desc("Generate attribute getters for operations") | , | ||
| llvm::cl::init(true) | , | ||
| llvm::cl::cat(OpGenCat) | ) |
| llvm::cl::opt< bool > GenOpAttributeSetters | ( | "gen-attribute-setters" | , |
| llvm::cl::desc("Generate attribute setters for operations") | , | ||
| llvm::cl::init(true) | , | ||
| llvm::cl::cat(OpGenCat) | ) |
| llvm::cl::opt< bool > GenOpBuild | ( | "gen-op-build" | , |
| llvm::cl::desc("Generate operation build(..) functions") | , | ||
| llvm::cl::init(true) | , | ||
| llvm::cl::cat(OpGenCat) | ) |
| llvm::cl::opt< bool > GenOpOperandGetters | ( | "gen-operand-getters" | , |
| llvm::cl::desc("Generate operand getters for operations") | , | ||
| llvm::cl::init(true) | , | ||
| llvm::cl::cat(OpGenCat) | ) |
| llvm::cl::opt< bool > GenOpOperandSetters | ( | "gen-operand-setters" | , |
| llvm::cl::desc("Generate operand setters for operations") | , | ||
| llvm::cl::init(true) | , | ||
| llvm::cl::cat(OpGenCat) | ) |
| llvm::cl::opt< bool > GenOpRegionGetters | ( | "gen-region-getters" | , |
| llvm::cl::desc("Generate region getters for operations") | , | ||
| llvm::cl::init(true) | , | ||
| llvm::cl::cat(OpGenCat) | ) |
| llvm::cl::opt< bool > GenOpResultGetters | ( | "gen-result-getters" | , |
| llvm::cl::desc("Generate result getters for operations") | , | ||
| llvm::cl::init(true) | , | ||
| llvm::cl::cat(OpGenCat) | ) |
| llvm::cl::opt< bool > GenTypeOrAttrGet | ( | "gen-type-attr-get" | , |
| llvm::cl::desc("Generate get functions for types and attributes") | , | ||
| llvm::cl::init(true) | , | ||
| llvm::cl::cat(OpGenCat) | ) |
| llvm::cl::opt< bool > GenTypeOrAttrParamGetters | ( | "gen-parameter-getters" | , |
| llvm::cl::desc("Generate parameter getters for types and attributes") | , | ||
| llvm::cl::init(true) | , | ||
| llvm::cl::cat(OpGenCat) | ) |
| std::string mapCppTypeToCapiType | ( | StringRef | cppType | ) |
Definition at line 788 of file CommonCAPIGen.cpp.
| bool matchesMLIRClass | ( | StringRef | cppType, |
| StringRef | typeName ) |
Check if a C++ type matches an MLIR type pattern.
Definition at line 654 of file CommonCAPIGen.cpp.
| llvm::cl::OptionCategory OpGenCat | ( | "Options for -gen-op-capi- | header, |
| -gen-op-capi- | impl, | ||
| and -gen-op-capi-tests" | ) |
| SmallVector< ExtraMethod > parseExtraMethods | ( | StringRef | extraDecl | ) |
Parse method declarations from extraClassDeclaration using Clang's Lexer.
This function parses C++ method declarations to extract method signatures. It identifies methods by looking for the pattern: <return_type> <identifier> '(' [params] ')' [const] ';'
The parsing process:
Definition at line 550 of file CommonCAPIGen.cpp.
| std::optional< std::string > tryCppTypeToCapiType | ( | StringRef | cppType | ) |
Convert C++ type to MLIR C API type.
Definition at line 670 of file CommonCAPIGen.cpp.