aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/arm/softfloat.c
blob: a71b2511388b33e71b4299cb00b392f18136fb3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "runtime.h"

// returns number of bytes that the fp instruction is occupying
static uint32
isfltinstr(uint32 *pc)
{
	uint32 i;
	uint32 c;
	
	i = *pc;
	c = i >> 25 & 7;
	
	switch(c) {
	case 6: // 110
//printf(" %p coproc multi: %x\n", pc, i);
		return 4;
	case 7: // 111
		if (i>>24 & 1) return 0; // ignore swi
//printf(" %p coproc %x\n", pc, i);
		return 4;
	}

	// lookahead for virtual instructions that span multiple arm instructions
	c = ((*pc & 0x0f000000) >> 16) |
		((*(pc + 1)  & 0x0f000000) >> 20) |
		((*(pc + 2) & 0x0f000000) >> 24);
	if(c == 0x50d) {
//printf(" %p coproc const %x\n", pc, i);
		return 12;
	}

//printf(" %p %x\n", pc, i);
	return 0;
}

#pragma textflag 7
uint32*
_sfloat2(uint32 *lr, uint32 r0)
{
	uint32 skip;
	
//printf("softfloat: pre %p\n", lr);
	while(skip = isfltinstr(lr))
		lr += skip;
//printf(" post: %p\n", lr);
	return lr;
}