19#include <mlir/IR/BuiltinOps.h>
23#define GEN_PASS_DEF_MEMBERWRITEVALIDATORPASS
33class MemberWriteValidatorPass
35 void runOnOperation()
override {
40 llvm::StringMap<MemberWriteOp> memberNameToWriteOp;
42 memberNameToWriteOp[x.getSymName()] =
nullptr;
46 for (Block &block : computeFunc.
getBody()) {
47 for (Operation &op : block) {
52 assert(structDef.
getType() == write.getComponent().getType());
53 StringRef writeToMemberName = write.getMemberName();
54 if (
MemberWriteOp earlierWrite = memberNameToWriteOp.at(writeToMemberName)) {
55 auto diag = write.emitWarning().append(
57 writeToMemberName,
'"'
59 diag.attachNote(earlierWrite.getLoc()).append(
"earlier write here");
62 memberNameToWriteOp[writeToMemberName] = write;
67 for (
auto &[a, b] : memberNameToWriteOp) {
69 computeFunc.emitWarning()
78 markAllAnalysesPreserved();
84 return std::make_unique<MemberWriteValidatorPass>();
static constexpr ::llvm::StringLiteral getOperationName()
StructType getType(::std::optional<::mlir::ArrayAttr > constParams={})
Gets the StructType representing this struct.
::std::vector< MemberDefOp > getMemberDefs()
Get all MemberDefOp 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 > createMemberWriteValidatorPass()