-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement inline assembly #21
Commits on Sep 7, 2023
-
feat: implement local variables
This commit introduces a new data type to represent local variable declarations. These are not currently attached to anything, but are used downstream during code generation. The local identifiers are also used in the in-crate representation of Miden Assembly, coming in a follow-on commit.
Configuration menu - View commit details
-
Copy full SHA for 840eacd - Browse repository at this point
Copy the full SHA 840eacdView commit details -
feat: implement inline assembly
This commit fleshes out the implementation of inline assembly that we had essentially stubbed out prior to this. The following are provided as part of this implementation: * A representation of the Miden Assembly instruction set, in crate, with the ops we intend to support in the near term. This is used to represent the contents of inline assembly, and is also used in the upcoming codegen backend as the target IR for Miden Assembly, as it is a flatter representation similar to Miden IR. The intent is to also implement a tiny evaluator for this subset of Miden Assembly for use in tests without having to emit MASM files, and run the Miden VM which is much more expensive. It also allows us to track the subset of Miden Assembly which we support in the compiler, as well as represent experimental changes that have not yet been implemented upstream. * `MasmBuilder`, which is constructed from an `InstBuilder` via `inline_asm`, and plays a similar role to `FunctionBuilder`+`InstBuilder`, but in terms of Miden Assembly, in the context of constructing a single inline assembly block. * Improved pretty printing of inline assembly. Now, an inline assembly block is printed like so (this block adds the two inputs, and squares the result, which is returned as the result of the inline assembly block): ```hir asm (v1, v2) { add mul.2 } : felt ``` * A generic data structure for use in representing the operand stack, and the common operations which are performed on it. This is used to validate inline assembly, as well as keep track of values during code generation. It will also likely be used for whatever evaluator we throw together for use in testing.
Configuration menu - View commit details
-
Copy full SHA for 0b907c5 - Browse repository at this point
Copy the full SHA 0b907c5View commit details
Commits on Sep 8, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 6a3f542 - Browse repository at this point
Copy the full SHA 6a3f542View commit details
Commits on Sep 9, 2023
-
feat: provide type representation enum
The [TypeRepr] enum is intended to represent how a specific [Type] will be encoded in terms of field elements/words on the operand stack in Miden. See the doc comments for details. This is meant to provide a single source for information regarding type layout in Miden. For types in linear memory, the encoding is slightly different, as we must preserve the semantics of byte-addressability in the IR. However, when placing values on the operand stack, the encoding is modified to provide a more natural alignment between individual terms and elements on the stack. The specific representations in this commit are just an initial draft based on details I'm aware of at this time, but we may make adjustments as necessary.
Configuration menu - View commit details
-
Copy full SHA for ce27449 - Browse repository at this point
Copy the full SHA ce27449View commit details -
Configuration menu - View commit details
-
Copy full SHA for e57d3d4 - Browse repository at this point
Copy the full SHA e57d3d4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 038a18d - Browse repository at this point
Copy the full SHA 038a18dView commit details -
Configuration menu - View commit details
-
Copy full SHA for f23d96f - Browse repository at this point
Copy the full SHA f23d96fView commit details -
Configuration menu - View commit details
-
Copy full SHA for f73ab07 - Browse repository at this point
Copy the full SHA f73ab07View commit details -
Configuration menu - View commit details
-
Copy full SHA for b52776d - Browse repository at this point
Copy the full SHA b52776dView commit details -
fix: reimplement builders for inline asm control flow
The previous implementation did not provide us with an opportunity to validate the state of the operand stack after the control flow instruction is constructed. It also failed to account for changes to the operand stack within the control flow instruction body. This commit introduces a new implementation, one for if.true, and one for the loop instructions, which provides a builder API for those instructions. These builders ensure that upon construction, the operand stack is consistent across all control flow edges leaving the instruction, as well as checking other important invariants, such as while.true requiring a boolean on top of the stack when entering/exiting.
Configuration menu - View commit details
-
Copy full SHA for 0485488 - Browse repository at this point
Copy the full SHA 0485488View commit details -
Configuration menu - View commit details
-
Copy full SHA for f30185c - Browse repository at this point
Copy the full SHA f30185cView commit details
Commits on Sep 13, 2023
-
feat: define type compatibility for operators
This implements a function on `Type` called `is_compatible_operand`, whose purpose is to determine if a type is compatible with another type in the context of a binary operator. Type compatibility is defined here in terms of what types can be implicitly coerced to the controlling type of the operator safely. For example, one can safely apply `u32.add` to `u32` and `u8`, where `u32` is the operand whose type "controls" the expected type produced by the operation. Similarly, applying `u32.add` to `u8` and `u8` is safe, albeit with no guarantees about catching overflow of the `u8` range, both operands are `u32` compatible. On the other hand, applying `u32.add` to `u32` and `i32` is not compatible, because `u32.add` does not handle signed integers, not to mention there is no way to handle negative results. This commit also has a couple small tweaks to how a few of the predicate functions are expressed to suppress some clippy warnings.
Configuration menu - View commit details
-
Copy full SHA for 79fc777 - Browse repository at this point
Copy the full SHA 79fc777View commit details
Commits on Sep 14, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 2b8d905 - Browse repository at this point
Copy the full SHA 2b8d905View commit details -
refactor: improve handling of stack effects in inline assembly
This commit extracts out the handle of stack affects for the inline assembly builders, and addresses a number of places in which the types were either not validated, or were incorrectly validated/applied.
Configuration menu - View commit details
-
Copy full SHA for c7760df - Browse repository at this point
Copy the full SHA c7760dfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 15a104c - Browse repository at this point
Copy the full SHA 15a104cView commit details