compiler/
lib/
examples/
std/
arch/
char/
collections/
lang/
alloc/
ast/
gen/
il/
binary/
binary.rad
5.9 KiB
printer.rad
16.0 KiB
tests.rad
14.7 KiB
module/
parser/
resolver/
scanner/
alloc.rad
7.1 KiB
ast.rad
26.7 KiB
gen.rad
513 B
il.rad
20.3 KiB
lower.rad
315.0 KiB
module.rad
14.9 KiB
package.rad
1.3 KiB
parser.rad
91.2 KiB
resolver.rad
452.9 KiB
scanner.rad
17.9 KiB
sexpr.rad
6.7 KiB
strings.rad
2.2 KiB
types.rad
1.6 KiB
sys/
arch.rad
68 B
char.rad
855 B
collections.rad
39 B
fmt.rad
8.3 KiB
intrinsics.rad
467 B
io.rad
1.7 KiB
lang.rad
276 B
mem.rad
2.3 KiB
sys.rad
179 B
testing.rad
2.4 KiB
tests.rad
15.7 KiB
vec.rad
3.2 KiB
std.rad
281 B
scripts/
seed/
sublime/
test/
vim/
.gitignore
336 B
.gitsigners
112 B
CONTRIBUTING
2.1 KiB
LICENSE
1.1 KiB
Makefile
5.4 KiB
README
2.5 KiB
STYLE
2.5 KiB
std.lib
1.5 KiB
std.lib.test
662 B
lib/std/lang/il/binary.rad
raw
| 1 | //! Binary RIL wire definitions. Integers use little-endian byte order. |
| 2 | //! Sequences have a u32 element count. Symbols use u32 table indices. |
| 3 | //! Optional fields use a byte: zero for absent, one for present. |
| 4 | |
| 5 | export mod writer; |
| 6 | export mod reader; |
| 7 | export mod program; |
| 8 | export mod collect; |
| 9 | |
| 10 | use std::lang::il; |
| 11 | @test export mod tests; |
| 12 | @test export mod decodeTests; |
| 13 | |
| 14 | /// Binary RIL signature, encoded as the bytes RIL followed by zero. |
| 15 | export constant MAGIC: u32 = 0x004c4952; |
| 16 | /// Binary RIL format version. |
| 17 | export constant VERSION: u32 = 1; |
| 18 | |
| 19 | /// A binary RIL encoding or decoding failure. |
| 20 | export union Error: Copy { |
| 21 | /// The output buffer has insufficient space. |
| 22 | Capacity, |
| 23 | /// A referenced name is absent from the symbol table. |
| 24 | Symbol, |
| 25 | /// An integer width, tag, or field is invalid. |
| 26 | Invalid, |
| 27 | /// The input ends inside a field. |
| 28 | Truncated, |
| 29 | /// The decode arena has insufficient space. |
| 30 | Storage, |
| 31 | } |
| 32 | |
| 33 | /// Wire tag for value Reg. |
| 34 | export constant VALUE_REG: u8 = 0; |
| 35 | /// Wire tag for value Imm. |
| 36 | export constant VALUE_IMM: u8 = 1; |
| 37 | /// Wire tag for value DataSym. |
| 38 | export constant VALUE_DATASYM: u8 = 2; |
| 39 | /// Wire tag for value FnAddr. |
| 40 | export constant VALUE_FNADDR: u8 = 3; |
| 41 | /// Wire tag for value Undef. |
| 42 | export constant VALUE_UNDEF: u8 = 4; |
| 43 | |
| 44 | /// Wire tag for instruction Reserve. |
| 45 | export constant INSTR_RESERVE: u8 = 0; |
| 46 | /// Wire tag for instruction Load. |
| 47 | export constant INSTR_LOAD: u8 = 1; |
| 48 | /// Wire tag for instruction Sload. |
| 49 | export constant INSTR_SLOAD: u8 = 2; |
| 50 | /// Wire tag for instruction Store. |
| 51 | export constant INSTR_STORE: u8 = 3; |
| 52 | /// Wire tag for instruction Blit. |
| 53 | export constant INSTR_BLIT: u8 = 4; |
| 54 | /// Wire tag for instruction Copy. |
| 55 | export constant INSTR_COPY: u8 = 5; |
| 56 | /// Wire tag for instruction BinOp. |
| 57 | export constant INSTR_BINOP: u8 = 6; |
| 58 | /// Wire tag for instruction UnOp. |
| 59 | export constant INSTR_UNOP: u8 = 7; |
| 60 | /// Wire tag for instruction Zext. |
| 61 | export constant INSTR_ZEXT: u8 = 8; |
| 62 | /// Wire tag for instruction Sext. |
| 63 | export constant INSTR_SEXT: u8 = 9; |
| 64 | /// Wire tag for instruction Call. |
| 65 | export constant INSTR_CALL: u8 = 10; |
| 66 | /// Wire tag for instruction Ret. |
| 67 | export constant INSTR_RET: u8 = 11; |
| 68 | /// Wire tag for instruction Jmp. |
| 69 | export constant INSTR_JMP: u8 = 12; |
| 70 | /// Wire tag for instruction Br. |
| 71 | export constant INSTR_BR: u8 = 13; |
| 72 | /// Wire tag for instruction Switch. |
| 73 | export constant INSTR_SWITCH: u8 = 14; |
| 74 | /// Wire tag for instruction Unreachable. |
| 75 | export constant INSTR_UNREACHABLE: u8 = 15; |
| 76 | /// Wire tag for instruction Ecall. |
| 77 | export constant INSTR_ECALL: u8 = 16; |
| 78 | /// Wire tag for instruction Ebreak. |
| 79 | export constant INSTR_EBREAK: u8 = 17; |
| 80 | /// Wire tag for instruction MemoryFence. |
| 81 | export constant INSTR_MEMORYFENCE: u8 = 18; |
| 82 | /// Wire tag for a checked device read. |
| 83 | export constant INSTR_DEVICE_READ: u8 = 19; |
| 84 | /// Wire tag for a checked device write. |
| 85 | export constant INSTR_DEVICE_WRITE: u8 = 20; |
| 86 | |
| 87 | /// Wire tag for data Val. |
| 88 | export constant DATA_VAL: u8 = 0; |
| 89 | /// Wire tag for data Sym. |
| 90 | export constant DATA_SYM: u8 = 1; |
| 91 | /// Wire tag for data Fn. |
| 92 | export constant DATA_FN: u8 = 2; |
| 93 | /// Wire tag for data Str. |
| 94 | export constant DATA_STR: u8 = 3; |
| 95 | /// Wire tag for data Undef. |
| 96 | export constant DATA_UNDEF: u8 = 4; |
| 97 | |
| 98 | /// Wire tag for binary operation Add. |
| 99 | export constant BIN_ADD: u8 = 0; |
| 100 | /// Wire tag for binary operation Sub. |
| 101 | export constant BIN_SUB: u8 = 1; |
| 102 | /// Wire tag for binary operation Mul. |
| 103 | export constant BIN_MUL: u8 = 2; |
| 104 | /// Wire tag for binary operation Sdiv. |
| 105 | export constant BIN_SDIV: u8 = 3; |
| 106 | /// Wire tag for binary operation Udiv. |
| 107 | export constant BIN_UDIV: u8 = 4; |
| 108 | /// Wire tag for binary operation Srem. |
| 109 | export constant BIN_SREM: u8 = 5; |
| 110 | /// Wire tag for binary operation Urem. |
| 111 | export constant BIN_UREM: u8 = 6; |
| 112 | /// Wire tag for binary operation Eq. |
| 113 | export constant BIN_EQ: u8 = 7; |
| 114 | /// Wire tag for binary operation Ne. |
| 115 | export constant BIN_NE: u8 = 8; |
| 116 | /// Wire tag for binary operation Slt. |
| 117 | export constant BIN_SLT: u8 = 9; |
| 118 | /// Wire tag for binary operation Sge. |
| 119 | export constant BIN_SGE: u8 = 10; |
| 120 | /// Wire tag for binary operation Ult. |
| 121 | export constant BIN_ULT: u8 = 11; |
| 122 | /// Wire tag for binary operation Uge. |
| 123 | export constant BIN_UGE: u8 = 12; |
| 124 | /// Wire tag for binary operation And. |
| 125 | export constant BIN_AND: u8 = 13; |
| 126 | /// Wire tag for binary operation Or. |
| 127 | export constant BIN_OR: u8 = 14; |
| 128 | /// Wire tag for binary operation Xor. |
| 129 | export constant BIN_XOR: u8 = 15; |
| 130 | /// Wire tag for binary operation Shl. |
| 131 | export constant BIN_SHL: u8 = 16; |
| 132 | /// Wire tag for binary operation Sshr. |
| 133 | export constant BIN_SSHR: u8 = 17; |
| 134 | /// Wire tag for binary operation Ushr. |
| 135 | export constant BIN_USHR: u8 = 18; |
| 136 | |
| 137 | /// Wire tag for unary operation Neg. |
| 138 | export constant UN_NEG: u8 = 0; |
| 139 | /// Wire tag for unary operation Not. |
| 140 | export constant UN_NOT: u8 = 1; |
| 141 | |
| 142 | /// Wire tag for comparison Eq. |
| 143 | export constant CMP_EQ: u8 = 0; |
| 144 | /// Wire tag for comparison Ne. |
| 145 | export constant CMP_NE: u8 = 1; |
| 146 | /// Wire tag for comparison Slt. |
| 147 | export constant CMP_SLT: u8 = 2; |
| 148 | /// Wire tag for comparison Ult. |
| 149 | export constant CMP_ULT: u8 = 3; |
| 150 | |
| 151 | |
| 152 | /// The kind of an exported package symbol. |
| 153 | export union ExportKind: Copy { |
| 154 | /// A callable function entry. |
| 155 | Function, |
| 156 | /// A global data definition. |
| 157 | Data, |
| 158 | } |
| 159 | |
| 160 | /// A public symbol supplied by a package. |
| 161 | export record Export: Copy { |
| 162 | /// Qualified symbol name. |
| 163 | name: *[u8], |
| 164 | /// Definition kind. |
| 165 | kind: ExportKind, |
| 166 | } |
| 167 | |
| 168 | /// A binary package and its IL definitions. |
| 169 | /// Referenced storage must remain valid and immutable while the package is read. |
| 170 | export record Package: Copy { |
| 171 | /// Unique symbol names in wire-index order. |
| 172 | symbols: *unsafe [*[u8]], |
| 173 | /// Immutable package name. |
| 174 | name: *[u8], |
| 175 | /// Names of required packages. |
| 176 | dependencies: *unsafe [*[u8]], |
| 177 | /// Public definitions. |
| 178 | exports: *unsafe [Export], |
| 179 | /// Default exported entry, if the package has one. |
| 180 | entry: ?*[u8], |
| 181 | /// Package-local functions and global data. |
| 182 | program: il::Program, |
| 183 | } |
| 184 | |
| 185 | /// Structural limits supplied by the consumer of decoded IL. |
| 186 | export record Limits: Copy { |
| 187 | /// Exclusive upper bound for SSA register numbers. |
| 188 | registers: u32, |
| 189 | /// Maximum number of blocks in one function. |
| 190 | blocks: u32, |
| 191 | } |