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:
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.
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 typeRefCell<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:
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:Then, we can replace the type for
stack_values_in
to beRefCell<HashMap<MemoryLocation, AvailableValue>>
to map a generic memory location to an available value. We could even rename the variable to bememory_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.