]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: arm: abort if VFPv3 support missing
authorDave Cheney <dave@cheney.net>
Mon, 17 Sep 2012 23:55:07 +0000 (09:55 +1000)
committerDave Cheney <dave@cheney.net>
Mon, 17 Sep 2012 23:55:07 +0000 (09:55 +1000)
Fixes #3456.

This proposal is a reformulation of CL 5987063. This CL resets
the default GOARM value to 6 and allows the use of the VFPv3
optimisation if GOARM=7. Binaries built with this CL in place
will abort if GOARM=7 was used and the target host does not
support VFPv3.

R=minux.ma, rsc, ajstarks
CC=golang-dev
https://golang.org/cl/6501099

src/cmd/5l/asm.c
src/cmd/5l/l.h
src/cmd/5l/obj.c
src/pkg/runtime/signal_linux_arm.c

index 108722979013ced6e6babde95e1767fe37007da9..f31c2f734fe94b28124bd1498aa8377202a6606d 100644 (file)
@@ -2213,7 +2213,8 @@ omvl(Prog *p, Adr *a, int dr)
 int
 chipzero(Ieee *e)
 {
-       if(e->l != 0 || e->h != 0)
+       // We use GOARM=7 to gate the use of VFPv3 vmov (imm) instructions.
+       if(goarm < 7 || e->l != 0 || e->h != 0)
                return -1;
        return 0;
 }
@@ -2224,6 +2225,10 @@ chipfloat(Ieee *e)
        int n;
        ulong h;
 
+       // We use GOARM=7 to gate the use of VFPv3 vmov (imm) instructions.
+       if(goarm < 7)
+               goto no;
+
        if(e->l != 0 || (e->h&0xffff) != 0)
                goto no;
        h = e->h & 0x7fc00000;
index ee2794ae00f0d349bfe0db75ab4dc548eff74a92..17598d720cd7c3dcc638f7b4164a2df902ec5bd4 100644 (file)
@@ -316,6 +316,8 @@ void        addpool(Prog*, Adr*);
 EXTERN Prog*   blitrl;
 EXTERN Prog*   elitrl;
 
+EXTERN int     goarm;
+
 void   initdiv(void);
 EXTERN Prog*   prog_div;
 EXTERN Prog*   prog_divu;
index 0e738394c82fe486a2d64dbe5f7531c3ba9e6e26..889dfbd252dcac5eaeb9f35032c87da9dbbe74f8 100644 (file)
@@ -93,7 +93,7 @@ main(int argc, char *argv[])
        if(p != nil)
                goarm = atoi(p);
        else
-               goarm = 7;
+               goarm = 6;
        if(goarm == 5)
                debug['F'] = 1;
 
index 7f93db5fb0408ceafce3bebf6437ab5262375d5a..786af82e194420044605cd2d179f701db02e4818 100644 (file)
@@ -147,7 +147,8 @@ runtime·setsig(int32 i, void (*fn)(int32, Siginfo*, void*, G*), bool restart)
 #define AT_PLATFORM    15 // introduced in at least 2.6.11
 #define AT_HWCAP       16 // introduced in at least 2.6.11
 #define AT_RANDOM      25 // introduced in 2.6.29
-#define HWCAP_VFP      (1 << 6)
+#define HWCAP_VFP      (1 << 6) // introduced in at least 2.6.11
+#define HWCAP_VFPv3    (1 << 13) // introduced in 2.6.30
 static uint32 runtime·randomNumber;
 uint8  runtime·armArch = 6;   // we default to ARMv6
 uint32 runtime·hwcap; // set by setup_auxv
@@ -161,6 +162,11 @@ runtime·checkgoarm(void)
                runtime·printf("this GOARM=%d binary. Recompile using GOARM=5.\n", runtime·goarm);
                runtime·exit(1);
        }
+       if(runtime·goarm > 6 && !(runtime·hwcap & HWCAP_VFPv3)) {
+               runtime·printf("runtime: this CPU has no VFPv3 floating point hardware, so it cannot run\n");
+               runtime·printf("this GOARM=%d binary. Recompile using GOARM=6.\n", runtime·goarm);
+               runtime·exit(1);
+       }
 }
 
 #pragma textflag 7