Commit f493e557 authored by Keith Randall's avatar Keith Randall Committed by Keith Randall

cmd/compile: document regalloc fields

Document what the fields of regalloc mean.
Hopefully will help people understand how the register allocator works.

Change-Id: Ic322ed2019cc839b812740afe8cd2cf0b61da046
Reviewed-on: https://go-review.googlesource.com/137016Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent fdceb2a1
...@@ -63,8 +63,13 @@ type blockData struct { ...@@ -63,8 +63,13 @@ type blockData struct {
} }
type regInfo struct { type regInfo struct {
// inputs[i] encodes the set of registers allowed for the i'th input.
// Inputs that don't use registers (flags, memory, etc.) should be 0.
inputs []regMask inputs []regMask
// clobbers encodes the set of registers that are overwritten by
// the instruction (other than the output registers).
clobbers regMask clobbers regMask
// outpus[i] encodes the set of registers allowed for the i'th output.
outputs []regMask outputs []regMask
} }
......
...@@ -50,9 +50,17 @@ type outputInfo struct { ...@@ -50,9 +50,17 @@ type outputInfo struct {
} }
type regInfo struct { type regInfo struct {
inputs []inputInfo // ordered in register allocation order // inputs encodes the register restrictions for an instruction's inputs.
// Each entry specifies an allowed register set for a particular input.
// They are listed in the order in which regalloc should pick a register
// from the register set (most constrained first).
// Inputs which do not need registers are not listed.
inputs []inputInfo
// clobbers encodes the set of registers that are overwritten by
// the instruction (other than the output registers).
clobbers regMask clobbers regMask
outputs []outputInfo // ordered in register allocation order // outputs is the same as inputs, but for the outputs of the instruction.
outputs []outputInfo
} }
type auxType int8 type auxType int8
......
...@@ -150,6 +150,8 @@ type register uint8 ...@@ -150,6 +150,8 @@ type register uint8
const noRegister register = 255 const noRegister register = 255
// A regMask encodes a set of machine registers.
// TODO: regMask -> regSet?
type regMask uint64 type regMask uint64
func (m regMask) String() string { func (m regMask) String() string {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment