@@ -640,13 +640,55 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *rd, cir::RecordType *ty) {
640
640
641
641
// Dump the layout, if requested.
642
642
if (getASTContext ().getLangOpts ().DumpRecordLayouts ) {
643
- cgm.errorNYI (rd->getSourceRange (), " computeRecordLayout: dump layout" );
643
+ llvm::outs () << " \n *** Dumping CIRgen Record Layout\n " ;
644
+ llvm::outs () << " Record: " ;
645
+ rd->dump (llvm::outs ());
646
+ llvm::outs () << " \n Layout: " ;
647
+ rl->print (llvm::outs ());
644
648
}
645
649
646
650
// TODO: implement verification
647
651
return rl;
648
652
}
649
653
654
+ void CIRGenRecordLayout::print (raw_ostream &os) const {
655
+ os << " <CIRecordLayout\n " ;
656
+ os << " CIR Type:" << completeObjectType << " \n " ;
657
+ if (baseSubobjectType)
658
+ os << " NonVirtualBaseCIRType:" << baseSubobjectType << " \n " ;
659
+ os << " IsZeroInitializable:" << zeroInitializable << " \n " ;
660
+ os << " BitFields:[\n " ;
661
+ std::vector<std::pair<unsigned , const CIRGenBitFieldInfo *>> bitInfo;
662
+ for (auto &[decl, info] : bitFields) {
663
+ const RecordDecl *rd = decl->getParent ();
664
+ unsigned index = 0 ;
665
+ for (RecordDecl::field_iterator it = rd->field_begin (); *it != decl; ++it)
666
+ ++index;
667
+ bitInfo.push_back (std::make_pair (index, &info));
668
+ }
669
+ llvm::array_pod_sort (bitInfo.begin (), bitInfo.end ());
670
+ for (std::pair<unsigned , const CIRGenBitFieldInfo *> &info : bitInfo) {
671
+ os.indent (4 );
672
+ info.second ->print (os);
673
+ os << " \n " ;
674
+ }
675
+ os << " ]>\n " ;
676
+ }
677
+
678
+ void CIRGenBitFieldInfo::print (raw_ostream &os) const {
679
+ os << " <CIRBitFieldInfo" << " name:" << name << " offset:" << offset
680
+ << " size:" << size << " isSigned:" << isSigned
681
+ << " storageSize:" << storageSize
682
+ << " storageOffset:" << storageOffset.getQuantity ()
683
+ << " volatileOffset:" << volatileOffset
684
+ << " volatileStorageSize:" << volatileStorageSize
685
+ << " volatileStorageOffset:" << volatileStorageOffset.getQuantity () << " >" ;
686
+ }
687
+
688
+ void CIRGenRecordLayout::dump () const { print (llvm::errs ()); }
689
+
690
+ void CIRGenBitFieldInfo::dump () const { print (llvm::errs ()); }
691
+
650
692
void CIRRecordLowering::lowerUnion () {
651
693
CharUnits layoutSize = astRecordLayout.getSize ();
652
694
mlir::Type storageType = nullptr ;
0 commit comments