asm templates - #7271
Open
gingerBill wants to merge 51 commits into
Open
Conversation
I know... a class. If only C++ had a nice way to package different things like Odin itself.
…hey are in terms of bits too.
…syntax for `[base]:u8` (not implemented yet)
…ermine the correct suffix to use
gingerBill
marked this pull request as ready for review
August 12, 2026 15:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: Only
-target:amd64is supported for now.The general
instruction [operand{, operand}]form is intended as a universal syntax across instruction set architectures: every ISA shares this common grammar while still exposing its own instructions and registers. The approach is modeled on Go's Plan 9–derived assembler, which likewise uses one syntax across all its targets (Go's assembler guide, the Plan 9 assembler manual). That syntax originated with Plan 9 (Ken Thompson's toolchain) and was carried into Go.Rather than free-standing assembly blocks, Odin uses assembly templates. A template is instantiated at each call site like a procedure, which makes it easy to compose and lets it behave much like an intrinsic.
Over time, some of the current platform-specific intrinsics will be reimplemented on top of this asm template system.
Plans:
core:rexcodefor all of the encoding table informationUniversal Syntax
n.b. A universal syntax does not mean a generic set of mnemonics, it just means the syntax (not the semantics) are shared across ISAs.
%rax[base + index*scale + disp]dispis not on ARM64, then the compiler the err on that.[base][base + index][base + index*scale][base + index<<scale][base + index>>scale](platform specific)[base + index*scale + disp](platform specific)[..]:type// type interpretation[]block. A specification can state:x -> yx = %raxacc0: #simd[4]f32oracc0: #simd[4]f32 = %xmm0#clobber memory#clobber cc#clobber %rcxmnemonic dst, srcExamples showing syntax