mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.ssa] cmd/internal/gc: convert standard IR into SSA.
Hook into the current compiler to convert the existing
IR (after walk) into SSA. Any function ending in "_ssa"
will take this path. The resulting assembly is printed
and then discarded.
Use gc.Type directly in ssa instead of a wrapper for go types.
It makes the IR->SSA rewrite a lot simpler.
Only a few opcodes are implemented in this change. It is
enough to compile simple examples like
func f(p *int) int { return *p }
func g(a []int, i int) int { return a[i] }
Change-Id: I5e18841b752a83ca0519aa1b2d36ef02ce1de6f9
Reviewed-on: https://go-review.googlesource.com/8971
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
2f09b599c3
commit
d2fd43aa77
28 changed files with 1472 additions and 791 deletions
|
|
@ -4,9 +4,7 @@
|
|||
|
||||
package ssa
|
||||
|
||||
import (
|
||||
"sort"
|
||||
)
|
||||
import "sort"
|
||||
|
||||
// cse does common-subexpression elimination on the Function.
|
||||
// Values are just relinked, nothing is deleted. A subsequent deadcode
|
||||
|
|
@ -115,7 +113,9 @@ func cse(f *Func) {
|
|||
// Replace all elements of e which v dominates
|
||||
for i := 0; i < len(e); {
|
||||
w := e[i]
|
||||
if w != v && dom(v.Block, w.Block, idom) {
|
||||
if w == v {
|
||||
e, e[i] = e[:len(e)-1], e[len(e)-1]
|
||||
} else if dom(v.Block, w.Block, idom) {
|
||||
rewrite[w.ID] = v
|
||||
e, e[i] = e[:len(e)-1], e[len(e)-1]
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue