##add-imm
Basic block instructions

Prev:##add
Next:##and

Vocabulary
compiler.cfg.instructions

DefinitionMethods
USING: accessors compiler.cfg.gvn.avail
compiler.cfg.instructions kernel ;
M: ##add-imm >avail-insn-defs [ ] change-dst drop ;

USING: accessors compiler.cfg.gvn.avail
compiler.cfg.instructions kernel ;
M: ##add-imm >avail-insn-uses
[ dup >avail-vreg swap or ] change-src1 drop ;

USING: accessors arrays compiler.cfg.gvn.expressions
compiler.cfg.gvn.graph compiler.cfg.instructions kernel
sequences.private ;
M: ##add-imm >expr
\ ##add-imm swap [ src1>> vreg>vn ] keep [ src2>> ] keep
drop 3 f <array> 2 swap [ set-array-nth ] keep 1 swap
[ set-array-nth ] keep 0 swap [ set-array-nth ] keep ;

USING: accessors arrays compiler.cfg.instructions
compiler.cfg.value-numbering.expressions
compiler.cfg.value-numbering.graph kernel sequences.private ;
M: ##add-imm >expr
\ ##add-imm swap [ src1>> vreg>vn ] keep [ src2>> ] keep
drop 3 f <array> 2 swap [ set-array-nth ] keep 1 swap
[ set-array-nth ] keep 0 swap [ set-array-nth ] keep ;

USING: accessors compiler.cfg.instructions
compiler.cfg.linear-scan.assignment kernel ;
M: ##add-imm assign-insn-defs [ vreg>reg ] change-dst drop ;

USING: accessors compiler.cfg.instructions
compiler.cfg.linear-scan.assignment kernel ;
M: ##add-imm assign-insn-uses [ vreg>reg ] change-src1 drop ;

USING: compiler.cfg.instructions
compiler.cfg.value-numbering.folding kernel math ;
M: ##add-imm binary-constant-fold* drop + ;

USING: compiler.cfg.gvn.folding compiler.cfg.instructions kernel
math ;
M: ##add-imm binary-constant-fold* drop + ;

USING: accessors compiler.cfg.instructions
compiler.cfg.representations.rewrite kernel ;
M: ##add-imm convert-insn-defs
[ converted-value ] change-dst drop ;

USING: accessors compiler.cfg.instructions
compiler.cfg.representations.rewrite kernel ;
M: ##add-imm convert-insn-uses
[ converted-value ] change-src1 drop ;

USING: compiler.cfg.instructions
compiler.cfg.representations.preferred cpu.architecture kernel ;
M: ##add-imm defs-vreg-reps drop { int-rep } ;

USING: accessors arrays compiler.cfg.def-use
compiler.cfg.instructions ;
M: ##add-imm defs-vregs dst>> 1array ;

USING: accessors compiler.cfg.instructions compiler.codegen
cpu.architecture kernel ;
M: ##add-imm generate-insn
[ dst>> ] keep [ src1>> ] keep [ src2>> ] keep drop %add-imm
;

USING: accessors compiler.cfg.instructions compiler.cfg.liveness
kernel ;
M: ##add-imm lookup-base-pointer*
nip src1>> lookup-base-pointer ;

USING: accessors compiler.cfg.instructions compiler.cfg.renaming
kernel ;
M: ##add-imm rename-insn-defs [ rename-value ] change-dst drop ;

USING: accessors compiler.cfg.instructions compiler.cfg.renaming
kernel ;
M: ##add-imm rename-insn-uses
[ rename-value ] change-src1 drop ;

USING: accessors combinators compiler.cfg.gvn.avail
compiler.cfg.gvn.folding compiler.cfg.gvn.graph
compiler.cfg.gvn.math compiler.cfg.gvn.rewrite
compiler.cfg.instructions kernel ;
M: ##add-imm rewrite
{
{ [ dup src2>> 0 = ] [ identity ] }
{
[ dup binary-constant-fold? ]
[ binary-constant-fold ]
}
{
[
dup src1>> vreg>insn
[ ##add-imm? ] with-available-uses?
]
[ ##add-imm reassociate-arithmetic ]
}
[ drop f ]
} cond ;

USING: accessors combinators compiler.cfg.instructions
compiler.cfg.value-numbering.folding
compiler.cfg.value-numbering.graph
compiler.cfg.value-numbering.math
compiler.cfg.value-numbering.rewrite kernel ;
M: ##add-imm rewrite
{
{ [ dup src2>> 0 = ] [ identity ] }
{
[ dup binary-constant-fold? ]
[ binary-constant-fold ]
}
{
[ dup src1>> vreg>insn ##add-imm? ]
[ ##add-imm reassociate-arithmetic ]
}
[ drop f ]
} cond ;

USING: accessors compiler.cfg.instructions
compiler.cfg.ssa.construction.private kernel ;
M: ##add-imm ssa-rename-insn-defs [ gen-name ] change-dst drop ;

USING: accessors compiler.cfg.instructions
compiler.cfg.ssa.construction.private kernel ;
M: ##add-imm ssa-rename-insn-uses
[ top-name ] change-src1 drop ;

USING: compiler.cfg.instructions
compiler.cfg.representations.preferred cpu.architecture kernel ;
M: ##add-imm uses-vreg-reps drop { int-rep } ;

USING: accessors arrays compiler.cfg.def-use
compiler.cfg.instructions ;
M: ##add-imm uses-vregs src1>> 1array ;