@@ -91,6 +91,10 @@ class Embedder {
91
91
// / the embeddings is specific to the kind of embeddings being computed.
92
92
virtual void computeEmbeddings () const = 0;
93
93
94
+ // / Helper function to compute the embedding for a given basic block.
95
+ // / Specific to the kind of embeddings being computed.
96
+ virtual void computeEmbeddings (const BasicBlock &BB) const = 0;
97
+
94
98
// / Lookup vocabulary for a given Key. If the key is not found, it returns a
95
99
// / zero vector.
96
100
Embedding lookupVocab (const std::string &Key) const ;
@@ -121,6 +125,11 @@ class Embedder {
121
125
// / for the function and returns the map.
122
126
const BBEmbeddingsMap &getBBVecMap () const ;
123
127
128
+ // / Returns the embedding for a given basic block in the function F if it has
129
+ // / been computed. If not, it computes the embedding for the basic block and
130
+ // / returns it.
131
+ const Embedding &getBBVector (const BasicBlock &BB) const ;
132
+
124
133
// / Computes and returns the embedding for the current function.
125
134
const Embedding &getFunctionVector () const ;
126
135
};
@@ -130,16 +139,14 @@ class Embedder {
130
139
// / representations obtained from the Vocabulary.
131
140
class SymbolicEmbedder : public Embedder {
132
141
private:
133
- // / Utility function to compute the embedding for a given basic block.
134
- Embedding computeBB2Vec (const BasicBlock &BB) const ;
135
-
136
142
// / Utility function to compute the embedding for a given type.
137
143
Embedding getTypeEmbedding (const Type *Ty) const ;
138
144
139
145
// / Utility function to compute the embedding for a given operand.
140
146
Embedding getOperandEmbedding (const Value *Op) const ;
141
147
142
148
void computeEmbeddings () const override ;
149
+ void computeEmbeddings (const BasicBlock &BB) const override ;
143
150
144
151
public:
145
152
SymbolicEmbedder (const Function &F, const Vocab &Vocabulary,
0 commit comments