2014-11-07 11:15:40 -05:00
USING: arrays classes compiler.cfg cpu.architecture help.markup help.syntax
kernel layouts slots.private ;
2014-05-04 19:12:41 -04:00
IN: compiler.cfg.instructions
2014-05-26 07:26:00 -04:00
HELP: new-insn
{ $values { "class" class } { "insn" insn } }
{ $description
"Boa wrapper for the " { $link insn } " class with " { $slot "insn#" } " set to " { $link f } "."
} ;
2014-05-10 19:45:07 -04:00
HELP: insn
{ $class-description
"Base class for all virtual cpu instructions, used by the CFG IR."
} ;
2014-05-04 19:12:41 -04:00
HELP: vreg-insn
{ $class-description
"Base class for instructions that uses vregs."
} ;
2014-05-18 13:45:09 -04:00
HELP: flushable-insn
{ $class-description
"Instructions which do not have side effects; used for dead code elimination." } ;
HELP: foldable-insn
{ $class-description
"Instructions which are referentially transparent; used for value numbering." } ;
2014-11-07 11:15:40 -05:00
HELP: ##load-reference
{ $class-description
"An instruction for loading a pointer to an object into a register. It has the following slots:"
{ $table
{ { $slot "dst" } { "Register to load the pointer into." } }
{ { $slot "obj" } { "A Factor object." } }
}
} ;
2014-05-04 19:12:41 -04:00
HELP: ##inc-d
{ $class-description
2014-05-26 07:26:00 -04:00
"An instruction that increases or decreases the data stacks height by n. For example, " { $link 2drop } " decreases it by two and pushing an item increases it by one."
2014-05-04 19:12:41 -04:00
} ;
2014-05-07 17:48:41 -04:00
HELP: ##prologue
{ $class-description
2014-07-07 17:34:10 -04:00
"An instruction for generating the prologue for a cfg. All it does is decrementing the stack register a number of cells to give the generated code some stack space to work with." }
2014-11-07 11:15:40 -05:00
{ $see-also ##epilogue } ;
HELP: ##allot
{ $class-description
"An instruction for allocating memory in the nursery. Usually the instruction is preceeded by " { $link ##check-nursery-branch } " which checks that there is enough room in the nursery to allocate. It has the following slots:"
{ $table
{ { $slot "dst" } { "Register to put the pointer to the memory in." } }
{ { $slot "size" } { "Number of bytes to allocate." } }
{ { $slot "class-of" } { "Class of object to allocate, e.g " { $link tuple } " or " { $link array } "." } }
{ { $slot "temp" } { "Temporary register to clobber." } }
}
} ;
2014-05-07 17:48:41 -04:00
2014-05-06 12:09:34 -04:00
HELP: ##alien-invoke
{ $class-description
2014-05-07 17:48:41 -04:00
"An instruction for calling a function in a dynamically linked library. It has the following slots:"
{ $table
{ { $slot "reg-inputs" } { "Registers to use for the arguments to the function call." } }
{ { $slot "stack-inputs" } { "Stack slots used for the arguments to the function call. Only used if all register arguments are already filled." } }
2014-07-18 04:47:08 -04:00
{
{ $slot "reg-outputs" }
{ "If the called function returns a value, then this slot is a one-element sequence containing a 3-tuple describing which register is used for the return value." }
}
2014-05-07 17:48:41 -04:00
{ { $slot "symbols" } { "Name of the function to call." } }
{ { $slot "dll" } { "A dll handle." } }
}
2014-05-06 12:09:34 -04:00
} ;
2014-07-07 17:34:10 -04:00
HELP: ##call
{ $class-description
"An instruction for calling a Factor word."
} ;
2014-05-04 19:12:41 -04:00
HELP: ##set-slot
{ $class-description
2014-05-08 12:50:49 -04:00
"An instruction for the non-primitive, non-immediate variant of " { $link set-slot } ". It has the following slots:"
2014-05-04 19:12:41 -04:00
{ $table
{ { $slot "src" } { "Object to put in the slot." } }
{ { $slot "obj" } { "Object to set the slot on." } }
{ { $slot "slot" } { "Slot index." } }
{ { $slot "tag" } { "Type tag for obj." } }
}
2014-11-07 11:15:40 -05:00
} ;
HELP: ##set-slot-imm
{ $class-description
"An instruction for what? It has the following slots:"
{ $table
{ { $slot "src" } { "Register containing the value to put in the slot." } }
{ { $slot "obj" } { "Register containing the object to set the slot on.." } }
{ { $slot "slot" } { "Slot index." } }
{ { $slot "tag" } { "Type tag for obj." } }
}
} ;
{ ##set-slot %set-slot } related-words
{ ##set-slot-imm %set-slot-imm } related-words
{ ##set-slot-imm ##set-slot } related-words
2014-05-04 19:12:41 -04:00
HELP: ##replace-imm
{ $class-description
"An instruction that replaces an item on the data or register stack with an " { $link immediate } " value." } ;
HELP: ##replace
{ $class-description
"Copies a value from a machine register to a stack location." }
2014-07-07 17:34:10 -04:00
{ $see-also ##peek ##replace-imm } ;
2014-05-04 19:12:41 -04:00
2014-07-18 04:47:08 -04:00
HELP: ##box-alien
{ $class-description
"An instruction for boxing an alien value."
} ;
2014-07-07 17:34:10 -04:00
HELP: ##write-barrier
{ $class-description
"An instruction for inserting a write barrier. This instruction is almost always inserted after a " { $link ##set-slot } " instruction. It has the following slots:"
{ $table
{ { $slot "src" } { "Object which the writer barrier refers." } }
{ { $slot "slot" } { "Slot index of the object." } }
{ { $slot "tag" } { "Type tag for obj." } }
{ { $slot "temp1" } { "First temporary register to clobber." } }
{ { $slot "temp2" } { "Second temporary register to clobber." } }
}
} ;
2014-05-04 19:12:41 -04:00
HELP: ##jump
{ $class-description
"An uncondiation jump instruction. It has the following slots:"
{ $table
{ { $slot "word" } { "Word whose address the instruction is jumping to." } }
}
"Note that the optimizer is sometimes able to optimize away a " { $link ##call } " and " { $link ##return } " pair into one ##jump instruction."
} ;
HELP: ##peek
{ $class-description
"Copies a value from a stack location to a machine register."
}
{ $see-also ##replace } ;
2014-05-08 12:50:49 -04:00
HELP: ##safepoint
{ $class-description "Instruction that inserts a safe point in the generated code." } ;
2014-05-11 07:02:00 -04:00
HELP: ##check-nursery-branch
{ $class-description
"Instruction that inserts a conditional branch to a " { $link basic-block } " that garbage collects the nursery. The " { $vocab-link "compiler.cfg.gc-checks" } " vocab goes through each block in the " { $link cfg } " and checks if it allocates memory. If it does, then this instruction is inserted in the cfg before that block and checks if there is enough available space in the nursery. If it isn't, then a basic block containing code for garbage collecting the nursery is executed."
$nl
"It has the following slots:"
{ $table
{ { $slot "size" } { "Number of bytes the next block in the cfg will allocate." } }
{ { $slot "cc" } { "A comparison symbol." } }
{ { $slot "temp1" } { "Register symbol." } }
{ { $slot "temp2" } { "Register symbol." } }
}
} ;
2014-05-08 12:50:49 -04:00
HELP: ##return
{ $class-description "Instruction that returns from a procedure call." } ;
HELP: ##no-tco
{ $class-description "A dummy instruction that simply inhibits TCO." } ;
2014-05-18 13:45:09 -04:00
HELP: ##copy
{ $class-description "Instruction that copies a value from one register to another." } ;
HELP: ##compare-integer
{ $class-description "This instruction is emitted for integer comparisons." } ;
2014-07-07 17:34:10 -04:00
2014-10-19 07:45:42 -04:00
HELP: ##spill
{ $class-description "Instruction that copies a value from a register to a " { $link spill-slot } "." } ;
2014-07-07 17:34:10 -04:00
HELP: gc-map-insn
{ $class-description "Union class of all instructions that contain subroutine calls to functions which allocate memory." } ;
2014-10-19 07:45:42 -04:00
ARTICLE: "compiler.cfg.instructions" "Basic block instructions"
"The " { $vocab-link "compiler.cfg.instructions" } " vocab contains all instruction classes used for generating CFG:s (Call Flow Graphs)."
$nl
"Instruction classes for moving values around:"
{ $subsections
##copy
2014-11-07 11:15:40 -05:00
##peek
2014-10-19 07:45:42 -04:00
##reload
##replace
2014-11-07 11:15:40 -05:00
##replace-imm
2014-10-19 07:45:42 -04:00
##spill
}
"Garbage collection words and instruction classes:"
{ $subsections
gc-map-insn
}
"Alien calls:"
{ $subsections
##alien-invoke
alien-call-insn
2014-11-07 11:15:40 -05:00
}
"Allocation:"
{ $subsections
##allot
}
"Constant loading:"
{ $subsections
##load-integer
##load-reference
}
"Integer arithmetic and bit operations:"
{ $subsections
##add
##add-imm
##and
##and-imm
##mul
##mul-imm
##or
##or-imm
##sar
##sar-imm
##shl
##shl-imm
##sub
##sub-imm
##xor
##xor-imm
}
"Slot access:"
{ $subsections
##slot
##slot-imm
##set-slot
##set-slot-imm
2014-10-19 07:45:42 -04:00
} ;