Skip to content

Commit e2c4a74

Browse files
scaleVector function changed to include std::transform
1 parent 38b7324 commit e2c4a74

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/IR2Vec.cpp

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

158-
void collectIR() {
158+
void collectIRfunc() {
159159
auto M = getLLVMIR();
160160
CollectIR cir(M);
161161
std::ofstream o;
@@ -230,7 +230,7 @@ int main(int argc, char **argv) {
230230
} else if (sym) {
231231
generateSYMEncodings();
232232
} else if (collectIR) {
233-
collectIR();
233+
collectIRfunc();
234234
}
235235
return 0;
236236
}

src/include/utils.h

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

1717
#include <cxxabi.h>
1818

19+
#include <algorithm>
1920
#include <map>
2021

2122
namespace IR2Vec {
@@ -46,7 +47,10 @@ extern float WT;
4647
extern bool debug;
4748
extern std::unordered_map<std::string, Vector> opcMap;
4849
std::unique_ptr<llvm::Module> getLLVMIR();
49-
void scaleVector(Vector &vec, float factor);
50+
inline void scaleVector(Vector &vec, float factor) {
51+
std::transform(vec.begin(), vec.end(), vec.begin(),
52+
[factor](const auto &val) { return val * factor; });
53+
}
5054
// newly added
5155
std::string getDemagledName(const llvm::Function *function);
5256
char *getActualName(llvm::Function *function);

src/utils.cpp

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

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

0 commit comments

Comments
 (0)