IRGen: Change the meaning of a dynamic StoredOffset

Instead of storing an llvm::Constant, store an offset relative to
the class metadata base.
This commit is contained in:
Slava Pestov
2017-12-21 00:38:41 -08:00
parent 810bc899ab
commit dd7f09d8de
2 changed files with 35 additions and 18 deletions

View File

@@ -44,6 +44,8 @@ class LayoutScanner : public Base<Impl> {
Optional<Size> AddressPoint;
protected:
Optional<Size> DynamicOffsetBase;
template <class... As>
LayoutScanner(As &&... args) : Base<Impl>(std::forward<As>(args)...) {}
@@ -52,7 +54,13 @@ public:
void noteAddressPoint() { AddressPoint = this->NextOffset; }
StoredOffset getNextOffset() const {
return StoredOffset(this->NextOffset - AddressPoint.getValue());
if (DynamicOffsetBase) {
return StoredOffset(this->NextOffset - *DynamicOffsetBase,
StoredOffset::Dynamic);
}
return StoredOffset(this->NextOffset - *AddressPoint,
StoredOffset::Static);
}
Size getAddressPoint() const {