@@ -164,13 +164,21 @@ class Builder {
164164
165165 // / Generates {slot, offset} for packed storage array indexing.
166166 Value genPackedStorageAddr (Value baseSlot, Value idx, Type eltTy,
167+ bool isDataLeftAligned = false ,
167168 std::optional<Location> locArg = std::nullopt );
168169
169170 // / Loads slot and punches hole: and(sload(slot), holeMask)
170171 // / where holeMask = not(ones(numBits) << shiftBits)
171172 Value genPunchHole (Value slot, Value shiftBits, unsigned numBits,
172173 std::optional<Location> locArg = std::nullopt );
173174
175+ // / Inserts integer value (<=32 bytes) to the slot value:
176+ // / or(and(slot, holeMask), shiftedVal), where
177+ // / holeMask = not(ones(numBits) << offset * 8),
178+ // / shiftedVal = (intVal << offset * 8)
179+ Value genInsertIntToSlot (Value slot, Value offset, Value intVal,
180+ unsigned numBits, std::optional<Location> locArg);
181+
174182 // / Generates a load from the low level integral type address.
175183 Value genLoad (Value addr, sol::DataLocation dataLoc,
176184 std::optional<Location> locArg = std::nullopt );
@@ -187,12 +195,48 @@ class Builder {
187195 void genStringStore (std::string const &str, Value addr,
188196 std::optional<Location> locArg = std::nullopt );
189197
190- // / Generates a loop to copy the data. This works for low level integral type
191- // / addresses.
192- void genCopyLoop (Value srcAddr, Value dstAddr, Value sizeInWords, Type srcTy,
193- Type dstTy, sol::DataLocation srcDataLoc,
194- sol::DataLocation dstDataLoc,
195- std::optional<Location> locArg = std::nullopt );
198+ // / Generates length of a string.
199+ mlir::Value
200+ genStringLength (mlir::Value lengthSlot, mlir::sol::DataLocation dataLoc,
201+ std::optional<mlir::Location> locArg = std::nullopt );
202+
203+ // / Copies a string from storage to memory.
204+ void
205+ genCopyStringToMemory (mlir::Value srcDataAddr, mlir::Value lengthSlot,
206+ mlir::Value length, mlir::Value dstAddr,
207+ std::optional<mlir::Location> locArg = std::nullopt );
208+
209+ // / Copies a string to the storage.
210+ void
211+ genCopyStringToStorage (mlir::Value srcDataAddr, mlir::Value lengthSlot,
212+ mlir::Value length, mlir::Value dstAddr,
213+ mlir::sol::DataLocation srcDataLoc,
214+ std::optional<mlir::Location> locArg = std::nullopt );
215+
216+ // / Copies an object of type \p ty from \p srcAddr to \p dstAddr.
217+ void genCopy (mlir::Type ty, mlir::Value srcAddr, mlir::Value dstAddr,
218+ mlir::sol::DataLocation srcDataLoc,
219+ mlir::sol::DataLocation dstDataLoc,
220+ std::optional<mlir::Location> locArg = std::nullopt );
221+
222+ // / Generates the 'push' of a value to string.
223+ void genPushToString (mlir::Value srcAddr, mlir::Value value,
224+ std::optional<mlir::Location> locArg = std::nullopt );
225+
226+ // / Generates the 'push' of a default value to string and
227+ // / returns a fat pointer to the newly added element.
228+ Value
229+ genPushVoidToString (Value srcAddr,
230+ std::optional<mlir::Location> locArg = std::nullopt );
231+
232+ // / Generates the 'pop' for string.
233+ void genPopString (mlir::Value srcAddr, mlir::Value oldData,
234+ mlir::Value length,
235+ std::optional<mlir::Location> locArg = std::nullopt );
236+
237+ // / Generates {slot, offset} for string storage indexing.
238+ Value genStringItemAddress (mlir::Value srcAddr, mlir::Value idx,
239+ std::optional<Location> locArg = std::nullopt );
196240
197241 // / Generates an assertion that the tuple size should be less than `size`.
198242 void genABITupleSizeAssert (TypeRange tys, Value size,
0 commit comments