IR2Vec
Loading...
Searching...
No Matches
Symbolic.h
1//===- Symbolic.h - Symbolic Encodings of IR2Vec ---------------*- 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_Symbolic_H__
10#define __IR2Vec_Symbolic_H__
11
12#include "utils.h"
13
14#include "llvm/ADT/MapVector.h"
15#include "llvm/IR/BasicBlock.h"
16#include "llvm/IR/Function.h"
17#include "llvm/Pass.h"
18#include "llvm/Support/raw_ostream.h"
19
20#include <fstream>
21#include <map>
22
24
25private:
26 llvm::Module &M;
27 IR2Vec::VocabTy &vocabulary;
28 IR2Vec::Vector pgmVector;
29
30 IR2Vec::Vector getValue(std::string key);
31 IR2Vec::Vector bb2Vec(llvm::BasicBlock &B,
32 llvm::SmallVector<llvm::Function *, 15> &funcStack);
33 IR2Vec::Vector func2Vec(llvm::Function &F,
34 llvm::SmallVector<llvm::Function *, 15> &funcStack);
35 std::string res;
36 llvm::SmallMapVector<const llvm::Function *, IR2Vec::Vector, 16> funcVecMap;
37 llvm::SmallMapVector<const llvm::BasicBlock *, IR2Vec::Vector, 16> bbVecMap;
38 llvm::SmallMapVector<const llvm::Instruction *, IR2Vec::Vector, 128>
39 instVecMap;
40
41public:
42 IR2Vec_Symbolic(llvm::Module &M, IR2Vec::VocabTy &vocab)
43 : M{M}, vocabulary{vocab} {
44 pgmVector = IR2Vec::Vector(IR2Vec::DIM, 0);
45 res = "";
46 }
47
48 void generateSymbolicEncodings(std::ostream *o = nullptr);
49 void generateSymbolicEncodingsForFunction(std::ostream *o = nullptr,
50 std::string name = "");
51 llvm::SmallMapVector<const llvm::Instruction *, IR2Vec::Vector, 128>
52 getInstVecMap() {
53 return instVecMap;
54 }
55
56 llvm::SmallMapVector<const llvm::BasicBlock *, IR2Vec::Vector, 16>
57 getBBVecMap() {
58 return bbVecMap;
59 }
60
61 llvm::SmallMapVector<const llvm::Function *, IR2Vec::Vector, 16>
62 getFuncVecMap() {
63 return funcVecMap;
64 }
65
66 IR2Vec::Vector getProgramVector() { return pgmVector; }
67};
68
69#endif
Definition Symbolic.h:23