[PATCH] D14348: Add Printable class to simplify the construction of Print helpers.

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 4 13:37:00 PST 2015


MatzeB created this revision.
MatzeB added a subscriber: llvm-commits.
MatzeB set the repository for this revision to rL LLVM.

Printable objects simply hold a function reference to a function that
does the printing. It allows the construction of Print helpers.

This would also be a good base to transform several MyClass::print(raw_ostream &OS, more arguments); function in llvm to a more C++-style interface (though I do not plan to do this refactoring myself at the moment).

Example:
```
Printable PrintLaneMask(unsigned LaneMask) {
  return Printable([LaneMask](raw_ostream &OS) {
    OS << format("%08X", LaneMask);
  });
}

// Usage:
OS << PrintLaneMask(Mask);
```

Repository:
  rL LLVM

http://reviews.llvm.org/D14348

Files:
  include/llvm/Support/Printable.h
  include/llvm/Target/TargetRegisterInfo.h
  lib/CodeGen/TargetRegisterInfo.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14348.39250.patch
Type: text/x-patch
Size: 8474 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151104/f2fc01d8/attachment.bin>


More information about the llvm-commits mailing list