interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tools / omega_emit / SCHEMA.md

65 lines · 3813 bytes Raw Blame History Source

Op-list schema v1 (omega_emit input)

You describe a program as one JSON object. omega_emit checks every op as it reads it and refuses the first invalid one with a reason; a fully valid list becomes canonical OSC binary IR.

Shape

{"functions": [ FUNCTION, ... ]}            1..32 functions
FUNCTION = {"name": NAME, "params": [TYPE, ...], "ret": TYPE or "void",
            "locals": [TYPE, ...], "blocks": [ BLOCK, ... ]}
BLOCK    = [ OP, ... ]                       1 or more ops; the LAST op is br, cbr or ret, and only the last

Ops

Fields are register numbers unless stated. dst is written; the others are read.

opfieldsmeaning
constdst, valuedst = value (a whole decimal number that fits dst's type; true/false for bool)
movdst, adst = a: the same scalar type; or, for an array dst, an array of the same element type and length: own: from own: (a move), mut: from own: or mut:, shared: from any
add sub mul div remdst, a, bdst = a op b; dst, a, b the same integer type
and or xordst, a, bbitwise (or logical, on bool); dst, a, b the same type
shl shrdst, a, bdst = a shifted by b; dst and a the same integer type, b any integer type
neg bnotdst, adst = -a / bitwise not of a (same integer type)
notdst, adst = logical not of a (bool)
eq ne lt le gt gedst, a, bdst (bool) = a compared with b (a, b the same type)
castdst, adst = a converted to dst's integer type
allocdst, initdst (an own: array) = new array, every element = init (element type)
releasearrgive an own: array back
loaddst, arr, indexdst = arr[index] (dst has the element type, index any integer type)
storearr, index, valuearr[index] = value (arr is own: or mut:)
callfunc (a function NAME), args (list of registers), dst (omit for a void callee)dst = func(args)
trapcode (1..14)stop with that trap code (the block still ends with br, cbr or ret)
brto (block number)continue at block to
cbrcond (bool register), then, else (block numbers)continue at then if cond, else at else
reta (omit in a void function)return a (the function's ret type)

Example: fn clamp_sub(a: u32, b: u32) -> u32: a - b when a >= b, else 0.

{"functions": [
  {"name": "clamp_sub", "params": ["u32", "u32"], "ret": "u32", "locals": ["bool", "u32", "u32"],
   "blocks": [
    [{"op": "ge", "dst": 2, "a": 0, "b": 1}, {"op": "cbr", "cond": 2, "then": 1, "else": 2}],
    [{"op": "sub", "dst": 3, "a": 0, "b": 1}, {"op": "ret", "a": 3}],
    [{"op": "const", "dst": 4, "value": 0}, {"op": "ret", "a": 4}]
   ]}
]}

A loop is a block that branches back to an earlier block (br or cbr to a lower block number).