================
@@ -43,13 +44,55 @@ static StringRef getImageName(const OffloadBinary &OB) {
   }
 }
 
-static void printBinary(const OffloadBinary &OB, uint64_t Index) {
-  outs() << "\nOFFLOADING IMAGE [" << Index << "]:\n";
-  outs() << left_justify("kind", 16) << getImageName(OB) << "\n";
-  outs() << left_justify("arch", 16) << OB.getArch() << "\n";
-  outs() << left_justify("triple", 16) << OB.getTriple() << "\n";
-  outs() << left_justify("producer", 16)
-         << getOffloadKindName(OB.getOffloadKind()) << "\n";
+/// Print metadata from an OffloadBinary.
+static void printOffloadBinaryMetadata(const OffloadBinary &OB,
+                                       uint64_t level) {
+  outs().indent(level * 2) << left_justify("kind", 16) << getImageName(OB)
+                           << "\n";
+  outs().indent(level * 2) << left_justify("arch", 16) << OB.getArch() << "\n";
+  outs().indent(level * 2) << left_justify("triple", 16) << OB.getTriple()
+                           << "\n";
+  outs().indent(level * 2) << left_justify("producer", 16)
+                           << getOffloadKindName(OB.getOffloadKind()) << "\n";
+
+  StringRef InnerImage = OB.getImage();
+  outs().indent(level * 2) << left_justify("image size", 16)
+                           << InnerImage.size() << " bytes\n";
+}
+
+static void printBinary(const OffloadBinary &OB, uint64_t Index,
+                        uint64_t Level = 0, std::string ParentIndex = "") {
----------------
jh7370 wrote:

I would rename `ParentIndex` to `ParentIndexPrefix` or simply `IndexPrefix`. 
I'm not a fan of it being simply called `ParentIndex` for two reasons:
* An index is typically a single integer, whereas this could consist of 
multiple values, if this entry is multiple levels deep.
* The "." at the end of the prefix feels out of place for the same reason.

Also, would it make sense to make this a `Twine`? This will impact the call 
site too, since `Twine` has a constructor for `to_string` style usage.

https://github.com/llvm/llvm-project/pull/185425
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to