[llvm] Refactoring llvm-ir2vec.cpp for better separation of concerns in the Tooling classes (PR #170078)
Nishant Sachdeva via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 8 03:20:51 PST 2025
================
@@ -497,28 +560,78 @@ class MIR2VecTool {
// Update MaxRelation if there were operands
if (ArgIndex > 0)
- MaxRelation = std::max(MaxRelation, MIRArgRelation + ArgIndex - 1);
+ Result.MaxRelation =
+ std::max(Result.MaxRelation, MIRArgRelation + ArgIndex - 1);
PrevOpcode = OpcodeID;
HasPrevOpcode = true;
}
}
- return MaxRelation;
+ return Result;
}
- /// Generate entity mappings with vocabulary
- void generateEntityMappings(raw_ostream &OS) const {
+ /// Get triplets for the entire module
+ /// Returns TripletResult containing aggregated MaxRelation and all Triplets
+ TripletResult generateTriplets(const Module &M) const {
+ TripletResult Result;
+ Result.MaxRelation = MIRNextRelation;
+
+ for (const Function &F : M) {
----------------
nishant-sachdeva wrote:
Accepted this
https://github.com/llvm/llvm-project/pull/170078
More information about the llvm-commits
mailing list