Skip to content

Commit

Permalink
scaleVector function changed to include std::transform
Browse files Browse the repository at this point in the history
  • Loading branch information
nishant-sachdeva committed Jul 31, 2024
1 parent ac7fce7 commit 90ffa85
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/IR2Vec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void generateSYMEncodings() {
o.close();
}

void collectIR() {
void collectIRfunc() {
auto M = getLLVMIR();
CollectIR cir(M);
std::ofstream o;
Expand Down Expand Up @@ -232,7 +232,7 @@ int main(int argc, char **argv) {
} else if (sym) {
generateSYMEncodings();
} else if (collectIR) {
collectIR();
collectIRfunc();
}
return 0;
}
6 changes: 5 additions & 1 deletion src/include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <cxxabi.h>

#include <algorithm>
#include <map>

namespace IR2Vec {
Expand Down Expand Up @@ -48,7 +49,10 @@ extern float WT;
extern bool debug;
extern std::unordered_map<std::string, Vector> opcMap;
std::unique_ptr<llvm::Module> getLLVMIR();
void scaleVector(Vector &vec, float factor);
inline void scaleVector(Vector &vec, float factor) {
std::transform(vec.begin(), vec.end(), vec.begin(),
[factor](const auto &val) { return val * factor; });
}
// newly added
std::string getDemagledName(const llvm::Function *function);
char *getActualName(llvm::Function *function);
Expand Down
6 changes: 0 additions & 6 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ std::unique_ptr<Module> IR2Vec::getLLVMIR() {
return M;
}

void IR2Vec::scaleVector(Vector &vec, float factor) {
for (unsigned i = 0; i < vec.size(); i++) {
vec[i] = vec[i] * factor;
}
}

// Function to get demangled function name
std::string IR2Vec::getDemagledName(const llvm::Function *function) {
auto functionName = function->getName().str();
Expand Down

0 comments on commit 90ffa85

Please sign in to comment.