-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backend: removes unnecessary ValueDefinition fields
Signed-off-by: Takeshi Yoneda <[email protected]>
- Loading branch information
Showing
3 changed files
with
22 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,19 @@ | ||
package backend | ||
|
||
import ( | ||
"github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc" | ||
"github.com/tetratelabs/wazero/internal/engine/wazevo/ssa" | ||
) | ||
|
||
// SSAValueDefinition represents a definition of an SSA value. | ||
// TODO: this eventually should be deleted. | ||
type SSAValueDefinition struct { | ||
// BlockParamValue is valid if Instr == nil | ||
BlockParamValue ssa.Value | ||
|
||
// BlkParamVReg is valid if Instr == nil | ||
BlkParamVReg regalloc.VReg | ||
|
||
V ssa.Value | ||
// Instr is not nil if this is a definition from an instruction. | ||
Instr *ssa.Instruction | ||
// N is the index of the return value in the instr's return values list. | ||
N int | ||
// RefCount is the number of references to the result. | ||
RefCount uint32 | ||
} | ||
|
||
func (d *SSAValueDefinition) IsFromInstr() bool { | ||
return d.Instr != nil | ||
} | ||
|
||
func (d *SSAValueDefinition) IsFromBlockParam() bool { | ||
return d.Instr == nil | ||
} | ||
|
||
func (d *SSAValueDefinition) SSAValue() ssa.Value { | ||
if d.IsFromBlockParam() { | ||
return d.BlockParamValue | ||
} else { | ||
r, rs := d.Instr.Returns() | ||
if d.N == 0 { | ||
return r | ||
} else { | ||
return rs[d.N-1] | ||
} | ||
} | ||
} |