added some const

parent bec634ca
......@@ -36,7 +36,7 @@ AffineRelation::AffineRelation(Function const* callee_func, AffineRelation const
// MARK: - AbstractState Interface
void AffineRelation::applyPHINode(BasicBlock const& bb, vector<AffineRelation> pred_values, Instruction const& phi) {
void AffineRelation::applyPHINode(BasicBlock const& bb, vector<AffineRelation> const& pred_values, Instruction const& phi) {
PHINode const* phiNode = dyn_cast<PHINode>(&phi);
int i = 0;
......@@ -156,7 +156,7 @@ bool AffineRelation::merge(Merge_op::Type op, AffineRelation const& other) {
// MARK: - Lattice Operations
bool AffineRelation::leastUpperBound(AffineRelation rhs) {
bool AffineRelation::leastUpperBound(AffineRelation const& rhs) {
assert(getNumberOfVariables() == rhs.getNumberOfVariables());
vector<Matrix<int>> before = basis;
vector<vector<int>> vectors;
......@@ -317,7 +317,7 @@ unordered_map<Value const*, int> AffineRelation::createVariableIndexMap(Function
// MARK: - debug output
unordered_map<int,Value const*> reverseMap(unordered_map<Value const*, int> map) {
unordered_map<int,Value const*> reverseMap(unordered_map<Value const*, int> const& map) {
unordered_map<int,Value const*> reversed;
for (auto [key, value]: map) {
reversed[value] = key;
......
......@@ -28,7 +28,7 @@ public:
explicit AffineRelation(llvm::Function const* callee_func, AffineRelation const& state, llvm::CallInst const* call);
/// Handles the evaluation of merging points
void applyPHINode(llvm::BasicBlock const& bb, std::vector<AffineRelation> pred_values, llvm::Instruction const& phi);
void applyPHINode(llvm::BasicBlock const& bb, std::vector<AffineRelation> const& pred_values, llvm::Instruction const& phi);
/// Handles the evaluation of function calls
/// This is the "combine" function as described in "Compiler Design: Analysis and Transformation"
void applyCallInst(llvm::Instruction const& inst, llvm::BasicBlock const* end_block, AffineRelation const& callee_state);
......@@ -38,7 +38,7 @@ public:
void applyDefault(llvm::Instruction const& inst);
bool merge(Merge_op::Type op, AffineRelation const& other);
void branch(llvm::BasicBlock const& from, llvm::BasicBlock const& towards) { return; };
bool leastUpperBound(AffineRelation rhs);
bool leastUpperBound(AffineRelation const& rhs);
bool checkOperandsForBottom(llvm::Instruction const& inst) { return false; }
......
......@@ -148,7 +148,7 @@ public:
}
/// Basis of the linear span of the column vectors
static Matrix<T> span(Matrix<T> matrix) {
static Matrix<T> span(Matrix<T> const& matrix) {
vector<vector<T>> columns;
int rank = matrix.getRank();
for (int col = 0; col<rank; col++) {
......@@ -158,7 +158,7 @@ public:
}
/// Computes the null space for the column vectors
static Matrix<T> null(Matrix<T> matrix);
static Matrix<T> null(Matrix<T> const& matrix);
/// Converts the matrix to a 1D Vector by stacking the column vectors
std::vector<T> toVector() const {
......@@ -370,14 +370,14 @@ template <typename T>
inline Matrix<T> operator-(Matrix<T> lhs, T scalar) { return lhs -= scalar; };
template <typename T>
llvm::raw_ostream& operator<<(llvm::raw_ostream& os, Matrix<T> matrix) {
llvm::raw_ostream& operator<<(llvm::raw_ostream& os, Matrix<T> const& matrix) {
for (int row = 0; row < matrix.getHeight(); row++) {
os << "[ ";
for (int column = 0; column < matrix.getWidth(); column++) {
if (column == matrix.getWidth() - 1) {
os << llvm::format("%d", matrix(row,column));
os << llvm::format("%d", matrix.value(row,column));
} else {
os << llvm::format("%-6d", matrix(row,column));
os << llvm::format("%-6d", matrix.value(row,column));
}
}
os << " ]\n";
......
......@@ -43,7 +43,7 @@ NormalizedConjunction::NormalizedConjunction(Function const* callee_func, Normal
isBottom = false;
}
NormalizedConjunction::NormalizedConjunction(std::unordered_map<Value const*, LinearEquality> equalaties) {
NormalizedConjunction::NormalizedConjunction(std::unordered_map<Value const*, LinearEquality> const& equalaties) {
this->values = equalaties;
isBottom = equalaties.empty();
for (auto& [key, value]: equalaties) {
......
......@@ -26,7 +26,7 @@ public:
NormalizedConjunction() = default;
NormalizedConjunction(NormalizedConjunction const& state) = default;
NormalizedConjunction(std::unordered_map<llvm::Value const*, LinearEquality> equalaties);
NormalizedConjunction(std::unordered_map<llvm::Value const*, LinearEquality> const& equalaties);
explicit NormalizedConjunction(llvm::Function const& f);
/// This constructor is used to initialize the state of a function call, to which parameters are passed.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment