summaryrefslogtreecommitdiff
path: root/willow/lib
diff options
context:
space:
mode:
authorStefan Weigl-Bosker <stefan@s00.xyz>2026-01-13 15:25:34 -0500
committerGitHub <noreply@github.com>2026-01-13 15:25:34 -0500
commit291bec344a99cd4a4874117d31fa1c66194fa81e (patch)
treefa1388af5580a1ca3a926d003122574d67640a2e /willow/lib
parentad744d11a70136459256f28380ec99c9274fb77d (diff)
downloadcompiler-291bec344a99cd4a4874117d31fa1c66194fa81e.tar.gz
[willow]: documentation cleanup (#4)
Diffstat (limited to 'willow/lib')
-rw-r--r--willow/lib/IR/Verifier.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/willow/lib/IR/Verifier.cpp b/willow/lib/IR/Verifier.cpp
index b692b2f..459989a 100644
--- a/willow/lib/IR/Verifier.cpp
+++ b/willow/lib/IR/Verifier.cpp
@@ -90,10 +90,8 @@ LogicalResult verifyInst(const Instruction &inst, DiagnosticEngine &diags) {
"instructions return i1",
ty);
- size_t num_operands = inst.getNumOperands();
- if (num_operands != 2)
- return emit(diags, Severity::Error, inst.getLoc())
- << std::format("expected 2 operands, found {}", num_operands);
+ if (failed(verifyNumOperands(inst, diags, 2)))
+ return failure();
const Value *lhs = inst.getOperand(0);
const Value *rhs = inst.getOperand(1);
@@ -111,6 +109,8 @@ LogicalResult verifyInst(const Instruction &inst, DiagnosticEngine &diags) {
if (lty != rty)
return emit(diags, Severity::Error, inst.getLoc())
<< "mismatched operand types";
+
+ break;
}
case Not: {
Type ty = inst.getType();
@@ -127,6 +127,7 @@ LogicalResult verifyInst(const Instruction &inst, DiagnosticEngine &diags) {
if (ty != oty)
return emit(diags, Severity::Error, inst.getLoc())
<< std::format("expected argument type '{}', got '{}'", ty, oty);
+ break;
}
case Jmp:
case Br:
@@ -174,8 +175,12 @@ LogicalResult verifyResult(const Instruction &inst, DiagnosticEngine &diags) {
LogicalResult verifyNumOperands(const Instruction &inst,
DiagnosticEngine &diags, std::size_t expected) {
- if (inst.getNumOperands() != expected)
- return emitE
+ std::size_t num_operands = inst.getNumOperands();
+ if (num_operands != expected)
+ return emit(diags, Severity::Error, inst.getLoc()) << std::format(
+ "expected {} operands, but got {}", expected, num_operands);
+
+ return success();
}
} // namespace willow