19#include <mlir/IR/BuiltinOps.h>
23#define GEN_PASS_DEF_FIELDWRITEVALIDATORPASS
33class FieldWriteValidatorPass
35 void runOnOperation()
override {
40 llvm::StringMap<FieldWriteOp> fieldNameToWriteOp;
42 fieldNameToWriteOp[x.getSymName()] =
nullptr;
46 for (Block &block : computeFunc.
getBody()) {
47 for (Operation &op : block) {
52 assert(structDef.
getType() == write.getComponent().getType());
53 StringRef writeToFieldName = write.getFieldName();
54 if (
FieldWriteOp earlierWrite = fieldNameToWriteOp.at(writeToFieldName)) {
55 auto diag = write.emitWarning().append(
59 diag.attachNote(earlierWrite.getLoc()).append(
"earlier write here");
62 fieldNameToWriteOp[writeToFieldName] = write;
67 for (
auto &[a, b] : fieldNameToWriteOp) {
69 computeFunc.emitWarning()
78 markAllAnalysesPreserved();
84 return std::make_unique<FieldWriteValidatorPass>();
static constexpr ::llvm::StringLiteral getOperationName()
StructType getType(::std::optional<::mlir::ArrayAttr > constParams={})
Gets the StructType representing this struct.
::std::vector< FieldDefOp > getFieldDefs()
Get all FieldDefOp in this structure.
::llzk::function::FuncDefOp getComputeFuncOp()
Gets the FuncDefOp that defines the compute function in this structure, if present,...
static constexpr ::llvm::StringLiteral getOperationName()
::mlir::Region & getBody()
constexpr char FUNC_NAME_COMPUTE[]
Symbol name for the witness generation (and resp.
std::unique_ptr< mlir::Pass > createFieldWriteValidatorPass()