Replies: 2 comments 2 replies
-
A very quick idea we could consider for N⋆ is this (key points are in bold):
For each of these points, we could create file “sections” (in a specific interface file), something along those lines: # x86.nsti
%registers 6;;
# Indicate there are only 6 registers named `%r0` to `%r5` for the X86 architecture
%instructions {
# `mov` takes 2 arguments, where `src` must have type `τ` and the continuation is neither `src` nor `dst`
mov/2 | src dst := ( Γ; Δ; Ξ; χ; σ; ε ⊢ src : τ
& src /= ε
& dst /= ε
) => (Γ; Δ; Ξ; χ; σ; ε ⊢ Γ; Δ; Ξ; χ ∖ dst, dst : τ; σ; ε);;
# No syntax errors: only type errors (clearer)
# In this case, we should have pattern matched on `dst` to only allow registers as the destination operand
# but for the sake of being a simple example, we did not
#
# This also lacks an alternative ASCII syntax, but this is not the main problem at all
}
%rewrite {
mov/2 | src dst := ignore;;
# Completely optimize away any `mov/2` from the source code, before generating machine code
}
let registerNumber
| (reg 0) := 2
| (reg 1) := 3
| (reg 2) := 0
# ...
;;
# We can also embed micro helper functions which can be used throughout the sections (mostly `%rewrite` and `%generate`)
%generate {
# move from register `src` to register `dst`
mov/2 | (reg src) (reg dst) := [ 0x10, 0x20, registerNumber src, 0x30, registerNumber dst ];;
# Not actual valid x86 machine code
} |
Beta Was this translation helpful? Give feedback.
-
This is in fact not that great of an idea. First of all, this makes N⋆ hard to maintain: 3 languages instead of 1, each having completely different evaluation strategies. Therefore, this will not happen. N⋆ stays the way it has been and will be extended with new features (see e.g. #59 and #47) or new targets (see #57 and #37). |
Beta Was this translation helpful? Give feedback.
-
It's that time of the year, thinking about re-designing N⋆ (again).
As of now, N⋆ lacks flexibility:
r0
untilr5
(whereas there are more than 16 registers on amd64)But here are some challenges:
Beta Was this translation helpful? Give feedback.
All reactions