github.com/ader1990/go@v0.0.0-20140630135419-8c24447fa791/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  	if(xtryexecfunc(useVFPv3))
    25  		return "7";
    26  	else if(xtryexecfunc(useVFPv1))
    27  		return "6";
    28  	return "5";
    29  }
    30  
    31  static void
    32  useVFPv3(void)
    33  {
    34  	// try to run VFPv3-only "vmov.f64 d0, #112" instruction
    35  	// we can't use that instruction directly, because we
    36  	// might be compiling with a soft-float only toolchain.
    37  	//
    38  	// some newer toolchains are configured to use thumb
    39  	// by default, so we need to do some mode changing magic
    40  	// here.
    41  	// We can use "bx pc; nop" here, but GNU as(1) insists
    42  	// on warning us
    43  	// "use of r15 in bx in ARM mode is not really useful"
    44  	// so we workaround that by using "bx r0"
    45  	__asm__ __volatile__ ("mov r0, pc");
    46  	__asm__ __volatile__ ("bx r0");
    47  	__asm__ __volatile__ (".word 0xeeb70b00"); // vmov.f64 d0, #112
    48  	__asm__ __volatile__ (".word 0xe12fff1e"); // bx lr
    49  }
    50  
    51  static void
    52  useVFPv1(void)
    53  {
    54  	// try to run "vmov.f64 d0, d0" instruction
    55  	// we can't use that instruction directly, because we
    56  	// might be compiling with a soft-float only toolchain
    57  	//
    58  	// some newer toolchains are configured to use thumb
    59  	// by default, so we need to do some mode changing magic
    60  	// here.
    61  	// We can use "bx pc; nop" here, but GNU as(1) insists
    62  	// on warning us
    63  	// "use of r15 in bx in ARM mode is not really useful"
    64  	// so we workaround that by using "bx r0"
    65  	__asm__ __volatile__ ("mov r0, pc");
    66  	__asm__ __volatile__ ("bx r0");
    67  	__asm__ __volatile__ (".word 0xeeb00b40"); // vomv.f64 d0, d0
    68  	__asm__ __volatile__ (".word 0xe12fff1e"); // bx lr
    69  }
    70  
    71  #endif