github.com/xushiwei/go@v0.0.0-20130601165731-2b9d83f45bc9/src/cmd/5l/softfloat.c (about) 1 // Copyright 2009 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 "l.h" 6 #include "../ld/lib.h" 7 8 // Software floating point. 9 10 void 11 softfloat(void) 12 { 13 Prog *p, *next, *psfloat; 14 Sym *symsfloat; 15 int wasfloat; 16 17 if(!debug['F']) 18 return; 19 20 symsfloat = lookup("_sfloat", 0); 21 psfloat = P; 22 if(symsfloat->type == STEXT) 23 psfloat = symsfloat->text; 24 25 for(cursym = textp; cursym != nil; cursym = cursym->next) { 26 wasfloat = 0; 27 for(p = cursym->text; p != P; p = p->link) 28 if(p->cond != P) 29 p->cond->mark |= LABEL; 30 for(p = cursym->text; p != P; p = p->link) { 31 switch(p->as) { 32 case AMOVW: 33 if(p->to.type == D_FREG || p->from.type == D_FREG) 34 goto soft; 35 goto notsoft; 36 37 case AMOVWD: 38 case AMOVWF: 39 case AMOVDW: 40 case AMOVFW: 41 case AMOVFD: 42 case AMOVDF: 43 case AMOVF: 44 case AMOVD: 45 46 case ACMPF: 47 case ACMPD: 48 case AADDF: 49 case AADDD: 50 case ASUBF: 51 case ASUBD: 52 case AMULF: 53 case AMULD: 54 case ADIVF: 55 case ADIVD: 56 case ASQRTF: 57 case ASQRTD: 58 case AABSF: 59 case AABSD: 60 goto soft; 61 62 default: 63 goto notsoft; 64 65 soft: 66 if (psfloat == P) 67 diag("floats used with _sfloat not defined"); 68 if (!wasfloat || (p->mark&LABEL)) { 69 next = prg(); 70 *next = *p; 71 72 // BL _sfloat(SB) 73 *p = zprg; 74 p->link = next; 75 p->as = ABL; 76 p->to.type = D_BRANCH; 77 p->to.sym = symsfloat; 78 p->cond = psfloat; 79 p->line = next->line; 80 81 p = next; 82 wasfloat = 1; 83 } 84 break; 85 86 notsoft: 87 wasfloat = 0; 88 } 89 } 90 } 91 }