Skip to content

feat : assembly code for scalar + matrix operation

HARDY FLORENT requested to merge feat-assembly-add-matrix-scalar into main

This RISCV assembly code :

  • reads a float on the top of the stack (0(sp)) (the scalar value)
  • reads an address (pointing to the matrix) (4(sp)) on the stack
  • allocates memory on the stack to hold the resulting matrix
  • sets the top of the stack (0(sp)) to be the address of the resulting matrix

Some problems appeared as I wrote this :

  • because we save registers in the stack (to be restored later), the new memory allocation for the resulting matrix makes it so this memory cannot be reused. In brief, we allocate stack memory to save registers, we allocate memory for the new matrix, therefore old memory for registers cannot be freed.
  • just making sure but operands (scalar first then matrix) need to be in that order, I do not know how annoying it is to make this in intermediate code representation so let me know if i should work on this
  • I use labels (_scalarLoopLabel for example) in order to loop through values, problem is RISC does not like copies of the same label in code. label "_scalarAdditionLoop" already defined Duplicate labels can appear when two different scalar/matrix additions take place.

Let me know if you have an idea. Thanks

Merge request reports