Skip to content

Commit 90ffa85

Browse files
scaleVector function changed to include std::transform
1 parent ac7fce7 commit 90ffa85

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

src/IR2Vec.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void generateSYMEncodings() {
157157
o.close();
158158
}
159159

160-
void collectIR() {
160+
void collectIRfunc() {
161161
auto M = getLLVMIR();
162162
CollectIR cir(M);
163163
std::ofstream o;
@@ -232,7 +232,7 @@ int main(int argc, char **argv) {
232232
} else if (sym) {
233233
generateSYMEncodings();
234234
} else if (collectIR) {
235-
collectIR();
235+
collectIRfunc();
236236
}
237237
return 0;
238238
}

src/include/utils.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <cxxabi.h>
2020

21+
#include <algorithm>
2122
#include <map>
2223

2324
namespace IR2Vec {
@@ -48,7 +49,10 @@ extern float WT;
4849
extern bool debug;
4950
extern std::unordered_map<std::string, Vector> opcMap;
5051
std::unique_ptr<llvm::Module> getLLVMIR();
51-
void scaleVector(Vector &vec, float factor);
52+
inline void scaleVector(Vector &vec, float factor) {
53+
std::transform(vec.begin(), vec.end(), vec.begin(),
54+
[factor](const auto &val) { return val * factor; });
55+
}
5256
// newly added
5357
std::string getDemagledName(const llvm::Function *function);
5458
char *getActualName(llvm::Function *function);

src/utils.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ std::unique_ptr<Module> IR2Vec::getLLVMIR() {
4343
return M;
4444
}
4545

46-
void IR2Vec::scaleVector(Vector &vec, float factor) {
47-
for (unsigned i = 0; i < vec.size(); i++) {
48-
vec[i] = vec[i] * factor;
49-
}
50-
}
51-
5246
// Function to get demangled function name
5347
std::string IR2Vec::getDemagledName(const llvm::Function *function) {
5448
auto functionName = function->getName().str();

0 commit comments

Comments
 (0)