github.com/yanyiwu/go@v0.0.0-20150106053140-03d6637dbb7f/src/cmd/dist/arm.c (about)

     1  // Copyright 2012 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  #include "a.h"
     6  
     7  #ifndef __ARMEL__
     8  char *
     9  xgetgoarm(void)
    10  {
    11  	return "6";
    12  }
    13  #else
    14  static void useVFPv3(void);
    15  static void useVFPv1(void);
    16  
    17  char *
    18  xgetgoarm(void)
    19  {
    20  #if defined(__FreeBSD__)
    21  	// FreeBSD has broken VFP support
    22  	return "5";
    23  #endif
    24  	// NaCl always has VFP support.
    25  	if(streq(goos, "nacl") || xtryexecfunc(useVFPv3))
    26  		return "7";
    27  	else if(xtryexecfunc(useVFPv1))
    28  		return "6";
    29  	return "5";
    30  }
    31  
    32  static void
    33  useVFPv3(void)
    34  {
    35  	// try to run VFPv3-only "vmov.f64 d0, #112" instruction
    36  	// we can't use that instruction directly, because we
    37  	// might be compiling with a soft-float only toolchain.
    38  	//
    39  	// some newer toolchains are configured to use thumb
    40  	// by default, so we need to do some mode changing magic
    41  	// here.
    42  	// We can use "bx pc; nop" here, but GNU as(1) insists
    43  	// on warning us
    44  	// "use of r15 in bx in ARM mode is not really useful"
    45  	// so we workaround that by using "bx r0"
    46  	__asm__ __volatile__ ("mov r0, pc");
    47  	__asm__ __volatile__ ("bx r0");
    48  	__asm__ __volatile__ (".word 0xeeb70b00"); // vmov.f64 d0, #112
    49  	__asm__ __volatile__ (".word 0xe12fff1e"); // bx lr
    50  }
    51  
    52  static void
    53  useVFPv1(void)
    54  {
    55  	// try to run "vmov.f64 d0, d0" instruction
    56  	// we can't use that instruction directly, because we
    57  	// might be compiling with a soft-float only toolchain
    58  	//
    59  	// some newer toolchains are configured to use thumb
    60  	// by default, so we need to do some mode changing magic
    61  	// here.
    62  	// We can use "bx pc; nop" here, but GNU as(1) insists
    63  	// on warning us
    64  	// "use of r15 in bx in ARM mode is not really useful"
    65  	// so we workaround that by using "bx r0"
    66  	__asm__ __volatile__ ("mov r0, pc");
    67  	__asm__ __volatile__ ("bx r0");
    68  	__asm__ __volatile__ (".word 0xeeb00b40"); // vomv.f64 d0, d0
    69  	__asm__ __volatile__ (".word 0xe12fff1e"); // bx lr
    70  }
    71  
    72  #endif