github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/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(__NetBSD__) || defined(__FreeBSD__) 21 // NetBSD has buggy support for VFPv2 (incorrect inexact, 22 // denormial, and NaN handling). When GOARM=6, some of our 23 // math tests fails on Raspberry Pi. 24 // Thus we return "5" here for safety, the user is free 25 // to override. 26 // Note: using GOARM=6 with cgo can trigger a kernel assertion 27 // failure and crash NetBSD/evbarm kernel. 28 // FreeBSD also have broken VFP support, so disable VFP also 29 // on FreeBSD. 30 return "5"; 31 #endif 32 if(xtryexecfunc(useVFPv3)) 33 return "7"; 34 else if(xtryexecfunc(useVFPv1)) 35 return "6"; 36 return "5"; 37 } 38 39 static void 40 useVFPv3(void) 41 { 42 // try to run VFPv3-only "vmov.f64 d0, #112" instruction 43 // we can't use that instruction directly, because we 44 // might be compiling with a soft-float only toolchain. 45 // 46 // some newer toolchains are configured to use thumb 47 // by default, so we need to do some mode changing magic 48 // here. 49 // We can use "bx pc; nop" here, but GNU as(1) insists 50 // on warning us 51 // "use of r15 in bx in ARM mode is not really useful" 52 // so we workaround that by using "bx r0" 53 __asm__ __volatile__ ("mov r0, pc"); 54 __asm__ __volatile__ ("bx r0"); 55 __asm__ __volatile__ (".word 0xeeb70b00"); // vmov.f64 d0, #112 56 __asm__ __volatile__ (".word 0xe12fff1e"); // bx lr 57 } 58 59 static void 60 useVFPv1(void) 61 { 62 // try to run "vmov.f64 d0, d0" instruction 63 // we can't use that instruction directly, because we 64 // might be compiling with a soft-float only toolchain 65 // 66 // some newer toolchains are configured to use thumb 67 // by default, so we need to do some mode changing magic 68 // here. 69 // We can use "bx pc; nop" here, but GNU as(1) insists 70 // on warning us 71 // "use of r15 in bx in ARM mode is not really useful" 72 // so we workaround that by using "bx r0" 73 __asm__ __volatile__ ("mov r0, pc"); 74 __asm__ __volatile__ ("bx r0"); 75 __asm__ __volatile__ (".word 0xeeb00b40"); // vomv.f64 d0, d0 76 __asm__ __volatile__ (".word 0xe12fff1e"); // bx lr 77 } 78 79 #endif