Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/misoc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 275caae
Choose a base ref
...
head repository: m-labs/misoc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 88a909e
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on May 24, 2012

  1. software/libbase: double precision FP glue

    Sebastien Bourdeauducq committed May 24, 2012

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    78d5645 View commit details
  2. software/libbase: now that we have double precision, printf hack no l…

    …onger needed
    Sebastien Bourdeauducq committed May 24, 2012

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    80f3d83 View commit details

Commits on May 25, 2012

  1. software: cleanup CFLAGS

    Sebastien Bourdeauducq committed May 25, 2012

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    88a909e View commit details
Showing with 171 additions and 45 deletions.
  1. +3 −4 software/common.mak
  2. +164 −36 software/libbase/softfloat-glue.c
  3. +4 −5 software/libbase/vsnprintf.c
7 changes: 3 additions & 4 deletions software/common.mak
Original file line number Diff line number Diff line change
@@ -35,11 +35,10 @@ endif

# Toolchain options
#
INCLUDES_NOLIBC ?= -nostdinc -I$(M2DIR)/software/include/base
INCLUDES = $(INCLUDES_NOLIBC) -I$(M2DIR)/software/include -I$(M2DIR)/common
ASFLAGS = $(INCLUDES) -nostdinc
INCLUDES = -I$(M2DIR)/software/include/base -I$(M2DIR)/software/include -I$(M2DIR)/common
ASFLAGS = -nostdinc $(INCLUDES)
CFLAGS = -O9 -Wall -Wstrict-prototypes -Wold-style-definition -Wshadow \
-Wmissing-prototypes -fsigned-char $(INCLUDES)
-Wmissing-prototypes -fsigned-char -nostdinc $(INCLUDES)
LDFLAGS = -nostdlib -nodefaultlibs

# compile and generate dependencies, based on
200 changes: 164 additions & 36 deletions software/libbase/softfloat-glue.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,72 @@
/* $NetBSD: fplib_glue.c,v 1.2 2000/02/22 01:18:28 mycroft Exp $ */

/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Neil A. Carson and Mark Brinicombe
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "milieu.h"
#include "softfloat.h"

int __eqsf2(float32 a,float32 b);
int __eqdf2(float64 a,float64 b);
int __nesf2(float32 a,float32 b);
int __nedf2(float64 a,float64 b);
int __gtsf2(float32 a,float32 b);
int __gtdf2(float64 a,float64 b);
int __gesf2(float32 a,float32 b);
int __gedf2(float64 a,float64 b);
int __ltsf2(float32 a,float32 b);
int __ltdf2(float64 a,float64 b);
int __lesf2(float32 a,float32 b);
int __ledf2(float64 a,float64 b);
float32 __negsf2(float32 a);
float64 __negdf2(float64 a);

/********************************* COMPARISONS ********************************/

/*
* 'Equal' wrapper. This returns 0 if the numbers are equal, or (1 | -1)
* otherwise. So we need to invert the output.
*/
flag __eqsf2(float32 a, float32 b);
flag __eqsf2(float32 a, float32 b)
{
return !float32_eq(a, b);

int __eqsf2(float32 a,float32 b) {
return float32_eq(a,b)?0:1;
}

int __eqdf2(float64 a,float64 b) {
return float64_eq(a,b)?0:1;
}

/*
@@ -17,10 +75,12 @@ flag __eqsf2(float32 a, float32 b)
* to use an 'equal' call and invert the result. The result is already
* inverted though! Confusing?!
*/
flag __nesf2(float32 a, float32 b);
flag __nesf2(float32 a, float32 b)
{
return !float32_eq(a, b);
int __nesf2(float32 a,float32 b) {
return float32_eq(a,b)?0:-1;
}

int __nedf2(float64 a,float64 b) {
return float64_eq(a,b)?0:-1;
}

/*
@@ -30,38 +90,46 @@ flag __nesf2(float32 a, float32 b)
* make up our mind. This means that we can call 'less than or equal' and
* invert the result.
*/
flag __gtsf2(float32 a, float32 b);
flag __gtsf2(float32 a, float32 b)
{
return !float32_le(a, b);
int __gtsf2(float32 a,float32 b) {
return float32_le(a,b)?0:1;
}

int __gtdf2(float64 a,float64 b) {
return float64_le(a,b)?0:1;
}

/*
* 'Greater Than or Equal' wrapper. We emulate this by inverting the result
* of a 'less than' call.
*/
flag __gesf2(float32 a, float32 b);
flag __gesf2(float32 a, float32 b)
{
return !float32_lt(a, b);
int __gesf2(float32 a,float32 b) {
return float32_lt(a,b)?-1:0;
}

int __gedf2(float64 a,float64 b) {
return float64_lt(a,b)?-1:0;
}

/*
* 'Less Than' wrapper.
* 'Less Than' wrapper. A 1 from the ARM code needs to be turned into -1.
*/
flag __ltsf2(float32 a, float32 b);
flag __ltsf2(float32 a, float32 b)
{
return float32_lt(a, b);
int __ltsf2(float32 a,float32 b) {
return float32_lt(a,b)?-1:0;
}

int __ltdf2(float64 a,float64 b) {
return float64_lt(a,b)?-1:0;
}

/*
* 'Less Than or Equal' wrapper. A 0 must turn into a 1, and a 1 into a 0.
*/
flag __lesf2(float32 a, float32 b);
flag __lesf2(float32 a, float32 b)
{
return !float32_le(a, b);
int __lesf2(float32 a,float32 b) {
return float32_le(a,b)?0:1;
}

int __ledf2(float64 a,float64 b) {
return float64_le(a,b)?0:1;
}

/*
@@ -70,14 +138,17 @@ flag __lesf2(float32 a, float32 b)
* position in the registers of arguments, the double precision version can
* go here too ;-)
*/
float32 __negsf2(float32 x);
float32 __negsf2(float32 x)
{
return x ^ 0x80000000;
float32 __negsf2(float32 a) {
return (a ^ 0x80000000);
}

float64 __negdf2(float64 a) {
a.high ^= 0x80000000;
return a;
}

/*
* 32-bit operations.
* 32-bit operations. This is not BSD code.
*/
float32 __addsf3(float32 a, float32 b);
float32 __addsf3(float32 a, float32 b)
@@ -103,20 +174,20 @@ float32 __divsf3(float32 a, float32 b)
return float32_div(a, b);
}

float32 __floatsisf(int x);
float32 __floatsisf(int x)
float32 __floatsisf(int32 x);
float32 __floatsisf(int32 x)
{
return int32_to_float32(x);
}

int __fixsfsi(float32 x);
int __fixsfsi(float32 x)
int32 __fixsfsi(float32 x);
int32 __fixsfsi(float32 x)
{
return float32_to_int32_round_to_zero(x);
}

unsigned int __fixunssfsi(float32 x);
unsigned int __fixunssfsi(float32 x)
uint32 __fixunssfsi(float32 x);
uint32 __fixunssfsi(float32 x)
{
return float32_to_int32_round_to_zero(x); // XXX
}
@@ -132,3 +203,60 @@ flag __unordsf2(float32 a, float32 b)
*/
return 1 ^ (float32_eq(a, a) & float32_eq(b, b));
}

/*
* 64-bit operations. This is not BSD code.
*/
float64 __adddf3(float64 a, float64 b);
float64 __adddf3(float64 a, float64 b)
{
return float64_add(a, b);
}

float64 __subdf3(float64 a, float64 b);
float64 __subdf3(float64 a, float64 b)
{
return float64_sub(a, b);
}

float64 __muldf3(float64 a, float64 b);
float64 __muldf3(float64 a, float64 b)
{
return float64_mul(a, b);
}

float64 __divdf3(float64 a, float64 b);
float64 __divdf3(float64 a, float64 b)
{
return float64_div(a, b);
}

float64 __floatsidf(int32 x);
float64 __floatsidf(int32 x)
{
return int32_to_float64(x);
}

int32 __fixdfsi(float64 x);
int32 __fixdfsi(float64 x)
{
return float64_to_int32_round_to_zero(x);
}

uint32 __fixunsdfsi(float64 x);
uint32 __fixunsdfsi(float64 x)
{
return float64_to_int32_round_to_zero(x); // XXX
}

flag __unorddf2(float64 a, float64 b);
flag __unorddf2(float64 a, float64 b)
{
/*
* The comparison is unordered if either input is a NaN.
* Test for this by comparing each operand with itself.
* We must perform both comparisons to correctly check for
* signalling NaNs.
*/
return 1 ^ (float64_eq(a, a) & float64_eq(b, b));
}
9 changes: 4 additions & 5 deletions software/libbase/vsnprintf.c
Original file line number Diff line number Diff line change
@@ -196,12 +196,11 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)

case 'f': {
int m;
float f;
double f;
int integer;

/* until I sort out how to disable this stupid promotion to double ... */
f = *(va_arg(args, float *));
if((f <= 0.0f) && (f != 0.0f)) { /* TODO: fix that |[#{'"é! '<' operator */
f = va_arg(args, double);
if(f < 0.0) {
*str = '-';
str++;
f = -f;
@@ -233,7 +232,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
for(i=0;i<6;i++) {
int n;

f = f*10.0f;
f = f*10.0;
n = f;
f = f - n;
if(str >= end) break;