Skip to content

Commit ddba8c6

Browse files
committed
yk ir: crash out on encountering nonsensical binary operators.
1 parent cf4476e commit ddba8c6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

llvm/lib/YkIR/YkIRWriter.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ enum OperandKind {
6060
Arg,
6161
Global,
6262
Predicate,
63+
OpKindBinOp,
6364
UnimplementedOperand = 255,
6465
};
6566

@@ -330,7 +331,7 @@ class YkIRWriter {
330331
// left-hand side:
331332
serialiseOperand(I, VLMap, I->getOperand(0));
332333
// binary operator:
333-
serialiseBinOperator(I->getOpcode());
334+
serialiseBinOperatorOperand(I->getOpcode());
334335
// right-hand side:
335336
serialiseOperand(I, VLMap, I->getOperand(1));
336337

@@ -339,7 +340,10 @@ class YkIRWriter {
339340
}
340341

341342
// Serialise a binary operator.
342-
void serialiseBinOperator(Instruction::BinaryOps BO) {
343+
void serialiseBinOperatorOperand(Instruction::BinaryOps BO) {
344+
// operand kind:
345+
OutStreamer.emitInt8(OperandKind::OpKindBinOp);
346+
// the operator:
343347
switch (BO) {
344348
case Instruction::BinaryOps::Add:
345349
OutStreamer.emitInt8(BinOp::BinOpAdd);
@@ -395,8 +399,8 @@ class YkIRWriter {
395399
case Instruction::BinaryOps::URem:
396400
OutStreamer.emitInt8(BinOp::BinOpURem);
397401
break;
398-
case Instruction::BinaryOps::BinaryOpsEnd:
399-
break;
402+
default:
403+
llvm::report_fatal_error("unknown binary operator");
400404
}
401405
}
402406

0 commit comments

Comments
 (0)