rajanmaghera / riscv-analysis

WIP
GNU General Public License v3.0
3 stars 0 forks source link

Replace stack available value representation with general memory available value representation. #75

Closed rajanmaghera closed 3 days ago

rajanmaghera commented 3 months ago

Currently, the available value code keeps track of values in registers and in the stack memory. The portion of code that keeps track of the stack memory can be easily extended to work with general memory. We would like to replace that logic for stack available values to be more general.

For example, the variable stack_values_in is of type RefCell<HashMap<i32, AvailableValue>> which maps an integer (stack offset) to an available value.

We would like to replace the stack offset integer with a new type. The type will look something like this:

enum MemoryLocation {
  StackOffset(i32),
  LabelOffset(LabelString, i32),
  Address(i32),
  FunctionLabel(LabelString),
}

In the first implementation, we only need to worry about the StackOffset(i32) variant, so don't even worry about adding in the others. For this issue to be completed, the type should look like this:

enum MemoryLocation {
  StackOffset(i32)
}

Then, we can replace the type for stack_values_in to be RefCell<HashMap<MemoryLocation, AvailableValue>> to map a generic memory location to an available value. We could even rename the variable to be memory_values_in.

This will require us to refactor some of the code, but the logic should be the same and the program should function the same.