nir/nirinsts

Search:
Group by:
Source   Edit  

NIR instructions. Somewhat inspired by LLVM's instructions.

Types

Instr = object
  info*: PackedLineInfo
Source   Edit  
LabelId = distinct int
Source   Edit  
NodePos = distinct int
Source   Edit  
Opcode = enum
  Nop, ImmediateVal, IntVal, StrVal, SymDef, SymUse, Typed, PragmaId, NilVal,
  Label, Goto, CheckedGoto, LoopLabel, GotoLoop, ModuleSymUse, ArrayConstr,
  ObjConstr, Ret, Yld, Select, SelectPair, SelectList, SelectValue, SelectRange,
  ForeignDecl, SummonGlobal, SummonThreadLocal, Summon, SummonResult,
  SummonParam, SummonConst, Kill, AddrOf, ArrayAt, DerefArrayAt, FieldAt,
  DerefFieldAt, Load, Store, Asgn, SetExc, TestExc, CheckedRange, CheckedIndex,
  Call, IndirectCall, CheckedCall, CheckedIndirectCall, CheckedAdd, CheckedSub,
  CheckedMul, CheckedDiv, CheckedMod, Add, Sub, Mul, Div, Mod, BitShl, BitShr,
  BitAnd, BitOr, BitXor, BitNot, BoolNot, Eq, Le, Lt, Cast, NumberConv,
  CheckedObjConv, ObjConv, TestOf, Emit, ProcDecl, ForeignProcDecl, PragmaPair
Source   Edit  
PatchPos = distinct int
Source   Edit  
PragmaKey = enum
  FastCall, StdCall, CDeclCall, SafeCall, SysCall, InlineCall, NoinlineCall,
  ThisCall, NoCall, CoreName, ExternName, HeaderImport, DllImport, DllExport,
  ObjExport
Source   Edit  
SymId = distinct int
Source   Edit  
SymNames = object
Source   Edit  
Tree = object
Source   Edit  
Value = distinct Tree
Source   Edit  
Values = object
Source   Edit  

Consts

InvalidPatchPos = -1
Source   Edit  
nirCookie = [0'u, 78'u, 73'u, 82'u, 64'u, 0, 0'u, 1'u]
Source   Edit  
ValueProducing = {ImmediateVal, IntVal, StrVal, SymUse, NilVal, ModuleSymUse,
                  ArrayConstr, ObjConstr, CheckedAdd, CheckedSub, CheckedMul,
                  CheckedDiv, CheckedMod, Add, Sub, Mul, Div, Mod, BitShl,
                  BitShr, BitAnd, BitOr, BitXor, BitNot, BoolNot, Eq, Le, Lt,
                  Cast, NumberConv, CheckedObjConv, ObjConv, AddrOf, Load,
                  ArrayAt, DerefArrayAt, FieldAt, DerefFieldAt, TestOf}
Source   Edit  

Procs

proc `$`(s: SymId): string {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc `==`(a, b: LabelId): bool {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc `==`(a, b: SymId): bool {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc `[]`(t: SymNames; key: SymId): LitId {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc `[]=`(t: var SymNames; key: SymId; val: LitId) {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc addImmediateVal(t: var Tree; info: PackedLineInfo; x: int) {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc addImmediateVal(t: var Value; info: PackedLineInfo; x: int) {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc addIntVal(t: var Tree; integers: var BiTable[int64]; info: PackedLineInfo;
               typ: TypeId; x: int64) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc addIntVal(t: var Value; integers: var BiTable[int64]; info: PackedLineInfo;
               typ: TypeId; x: int64) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc addLabel(t: var Tree; info: PackedLineInfo; k: Opcode; L: LabelId) {.
    inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc addNewLabel(t: var Tree; labelGen: var int; info: PackedLineInfo; k: Opcode): LabelId {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc addNilVal(t: var Tree; info: PackedLineInfo; typ: TypeId) {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc addNilVal(t: var Value; info: PackedLineInfo; typ: TypeId) {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc addNop(t: var Tree; info: PackedLineInfo) {.inline, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc addPragmaId(t: var Tree; info: PackedLineInfo; x: PragmaKey) {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc addStrLit(t: var Tree; info: PackedLineInfo; s: LitId) {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc addStrVal(t: var Tree; strings: var BiTable[string]; info: PackedLineInfo;
               s: string) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc addStrVal(t: var Value; strings: var BiTable[string]; info: PackedLineInfo;
               s: string) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc addSummon(t: var Tree; info: PackedLineInfo; s: SymId; typ: TypeId;
               opc = Summon) {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc addSymDef(t: var Tree; info: PackedLineInfo; s: SymId) {.inline,
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc addSymUse(t: var Tree; info: PackedLineInfo; s: SymId) {.inline,
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc addTyped(t: var Tree; info: PackedLineInfo; typ: TypeId) {.inline,
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc addTyped(t: var Value; info: PackedLineInfo; typ: TypeId) {.inline,
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc allTreesToString(t: Tree; strings: BiTable[string];
                      integers: BiTable[int64]; names: SymNames; r: var string) {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc boolVal(t: var Tree; integers: var BiTable[int64]; info: PackedLineInfo;
             b: bool) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc copyTree(dest: var Tree; src: Tree) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc copyTree(dest: var Tree; src: Value) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc escapeToNimLit(s: string; result: var string) {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc extractTemp(v: Value): SymId {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc gotoLabel(t: var Tree; info: PackedLineInfo; k: Opcode; L: LabelId) {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc hash(a: LabelId): Hash {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc hash(s: SymId): Hash {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc hasValue(v: Value): bool {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc immediateVal(ins: Instr): int {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc isEmpty(v: Value): bool {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc label(ins: Instr): LabelId {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc len(tree: Tree): int {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc litId(ins: Instr): LitId {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc load(r: var RodFile; t: var SymNames) {....raises: [IOError],
    tags: [ReadIOEffect], forbids: [].}
Source   Edit  
proc load(r: var RodFile; t: var Tree) {....raises: [IOError],
    tags: [ReadIOEffect], forbids: [].}
Source   Edit  
proc localToValue(info: PackedLineInfo; s: SymId): Value {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc newLabel(labelGen: var int): LabelId {.inline, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc newLabels(labelGen: var int; n: int): LabelId {.inline, ...raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc next(tree: Tree; pos: var NodePos) {.inline, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc patch(dest: var Value; pos: PatchPos) {.inline, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc patch(tree: var Tree; pos: PatchPos) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc prepare(dest: var Value; info: PackedLineInfo; k: Opcode): PatchPos {.
    inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc prepare(tree: var Tree; info: PackedLineInfo; kind: Opcode): PatchPos {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc sons2(tree: Tree; n: NodePos): (NodePos, NodePos) {.inline, ...raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc sons3(tree: Tree; n: NodePos): (NodePos, NodePos, NodePos) {.inline,
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc sons4(tree: Tree; n: NodePos): (NodePos, NodePos, NodePos, NodePos) {.
    inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc sons5(tree: Tree; n: NodePos): (NodePos, NodePos, NodePos, NodePos, NodePos) {.
    inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc store(r: var RodFile; t: SymNames) {....raises: [IOError],
    tags: [WriteIOEffect], forbids: [].}
Source   Edit  
proc store(r: var RodFile; t: Tree) {....raises: [IOError], tags: [WriteIOEffect],
                                      forbids: [].}
Source   Edit  
proc symId(ins: Instr): SymId {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc toString(t: Tree; pos: NodePos; strings: BiTable[string];
              integers: BiTable[int64]; names: SymNames; r: var string;
              nesting = 0) {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc typeId(ins: Instr): TypeId {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  

Iterators

iterator sons(tree: Tree; n: NodePos): NodePos {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
iterator sonsFrom1(tree: Tree; n: NodePos): NodePos {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
iterator sonsFromN(tree: Tree; n: NodePos; toSkip = 2): NodePos {....raises: [],
    tags: [], forbids: [].}
Source   Edit  
iterator sonsRest(tree: Tree; parent, n: NodePos): NodePos {....raises: [],
    tags: [], forbids: [].}
Source   Edit  

Templates

template `[]`(t: Tree; n: NodePos): Instr
Source   Edit  
template build(tree: var Tree; info: PackedLineInfo; kind: Opcode; body: untyped)
Source   Edit  
template build(tree: var Value; info: PackedLineInfo; kind: Opcode;
               body: untyped)
Source   Edit  
template buildTyped(tree: var Tree; info: PackedLineInfo; kind: Opcode;
                    typ: TypeId; body: untyped)
Source   Edit  
template buildTyped(tree: var Value; info: PackedLineInfo; kind: Opcode;
                    typ: TypeId; body: untyped)
Source   Edit  
template firstSon(n: NodePos): NodePos
Source   Edit  
template kind(n: Instr): Opcode
Source   Edit  
template rawOperand(n: Instr): uint32
Source   Edit  
template skipTyped(n: NodePos): NodePos
Source   Edit