Implement MLValue, statement operands, operation statement operands and values. ML functions now have full support for expressing operations. Induction variables, function arguments and return values are still todo.
PiperOrigin-RevId: 206253643
diff --git a/lib/IR/Operation.cpp b/lib/IR/Operation.cpp
index 92a01ba..f2f9eb4 100644
--- a/lib/IR/Operation.cpp
+++ b/lib/IR/Operation.cpp
@@ -39,10 +39,7 @@
if (auto *inst = dyn_cast<OperationInst>(this)) {
return inst->getNumOperands();
} else {
- auto *stmt = cast<OperationStmt>(this);
- (void)stmt;
- // TODO: Add operands to OperationStmt.
- return 0;
+ return cast<OperationStmt>(this)->getNumOperands();
}
}
@@ -51,9 +48,7 @@
return inst->getOperand(idx);
} else {
auto *stmt = cast<OperationStmt>(this);
- (void)stmt;
- // TODO: Add operands to OperationStmt.
- abort();
+ return stmt->getOperand(idx);
}
}
@@ -62,9 +57,7 @@
inst->setOperand(idx, cast<CFGValue>(value));
} else {
auto *stmt = cast<OperationStmt>(this);
- (void)stmt;
- // TODO: Add operands to OperationStmt.
- abort();
+ stmt->setOperand(idx, cast<MLValue>(value));
}
}
@@ -74,9 +67,7 @@
return inst->getNumResults();
} else {
auto *stmt = cast<OperationStmt>(this);
- (void)stmt;
- // TODO: Add results to OperationStmt.
- return 0;
+ return stmt->getNumResults();
}
}
@@ -86,9 +77,7 @@
return inst->getResult(idx);
} else {
auto *stmt = cast<OperationStmt>(this);
- (void)stmt;
- // TODO: Add operands to OperationStmt.
- abort();
+ return stmt->getResult(idx);
}
}