[cfe-commits] r101051 - in /cfe/trunk/lib/CodeGen: CGRecordLayout.h CGRecordLayoutBuilder.cpp
Daniel Dunbar
daniel at zuster.org
Mon Apr 12 11:14:18 PDT 2010
Author: ddunbar
Date: Mon Apr 12 13:14:18 2010
New Revision: 101051
URL: http://llvm.org/viewvc/llvm-project?rev=101051&view=rev
Log:
IRgen: Add CGRecordLayout::dump, and dump (irgen) record layouts as part of -fdump-record-layouts.
Modified:
cfe/trunk/lib/CodeGen/CGRecordLayout.h
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
Modified: cfe/trunk/lib/CodeGen/CGRecordLayout.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayout.h?rev=101051&r1=101050&r2=101051&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayout.h (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayout.h Mon Apr 12 13:14:18 2010
@@ -13,12 +13,15 @@
#include "llvm/ADT/DenseMap.h"
#include "clang/AST/Decl.h"
namespace llvm {
+ class raw_ostream;
class Type;
}
namespace clang {
namespace CodeGen {
+/// Helper object for describing how to generate the code for access to a
+/// bit-field.
class CGBitFieldInfo {
public:
CGBitFieldInfo(const llvm::Type *FieldTy, unsigned FieldNo,
@@ -32,6 +35,9 @@
unsigned Start;
unsigned Size;
bool IsSigned : 1;
+
+ void print(llvm::raw_ostream &OS) const;
+ void dump() const;
};
/// CGRecordLayout - This class handles struct and union layout info while
@@ -90,6 +96,9 @@
assert(it != BitFields.end() && "Unable to find bitfield info");
return it->second;
}
+
+ void print(llvm::raw_ostream &OS) const;
+ void dump() const;
};
} // end namespace CodeGen
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=101051&r1=101050&r2=101051&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Mon Apr 12 13:14:18 2010
@@ -18,8 +18,9 @@
#include "clang/AST/Expr.h"
#include "clang/AST/RecordLayout.h"
#include "CodeGenTypes.h"
-#include "llvm/Type.h"
#include "llvm/DerivedTypes.h"
+#include "llvm/Type.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetData.h"
using namespace clang;
using namespace CodeGen;
@@ -496,5 +497,41 @@
for (unsigned i = 0, e = Builder.LLVMBitFields.size(); i != e; ++i)
RL->BitFields.insert(Builder.LLVMBitFields[i]);
+ if (getContext().getLangOptions().DumpRecordLayouts)
+ RL->dump();
+
return RL;
}
+
+void CGRecordLayout::print(llvm::raw_ostream &OS) const {
+ OS << "<CGRecordLayout\n";
+ OS << " LLVMType:" << *LLVMType << "\n";
+ OS << " ContainsPointerToDataMember:" << ContainsPointerToDataMember << "\n";
+ OS << " BitFields:[\n";
+ for (llvm::DenseMap<const FieldDecl*, CGBitFieldInfo>::const_iterator
+ it = BitFields.begin(), ie = BitFields.end();
+ it != ie; ++it) {
+ OS << " ";
+ it->second.print(OS);
+ OS << "\n";
+ }
+ OS << "]>\n";
+}
+
+void CGRecordLayout::dump() const {
+ print(llvm::errs());
+}
+
+void CGBitFieldInfo::print(llvm::raw_ostream &OS) const {
+ OS << "<CGBitFieldInfo";
+ OS << " FieldTy:" << *FieldTy;
+ OS << " FieldNo:" << FieldNo;
+ OS << " Start:" << Start;
+ OS << " Size:" << Size;
+ OS << " IsSigned:" << IsSigned;
+ OS << ">";
+}
+
+void CGBitFieldInfo::dump() const {
+ print(llvm::errs());
+}
More information about the cfe-commits
mailing list