pub(crate) struct Validator {
writer_map: RegisterWriterMap,
multiply_count: usize,
}
Expand description
Stateful program constraint checker
This keeps additional state during the construction of a new program, in order to check constraints that may reject registers and entire programs.
Fields§
§writer_map: RegisterWriterMap
For each register in the file, keep track of the instruction it was written by.
This becomes part of the constraints for destination registers in future instructions.
multiply_count: usize
Total multiplication operations of all types
Implementations§
Source§impl Validator
impl Validator
Sourcepub(crate) fn commit_instruction(
&mut self,
inst: &Instruction,
regw: RegisterWriter,
)
pub(crate) fn commit_instruction( &mut self, inst: &Instruction, regw: RegisterWriter, )
Commit a new instruction to the validator state.
Sourcepub(crate) fn check_whole_program(
&self,
scheduler: &Scheduler,
instructions: &FixedCapacityVec<Instruction, NUM_INSTRUCTIONS>,
) -> Result<(), ()>
pub(crate) fn check_whole_program( &self, scheduler: &Scheduler, instructions: &FixedCapacityVec<Instruction, NUM_INSTRUCTIONS>, ) -> Result<(), ()>
Is the completed program acceptable?
Once the whole program is assembled, HashX still has a chance to reject it if it fails certain criteria.
Sourcepub(crate) fn dst_registers_allowed(
&self,
op: Opcode,
pass: Pass,
writer_info: RegisterWriter,
src: Option<RegisterId>,
) -> DstRegisterChecker<'_>
pub(crate) fn dst_registers_allowed( &self, op: Opcode, pass: Pass, writer_info: RegisterWriter, src: Option<RegisterId>, ) -> DstRegisterChecker<'_>
Begin checking which destination registers are allowed for an op after its source is known, using the current state of the validator.
Returns a DstRegisterChecker which can be used to test each specific destination RegisterId quickly.