SimEng icon indicating copy to clipboard operation
SimEng copied to clipboard

Modify Instruction_Execute Helper Functions

Open FinnWilkinson opened this issue 3 years ago • 1 comments

Current helper function implementation is verbose (i.e. most instruction types have their own helper function). However, a better implementation would be a series of generic helper functions which can be passed a lambda function for the operation to be performed.

Such an implementation would require operand getter functions which automatically fetch the appropriate operands for the instruction.

Additionally, the following changes should be made to the current implementation :

  • Instead of helper functions returning RegisterValues, pass the Results array by reference into the helper function (To reduce the amount of data being passed around, and number of RegisterValue objects instantiated).
  • As a result of the above, change type of all functions to void.
  • Reduce amount of repeated calculations within helper functions (e.g. if the same value is calculated within each pass of a loop, create a new variable outside of the loop).

FinnWilkinson avatar Feb 03 '22 13:02 FinnWilkinson

An alternative to lambda functions would be to use templates with the "lambda" passed in. That will generate more code, but avoid any runtime cost of binding lambda arguments.

JimCownie avatar Feb 05 '22 08:02 JimCownie