+ if (Layouts) {
+ // Remove any layouts for this TD.
+ std::map<std::pair<const TargetData*,
+ const StructType*>, StructLayout>::iterator
+ I = Layouts->lower_bound(std::make_pair(this, (const StructType*)0));
+ while (I != Layouts->end() && I->first.first == this)
+ Layouts->erase(I++);
+ if (Layouts->empty()) {
+ delete Layouts;
+ Layouts = 0;
+ }
+ }
+}
+
+const StructLayout *TargetData::getStructLayout(const StructType *Ty) const {
+ if (Layouts == 0)
+ Layouts = new std::map<std::pair<const TargetData*,const StructType*>,
+ StructLayout>();
+ std::map<std::pair<const TargetData*,const StructType*>,
+ StructLayout>::iterator
+ I = Layouts->lower_bound(std::make_pair(this, Ty));
+ if (I != Layouts->end() && I->first.first == this && I->first.second == Ty)
+ return &I->second;
+ else {
+ return &Layouts->insert(I, std::make_pair(std::make_pair(this, Ty),
+ StructLayout(Ty, *this)))->second;
+ }