Source file test/abi/s_sif_sif.go

     1  // run
     2  
     3  //go:build !wasm
     4  // +build !wasm
     5  
     6  // Copyright 2021 The Go Authors. All rights reserved.
     7  // Use of this source code is governed by a BSD-style
     8  // license that can be found in the LICENSE file.
     9  
    10  package main
    11  
    12  // Test ensures that abi information producer and consumer agree about the
    13  // order of registers for inputs.  T's registers should be I0, F0, I1, F1.
    14  
    15  import "fmt"
    16  
    17  type P struct {
    18  	a int8
    19  	x float64
    20  }
    21  
    22  type T struct {
    23  	d, e P
    24  }
    25  
    26  //go:registerparams
    27  //go:noinline
    28  func G(t T) float64 {
    29  	return float64(t.d.a+t.e.a) + t.d.x + t.e.x
    30  }
    31  
    32  func main() {
    33  	x := G(T{P{10, 20}, P{30, 40}})
    34  	if x != 100.0 {
    35  		fmt.Printf("FAIL, Expected 100, got %f\n", x)
    36  	}
    37  }
    38  

View as plain text