IR2Vec
Loading...
Searching...
No Matches
utils.h
1//===- utils.h - Helper utilities -----------------------------*- C++ -*-===//
2//
3// Part of the IR2Vec Project, under the Apache License v2.0 with LLVM
4// Exceptions. See the LICENSE file for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef __IR2Vec_Utils__
10#define __IR2Vec_Utils__
11
12#include "llvm/ADT/SmallVector.h"
13#include "llvm/Demangle/Demangle.h" //for getting function base name
14#include "llvm/IR/Module.h"
15#include "llvm/IRReader/IRReader.h"
16#include "llvm/Support/SourceMgr.h"
17#include "llvm/Support/raw_ostream.h"
18
19#include <cxxabi.h>
20
21#include <map>
22
23namespace IR2Vec {
24
25#define IR2VEC_DEBUG(X) \
26 ({ \
27 if (IR2Vec::debug) { \
28 X; \
29 } \
30 })
31
32#define DIM 300
33using Vector = llvm::SmallVector<double, DIM>;
34using abi::__cxa_demangle;
35
36extern bool fa;
37extern bool sym;
38extern bool printTime;
39extern bool collectIR;
40extern std::string iname;
41extern std::string oname;
42extern std::string funcName;
43extern char level;
44extern int cls;
45extern float WO;
46extern float WA;
47extern float WT;
48extern bool debug;
49extern std::map<std::string, Vector> opcMap;
50std::unique_ptr<llvm::Module> getLLVMIR();
51void scaleVector(Vector &vec, float factor);
52// newly added
53std::string getDemagledName(const llvm::Function *function);
54char *getActualName(llvm::Function *function);
55std::string updatedRes(IR2Vec::Vector tmp, llvm::Function *f, llvm::Module *M);
56} // namespace IR2Vec
57
58#endif