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

     1  // Copyright 2020 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  import (
     8  	"fmt"
     9  
    10  	"cmd/compile/internal/abi"
    11  	"cmd/compile/internal/ir"
    12  	"cmd/compile/internal/ssa/ssaop"
    13  )
    14  
    15  // ArgOpAndRegisterFor converts an abi register index into an ssa Op and corresponding
    16  // arg register index.
    17  func ArgOpAndRegisterFor(r abi.RegIndex, abiConfig *abi.ABIConfig) (ssaop.Op, int64) {
    18  	i := abiConfig.FloatIndexFor(r)
    19  	if i >= 0 { // float PR
    20  		return ssaop.OpArgFloatReg, i
    21  	}
    22  	return ssaop.OpArgIntReg, int64(r)
    23  }
    24  
    25  // ParamAssignmentForArgName returns the ABIParamAssignment for f's arg with matching name.
    26  func ParamAssignmentForArgName(f *Func, name *ir.Name) *abi.ABIParamAssignment {
    27  	abiInfo := f.OwnAux.AbiInfo
    28  	ip := abiInfo.InParams()
    29  	for i, a := range ip {
    30  		if a.Name == name {
    31  			return &ip[i]
    32  		}
    33  	}
    34  	panic(fmt.Errorf("Did not match param %v in prInfo %+v", name, abiInfo.InParams()))
    35  }
    36  

View as plain text