summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Transforms/ConstantFold.cpp
diff options
context:
space:
mode:
authorChris Lattner <clattner@google.com>2018-12-27 14:35:10 -0800
committerjpienaar <jpienaar@google.com>2019-03-29 14:40:06 -0700
commit3f190312f8f7f09b5910bc77e80268402732ce6b (patch)
tree1ac0989c889d04e1acb0370952ed3bf1f141e17d /mlir/lib/Transforms/ConstantFold.cpp
parent776b035646d809d8b31662363e797f4d7f26c223 (diff)
downloadbcm5719-llvm-3f190312f8f7f09b5910bc77e80268402732ce6b.tar.gz
bcm5719-llvm-3f190312f8f7f09b5910bc77e80268402732ce6b.zip
Merge SSAValue, CFGValue, and MLValue together into a single Value class, which
is the new base of the SSA value hierarchy. This CL also standardizes all the nomenclature and comments to use 'Value' where appropriate. This also eliminates a large number of cast<MLValue>(x)'s, which is very soothing. This is step 11/n towards merging instructions and statements, NFC. PiperOrigin-RevId: 227064624
Diffstat (limited to 'mlir/lib/Transforms/ConstantFold.cpp')
-rw-r--r--mlir/lib/Transforms/ConstantFold.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/mlir/lib/Transforms/ConstantFold.cpp b/mlir/lib/Transforms/ConstantFold.cpp
index d4a50a05989..53e633f53cd 100644
--- a/mlir/lib/Transforms/ConstantFold.cpp
+++ b/mlir/lib/Transforms/ConstantFold.cpp
@@ -30,13 +30,12 @@ struct ConstantFold : public FunctionPass, StmtWalker<ConstantFold> {
ConstantFold() : FunctionPass(&ConstantFold::passID) {}
// All constants in the function post folding.
- SmallVector<SSAValue *, 8> existingConstants;
+ SmallVector<Value *, 8> existingConstants;
// Operation statements that were folded and that need to be erased.
std::vector<OperationStmt *> opStmtsToErase;
- using ConstantFactoryType = std::function<SSAValue *(Attribute, Type)>;
+ using ConstantFactoryType = std::function<Value *(Attribute, Type)>;
- bool foldOperation(Operation *op,
- SmallVectorImpl<SSAValue *> &existingConstants,
+ bool foldOperation(Operation *op, SmallVectorImpl<Value *> &existingConstants,
ConstantFactoryType constantFactory);
void visitOperationStmt(OperationStmt *stmt);
void visitForStmt(ForStmt *stmt);
@@ -54,9 +53,8 @@ char ConstantFold::passID = 0;
///
/// This returns false if the operation was successfully folded.
bool ConstantFold::foldOperation(Operation *op,
- SmallVectorImpl<SSAValue *> &existingConstants,
+ SmallVectorImpl<Value *> &existingConstants,
ConstantFactoryType constantFactory) {
-
// If this operation is already a constant, just remember it for cleanup
// later, and don't try to fold it.
if (auto constant = op->dyn_cast<ConstantOp>()) {
@@ -114,7 +112,7 @@ PassResult ConstantFold::runOnCFGFunction(CFGFunction *f) {
if (!inst)
continue;
- auto constantFactory = [&](Attribute value, Type type) -> SSAValue * {
+ auto constantFactory = [&](Attribute value, Type type) -> Value * {
builder.setInsertionPoint(inst);
return builder.create<ConstantOp>(inst->getLoc(), value, type);
};
@@ -142,7 +140,7 @@ PassResult ConstantFold::runOnCFGFunction(CFGFunction *f) {
// Override the walker's operation statement visit for constant folding.
void ConstantFold::visitOperationStmt(OperationStmt *stmt) {
- auto constantFactory = [&](Attribute value, Type type) -> SSAValue * {
+ auto constantFactory = [&](Attribute value, Type type) -> Value * {
MLFuncBuilder builder(stmt);
return builder.create<ConstantOp>(stmt->getLoc(), value, type);
};
OpenPOWER on IntegriCloud