Exemple #1
0
func softfloat(ctxt *liblink.Link, cursym *liblink.LSym) {
	var p *liblink.Prog
	var next *liblink.Prog
	var symsfloat *liblink.LSym
	var wasfloat int
	if ctxt.Goarm > 5 {
		return
	}
	symsfloat = liblink.Linklookup(ctxt, "_sfloat", 0)
	wasfloat = 0
	for p = cursym.Text; p != nil; p = p.Link {
		if p.Pcond != nil {
			p.Pcond.Mark |= LABEL
		}
	}
	for p = cursym.Text; p != nil; p = p.Link {
		switch p.As {
		case AMOVW:
			if p.To.Typ == D_FREG || p.From.Typ == D_FREG {
				goto soft
			}
			goto notsoft
		case AMOVWD,
			AMOVWF,
			AMOVDW,
			AMOVFW,
			AMOVFD,
			AMOVDF,
			AMOVF,
			AMOVD,
			ACMPF,
			ACMPD,
			AADDF,
			AADDD,
			ASUBF,
			ASUBD,
			AMULF,
			AMULD,
			ADIVF,
			ADIVD,
			ASQRTF,
			ASQRTD,
			AABSF,
			AABSD:
			goto soft
		default:
			goto notsoft
		}
	soft:
		if wasfloat == 0 || (p.Mark&LABEL != 0) {
			next = ctxt.Prg()
			*next = *p
			// BL _sfloat(SB)
			*p = zprg_obj5
			p.Ctxt = ctxt
			p.Link = next
			p.As = ABL
			p.To.Typ = D_BRANCH
			p.To.Sym = symsfloat
			p.Lineno = next.Lineno
			p = next
			wasfloat = 1
		}
		continue
	notsoft:
		wasfloat = 0
	}
}