[llvm] r262869 - [IR] Provide an API to skip the details of a structured type when printed.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 7 14:32:43 PST 2016
Author: qcolombet
Date: Mon Mar 7 16:32:42 2016
New Revision: 262869
URL: http://llvm.org/viewvc/llvm-project?rev=262869&view=rev
Log:
[IR] Provide an API to skip the details of a structured type when printed.
The mir infrastructure will need this for generic instructions and currently
this feature was only available through the anonymous TypePrinter class.
Modified:
llvm/trunk/include/llvm/IR/Type.h
llvm/trunk/lib/IR/AsmWriter.cpp
Modified: llvm/trunk/include/llvm/IR/Type.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Type.h?rev=262869&r1=262868&r2=262869&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Type.h (original)
+++ llvm/trunk/include/llvm/IR/Type.h Mon Mar 7 16:32:42 2016
@@ -112,7 +112,14 @@ protected:
}
public:
- void print(raw_ostream &O, bool IsForDebug = false) const;
+ /// Print the current type.
+ /// Omit the type details if \p NoDetails == true.
+ /// E.g., let %st = type { i32, i16 }
+ /// When \p NoDetails is true, we only print %st.
+ /// Put differently, \p NoDetails prints the type as if
+ /// inlined with the operands when printing an instruction.
+ void print(raw_ostream &O, bool IsForDebug = false,
+ bool NoDetails = false) const;
void dump() const;
/// getContext - Return the LLVMContext in which this type was uniqued.
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=262869&r1=262868&r2=262869&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Mon Mar 7 16:32:42 2016
@@ -3269,10 +3269,13 @@ void Comdat::print(raw_ostream &ROS, boo
ROS << '\n';
}
-void Type::print(raw_ostream &OS, bool /*IsForDebug*/) const {
+void Type::print(raw_ostream &OS, bool /*IsForDebug*/, bool NoDetails) const {
TypePrinting TP;
TP.print(const_cast<Type*>(this), OS);
+ if (NoDetails)
+ return;
+
// If the type is a named struct type, print the body as well.
if (StructType *STy = dyn_cast<StructType>(const_cast<Type*>(this)))
if (!STy->isLiteral()) {
More information about the llvm-commits
mailing list