From 6f8acb87b332d77d76ad81d56ab7bcf1125afcf3 Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Thu, 18 Oct 2018 14:22:26 +0100 Subject: Move unrelated function from ReadExpr class --- lib/Expr/ArrayExprOptimizer.cpp | 45 +++++++++++++++++++++++++++++++++++++++-- lib/Expr/Expr.cpp | 41 ------------------------------------- 2 files changed, 43 insertions(+), 43 deletions(-) (limited to 'lib') diff --git a/lib/Expr/ArrayExprOptimizer.cpp b/lib/Expr/ArrayExprOptimizer.cpp index 94bf2487..475b8b5c 100644 --- a/lib/Expr/ArrayExprOptimizer.cpp +++ b/lib/Expr/ArrayExprOptimizer.cpp @@ -54,6 +54,47 @@ llvm::cl::opt ArrayValueSymbRatio( llvm::cl::init(1.0), llvm::cl::value_desc("Symbolic Values / Array Size")); }; +ref extendRead(const UpdateList &ul, const ref index, + Expr::Width w) { + switch (w) { + default: + assert(0 && "invalid width"); + case Expr::Int8: + return ReadExpr::alloc(ul, index); + case Expr::Int16: + return ConcatExpr::create( + ReadExpr::alloc( + ul, AddExpr::create(ConstantExpr::create(1, Expr::Int32), index)), + ReadExpr::alloc(ul, index)); + case Expr::Int32: + return ConcatExpr::create4( + ReadExpr::alloc( + ul, AddExpr::create(ConstantExpr::create(3, Expr::Int32), index)), + ReadExpr::alloc( + ul, AddExpr::create(ConstantExpr::create(2, Expr::Int32), index)), + ReadExpr::alloc( + ul, AddExpr::create(ConstantExpr::create(1, Expr::Int32), index)), + ReadExpr::alloc(ul, index)); + case Expr::Int64: + return ConcatExpr::create8( + ReadExpr::alloc( + ul, AddExpr::create(ConstantExpr::create(7, Expr::Int32), index)), + ReadExpr::alloc( + ul, AddExpr::create(ConstantExpr::create(6, Expr::Int32), index)), + ReadExpr::alloc( + ul, AddExpr::create(ConstantExpr::create(5, Expr::Int32), index)), + ReadExpr::alloc( + ul, AddExpr::create(ConstantExpr::create(4, Expr::Int32), index)), + ReadExpr::alloc( + ul, AddExpr::create(ConstantExpr::create(3, Expr::Int32), index)), + ReadExpr::alloc( + ul, AddExpr::create(ConstantExpr::create(2, Expr::Int32), index)), + ReadExpr::alloc( + ul, AddExpr::create(ConstantExpr::create(1, Expr::Int32), index)), + ReadExpr::alloc(ul, index)); + } +} + ref ExprOptimizer::optimizeExpr(const ref &e, bool valueOnly) { // Nothing to optimise for constant expressions if (isa(e)) @@ -574,7 +615,7 @@ ref ExprOptimizer::buildMixedSelectExpr( ref firstIndex = MulExpr::create( ConstantExpr::create(holes[0], re->index->getWidth()), ConstantExpr::create(width / 8, re->index->getWidth())); - result = ReadExpr::extendRead(re->updates, firstIndex, width); + result = extendRead(re->updates, firstIndex, width); for (size_t i = 1; i < holes.size(); i++) { ref temp_idx = MulExpr::create( ConstantExpr::create(holes[i], re->index->getWidth()), @@ -582,7 +623,7 @@ ref ExprOptimizer::buildMixedSelectExpr( ref cond = EqExpr::create( re->index, ConstantExpr::create(holes[i], re->index->getWidth())); ref temp = SelectExpr::create( - cond, ReadExpr::extendRead(re->updates, temp_idx, width), result); + cond, extendRead(re->updates, temp_idx, width), result); result = temp; } } diff --git a/lib/Expr/Expr.cpp b/lib/Expr/Expr.cpp index 9e524f62..a5c7f652 100644 --- a/lib/Expr/Expr.cpp +++ b/lib/Expr/Expr.cpp @@ -81,47 +81,6 @@ ref Expr::createTempRead(const Array *array, Expr::Width w) { } } -ref ReadExpr::extendRead(const UpdateList &ul, const ref index, - Expr::Width w) { - switch (w) { - default: - assert(0 && "invalid width"); - case Expr::Int8: - return ReadExpr::alloc(ul, index); - case Expr::Int16: - return ConcatExpr::create( - ReadExpr::alloc( - ul, AddExpr::create(ConstantExpr::create(1, Expr::Int32), index)), - ReadExpr::alloc(ul, index)); - case Expr::Int32: - return ConcatExpr::create4( - ReadExpr::alloc( - ul, AddExpr::create(ConstantExpr::create(3, Expr::Int32), index)), - ReadExpr::alloc( - ul, AddExpr::create(ConstantExpr::create(2, Expr::Int32), index)), - ReadExpr::alloc( - ul, AddExpr::create(ConstantExpr::create(1, Expr::Int32), index)), - ReadExpr::alloc(ul, index)); - case Expr::Int64: - return ConcatExpr::create8( - ReadExpr::alloc( - ul, AddExpr::create(ConstantExpr::create(7, Expr::Int32), index)), - ReadExpr::alloc( - ul, AddExpr::create(ConstantExpr::create(6, Expr::Int32), index)), - ReadExpr::alloc( - ul, AddExpr::create(ConstantExpr::create(5, Expr::Int32), index)), - ReadExpr::alloc( - ul, AddExpr::create(ConstantExpr::create(4, Expr::Int32), index)), - ReadExpr::alloc( - ul, AddExpr::create(ConstantExpr::create(3, Expr::Int32), index)), - ReadExpr::alloc( - ul, AddExpr::create(ConstantExpr::create(2, Expr::Int32), index)), - ReadExpr::alloc( - ul, AddExpr::create(ConstantExpr::create(1, Expr::Int32), index)), - ReadExpr::alloc(ul, index)); - } -} - int Expr::compare(const Expr &b) const { static ExprEquivSet equivs; int r = compare(b, equivs); -- cgit 1.4.1