Skip to content

Commit

Permalink
Add comments about offset convention
Browse files Browse the repository at this point in the history
  • Loading branch information
aborg-dev committed Jan 26, 2024
1 parent f5b9c55 commit fe4edfb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions cranelift/codegen/src/isa/zkasm/lower.isle
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@
(load_ext_name name 0))

;;;;; Rules for `symbol_value`;;;;;;;;;
;; Heap starts at offset 0 in zkAsm machine memory.
(rule
(lower (symbol_value (zkasm_base ZkasmBase.Heap)))
(imm $I32 0))
Expand Down
4 changes: 4 additions & 0 deletions cranelift/codegen/src/isa/zkasm/lower/isle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ impl generated_code::Context for ZkAsmIsleContext<'_, '_, MInst, ZkAsmBackend> {
match name {
ExternalName::User(user_name_ref) => {
// All ZKASM "memory"-like accesses use this name, but different offsets.
// This is our convention as is not related to the actual offsets in zkAsm
// machine memory that will be used by each base.
// These offsets need to be aligned with the offsets used in
// `cranelift_wasm::environ::zkasm::ZkasmFuncEnvironment`.
if user_name_ref.index() != 0 {
return None;
}
Expand Down

0 comments on commit fe4edfb

Please sign in to comment.