@@ -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,49 @@ 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 to the memory.
204+ void
205+ genCopyStringToMemory (mlir::Value srcDataAddr, mlir::Value lengthSlot,
206+ mlir::Value length, mlir::Value dstAddr,
207+ mlir::sol::DataLocation srcDataLoc,
208+ std::optional<mlir::Location> locArg = std::nullopt );
209+
210+ // / Copies a string to the storage.
211+ void
212+ genCopyStringToStorage (mlir::Value srcDataAddr, mlir::Value lengthSlot,
213+ mlir::Value length, mlir::Value dstAddr,
214+ mlir::sol::DataLocation srcDataLoc,
215+ std::optional<mlir::Location> locArg = std::nullopt );
216+
217+ // / Copies an object of type \p ty from \p srcAddr to \p dstAddr.
218+ void genCopy (mlir::Type ty, mlir::Value srcAddr, mlir::Value dstAddr,
219+ mlir::sol::DataLocation srcDataLoc,
220+ mlir::sol::DataLocation dstDataLoc,
221+ std::optional<mlir::Location> locArg = std::nullopt );
222+
223+ // / Generates the 'push' of a value to string.
224+ void genPushToString (mlir::Value srcAddr, mlir::Value value,
225+ std::optional<mlir::Location> locArg = std::nullopt );
226+
227+ // / Generates the 'push' of a default value to string and
228+ // / returns a fat pointer to the newly added element.
229+ Value
230+ genPushVoidToString (Value srcAddr,
231+ std::optional<mlir::Location> locArg = std::nullopt );
232+
233+ // / Generates the 'pop' for string.
234+ void genPopString (mlir::Value srcAddr, mlir::Value oldData,
235+ mlir::Value length,
236+ std::optional<mlir::Location> locArg = std::nullopt );
237+
238+ // / Generates {slot, offset} for string storage indexing.
239+ Value genStringItemAddress (mlir::Value srcAddr, mlir::Value idx,
240+ std::optional<Location> locArg = std::nullopt );
196241
197242 // / Generates an assertion that the tuple size should be less than `size`.
198243 void genABITupleSizeAssert (TypeRange tys, Value size,
0 commit comments