@@ -640,13 +640,55 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *rd, cir::RecordType *ty) {
640640
641641 // Dump the layout, if requested.
642642 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 ());
644648 }
645649
646650 // TODO: implement verification
647651 return rl;
648652}
649653
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+
650692void CIRRecordLowering::lowerUnion () {
651693 CharUnits layoutSize = astRecordLayout.getSize ();
652694 mlir::Type storageType = nullptr ;
0 commit comments