2015-03-23 17:02:11 -07:00
|
|
|
// Copyright 2015 The Go Authors. All rights reserved.
|
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
package ssa
|
|
|
|
|
|
|
|
|
|
// convert to machine-dependent ops
|
|
|
|
|
func lower(f *Func) {
|
|
|
|
|
// repeat rewrites until we find no more rewrites
|
2015-05-28 16:45:33 -07:00
|
|
|
applyRewrite(f, f.Config.lowerBlock, f.Config.lowerValue)
|
2015-08-04 15:47:22 -07:00
|
|
|
}
|
2015-03-23 17:02:11 -07:00
|
|
|
|
2015-08-04 15:47:22 -07:00
|
|
|
// checkLower checks for unlowered opcodes and fails if we find one.
|
|
|
|
|
func checkLower(f *Func) {
|
|
|
|
|
// Needs to be a separate phase because it must run after both
|
|
|
|
|
// lowering and a subsequent dead code elimination (because lowering
|
|
|
|
|
// rules may leave dead generic ops behind).
|
2015-05-28 10:47:24 -07:00
|
|
|
for _, b := range f.Blocks {
|
|
|
|
|
for _, v := range b.Values {
|
2015-08-11 09:47:45 -07:00
|
|
|
if !opcodeTable[v.Op].generic {
|
|
|
|
|
continue // lowered
|
2015-05-28 10:47:24 -07:00
|
|
|
}
|
2015-08-11 09:47:45 -07:00
|
|
|
switch v.Op {
|
2016-04-21 19:28:28 -07:00
|
|
|
case OpSP, OpSB, OpInitMem, OpArg, OpPhi, OpVarDef, OpVarKill, OpVarLive, OpKeepAlive:
|
2015-08-11 09:47:45 -07:00
|
|
|
continue // ok not to lower
|
|
|
|
|
}
|
2015-08-23 20:29:43 -07:00
|
|
|
s := "not lowered: " + v.Op.String() + " " + v.Type.SimpleString()
|
|
|
|
|
for _, a := range v.Args {
|
|
|
|
|
s += " " + a.Type.SimpleString()
|
|
|
|
|
}
|
|
|
|
|
f.Unimplementedf("%s", s)
|
2015-05-28 10:47:24 -07:00
|
|
|
}
|
|
|
|
|
}
|
2015-03-23 17:02:11 -07:00
|
|
|
}
|