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)) {
58 writeToFieldName,
"\""
60 .attachNote(earlierWrite.getLoc())
61 .append(
"earlier write here");
63 fieldNameToWriteOp[writeToFieldName] = write;
68 for (
auto &[a, b] : fieldNameToWriteOp) {
70 computeFunc.emitWarning().append(
77 markAllAnalysesPreserved();
83 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()