...

Source file src/cmd/compile/internal/inline/inlheur/funcprop_string.go

Documentation: cmd/compile/internal/inline/inlheur

     1  // Copyright 2023 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 inlheur
     6  
     7  import (
     8  	"fmt"
     9  	"strings"
    10  )
    11  
    12  func (fp *FuncProps) String() string {
    13  	return fp.ToString("")
    14  }
    15  
    16  func (fp *FuncProps) ToString(prefix string) string {
    17  	var sb strings.Builder
    18  	if fp.Flags != 0 {
    19  		fmt.Fprintf(&sb, "%sFlags %s\n", prefix, fp.Flags)
    20  	}
    21  	flagSliceToSB[ParamPropBits](&sb, fp.ParamFlags,
    22  		prefix, "ParamFlags")
    23  	flagSliceToSB[ResultPropBits](&sb, fp.ResultFlags,
    24  		prefix, "ResultFlags")
    25  	return sb.String()
    26  }
    27  
    28  func flagSliceToSB[T interface {
    29  	~uint32
    30  	String() string
    31  }](sb *strings.Builder, sl []T, prefix string, tag string) {
    32  	var sb2 strings.Builder
    33  	foundnz := false
    34  	fmt.Fprintf(&sb2, "%s%s\n", prefix, tag)
    35  	for i, e := range sl {
    36  		if e != 0 {
    37  			foundnz = true
    38  		}
    39  		fmt.Fprintf(&sb2, "%s  %d %s\n", prefix, i, e.String())
    40  	}
    41  	if foundnz {
    42  		sb.WriteString(sb2.String())
    43  	}
    44  }
    45  

View as plain text