2009-12-17 17:08:42 -07:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
#define EXTERN
|
|
|
|
#include "l.h"
|
|
|
|
|
2010-10-13 13:51:21 -06:00
|
|
|
// Software floating point.
|
|
|
|
|
2009-12-17 17:08:42 -07:00
|
|
|
void
|
2010-10-13 13:51:21 -06:00
|
|
|
softfloat(void)
|
2009-12-17 17:08:42 -07:00
|
|
|
{
|
2010-04-06 13:17:24 -06:00
|
|
|
Prog *p, *next, *psfloat;
|
2009-12-17 17:08:42 -07:00
|
|
|
Sym *symsfloat;
|
|
|
|
int wasfloat;
|
|
|
|
|
|
|
|
symsfloat = lookup("_sfloat", 0);
|
|
|
|
psfloat = P;
|
|
|
|
if(symsfloat->type == STEXT)
|
2010-10-13 13:51:21 -06:00
|
|
|
psfloat = symsfloat->text;
|
2009-12-17 17:08:42 -07:00
|
|
|
|
|
|
|
wasfloat = 0;
|
2010-10-13 13:51:21 -06:00
|
|
|
for(cursym = textp; cursym != nil; cursym = cursym->next) {
|
|
|
|
for(p = cursym->text; p != P; p = p->link) {
|
2010-10-13 13:19:53 -06:00
|
|
|
switch(p->as) {
|
|
|
|
case AMOVWD:
|
|
|
|
case AMOVWF:
|
|
|
|
case AMOVDW:
|
|
|
|
case AMOVFW:
|
|
|
|
case AMOVFD:
|
|
|
|
case AMOVDF:
|
|
|
|
case AMOVF:
|
|
|
|
case AMOVD:
|
|
|
|
case ACMPF:
|
|
|
|
case ACMPD:
|
|
|
|
case AADDF:
|
|
|
|
case AADDD:
|
|
|
|
case ASUBF:
|
|
|
|
case ASUBD:
|
|
|
|
case AMULF:
|
|
|
|
case AMULD:
|
|
|
|
case ADIVF:
|
|
|
|
case ADIVD:
|
|
|
|
if (psfloat == P)
|
|
|
|
diag("floats used with _sfloat not defined");
|
|
|
|
if (!wasfloat) {
|
|
|
|
next = prg();
|
|
|
|
*next = *p;
|
|
|
|
|
|
|
|
// BL _sfloat(SB)
|
|
|
|
*p = zprg;
|
|
|
|
p->link = next;
|
|
|
|
p->as = ABL;
|
|
|
|
p->to.type = D_BRANCH;
|
|
|
|
p->to.sym = symsfloat;
|
|
|
|
p->cond = psfloat;
|
|
|
|
|
|
|
|
p = next;
|
|
|
|
wasfloat = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
wasfloat = 0;
|
2009-12-17 17:08:42 -07:00
|
|
|
}
|
2010-10-13 13:51:21 -06:00
|
|
|
}
|
2009-12-17 17:08:42 -07:00
|
|
|
}
|
|
|
|
}
|