diff options
| author | Stefan Weigl-Bosker <stefan@s00.xyz> | 2026-02-19 13:13:41 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-19 13:13:41 -0500 |
| commit | 1fd2d6d88f5f78d879bf38bb3fba7fa2e749d3b0 (patch) | |
| tree | eb5a0740956812678131970687377339fad5a541 /willow/lib/IR/Verifier.cpp | |
| parent | add95b14f74e6dbe04a6efe98ff0f20424930b73 (diff) | |
| download | compiler-1fd2d6d88f5f78d879bf38bb3fba7fa2e749d3b0.tar.gz | |
[willow]: initial IRBuilder API (#9)
- add IRBuilder api
- remove `name` field from `Value`
- fix some bugs in IList interface
- more verifier tests
Diffstat (limited to 'willow/lib/IR/Verifier.cpp')
| -rw-r--r-- | willow/lib/IR/Verifier.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/willow/lib/IR/Verifier.cpp b/willow/lib/IR/Verifier.cpp index d19bc83..b622f10 100644 --- a/willow/lib/IR/Verifier.cpp +++ b/willow/lib/IR/Verifier.cpp @@ -1,3 +1,4 @@ +#include <iostream> #include <willow/IR/BasicBlock.h> #include <willow/IR/Diagnostic.h> #include <willow/IR/DiagnosticEngine.h> @@ -75,20 +76,19 @@ LogicalResult verifyBasicBlock(WillowContext &ctx, const BasicBlock &BB, DiagnosticEngine &diags) { if (BB.empty()) return emit(diags, Severity::Error, BB.getLoc()) - << "Basic block '" << BB.getName() << "' has an empty body"; + << "Basic block has empty body"; - if (!BB.trailer()->isTerminator()) + if (!BB.trailer().isTerminator()) return emit(diags, Severity::Error, BB.getLoc()) - << "Basic block '" << BB.getName() - << "' does not end with a terminator"; + << "Basic block does not end with a terminator"; bool has_failed = false; - for (auto &inst : BB.getBody()) { + for (auto& inst : BB) { // verify inst if (failed(verifyInst(ctx, inst, diags))) has_failed = true; - if (&inst != BB.trailer() && inst.isTerminator()) + if (&inst != &BB.trailer() && inst.isTerminator()) return emit(diags, Severity::Error, BB.getLoc()) << "Illegal terminator in the middle of a block"; } @@ -219,11 +219,9 @@ LogicalResult verifyInst(WillowContext &ctx, const Instruction &inst, if (aty == pty) continue; - DiagnosticBuilder d(diags, Severity::Error, inst.getLoc()); - d << "invalid argument: expected '" << pty << "', got '" << aty << "'"; - if (param.hasName()) - d.note(Diagnostic{Severity::Remark, - std::format("param name: {}", param.getName())}); + return emit(diags, Severity::Error, inst.getLoc()) + << "invalid argument: expected '" << pty << "', got '" << aty + << "'"; return failure(); } @@ -266,8 +264,7 @@ LogicalResult verifyInst(WillowContext &ctx, const Instruction &inst, if (BB && fn && (pred->getParent() != fn)) return emit(diags, Severity::Error, inst.getLoc()) - << "basic block: '" << pred->getName() - << "' is not a child of function '" << fn->getName() << "'"; + << "invalid predecessor"; } return success(); @@ -344,14 +341,14 @@ LogicalResult verifyBinaryIntegerCmp(WillowContext &ctx, } LogicalResult verifyResult(const Instruction &inst, DiagnosticEngine &diags) { - if (inst.hasName()) - return success(); + if (!inst.getType().isVoid()) + return success(); return emit(diags, Severity::Error, inst.getLoc()) << "expected ssa result"; } LogicalResult verifyNoResult(const Instruction &inst, DiagnosticEngine &diags) { - if (!inst.hasName()) + if (inst.getType().isVoid()) return success(); return emit(diags, Severity::Error, inst.getLoc()) << "unexpected ssa result"; |