|
LLZK 0.1.0
Veridise's ZK Language IR
|
This file provides common utilities for generating C API link tests for attributes and types. More...
#include <mlir/TableGen/AttrOrTypeDef.h>#include <mlir/TableGen/Dialect.h>#include <llvm/ADT/StringExtras.h>#include <llvm/Support/FormatVariadic.h>#include <llvm/Support/raw_ostream.h>#include "CommonCAPIGen.h"Go to the source code of this file.
Classes | |
| struct | AttrOrTypeTestGenerator |
| Base class for attribute and type test generators. More... | |
Functions | |
| std::string | generateDummyParamsForAttrOrTypeGet (const mlir::tblgen::AttrOrTypeDef &def, bool isType) |
| Generate dummy parameters for Get builder (used by both Attr and Type) | |
| std::string | generateParamListForAttrOrTypeGet (const mlir::tblgen::AttrOrTypeDef &def) |
| Generate parameter list for Get builder call (used by both Attr and Type) | |
This file provides common utilities for generating C API link tests for attributes and types.
The test generation strategy is:
Test Philosophy: These are link-time verification tests, not functional tests. They ensure that all generated C API functions compile correctly and link properly, catching issues like:
Test Pattern: Each test creates a dummy object (IndexType or IntegerAttr from MLIR builtins) and wraps the C API function call inside a conditional that checks if the dummy object is of the target dialect type. Since the dummy is from a different dialect, the condition is always false at runtime, but the compiler still verifies type correctness and the linker ensures symbol resolution.
Limitations: These tests do NOT verify:
For functional testing, separate integration tests are needed.
Definition in file CommonAttrOrTypeCAPITestGen.h.
| std::string generateDummyParamsForAttrOrTypeGet | ( | const mlir::tblgen::AttrOrTypeDef & | def, |
| bool | isType ) |
Generate dummy parameters for Get builder (used by both Attr and Type)
| def | The attribute or type definition |
| isType | true if generating for a type, false for an attribute |
This function generates C code that declares dummy variables for all parameters of an attribute or type Get builder. For ArrayRef parameters, it generates both a count variable and an array variable. For MlirType/MlirAttribute parameters, it calls helper functions to create test instances.
| std::string generateParamListForAttrOrTypeGet | ( | const mlir::tblgen::AttrOrTypeDef & | def | ) |
Generate parameter list for Get builder call (used by both Attr and Type)
| def | The attribute or type definition |
This function generates a comma-separated list of parameter names to pass to a Get builder function. For ArrayRef parameters, it includes both the count and array pointer. For regular parameters, it includes just the parameter name.