tnj-air

Crates.iotnj-air
lib.rstnj-air
version0.3.0
sourcesrc
created_at2024-08-26 16:11:35.601527
updated_at2024-10-09 15:00:16.526383
descriptionTNJ Assembly Intermediate Representation (AIR)
homepage
repository
max_upload_size
id1352392
size110,127
Martin Fink (martin-fink)

documentation

README

Assembly Intermediate Representation (AIR)

This IR's purpose to model the semantics of assembly languages without delving into the detail of architectures.

Example

Currently, AIR looks like this:

arch:
  # define the pointer type of the current architecture
  ptr: i64
  # define the CPU registers and their type
  regs:
    "x0": i64
    "x1": i64
  # here, the user can define architecture-specific instructions 
  instructions:
    pacia:
      ty: i64
      operands: i64, i64

entry:
  v0 = i64.read_reg "x0"
  v1 = arch.pacia v0, 0x2a
  i64.write_reg v1, "x0"
  v2 = i64.read_reg "x1"
  v3 = i64.icmp.eq v2, 0x0
  jumpif v3, block1, block2

block1:
  ret

block2:
  trap

The above code roughly corresponds to something like this:

  pacia x0, #0x2a
  cmp x1, #0
  bne block2
  ret

block2:
  udf # unconditionally trap
Commit count: 0

cargo fmt