Source file src/cmd/compile/internal/ssa/lower.go

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package ssa
     6  
     7  // convert to machine-dependent ops.
     8  func lower(f *Func) {
     9  	// repeat rewrites until we find no more rewrites
    10  	applyRewrite(f, f.Config.lowerBlock, f.Config.lowerValue, removeDeadValues)
    11  }
    12  
    13  // lateLower applies those rules that need to be run after the general lower rules.
    14  func lateLower(f *Func) {
    15  	// repeat rewrites until we find no more rewrites
    16  	if f.Config.lateLowerValue != nil {
    17  		applyRewrite(f, f.Config.lateLowerBlock, f.Config.lateLowerValue, removeDeadValues)
    18  	}
    19  }
    20  
    21  // checkLower checks for unlowered opcodes and fails if we find one.
    22  func checkLower(f *Func) {
    23  	// Needs to be a separate phase because it must run after both
    24  	// lowering and a subsequent dead code elimination (because lowering
    25  	// rules may leave dead generic ops behind).
    26  	for _, b := range f.Blocks {
    27  		for _, v := range b.Values {
    28  			if !opcodeTable[v.Op].generic {
    29  				continue // lowered
    30  			}
    31  			switch v.Op {
    32  			case OpSP, OpSPanchored, OpSB, OpInitMem, OpArg, OpArgIntReg, OpArgFloatReg, OpPhi, OpVarDef, OpVarLive, OpKeepAlive, OpSelect0, OpSelect1, OpSelectN, OpConvert, OpInlMark, OpWBend:
    33  				continue // ok not to lower
    34  			case OpMakeResult:
    35  				if b.Controls[0] == v {
    36  					continue
    37  				}
    38  			case OpGetG:
    39  				if f.Config.hasGReg {
    40  					// has hardware g register, regalloc takes care of it
    41  					continue // ok not to lower
    42  				}
    43  			}
    44  			s := "not lowered: " + v.String() + ", " + v.Op.String() + " " + v.Type.SimpleString()
    45  
    46  			for _, a := range v.Args {
    47  				s += " " + a.Type.SimpleString()
    48  			}
    49  			f.Fatalf("%s", s)
    50  		}
    51  	}
    52  }
    53  

View as plain text