mirror of
https://github.com/libretro/NP2kai.git
synced 2024-10-06 22:33:28 +00:00
NP21/W rev.87,88
This commit is contained in:
parent
606fafa708
commit
2ca8e7ebc4
@ -507,7 +507,7 @@ void bios_initialize(void) {
|
||||
mem[0xffff0] = 0xea;
|
||||
STOREINTELDWORD(mem + 0xffff1, 0xfd800000);
|
||||
|
||||
CopyMemory(mem + 0x0fd800 + 0x0e00, keytable[0], 0x300);
|
||||
CopyMemory(mem + 0x0fd800 + 0x0e00, keytable[0], 0x60 * 8);
|
||||
|
||||
//fh = file_create_c(_T("emuitf.rom"));
|
||||
//if (fh != FILEH_INVALID) {
|
||||
@ -515,7 +515,8 @@ void bios_initialize(void) {
|
||||
// file_close(fh);
|
||||
// TRACEOUT(("write emuitf.rom"));
|
||||
//}
|
||||
CopyMemory(mem + ITF_ADRS, itfrom, sizeof(itfrom)+1);
|
||||
memset(mem + ITF_ADRS, 0, sizeof(itfrom)+1);
|
||||
CopyMemory(mem + ITF_ADRS, itfrom, sizeof(itfrom));
|
||||
#if defined(SUPPORT_FAST_MEMORYCHECK)
|
||||
// 高速メモリチェック
|
||||
if(np2cfg.memcheckspeed > 1){
|
||||
|
238
cbus/atapicmd.c
238
cbus/atapicmd.c
@ -174,6 +174,8 @@ static void atapi_cmd_start_stop_unit(IDEDRV drv);
|
||||
static void atapi_cmd_prevent_allow_medium_removal(IDEDRV drv);
|
||||
static void atapi_cmd_read_capacity(IDEDRV drv);
|
||||
static void atapi_cmd_read(IDEDRV drv, UINT32 lba, UINT32 leng);
|
||||
static void atapi_cmd_read_cd(IDEDRV drv, UINT32 lba, UINT32 leng);
|
||||
static void atapi_cmd_read_cd_msf(IDEDRV drv);
|
||||
static void atapi_cmd_mode_select(IDEDRV drv);
|
||||
static void atapi_cmd_mode_sense(IDEDRV drv);
|
||||
static void atapi_cmd_readsubch(IDEDRV drv);
|
||||
@ -306,11 +308,21 @@ void atapicmd_a0(IDEDRV drv) {
|
||||
atapi_cmd_read(drv, lba, leng);
|
||||
break;
|
||||
|
||||
case 0xbe: // read cd
|
||||
lba = (drv->buf[2] << 24) + (drv->buf[3] << 16) + (drv->buf[4] << 8) + drv->buf[5];
|
||||
leng = (drv->buf[6] << 16) + (drv->buf[7] << 8) + drv->buf[8];
|
||||
atapi_cmd_read_cd(drv, lba, leng);
|
||||
break;
|
||||
|
||||
case 0xb9: // read cd msf
|
||||
atapi_cmd_read_cd_msf(drv);
|
||||
break;
|
||||
|
||||
case 0x2b: // Seek
|
||||
lba = (drv->buf[2] << 24) + (drv->buf[3] << 16) + (drv->buf[4] << 8) + drv->buf[5];
|
||||
atapi_cmd_seek(drv, lba);
|
||||
break;
|
||||
|
||||
|
||||
case 0x55: // mode select
|
||||
TRACEOUT(("atapicmd: mode select"));
|
||||
atapi_cmd_mode_select(drv);
|
||||
@ -719,12 +731,229 @@ void atapi_dataread(IDEDRV drv) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void atapi_dataread_end(IDEDRV drv) {
|
||||
SXSIDEV sxsi;
|
||||
sxsi = sxsi_getptr(drv->sxsidrv);
|
||||
|
||||
drv->sector++;
|
||||
drv->nsectors--;
|
||||
|
||||
drv->sc = IDEINTR_IO;
|
||||
drv->cy = 2048;
|
||||
drv->status &= ~(IDESTAT_DMRD|IDESTAT_SERV|IDESTAT_CHK);
|
||||
drv->status |= IDESTAT_DRQ;
|
||||
drv->error = 0;
|
||||
ATAPI_SET_SENSE_KEY(drv, ATAPI_SK_NO_SENSE);
|
||||
drv->asc = ATAPI_ASC_NO_ADDITIONAL_SENSE_INFORMATION;
|
||||
drv->bufdir = IDEDIR_IN;
|
||||
drv->buftc = (drv->nsectors)?IDETC_ATAPIREAD:IDETC_TRANSFEREND;
|
||||
drv->bufpos = 0;
|
||||
drv->bufsize = 2048;
|
||||
|
||||
if(np2cfg.usecdecc && (sxsi->cdflag_ecc & CD_ECC_BITMASK)==CD_ECC_RECOVERED){
|
||||
drv->status |= IDESTAT_CORR;
|
||||
ATAPI_SET_SENSE_KEY(drv, ATAPI_SK_RECOVERED_ERROR);
|
||||
drv->asc = 0x18;
|
||||
}
|
||||
sxsi->cdflag_ecc = (sxsi->cdflag_ecc & ~CD_ECC_BITMASK) | CD_ECC_NOERROR;
|
||||
|
||||
drv->status &= ~(IDESTAT_BSY); // 念のため直前で解除
|
||||
if (!(drv->ctrl & IDECTRL_NIEN)) {
|
||||
//TRACEOUT(("atapicmd: senddata()"));
|
||||
ideio.bank[0] = ideio.bank[1] | 0x80; // ????
|
||||
pic_setirq(IDE_IRQ);
|
||||
}
|
||||
#if defined(_WINDOWS)
|
||||
atapi_dataread_error = -1;
|
||||
#endif
|
||||
}
|
||||
void atapi_dataread_errorend(IDEDRV drv) {
|
||||
SXSIDEV sxsi;
|
||||
sxsi = sxsi_getptr(drv->sxsidrv);
|
||||
|
||||
drv->status &= ~(IDESTAT_DRQ);
|
||||
|
||||
ATAPI_SET_SENSE_KEY(drv, ATAPI_SK_ILLEGAL_REQUEST);
|
||||
drv->asc = 0x21;
|
||||
sxsi->cdflag_ecc = (sxsi->cdflag_ecc & ~CD_ECC_BITMASK) | CD_ECC_NOERROR;
|
||||
senderror(drv);
|
||||
TRACEOUT(("atapicmd: read error at sector %d", drv->sector));
|
||||
#if defined(_WINDOWS)
|
||||
atapi_dataread_error = -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void atapi_cmd_read(IDEDRV drv, UINT32 lba, UINT32 nsec) {
|
||||
|
||||
drv->sector = lba;
|
||||
drv->nsectors = nsec;
|
||||
atapi_dataread(drv);
|
||||
}
|
||||
static void atapi_cmd_read_cd(IDEDRV drv, UINT32 lba, UINT32 nsec) {
|
||||
|
||||
int i;
|
||||
SXSIDEV sxsi;
|
||||
CDTRK trk;
|
||||
UINT tracks;
|
||||
UINT8 *bufptr;
|
||||
UINT bufsize;
|
||||
|
||||
UINT8 rawdata[2352];
|
||||
|
||||
UINT8 hassync;
|
||||
UINT8 hashead;
|
||||
UINT8 hassubhead;
|
||||
UINT8 hasdata;
|
||||
UINT8 hasedcecc;
|
||||
|
||||
UINT16 isCDDA = 1;
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
atapi_thread_drv = drv;
|
||||
#endif
|
||||
sxsi = sxsi_getptr(drv->sxsidrv);
|
||||
|
||||
hassync = (drv->buf[9] & 0x80) ? 1 : 0;
|
||||
hassubhead = (drv->buf[9] & 0x40) ? 1 : 0;
|
||||
hashead = (drv->buf[9] & 0x20) ? 1 : 0;
|
||||
hasdata = (drv->buf[9] & 0x10) ? 1 : 0;
|
||||
hasedcecc = (drv->buf[9] & 0x08) ? 1 : 0;
|
||||
|
||||
drv->sector = lba;
|
||||
drv->nsectors = nsec;
|
||||
|
||||
// エラー処理目茶苦茶〜
|
||||
if (drv->nsectors == 0) {
|
||||
cmddone(drv);
|
||||
return;
|
||||
}
|
||||
|
||||
sxsi->cdflag_ecc = (sxsi->cdflag_ecc & ~CD_ECC_BITMASK) | CD_ECC_NOERROR;
|
||||
|
||||
trk = sxsicd_gettrk(sxsi, &tracks);
|
||||
for (i = 0; i < tracks; i++) {
|
||||
if (trk[i].str_sec <= (UINT32)drv->sector && (UINT32)drv->sector <= trk[i].end_sec) {
|
||||
isCDDA = (trk[i].adr_ctl == TRACKTYPE_AUDIO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(isCDDA){
|
||||
// Audio
|
||||
if (sxsicd_readraw(sxsi, drv->sector, drv->buf) != SUCCESS) {
|
||||
atapi_dataread_errorend(0);
|
||||
return;
|
||||
}
|
||||
bufsize = 2352;
|
||||
}else{
|
||||
// 条件がかなり複雑。
|
||||
// ATAPI CD-ROM Specificationの
|
||||
// Table 99 - Number of Bytes Returned Based on Data Selection Field
|
||||
// を参照
|
||||
|
||||
// MODE1決め打ち
|
||||
if (sxsicd_readraw(sxsi, drv->sector, rawdata) != SUCCESS) {
|
||||
atapi_dataread_errorend(0);
|
||||
return;
|
||||
}
|
||||
|
||||
bufsize = 0;
|
||||
bufptr = drv->buf;
|
||||
if (hassync){
|
||||
if(hashead){
|
||||
// Headerがいるときだけ有効
|
||||
memcpy(bufptr, rawdata, 12);
|
||||
bufptr += 12;
|
||||
bufsize += 12;
|
||||
}
|
||||
}
|
||||
if (hashead){
|
||||
memcpy(bufptr, rawdata + 12, 4);
|
||||
bufptr += 4;
|
||||
bufsize += 4;
|
||||
}
|
||||
if (hassubhead){
|
||||
// MODE1(本来ないが、User Dataが無いときだけ特例で書く)
|
||||
if(!hasdata){
|
||||
memset(bufptr, 0, 8);
|
||||
bufptr += 8;
|
||||
bufsize += 8;
|
||||
|
||||
}
|
||||
|
||||
//// XA
|
||||
//memcpy(bufptr, rawdata + 12 + 4, 8);
|
||||
|
||||
//bufptr += 8;
|
||||
//bufsize += 8;
|
||||
}
|
||||
if (hasdata){
|
||||
memcpy(bufptr, rawdata + 12 + 4 + 8, 2048);
|
||||
bufptr += 2048;
|
||||
bufsize += 2048;
|
||||
}
|
||||
if (hasedcecc){
|
||||
//// MODE1
|
||||
//memcpy(bufptr, rawdata + 12 + 4 + 8 + 2048, 4);
|
||||
//memcpy(bufptr + 4, rawdata + 12 + 4 + 8 + 2048 + 12, 276);
|
||||
|
||||
////// XA
|
||||
////memcpy(bufptr, rawdata + 12 + 4 + 8 + 2048, 280);
|
||||
|
||||
//bufptr += 280;
|
||||
//bufsize += 280;
|
||||
|
||||
memcpy(bufptr, rawdata + 12 + 4 + 8 + 2048, 288);
|
||||
bufptr += 288;
|
||||
bufsize += 288;
|
||||
}
|
||||
}
|
||||
|
||||
atapi_dataread_end(drv);
|
||||
|
||||
drv->bufsize = bufsize;
|
||||
drv->cy = bufsize;
|
||||
}
|
||||
|
||||
static void atapi_cmd_read_cd_msf(IDEDRV drv) {
|
||||
|
||||
UINT32 pos;
|
||||
UINT32 leng;
|
||||
|
||||
int M, S, F;
|
||||
if(drv->damsfbcd){
|
||||
M = BCD2HEX(drv->buf[3]);
|
||||
S = BCD2HEX(drv->buf[4]);
|
||||
F = BCD2HEX(drv->buf[5]);
|
||||
pos = (((M * 60) + S) * 75) + F;
|
||||
M = BCD2HEX(drv->buf[6]);
|
||||
S = BCD2HEX(drv->buf[7]);
|
||||
F = BCD2HEX(drv->buf[8]);
|
||||
leng = (((M * 60) + S) * 75) + F;
|
||||
}else{
|
||||
M = drv->buf[3];
|
||||
S = drv->buf[4];
|
||||
F = drv->buf[5];
|
||||
pos = (((M * 60) + S) * 75) + F;
|
||||
M = drv->buf[6];
|
||||
S = drv->buf[7];
|
||||
F = drv->buf[8];
|
||||
leng = (((M * 60) + S) * 75) + F;
|
||||
}
|
||||
if (leng > pos) {
|
||||
leng -= pos;
|
||||
}
|
||||
else {
|
||||
leng = 0;
|
||||
}
|
||||
if (pos >= 150) {
|
||||
pos -= 150;
|
||||
}
|
||||
else {
|
||||
pos = 0;
|
||||
}
|
||||
atapi_cmd_read_cd(drv, pos, leng);
|
||||
}
|
||||
|
||||
// -- MODE SELECT/SENSE
|
||||
#define PC_01_SIZE 8
|
||||
@ -804,7 +1033,7 @@ static void atapi_cmd_mode_select(IDEDRV drv) {
|
||||
senderror(drv);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#if 1
|
||||
cmddone(drv); /* workaround */
|
||||
#else
|
||||
@ -1198,7 +1427,10 @@ static void atapi_cmd_readtoc(IDEDRV drv) {
|
||||
drv->buf[5] = 0x14;
|
||||
drv->buf[6] = 0x01;
|
||||
//drv->buf[10] = 0x02;
|
||||
drv->buf[10] = time ? 0x02 : 0;
|
||||
if (time)
|
||||
storemsf(drv->buf + 8, (UINT32)(150), drv->damsfbcd);
|
||||
else
|
||||
storelba(drv->buf + 8, (UINT32)(0));
|
||||
senddata(drv, 12, leng);
|
||||
drv->media &= ~IDEIO_MEDIA_CHANGED;
|
||||
break;
|
||||
|
@ -228,7 +228,9 @@ static REG8 IOINPCALL pc9861k_ib0(UINT port) {
|
||||
if (cm_pc9861ch1 == NULL) {
|
||||
pc9861ch1_open();
|
||||
}
|
||||
(void)port;
|
||||
if (cm_pc9861ch1 == NULL) {
|
||||
return 0;
|
||||
}
|
||||
return(cm_pc9861ch1->getstat(cm_pc9861ch1) | pc9861k.ch1.vect);
|
||||
}
|
||||
|
||||
@ -237,7 +239,9 @@ static REG8 IOINPCALL pc9861k_ib2(UINT port) {
|
||||
if (cm_pc9861ch2 == NULL) {
|
||||
pc9861ch2_open();
|
||||
}
|
||||
(void)port;
|
||||
if (cm_pc9861ch1 == NULL) {
|
||||
return 0;
|
||||
}
|
||||
return(cm_pc9861ch2->getstat(cm_pc9861ch2) | pc9861k.ch2.vect);
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ static void IOOUTCALL pcm86_oa468(UINT port, REG8 val) {
|
||||
g_pcm86.lastclock = CPU_CLOCK + CPU_BASECLOCK - CPU_REMCLOCK;
|
||||
g_pcm86.lastclock <<= 6;
|
||||
}
|
||||
if ((xchgbit & 0x10) && (!(val & 0x10))) {
|
||||
if (/*(xchgbit & 0x10) &&*/ (!(val & 0x10))) {
|
||||
g_pcm86.irqflag = 0;
|
||||
// g_pcm86.write = 0;
|
||||
// g_pcm86.reqirq = 0;
|
||||
@ -193,7 +193,7 @@ static REG8 IOINPCALL pcm86_ia466(UINT port) {
|
||||
g_pcm86.lastclock += (cnt * stepclock);
|
||||
past -= cnt * stepclock;
|
||||
if (g_pcm86.fifo & 0x80) {
|
||||
sound_sync();
|
||||
//sound_sync();
|
||||
RECALC_NOWCLKWAIT(cnt);
|
||||
}
|
||||
}
|
||||
@ -215,7 +215,7 @@ static REG8 IOINPCALL pcm86_ia468(UINT port) {
|
||||
|
||||
ret = g_pcm86.fifo & (~0x10);
|
||||
#if 1
|
||||
if (pcm86gen_intrq() || g_pcm86.irqflag) {
|
||||
if (pcm86gen_intrq()) {
|
||||
ret |= 0x10;
|
||||
}
|
||||
#elif 1 // むしろこう?
|
||||
|
@ -1213,6 +1213,7 @@ static UINT sjis2ucs2(UINT16 *lpOutput, UINT cchOutput, const char *lpInput, UIN
|
||||
UINT nRemain;
|
||||
UINT c;
|
||||
UINT r;
|
||||
UINT32 idx;
|
||||
|
||||
nRemain = cchOutput;
|
||||
while ((cchInput > 0) && (nRemain > 0))
|
||||
@ -1231,7 +1232,8 @@ static UINT sjis2ucs2(UINT16 *lpOutput, UINT cchOutput, const char *lpInput, UIN
|
||||
c = ((*lpInput++) - r) & 0xff;
|
||||
if (c < ((r >> 8) & 0xff))
|
||||
{
|
||||
r = s_level2[((r >> 16) & 0xffff) + c];
|
||||
idx = ((r >> 16) & 0xffff) + c;
|
||||
r = idx < NELEMENTS(s_level2) ? s_level2[idx] : UDCODE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1300,6 +1302,7 @@ static UINT sjis2utf8(char *lpOutput, UINT cchOutput, const char *lpInput, UINT
|
||||
UINT nRemain;
|
||||
UINT c;
|
||||
UINT r;
|
||||
UINT32 idx;
|
||||
|
||||
nRemain = cchOutput;
|
||||
while ((cchInput > 0) && (nRemain > 0))
|
||||
@ -1318,7 +1321,8 @@ static UINT sjis2utf8(char *lpOutput, UINT cchOutput, const char *lpInput, UINT
|
||||
c = ((*lpInput++) - r) & 0xff;
|
||||
if (c < ((r >> 8) & 0xff))
|
||||
{
|
||||
r = s_level2[((r >> 16) & 0xffff) + c];
|
||||
idx = ((r >> 16) & 0xffff) + c;
|
||||
r = idx < NELEMENTS(s_level2) ? s_level2[idx] : UDCODE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ UINT bmpdata_setinfo(BMPINFO *bi, const BMPDATA *inf) {
|
||||
UINT tmp;
|
||||
|
||||
ret = 0;
|
||||
if ((bi == NULL) && (inf == NULL)) {
|
||||
if ((bi == NULL) || (inf == NULL)) {
|
||||
goto bdsi_exit;
|
||||
}
|
||||
ZeroMemory(bi, sizeof(BMPINFO));
|
||||
|
@ -40,7 +40,7 @@ struct sptdreadcapacityinfo
|
||||
|
||||
|
||||
// ----
|
||||
// イメージファイル内全トラックセクタ長2048byte用
|
||||
// イメージファイル内全トラックセクタ長2048byte用
|
||||
REG8 sec2048_read_SPTI(SXSIDEV sxsi, FILEPOS pos, UINT8 *buf, UINT size) {
|
||||
|
||||
CDINFO cdinfo;
|
||||
@ -59,135 +59,66 @@ REG8 sec2048_read_SPTI(SXSIDEV sxsi, FILEPOS pos, UINT8 *buf, UINT size) {
|
||||
|
||||
size /= 2048;
|
||||
|
||||
if(1 || size!=2048) {
|
||||
DWORD sptisize=0;
|
||||
struct sptdinfo sptd = {0};
|
||||
if (1 || size != 2048) {
|
||||
DWORD sptisize = 0;
|
||||
struct sptdinfo* psptd = (struct sptdinfo*)malloc(sizeof(struct sptdinfo));
|
||||
if (!psptd) {
|
||||
return(0x60);
|
||||
}
|
||||
memset(psptd, 0, sizeof(struct sptdinfo));
|
||||
//UCHAR ucDataBuf[2048*8];
|
||||
|
||||
// READ command
|
||||
sptd.info.Cdb[0] = 0x28;//0xBE;//0x3C;//0xBE;
|
||||
psptd->info.Cdb[0] = 0x28;//0xBE;//0x3C;//0xBE;
|
||||
// Don't care about sector type.
|
||||
//sptd.info.Cdb[1] = 0;
|
||||
//sptd.info.Cdb[2] = (pos >> 24) & 0xFF;
|
||||
//sptd.info.Cdb[3] = (pos >> 16) & 0xFF;
|
||||
//sptd.info.Cdb[4] = (pos >> 8) & 0xFF;
|
||||
//sptd.info.Cdb[5] = pos & 0xFF;
|
||||
//sptd.info.Cdb[6] = (size >> 16) & 0xFF;
|
||||
//sptd.info.Cdb[7] = (size >> 8) & 0xFF;
|
||||
//sptd.info.Cdb[8] = size & 0xFF;
|
||||
//psptd->info.Cdb[1] = 0;
|
||||
//psptd->info.Cdb[2] = (pos >> 24) & 0xFF;
|
||||
//psptd->info.Cdb[3] = (pos >> 16) & 0xFF;
|
||||
//psptd->info.Cdb[4] = (pos >> 8) & 0xFF;
|
||||
//psptd->info.Cdb[5] = pos & 0xFF;
|
||||
//psptd->info.Cdb[6] = (size >> 16) & 0xFF;
|
||||
//psptd->info.Cdb[7] = (size >> 8) & 0xFF;
|
||||
//psptd->info.Cdb[8] = size & 0xFF;
|
||||
//// Sync + all headers + user data + EDC/ECC. Excludes C2 + subchannel
|
||||
sptd.info.Cdb[1] = 2; // Data mode
|
||||
sptd.info.Cdb[2] = (pos >> 24) & 0xFF;
|
||||
sptd.info.Cdb[3] = (pos >> 16) & 0xFF;
|
||||
sptd.info.Cdb[4] = (pos >> 8) & 0xFF;
|
||||
sptd.info.Cdb[5] = pos & 0xFF;
|
||||
sptd.info.Cdb[6] = (size >> 16) & 0xFF;
|
||||
sptd.info.Cdb[7] = (size >> 8) & 0xFF;
|
||||
sptd.info.Cdb[8] = size & 0xFF;
|
||||
sptd.info.Cdb[9] = 0xF8;
|
||||
sptd.info.Cdb[10] = 0;
|
||||
sptd.info.Cdb[11] = 0;
|
||||
psptd->info.Cdb[1] = 2; // Data mode
|
||||
psptd->info.Cdb[2] = (pos >> 24) & 0xFF;
|
||||
psptd->info.Cdb[3] = (pos >> 16) & 0xFF;
|
||||
psptd->info.Cdb[4] = (pos >> 8) & 0xFF;
|
||||
psptd->info.Cdb[5] = pos & 0xFF;
|
||||
psptd->info.Cdb[6] = (size >> 16) & 0xFF;
|
||||
psptd->info.Cdb[7] = (size >> 8) & 0xFF;
|
||||
psptd->info.Cdb[8] = size & 0xFF;
|
||||
psptd->info.Cdb[9] = 0xF8;
|
||||
psptd->info.Cdb[10] = 0;
|
||||
psptd->info.Cdb[11] = 0;
|
||||
|
||||
sptd.info.CdbLength = 12;
|
||||
sptd.info.Length = sizeof(SCSI_PASS_THROUGH);
|
||||
sptd.info.DataIn = SCSI_IOCTL_DATA_IN;
|
||||
sptd.info.DataTransferLength = 2048 * size;
|
||||
sptd.info.DataBufferOffset = offsetof(struct sptdinfo, ucDataBuf);
|
||||
//sptd.info.DataBuffer = ucDataBuf;
|
||||
sptd.info.SenseInfoLength = sizeof(sptd.sense_buffer);
|
||||
sptd.info.SenseInfoOffset = offsetof(struct sptdinfo, sense_buffer);
|
||||
sptd.info.TimeOutValue = 5;
|
||||
|
||||
if(sptd.info.DataTransferLength > sizeof(sptd.ucDataBuf)) return 0xd0;
|
||||
psptd->info.CdbLength = 12;
|
||||
psptd->info.Length = sizeof(SCSI_PASS_THROUGH);
|
||||
psptd->info.DataIn = SCSI_IOCTL_DATA_IN;
|
||||
psptd->info.DataTransferLength = 2048 * size;
|
||||
psptd->info.DataBufferOffset = offsetof(struct sptdinfo, ucDataBuf);
|
||||
//psptd->info.DataBuffer = ucDataBuf;
|
||||
psptd->info.SenseInfoLength = sizeof(psptd->sense_buffer);
|
||||
psptd->info.SenseInfoOffset = offsetof(struct sptdinfo, sense_buffer);
|
||||
psptd->info.TimeOutValue = 5;
|
||||
|
||||
//memset(buf, 0, 2048 * size);
|
||||
//memset(ucDataBuf, 0, 16384);
|
||||
//SetLastError(0);
|
||||
if (DeviceIoControl(fh, IOCTL_SCSI_PASS_THROUGH, &sptd, offsetof(struct sptdinfo, sense_buffer)+sizeof(sptd.sense_buffer), &sptd, offsetof(struct sptdinfo, ucDataBuf)+2048 * size, &sptisize, FALSE))
|
||||
if (psptd->info.DataTransferLength > sizeof(psptd->ucDataBuf)) return 0xd0;
|
||||
|
||||
if (DeviceIoControl(fh, IOCTL_SCSI_PASS_THROUGH, psptd, offsetof(struct sptdinfo, sense_buffer) + sizeof(psptd->sense_buffer), psptd, offsetof(struct sptdinfo, ucDataBuf) + 2048 * size, &sptisize, FALSE))
|
||||
{
|
||||
if (sptd.info.DataTransferLength != 0){
|
||||
memcpy(buf, sptd.ucDataBuf, sptd.info.DataTransferLength);
|
||||
if (psptd->info.DataTransferLength != 0) {
|
||||
memcpy(buf, psptd->ucDataBuf, psptd->info.DataTransferLength);
|
||||
free(psptd);
|
||||
return(0x00);
|
||||
}
|
||||
}
|
||||
free(psptd);
|
||||
}
|
||||
|
||||
//{
|
||||
// DWORD sptisize=0;
|
||||
// struct sptdinfo sptd = {0};
|
||||
// //UCHAR ucDataBuf[2048*8];
|
||||
|
||||
// //size /= 2048;
|
||||
// // READ CD command
|
||||
// sptd.info.Cdb[0] = 0xBE;//0x3C;//0xBE;
|
||||
// // Don't care about sector type.
|
||||
// //sptd.info.Cdb[1] = 0;
|
||||
// //sptd.info.Cdb[2] = (pos >> 24) & 0xFF;
|
||||
// //sptd.info.Cdb[3] = (pos >> 16) & 0xFF;
|
||||
// //sptd.info.Cdb[4] = (pos >> 8) & 0xFF;
|
||||
// //sptd.info.Cdb[5] = pos & 0xFF;
|
||||
// //sptd.info.Cdb[6] = (size >> 16) & 0xFF;
|
||||
// //sptd.info.Cdb[7] = (size >> 8) & 0xFF;
|
||||
// //sptd.info.Cdb[8] = size & 0xFF;
|
||||
// //// Sync + all headers + user data + EDC/ECC. Excludes C2 + subchannel
|
||||
// sptd.info.Cdb[1] = 2; // Data mode
|
||||
// sptd.info.Cdb[2] = (pos >> 24) & 0xFF;
|
||||
// sptd.info.Cdb[3] = (pos >> 16) & 0xFF;
|
||||
// sptd.info.Cdb[4] = (pos >> 8) & 0xFF;
|
||||
// sptd.info.Cdb[5] = pos & 0xFF;
|
||||
// sptd.info.Cdb[6] = (size >> 16) & 0xFF;
|
||||
// sptd.info.Cdb[7] = (size >> 8) & 0xFF;
|
||||
// sptd.info.Cdb[8] = size & 0xFF;
|
||||
// sptd.info.Cdb[9] = 0xF8;
|
||||
// sptd.info.Cdb[10] = 0;
|
||||
// sptd.info.Cdb[11] = 0;
|
||||
|
||||
// sptd.info.CdbLength = 12;
|
||||
// sptd.info.Length = sizeof(SCSI_PASS_THROUGH);
|
||||
// sptd.info.DataIn = SCSI_IOCTL_DATA_IN;
|
||||
// sptd.info.DataTransferLength = 2352;
|
||||
// sptd.info.DataBufferOffset = offsetof(struct sptdinfo, ucDataBuf);
|
||||
// //sptd.info.DataBuffer = ucDataBuf;
|
||||
// sptd.info.SenseInfoLength = sizeof(sptd.sense_buffer);
|
||||
// sptd.info.SenseInfoOffset = offsetof(struct sptdinfo, sense_buffer);
|
||||
// sptd.info.TimeOutValue = 5;
|
||||
//
|
||||
// if(sptd.info.DataTransferLength > sizeof(sptd.ucDataBuf)) return 0xd0;
|
||||
|
||||
// //memset(buf, 0, 2048 * size);
|
||||
// //memset(ucDataBuf, 0, 16384);
|
||||
// //SetLastError(0);
|
||||
// if (DeviceIoControl(fh, IOCTL_SCSI_PASS_THROUGH, &sptd, offsetof(struct sptdinfo, sense_buffer)+sizeof(sptd.sense_buffer), &sptd, offsetof(struct sptdinfo, ucDataBuf)+2352, &sptisize, FALSE))
|
||||
// {
|
||||
// //if (sptd.info.DataTransferLength != 0){
|
||||
// //memcpy(buf, sptd.ucDataBuf + 16, sptd.info.DataTransferLength);
|
||||
// sxsi->cdflag_ecc = 2;
|
||||
// return(0xd0);
|
||||
// //return(0x00);
|
||||
// //}
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//if (file_seek(fh, pos, FSEEK_SET) != pos) {
|
||||
// return(0xd0);
|
||||
//}
|
||||
|
||||
//while(size) {
|
||||
// rsize = min(size, 2048);
|
||||
// CPU_REMCLOCK -= rsize;
|
||||
// if (file_read(fh, buf, rsize) != rsize) {
|
||||
// return(0xd0);
|
||||
// }
|
||||
// buf += rsize;
|
||||
// size -= rsize;
|
||||
//}
|
||||
//
|
||||
//rsize = GetLastError();
|
||||
return(0xd0);
|
||||
}
|
||||
|
||||
// イメージファイルの実体を開き、各種情報構築
|
||||
// イメージファイルの実体を開き、各種情報構築
|
||||
BRESULT setsxsidev_SPTI(SXSIDEV sxsi, const OEMCHAR *path, const _CDTRK *trk, UINT trks) {
|
||||
|
||||
FILEH fh;
|
||||
@ -201,7 +132,7 @@ BRESULT setsxsidev_SPTI(SXSIDEV sxsi, const OEMCHAR *path, const _CDTRK *trk, UI
|
||||
TEXTFILEH tfh;
|
||||
#endif
|
||||
|
||||
// trk、trksは有効な値が設定済みなのが前提
|
||||
// trk、trksは有効な値が設定済みなのが前提
|
||||
if ((trk == NULL) || (trks == 0)) {
|
||||
goto sxsiope_err1;
|
||||
}
|
||||
@ -267,7 +198,7 @@ BRESULT setsxsidev_SPTI(SXSIDEV sxsi, const OEMCHAR *path, const _CDTRK *trk, UI
|
||||
sxsi->totals = totals;
|
||||
}
|
||||
#else
|
||||
totals = issec(fh, cdinfo->trk, trks); // とりあえず
|
||||
totals = issec(fh, cdinfo->trk, trks); // とりあえず
|
||||
sxsi->read = sec2048_read;
|
||||
totals = issec2048(cdinfo->fh);
|
||||
if (totals < 0) {
|
||||
@ -297,7 +228,7 @@ BRESULT setsxsidev_SPTI(SXSIDEV sxsi, const OEMCHAR *path, const _CDTRK *trk, UI
|
||||
}
|
||||
}
|
||||
|
||||
// リードアウトトラックを生成
|
||||
// リードアウトトラックを生成
|
||||
cdinfo->trk[trks].adr_ctl = 0x10;
|
||||
cdinfo->trk[trks].point = 0xaa;
|
||||
// cdinfo->trk[trks].pos = totals;
|
||||
@ -369,7 +300,7 @@ sxsiope_err1:
|
||||
}
|
||||
|
||||
// ----
|
||||
// セクタ長取得用(でもREAD CAPACITYコマンドに返事してくれない場合があるような・・・)
|
||||
// セクタ長取得用(でもREAD CAPACITYコマンドに返事してくれない場合があるような・・・)
|
||||
UINT32 readcapacity_SPTI(FILEH fh) {
|
||||
|
||||
//CDINFO cdinfo;
|
||||
@ -423,7 +354,7 @@ UINT32 readcapacity_SPTI(FILEH fh) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 実ドライブを開く
|
||||
// 実ドライブを開く
|
||||
BRESULT openrealcdd(SXSIDEV sxsi, const OEMCHAR *path) {
|
||||
|
||||
_CDTRK trk[99];
|
||||
@ -446,7 +377,7 @@ BRESULT openrealcdd(SXSIDEV sxsi, const OEMCHAR *path) {
|
||||
goto openiso_err1;
|
||||
}
|
||||
|
||||
// セクタサイズが2048byte、2352byte、2448byteのどれかをチェック
|
||||
// セクタサイズが2048byte、2352byte、2448byteのどれかをチェック
|
||||
DeviceIoControl(fh, IOCTL_CDROM_GET_DRIVE_GEOMETRY,
|
||||
NULL, 0, &dgCDROM, sizeof(DISK_GEOMETRY),
|
||||
&dwNotUsed, NULL);
|
||||
@ -456,7 +387,7 @@ BRESULT openrealcdd(SXSIDEV sxsi, const OEMCHAR *path) {
|
||||
}
|
||||
|
||||
sector_size = (UINT16)dgCDROM.BytesPerSector;
|
||||
totals = dgCDROM.SectorsPerTrack*dgCDROM.TracksPerCylinder*dgCDROM.Cylinders.QuadPart;
|
||||
totals = (FILELEN)dgCDROM.SectorsPerTrack*dgCDROM.TracksPerCylinder*dgCDROM.Cylinders.QuadPart;
|
||||
switch(sector_size){
|
||||
case 2048:
|
||||
if(readcapacity_SPTI(fh) == 2048){
|
||||
@ -475,12 +406,13 @@ BRESULT openrealcdd(SXSIDEV sxsi, const OEMCHAR *path) {
|
||||
goto openiso_err2;
|
||||
}
|
||||
|
||||
// トラック情報を拾う
|
||||
// トラック情報を拾う
|
||||
DeviceIoControl(fh, IOCTL_CDROM_READ_TOC,
|
||||
NULL, 0, &tocCDROM, sizeof(tocCDROM),
|
||||
&dwNotUsed, NULL);
|
||||
|
||||
trks = tocCDROM.LastTrack - tocCDROM.FirstTrack + 1;
|
||||
if (trks <= 0) goto openiso_err2;
|
||||
for(i=0;i<trks;i++){
|
||||
if((tocCDROM.TrackData[i].Control & 0xC) == 0x4){
|
||||
trk[i].adr_ctl = TRACKTYPE_DATA;
|
||||
@ -512,9 +444,9 @@ BRESULT openrealcdd(SXSIDEV sxsi, const OEMCHAR *path) {
|
||||
trk[i].end_sec = trk[i].end_sector;
|
||||
trk[i].sectors = trk[i].track_sectors;
|
||||
|
||||
trk[i].pregap_offset = trk[i].start_sector * trk[i].sector_size;
|
||||
trk[i].start_offset = trk[i].start_sector * trk[i].sector_size;
|
||||
trk[i].end_offset = trk[i].end_sector * trk[i].sector_size;
|
||||
trk[i].pregap_offset = (UINT64)trk[i].start_sector * trk[i].sector_size;
|
||||
trk[i].start_offset = (UINT64)trk[i].start_sector * trk[i].sector_size;
|
||||
trk[i].end_offset = (UINT64)trk[i].end_sector * trk[i].sector_size;
|
||||
}
|
||||
|
||||
//trk[0].adr_ctl = TRACKTYPE_DATA;
|
||||
@ -580,7 +512,7 @@ openiso_err1:
|
||||
// goto openiso_err1;
|
||||
// }
|
||||
//
|
||||
// // セクタサイズが2048byte、2352byte、2448byteのどれかをチェック
|
||||
// // セクタサイズが2048byte、2352byte、2448byteのどれかをチェック
|
||||
// DeviceIoControl(fh, IOCTL_CDROM_GET_DRIVE_GEOMETRY,
|
||||
// NULL, 0, &dgCDROM, sizeof(DISK_GEOMETRY),
|
||||
// &dwNotUsed, NULL);
|
||||
@ -604,7 +536,7 @@ openiso_err1:
|
||||
// goto openiso_err2;
|
||||
// }
|
||||
//
|
||||
// // トラック情報を拾う
|
||||
// // トラック情報を拾う
|
||||
// DeviceIoControl(fh, IOCTL_CDROM_READ_TOC_EX,
|
||||
// &TOCEx, sizeof(TOCEx), &tocCDROMtmp, sizeof(tocCDROMtmp),
|
||||
// &dwNotUsed, NULL);
|
||||
|
@ -581,9 +581,9 @@ static int fileappend(FILEH hdl, FDDFILE fdd,
|
||||
size = length;
|
||||
}
|
||||
length -= size;
|
||||
file_seek(hdl, ptr + length, 0);
|
||||
file_seek(hdl, (FILEPOS)ptr + length, 0);
|
||||
rsize = file_read(hdl, tmp, size);
|
||||
file_seek(hdl, ptr + length + apsize, 0);
|
||||
file_seek(hdl, (FILEPOS)ptr + length + apsize, 0);
|
||||
file_write(hdl, tmp, rsize);
|
||||
}
|
||||
|
||||
@ -659,6 +659,10 @@ static void endoftrack(UINT fmtsize, UINT8 sectors) {
|
||||
fdd->inf.d88.fd_size += apsize;
|
||||
STOREINTELDWORD(fdd->inf.d88.head.fd_size, fdd->inf.d88.fd_size);
|
||||
}
|
||||
if (trk >= D88_TRACKMAX) {
|
||||
file_close(hdl);
|
||||
return;
|
||||
}
|
||||
fdd->inf.d88.ptr[trk] = fpointer;
|
||||
STOREINTELDWORD(fdd->inf.d88.head.trackp[trk], fpointer);
|
||||
file_seek(hdl, fpointer, 0);
|
||||
|
@ -277,9 +277,9 @@ BRESULT makenewtrack_dcp(FDDFILE fdd) {
|
||||
size = length;
|
||||
}
|
||||
length -= size;
|
||||
file_seek(hdl, ptr + length, 0);
|
||||
file_seek(hdl, (FILEPOS)ptr + length, 0);
|
||||
rsize = file_read(hdl, tmp, size);
|
||||
file_seek(hdl, ptr + length + tracksize, 0);
|
||||
file_seek(hdl, (FILEPOS)ptr + length + tracksize, 0);
|
||||
file_write(hdl, tmp, rsize);
|
||||
}
|
||||
|
||||
@ -294,6 +294,10 @@ BRESULT makenewtrack_dcp(FDDFILE fdd) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (newtrack >= DCP_TRACKMAX) {
|
||||
file_close(hdl);
|
||||
return(FAILURE);
|
||||
}
|
||||
fdd->inf.dcp.ptr[newtrack] = fdsize;
|
||||
}
|
||||
|
||||
|
@ -459,6 +459,10 @@ BRESULT fdd_write_nfd(FDDFILE fdd) {
|
||||
}
|
||||
file_close(hdl);
|
||||
}
|
||||
else {
|
||||
fddlasterror = 0xc0;
|
||||
return(FAILURE);
|
||||
}
|
||||
|
||||
fdc.bufcnt = secsize;
|
||||
fddlasterror = 0x00;
|
||||
@ -807,6 +811,11 @@ BRESULT fdd_read_nfd1(FDDFILE fdd) {
|
||||
return(FAILURE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fddlasterror = 0xc0;
|
||||
file_close(hdl);
|
||||
return(FAILURE);
|
||||
}
|
||||
file_close(hdl);
|
||||
|
||||
// イメージ内情報のREAD DATA RESULTを反映
|
||||
@ -886,6 +895,11 @@ BRESULT fdd_write_nfd1(FDDFILE fdd) {
|
||||
return(FAILURE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fddlasterror = 0xc0;
|
||||
file_close(hdl);
|
||||
return(FAILURE);
|
||||
}
|
||||
|
||||
file_close(hdl);
|
||||
fdc.bufcnt = secsize;
|
||||
|
@ -158,6 +158,10 @@ BRESULT fdd_read_vfdd(FDDFILE fdd) {
|
||||
file_close(hdl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fddlasterror = 0xc0;
|
||||
return(FAILURE);
|
||||
}
|
||||
|
||||
fdc.bufcnt = secsize;
|
||||
fddlasterror = 0x00;
|
||||
@ -226,6 +230,10 @@ BRESULT fdd_write_vfdd(FDDFILE fdd) {
|
||||
}
|
||||
file_close(hdl);
|
||||
}
|
||||
else {
|
||||
fddlasterror = 0xc0;
|
||||
return(FAILURE);
|
||||
}
|
||||
|
||||
fdc.bufcnt = secsize;
|
||||
fddlasterror = 0x00;
|
||||
|
@ -110,6 +110,9 @@ static BRESULT writehddiplex2(FILEH fh, UINT ssize, FILELEN tsize, int blank, in
|
||||
if(tsize > 8*1024*1024) worksize = 8*1024*1024;
|
||||
if(worksize < sizeof(hdddiskboot)) worksize = sizeof(hdddiskboot);
|
||||
work = (UINT8*)malloc(worksize);
|
||||
if (!work) {
|
||||
return(FAILURE);
|
||||
}
|
||||
|
||||
progtotal = tsize;
|
||||
*progress = 0;
|
||||
@ -161,19 +164,19 @@ static void hddsize2CHS(UINT hddsizeMB, UINT32 *C, UINT16 *H, UINT16 *S, UINT16
|
||||
FILELEN size;
|
||||
#ifdef SUPPORT_LARGE_HDD
|
||||
if(hddsizeMB <= 4351){
|
||||
size = hddsizeMB * 15;
|
||||
size = (FILELEN)hddsizeMB * 15;
|
||||
*C = (UINT32)size;
|
||||
*H = 8;
|
||||
*S = 17;
|
||||
*SS = 512;
|
||||
}else if(hddsizeMB <= 32255){
|
||||
size = hddsizeMB * 15 * 17 / 2 / 63;
|
||||
size = (FILELEN)hddsizeMB * 15 * 17 / 2 / 63;
|
||||
*C = (UINT32)size;
|
||||
*H = 16;
|
||||
*S = 63;
|
||||
*SS = 512;
|
||||
}else{
|
||||
size = hddsizeMB * 15 * 17 / 2 / 255;
|
||||
size = (FILELEN)hddsizeMB * 15 * 17 / 2 / 255;
|
||||
*C = (UINT32)size;
|
||||
*H = 16;
|
||||
*S = 255;
|
||||
@ -323,7 +326,7 @@ void newdisk_hdi_ex_CHS(const OEMCHAR *fname, UINT32 C, UINT16 H, UINT16 S, UINT
|
||||
goto ndhdi_err;
|
||||
}
|
||||
ZeroMemory(&hdi, sizeof(hdi));
|
||||
hddsize = SS * S * H * C;
|
||||
hddsize = (FILELEN)SS * S * H * C;
|
||||
STOREINTELDWORD(hdi.headersize, 4096);
|
||||
STOREINTELDWORD(hdi.hddsize, hddsize);
|
||||
STOREINTELDWORD(hdi.sectorsize, SS);
|
||||
@ -407,7 +410,7 @@ void newdisk_hdn(const OEMCHAR *fname, UINT hddsize) {
|
||||
if (fh == FILEH_INVALID) {
|
||||
goto ndhdn_err;
|
||||
}
|
||||
tmp = hddsize * 1024 * 1024;
|
||||
tmp = (FILELEN)hddsize * 1024 * 1024;
|
||||
// round up
|
||||
if ((tmp % (512 * 25 * 8)) != 0) {
|
||||
tmp = tmp / (512 * 25 * 8) + 1;
|
||||
|
@ -310,7 +310,7 @@ BRESULT sxsi_devopen(REG8 drv, const OEMCHAR *fname) {
|
||||
return(FAILURE);
|
||||
}
|
||||
if ((fname == NULL) || (fname[0] == '\0')) {
|
||||
int num = drv & 0x0f;
|
||||
int num = drv & 0x03;
|
||||
if (sxsi->flag & SXSIFLAG_FILEOPENED) {
|
||||
ideio_notify(sxsi->drv, 0);
|
||||
(*sxsi->close)(sxsi);
|
||||
@ -337,7 +337,7 @@ BRESULT sxsi_devopen(REG8 drv, const OEMCHAR *fname) {
|
||||
sxsi->flag = 0;
|
||||
cdchange_drv = drv;
|
||||
file_cpyname(sxsi->fname, _T("\0\0\0\0"), 1);
|
||||
file_cpyname(np2cfg.idecd[drv & 0x0f], _T("\0\0\0\0"), NELEMENTS(cdchange_fname));
|
||||
file_cpyname(np2cfg.idecd[drv & 0x03], _T("\0\0\0\0"), NELEMENTS(cdchange_fname));
|
||||
file_cpyname(cdchange_fname, fname, NELEMENTS(cdchange_fname));
|
||||
cdchange_flag = 1;
|
||||
cdchange_timeoutset();
|
||||
@ -347,13 +347,13 @@ BRESULT sxsi_devopen(REG8 drv, const OEMCHAR *fname) {
|
||||
}
|
||||
r = sxsicd_open(sxsi, fname);
|
||||
if (r == SUCCESS || _tcsnicmp(fname, OEMTEXT("\\\\.\\"), 4)==0) {
|
||||
int num = drv & 0x0f;
|
||||
int num = drv & 0x03;
|
||||
file_cpyname(np2cfg.idecd[num], fname, MAX_PATH);
|
||||
if(r != SUCCESS && _tcsnicmp(fname, OEMTEXT("\\\\.\\"), 4)==0){
|
||||
ideio_notify(sxsi->drv, 0);
|
||||
}
|
||||
}else{
|
||||
int num = drv & 0x0f;
|
||||
int num = drv & 0x03;
|
||||
file_cpyname(np2cfg.idecd[num], _T("\0\0\0\0"), 1);
|
||||
}
|
||||
sysmng_updatecaption(1); // SYS_UPDATECAPTION_FDD
|
||||
|
13
fdd/sxsicd.c
13
fdd/sxsicd.c
@ -72,8 +72,8 @@ BRESULT sxsicd_readraw(SXSIDEV sxsi, FILEPOS pos, void *buf) {
|
||||
CDINFO cdinfo;
|
||||
FILEH fh;
|
||||
FILEPOS fpos;
|
||||
UINT16 secsize;
|
||||
UINT i;
|
||||
UINT16 secsize = 0;
|
||||
SINT32 i;
|
||||
UINT32 secs;
|
||||
// UINT64 trk_offset;
|
||||
|
||||
@ -93,6 +93,10 @@ BRESULT sxsicd_readraw(SXSIDEV sxsi, FILEPOS pos, void *buf) {
|
||||
|
||||
#endif
|
||||
|
||||
if (cdinfo->trks == 0) {
|
||||
return(FAILURE);
|
||||
}
|
||||
|
||||
// pos位置のセクタサイズを取得
|
||||
for (i = cdinfo->trks - 1; i >= 0; i--) {
|
||||
if (cdinfo->trk[i].pos <= (UINT32)pos) {
|
||||
@ -100,6 +104,9 @@ BRESULT sxsicd_readraw(SXSIDEV sxsi, FILEPOS pos, void *buf) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (secsize == 0) {
|
||||
return(FAILURE);
|
||||
}
|
||||
if (secsize == 2048 && !isPhysicalCD) {
|
||||
return(FAILURE);
|
||||
}
|
||||
@ -116,7 +123,7 @@ BRESULT sxsicd_readraw(SXSIDEV sxsi, FILEPOS pos, void *buf) {
|
||||
fpos += (pos - secs) * cdinfo->trk[i].sector_size;
|
||||
break;
|
||||
}
|
||||
fpos += cdinfo->trk[i].sectors * cdinfo->trk[i].sector_size;
|
||||
fpos += (FILEPOS)cdinfo->trk[i].sectors * cdinfo->trk[i].sector_size;
|
||||
secs += cdinfo->trk[i].sectors;
|
||||
}
|
||||
fpos += (FILEPOS)(cdinfo->trk[0].start_offset);
|
||||
|
@ -190,7 +190,7 @@ const OEMCHAR *ext;
|
||||
cylinders = LOADINTELWORD(thd.cylinders);
|
||||
sectors = 33;
|
||||
size = 256;
|
||||
totals = cylinders * sectors * surfaces;
|
||||
totals = (FILEPOS)cylinders * sectors * surfaces;
|
||||
}
|
||||
else if ((iftype == SXSIDRV_SASI) && (!file_cmpname(ext, str_nhd))) {
|
||||
NHDHDR nhd; // T98Next HDD (IDE)
|
||||
@ -215,7 +215,7 @@ const OEMCHAR *ext;
|
||||
cylinders = LOADINTELDWORD(hdi.cylinders);
|
||||
sectors = LOADINTELDWORD(hdi.sectors);
|
||||
size = LOADINTELDWORD(hdi.sectorsize);
|
||||
totals = cylinders * sectors * surfaces;
|
||||
totals = (FILEPOS)cylinders * sectors * surfaces;
|
||||
}
|
||||
else if ((iftype == SXSIDRV_SCSI) && (!file_cmpname(ext, str_hdd))) {
|
||||
VHDHDR vhd; // Virtual98 HDD (SCSI)
|
||||
@ -241,7 +241,7 @@ const OEMCHAR *ext;
|
||||
}else{
|
||||
sectors = 25;
|
||||
}
|
||||
cylinders = (UINT32)(fsize / (sectors * surfaces * size));
|
||||
cylinders = (UINT32)(fsize / ((FILELEN)sectors * surfaces * size));
|
||||
totals = fsize / size;
|
||||
// totals = (FILEPOS)cylinders * sectors * surfaces;
|
||||
}
|
||||
@ -252,7 +252,7 @@ const OEMCHAR *ext;
|
||||
size = 512;
|
||||
surfaces = 8;
|
||||
sectors = 32;
|
||||
cylinders = (UINT32)(fsize / (sectors * surfaces * size));
|
||||
cylinders = (UINT32)(fsize / ((FILELEN)sectors * surfaces * size));
|
||||
totals = fsize / size;
|
||||
// totals = (FILEPOS)cylinders * sectors * surfaces;
|
||||
}
|
||||
|
@ -54,6 +54,9 @@ static UINT8 *getbmpres(const OEMCHAR* resname, DIPBMP *dipbmp) {
|
||||
int ressize;
|
||||
|
||||
hRsrc = FindResource(NULL, resname, OEMTEXT("RAWBMP"));
|
||||
if (hRsrc == NULL) {
|
||||
goto gb_err1;
|
||||
}
|
||||
hRes = LoadResource(NULL, hRsrc);
|
||||
if (hRes == NULL) {
|
||||
goto gb_err1;
|
||||
|
@ -428,6 +428,9 @@ void keydisp_opnakeyon(const UINT8 *pcRegister, REG8 cData)
|
||||
{
|
||||
nChannelNum--;
|
||||
}
|
||||
if (nChannelNum >= NELEMENTS(k->ch)) {
|
||||
continue;
|
||||
}
|
||||
if ((nChannelNum < k->cFMChannels) && (k->ch[nChannelNum].cKeyOn != cData))
|
||||
{
|
||||
if (cData)
|
||||
@ -942,10 +945,9 @@ void keydisp_midi(const UINT8 *cmd)
|
||||
chkeyoff(&s_keydisp, cmd[0] & 0x0f);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xfe:
|
||||
keyalloff(&s_keydisp);
|
||||
break;
|
||||
}
|
||||
if (cmd[0] == 0xfe) {
|
||||
keyalloff(&s_keydisp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -582,7 +582,9 @@ opeana_ea:
|
||||
}
|
||||
|
||||
opeana_ed:
|
||||
r->mnemonic = rstr.ope[mnemonic];
|
||||
if (mnemonic < NELEMENTS(rstr.ope)) {
|
||||
r->mnemonic = rstr.ope[mnemonic];
|
||||
}
|
||||
p[0] = '\0';
|
||||
return((UINT)(ptr - org));
|
||||
}
|
||||
|
@ -772,7 +772,7 @@ UINT32 MEMCALL memp_read32(UINT32 address) {
|
||||
return(LOADINTELDWORD(mem + address));
|
||||
}
|
||||
else{
|
||||
if (((address + 1) & 0x7fff) && ((address + 2) & 0x7fff) && ((address + 3) & 0x7fff)) { // non 32kb boundary
|
||||
if (((address + 3) & 0x7fff) > (address & 0x7fff)) { // non 32kb boundary
|
||||
#if defined(SUPPORT_CL_GD5430)
|
||||
if(np2clvga.enabled && cirrusvga_opaque && (cirrusvga_wab_46e8 & 0x08)){
|
||||
UINT32 vramWndAddr = np2clvga.VRAMWindowAddr;
|
||||
|
@ -2,8 +2,12 @@
|
||||
#define NP2_I386C_CPUMEM_H__
|
||||
|
||||
#ifdef NP2_MEMORY_ASM // アセンブラ版は 必ずfastcallで
|
||||
//#undef MEMCALL
|
||||
//#define MEMCALL FASTCALL
|
||||
#undef MEMCALL
|
||||
#define MEMCALL FASTCALL
|
||||
#endif
|
||||
|
||||
#if !defined(MEMCALL)
|
||||
#define MEMCALL
|
||||
#endif
|
||||
|
||||
// 000000-0fffff メインメモリ
|
||||
|
200
i386c/ia32/cpu.c
200
i386c/ia32/cpu.c
@ -51,6 +51,7 @@
|
||||
|
||||
UINT8 cpu_drawskip = 1;
|
||||
UINT8 cpu_nowait = 0;
|
||||
double np2cpu_lastTimingValue = 1.0;
|
||||
|
||||
sigjmp_buf exec_1step_jmpbuf;
|
||||
|
||||
@ -284,13 +285,7 @@ exec_allstep(void)
|
||||
UINT32 op;
|
||||
void (*func)(void);
|
||||
#if defined(SUPPORT_ASYNC_CPU)
|
||||
int firstflag = 1;
|
||||
UINT timing;
|
||||
UINT lcflag = 0;
|
||||
SINT32 oldremclock = CPU_REMCLOCK;
|
||||
static int remclock_mul = 1000;
|
||||
int remclockb = 0;
|
||||
int remclkcnt = 0x100;
|
||||
int remclkcnt = INT_MAX;
|
||||
static int latecount = 0;
|
||||
static int latecount2 = 0;
|
||||
static unsigned int hltflag = 0;
|
||||
@ -534,98 +529,111 @@ exec_allstep(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
cpucontinue:
|
||||
#if defined(SUPPORT_ASYNC_CPU)
|
||||
// 非同期CPU処理
|
||||
if(np2cfg.asynccpu && !cpu_nowait){
|
||||
UINT8 drawskip = cpu_drawskip;
|
||||
#define LATECOUNTER_THRESHOLD 6
|
||||
#define LATECOUNTER_THRESHOLDM 2
|
||||
int realclock = 0;
|
||||
if(CPU_STAT_HLT){
|
||||
hltflag = pccore.multiple;
|
||||
}
|
||||
if(CPU_REMCLOCK >= 0 && !realclock && (remclkcnt > 0x7)){
|
||||
remclkcnt = 0;
|
||||
firstflag = 0;
|
||||
timing = timing_getcount_baseclock();
|
||||
if(timing>=drawskip){
|
||||
if(!asynccpu_fastflag && !asynccpu_lateflag){
|
||||
if(remclock_mul < 100000) {
|
||||
latecount++;
|
||||
if(latecount > +LATECOUNTER_THRESHOLD){
|
||||
if(pccore.multiple > 4){
|
||||
UINT32 oldmultiple = pccore.multiple;
|
||||
if(pccore.multiple > 40){
|
||||
pccore.multiple-=3;
|
||||
}else if(pccore.multiple > 20){
|
||||
pccore.multiple-=2;
|
||||
}else{
|
||||
pccore.multiple-=1;
|
||||
}
|
||||
pccore.realclock = pccore.baseclock * pccore.multiple;
|
||||
nevent_changeclock(oldmultiple, pccore.multiple);
|
||||
|
||||
sound_changeclock();
|
||||
pcm86_changeclock(oldmultiple);
|
||||
beep_changeclock();
|
||||
mpu98ii_changeclock();
|
||||
#if defined(SUPPORT_SMPU98)
|
||||
smpu98_changeclock();
|
||||
#endif
|
||||
keyboard_changeclock();
|
||||
mouseif_changeclock();
|
||||
gdc_updateclock();
|
||||
}
|
||||
|
||||
latecount = 0;
|
||||
}
|
||||
}
|
||||
asynccpu_lateflag = 1;
|
||||
|
||||
CPU_REMCLOCK = 0;
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
if(!hltflag && !asynccpu_lateflag && g_nevent.item[NEVENT_FLAMES].proc==screendisp && g_nevent.item[NEVENT_FLAMES].clock >= CPU_BASECLOCK){
|
||||
//CPU_REMCLOCK = 10000;
|
||||
//oldremclock = CPU_REMCLOCK;
|
||||
if(!asynccpu_fastflag){
|
||||
latecount--;
|
||||
if(latecount < -LATECOUNTER_THRESHOLDM * ((g_pcm86.fifo & 0x80) || nevent_iswork(NEVENT_CS4231) || nevent_iswork(NEVENT_CT1741) ? 10 : 1)){
|
||||
if(pccore.multiple < pccore.maxmultiple){
|
||||
UINT32 oldmultiple = pccore.multiple;
|
||||
pccore.multiple+=1;
|
||||
pccore.realclock = pccore.baseclock * pccore.multiple;
|
||||
nevent_changeclock(oldmultiple, pccore.multiple);
|
||||
|
||||
sound_changeclock();
|
||||
pcm86_changeclock(oldmultiple);
|
||||
beep_changeclock();
|
||||
mpu98ii_changeclock();
|
||||
#if defined(SUPPORT_SMPU98)
|
||||
smpu98_changeclock();
|
||||
#endif
|
||||
keyboard_changeclock();
|
||||
mouseif_changeclock();
|
||||
gdc_updateclock();
|
||||
}
|
||||
latecount = 0;
|
||||
}
|
||||
asynccpu_fastflag = 1;
|
||||
}
|
||||
}
|
||||
firstflag = 1;
|
||||
}
|
||||
}
|
||||
remclkcnt++;
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
cpucontinue:;
|
||||
|
||||
} while (CPU_REMCLOCK > 0);
|
||||
|
||||
#if defined(SUPPORT_ASYNC_CPU)
|
||||
// 非同期CPU処理
|
||||
if(np2cfg.asynccpu && !cpu_nowait){
|
||||
#define LATECOUNTER_THRESHOLD 6
|
||||
#define LATECOUNTER_THRESHOLDM 2
|
||||
if(CPU_STAT_HLT){
|
||||
hltflag = pccore.multiple;
|
||||
}
|
||||
if (!asynccpu_fastflag && !asynccpu_lateflag) {
|
||||
double timimg = np2cpu_lastTimingValue;
|
||||
if (timimg > cpu_drawskip) {
|
||||
latecount++;
|
||||
if (latecount > +LATECOUNTER_THRESHOLD) {
|
||||
if (pccore.multiple > 4) {
|
||||
UINT32 oldmultiple = pccore.multiple;
|
||||
if (pccore.multiple > 40) {
|
||||
if (timimg > 2.0) {
|
||||
pccore.multiple -= 10;
|
||||
}
|
||||
else if (timimg > 1.5) {
|
||||
pccore.multiple -= 5;
|
||||
}
|
||||
else if (timimg > 1.2) {
|
||||
pccore.multiple -= 3;
|
||||
}
|
||||
else {
|
||||
pccore.multiple -= 1;
|
||||
}
|
||||
}
|
||||
else if (pccore.multiple > 20) {
|
||||
if (timimg > 2.0) {
|
||||
pccore.multiple -= 6;
|
||||
}
|
||||
else if (timimg > 1.5) {
|
||||
pccore.multiple -= 3;
|
||||
}
|
||||
else if (timimg > 1.2) {
|
||||
pccore.multiple -= 2;
|
||||
}
|
||||
else {
|
||||
pccore.multiple -= 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
pccore.multiple -= 1;
|
||||
}
|
||||
pccore.realclock = pccore.baseclock * pccore.multiple;
|
||||
nevent_changeclock(oldmultiple, pccore.multiple);
|
||||
|
||||
sound_changeclock();
|
||||
pcm86_changeclock(oldmultiple);
|
||||
beep_changeclock();
|
||||
mpu98ii_changeclock();
|
||||
#if defined(SUPPORT_SMPU98)
|
||||
smpu98_changeclock();
|
||||
#endif
|
||||
keyboard_changeclock();
|
||||
mouseif_changeclock();
|
||||
gdc_updateclock();
|
||||
}
|
||||
|
||||
latecount = 0;
|
||||
}
|
||||
asynccpu_lateflag = 1;
|
||||
}
|
||||
else if(timimg < cpu_drawskip){
|
||||
if (!hltflag && g_nevent.item[NEVENT_FLAMES].proc == screendisp && g_nevent.item[NEVENT_FLAMES].clock >= CPU_BASECLOCK) {
|
||||
latecount--;
|
||||
if (latecount < -LATECOUNTER_THRESHOLDM) {
|
||||
if (pccore.multiple < pccore.maxmultiple) {
|
||||
UINT32 oldmultiple = pccore.multiple;
|
||||
if (timimg < 0.5) {
|
||||
pccore.multiple += 3;
|
||||
}
|
||||
else if (timimg < 0.7) {
|
||||
pccore.multiple += 2;
|
||||
}
|
||||
else {
|
||||
pccore.multiple += 1;
|
||||
}
|
||||
pccore.realclock = pccore.baseclock * pccore.multiple;
|
||||
nevent_changeclock(oldmultiple, pccore.multiple);
|
||||
|
||||
sound_changeclock();
|
||||
pcm86_changeclock(oldmultiple);
|
||||
beep_changeclock();
|
||||
mpu98ii_changeclock();
|
||||
#if defined(SUPPORT_SMPU98)
|
||||
smpu98_changeclock();
|
||||
#endif
|
||||
keyboard_changeclock();
|
||||
mouseif_changeclock();
|
||||
gdc_updateclock();
|
||||
}
|
||||
latecount = 0;
|
||||
}
|
||||
asynccpu_fastflag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(hltflag > 0) hltflag--;
|
||||
#endif
|
||||
}
|
||||
|
@ -70,8 +70,13 @@ typedef union {
|
||||
UINT32 d;
|
||||
} REG32;
|
||||
|
||||
typedef struct {
|
||||
typedef union {
|
||||
UINT8 b[10];
|
||||
UINT16 w[5];
|
||||
struct {
|
||||
UINT32 l[2];
|
||||
UINT16 h;
|
||||
} d;
|
||||
} REG80;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -209,16 +214,13 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
UINT16 control; // 制御レジスター
|
||||
#ifdef USE_FPU_ASM
|
||||
UINT16 cw_mask_all; // 制御レジスターmask
|
||||
#endif
|
||||
UINT16 status; // ステータスレジスター
|
||||
UINT16 op; // オペコードレジスター
|
||||
UINT16 tag; // タグワードレジスター
|
||||
|
||||
FPU_PTR inst; // ラスト命令ポインタレジスター
|
||||
FPU_PTR data; // ラストデータポインタレジスター
|
||||
} FPU_REGS;
|
||||
} FPU_REGS_S;
|
||||
|
||||
#if 0
|
||||
|
||||
@ -259,11 +261,7 @@ typedef enum {
|
||||
} FP_RND;
|
||||
|
||||
typedef union {
|
||||
#ifdef SUPPORT_FPU_SOFTFLOAT
|
||||
sw_extFloat80_t d;
|
||||
#else
|
||||
float d;
|
||||
#endif
|
||||
floatx80 d;
|
||||
double d64;
|
||||
struct {
|
||||
UINT32 lower;
|
||||
@ -276,17 +274,9 @@ typedef union {
|
||||
SINT16 ext;
|
||||
} ul;
|
||||
SINT64 ll;
|
||||
UINT8 b[10];
|
||||
} FP_REG;
|
||||
|
||||
typedef struct {
|
||||
UINT32 m1;
|
||||
UINT32 m2;
|
||||
UINT16 m3;
|
||||
|
||||
UINT16 d1;
|
||||
UINT32 d2;
|
||||
} FP_P_REG;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
UINT32 m1;
|
||||
@ -318,21 +308,13 @@ typedef union {
|
||||
} XMM_REG;
|
||||
|
||||
typedef struct {
|
||||
#ifdef USE_FPU_ASM
|
||||
unsigned int top;
|
||||
#else
|
||||
UINT8 top;
|
||||
#endif
|
||||
UINT8 pc;
|
||||
UINT8 rc;
|
||||
UINT8 dmy[1];
|
||||
//
|
||||
//#if defined(USE_FPU_ASM)
|
||||
// FP_P_REG p_reg[FPU_REG_NUM+1]; // R0 to R7
|
||||
//#else
|
||||
FP_REG reg[FPU_REG_NUM+1]; // R0 to R7
|
||||
//#endif
|
||||
FP_TAG tag[FPU_REG_NUM+1]; // R0 to R7
|
||||
|
||||
FP_REG reg[FPU_REG_NUM+1]; // R0 to R7 + α
|
||||
FP_TAG tag[FPU_REG_NUM+1]; // R0 to R7 + α
|
||||
FP_RND round;
|
||||
#ifdef SUPPORT_FPU_DOSBOX2 // XXX: 整数間だけ正確にするため用
|
||||
FP_INT_REG int_reg[FPU_REG_NUM+1];
|
||||
@ -344,7 +326,7 @@ typedef struct {
|
||||
#ifdef USE_MMX
|
||||
UINT8 mmxenable;
|
||||
#endif
|
||||
} FPU_STAT;
|
||||
} FPU_STAT_S;
|
||||
|
||||
#endif
|
||||
|
||||
@ -356,8 +338,8 @@ typedef struct {
|
||||
CPU_INST cpu_inst_default;
|
||||
|
||||
#if defined(USE_FPU)
|
||||
FPU_REGS fpu_regs;
|
||||
FPU_STAT fpu_stat;
|
||||
FPU_REGS_S fpu_regs;
|
||||
FPU_STAT_S fpu_stat;
|
||||
#endif
|
||||
|
||||
/* protected by cpu shut */
|
||||
@ -1256,7 +1238,10 @@ void dbg_printf(const char *str, ...);
|
||||
|
||||
#define FP_TOP_SHIFT 11
|
||||
#define FP_TOP_GET() ((FPU_STATUSWORD & FP_TOP_FLAG) >> FP_TOP_SHIFT)
|
||||
#define FP_TOP_SET(v) ((FPU_STATUSWORD & ~FP_TOP_FLAG) | ((v) << FP_TOP_SHIFT))
|
||||
#define FP_TOP_SET(v) \
|
||||
do { \
|
||||
FPU_STATUSWORD = ((FPU_STATUSWORD & ~FP_TOP_FLAG) | (((v) & 0x7) << FP_TOP_SHIFT)); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
#define FPU_STAT_TOP_INC() \
|
||||
do { \
|
||||
|
@ -44,8 +44,7 @@ check_io(UINT port, UINT len)
|
||||
EXCEPTION(GP_EXCEPTION, 0);
|
||||
}
|
||||
|
||||
// if ((port + len) / 8 >= CPU_STAT_IOLIMIT) {
|
||||
if ((port + len - 1) / 8 >= CPU_STAT_IOLIMIT) {
|
||||
if ((port + len) / 8 >= CPU_STAT_IOLIMIT) {
|
||||
VERBOSE(("check_io: out of range: CPU_STAT_IOLIMIT(%08x) (port = %04x, len = %d)", CPU_STAT_IOLIMIT, port, len));
|
||||
EXCEPTION(GP_EXCEPTION, 0);
|
||||
}
|
||||
|
@ -455,22 +455,27 @@ REG80 MEMCALL
|
||||
cpu_memoryread_f(UINT32 paddr)
|
||||
{
|
||||
REG80 value;
|
||||
int i;
|
||||
//int i;
|
||||
|
||||
for (i = 0; i < (int)sizeof(REG80); ++i) {
|
||||
value.b[i] = cpu_memoryread(paddr + i);
|
||||
}
|
||||
return value;
|
||||
//for (i = 0; i < (int)sizeof(REG80); ++i) {
|
||||
// value.b[i] = cpu_memoryread(paddr + i);
|
||||
//}
|
||||
value.d.l[0] = cpu_memoryread_d(paddr);
|
||||
value.d.l[1] = cpu_memoryread_d(paddr + 4);
|
||||
value.d.h = cpu_memoryread_w(paddr + 8);
|
||||
}
|
||||
|
||||
void MEMCALL
|
||||
cpu_memorywrite_f(UINT32 paddr, const REG80 *value)
|
||||
{
|
||||
int i;
|
||||
//int i;
|
||||
|
||||
for (i = 0; i < (int)sizeof(REG80); ++i) {
|
||||
cpu_memorywrite(paddr + i, value->b[i]);
|
||||
}
|
||||
//for (i = 0; i < (int)sizeof(REG80); ++i) {
|
||||
// cpu_memorywrite(paddr + i, value->b[i]);
|
||||
//}
|
||||
cpu_memorywrite_d(paddr, value->d.l[0]);
|
||||
cpu_memorywrite_d(paddr + 4, value->d.l[1]);
|
||||
cpu_memorywrite_w(paddr + 8, value->d.h);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -132,6 +132,7 @@ dbg_printf(const char *str, ...)
|
||||
va_start(ap, str);
|
||||
vsnprintf(buf, sizeof(buf), str, ap);
|
||||
va_end(ap);
|
||||
buf[NELEMENTS(buf) - 2] = '\0';
|
||||
strcat(buf, "\n");
|
||||
|
||||
printf("%s", buf);
|
||||
|
@ -209,6 +209,36 @@ fpu_memoryread_f(UINT32 address)
|
||||
return cpu_vmemoryread_f(seg, address);
|
||||
}
|
||||
|
||||
float MEMCALL
|
||||
fpu_memoryread_f32(UINT32 address)
|
||||
{
|
||||
UINT16 seg;
|
||||
union {
|
||||
float f;
|
||||
UINT32 l;
|
||||
} val;
|
||||
|
||||
FPU_DATAPTR_SEG = seg = CPU_INST_SEGREG_INDEX;
|
||||
FPU_DATAPTR_OFFSET = address;
|
||||
val.l = cpu_vmemoryread_d(seg, address);
|
||||
return val.f;
|
||||
}
|
||||
|
||||
double MEMCALL
|
||||
fpu_memoryread_f64(UINT32 address)
|
||||
{
|
||||
UINT16 seg;
|
||||
union {
|
||||
double f;
|
||||
UINT64 q;
|
||||
} val;
|
||||
|
||||
FPU_DATAPTR_SEG = seg = CPU_INST_SEGREG_INDEX;
|
||||
FPU_DATAPTR_OFFSET = address;
|
||||
val.q = cpu_vmemoryread_q(seg, address);
|
||||
return val.f;
|
||||
}
|
||||
|
||||
void MEMCALL
|
||||
fpu_memorywrite_b(UINT32 address, UINT8 value)
|
||||
{
|
||||
@ -258,6 +288,38 @@ fpu_memorywrite_f(UINT32 address, REG80 *value)
|
||||
FPU_DATAPTR_OFFSET = address;
|
||||
cpu_vmemorywrite_f(seg, address, value);
|
||||
}
|
||||
|
||||
void MEMCALL
|
||||
fpu_memorywrite_f32(UINT32 address, float value)
|
||||
{
|
||||
UINT16 seg;
|
||||
union {
|
||||
float f;
|
||||
UINT32 l;
|
||||
} val;
|
||||
|
||||
val.f = value;
|
||||
|
||||
FPU_DATAPTR_SEG = seg = CPU_INST_SEGREG_INDEX;
|
||||
FPU_DATAPTR_OFFSET = address;
|
||||
cpu_vmemorywrite_d(seg, address, val.l);
|
||||
}
|
||||
|
||||
void MEMCALL
|
||||
fpu_memorywrite_f64(UINT32 address, double value)
|
||||
{
|
||||
UINT16 seg;
|
||||
union {
|
||||
double f;
|
||||
UINT64 q;
|
||||
} val;
|
||||
|
||||
val.f = value;
|
||||
|
||||
FPU_DATAPTR_SEG = seg = CPU_INST_SEGREG_INDEX;
|
||||
FPU_DATAPTR_OFFSET = address;
|
||||
cpu_vmemorywrite_q(seg, address, val.q);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
@ -278,4 +340,4 @@ FPU_FWAIT(void)
|
||||
EXCEPTION(MF_EXCEPTION, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -48,6 +48,12 @@ fpu_memoryread_q(UINT32 address);
|
||||
REG80 MEMCALL
|
||||
fpu_memoryread_f(UINT32 address);
|
||||
|
||||
float MEMCALL
|
||||
fpu_memoryread_f32(UINT32 address);
|
||||
|
||||
double MEMCALL
|
||||
fpu_memoryread_f64(UINT32 address);
|
||||
|
||||
void MEMCALL
|
||||
fpu_memorywrite_b(UINT32 address, UINT8 value);
|
||||
|
||||
@ -63,6 +69,12 @@ fpu_memorywrite_q(UINT32 address, UINT64 value);
|
||||
void MEMCALL
|
||||
fpu_memorywrite_f(UINT32 address, REG80 *value);
|
||||
|
||||
void MEMCALL
|
||||
fpu_memorywrite_f32(UINT32 address, float value);
|
||||
|
||||
void MEMCALL
|
||||
fpu_memorywrite_f64(UINT32 address, double value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,37 +0,0 @@
|
||||
|
||||
License for Berkeley SoftFloat Release 3e
|
||||
|
||||
John R. Hauser
|
||||
2018 January 20
|
||||
|
||||
The following applies to the whole of SoftFloat Release 3e as well as to
|
||||
each source file individually.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
|
@ -1,24 +0,0 @@
|
||||
|
||||
Package Overview for Berkeley SoftFloat Release 3e
|
||||
==================================================
|
||||
|
||||
John R. Hauser<br>
|
||||
2018 January 20
|
||||
|
||||
|
||||
Berkeley SoftFloat is a software implementation of binary floating-point
|
||||
that conforms to the IEEE Standard for Floating-Point Arithmetic. SoftFloat
|
||||
is distributed in the form of C source code. Building the SoftFloat sources
|
||||
generates a library file (typically `softfloat.a` or `libsoftfloat.a`)
|
||||
containing the floating-point subroutines.
|
||||
|
||||
|
||||
The SoftFloat package is documented in the following files in the `doc`
|
||||
subdirectory:
|
||||
|
||||
* [SoftFloat.html](http://www.jhauser.us/arithmetic/SoftFloat-3/doc/SoftFloat.html) Documentation for using the SoftFloat functions.
|
||||
* [SoftFloat-source.html](http://www.jhauser.us/arithmetic/SoftFloat-3/doc/SoftFloat-source.html) Documentation for building SoftFloat.
|
||||
* [SoftFloat-history.html](http://www.jhauser.us/arithmetic/SoftFloat-3/doc/SoftFloat-history.html) History of the major changes to SoftFloat.
|
||||
|
||||
Other files in the package comprise the source code for SoftFloat.
|
||||
|
@ -1,21 +1,83 @@
|
||||
|
||||
Package Overview for Berkeley SoftFloat Release 3e
|
||||
|
||||
John R. Hauser
|
||||
2018 January 20
|
||||
|
||||
Berkeley SoftFloat is a software implementation of binary floating-point
|
||||
that conforms to the IEEE Standard for Floating-Point Arithmetic. SoftFloat
|
||||
is distributed in the form of C source code. Building the SoftFloat sources
|
||||
generates a library file (typically "softfloat.a" or "libsoftfloat.a")
|
||||
containing the floating-point subroutines.
|
||||
|
||||
The SoftFloat package is documented in the following files in the "doc"
|
||||
subdirectory:
|
||||
|
||||
SoftFloat.html Documentation for using the SoftFloat functions.
|
||||
SoftFloat-source.html Documentation for building SoftFloat.
|
||||
SoftFloat-history.html History of the major changes to SoftFloat.
|
||||
|
||||
Other files in the package comprise the source code for SoftFloat.
|
||||
|
||||
|
||||
Package Overview for Berkeley SoftFloat Release 2c
|
||||
|
||||
John R. Hauser
|
||||
2015 January 30
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Overview
|
||||
|
||||
Berkeley SoftFloat is a software implementation of binary floating-point
|
||||
that conforms to the IEEE Standard for Floating-Point Arithmetic.
|
||||
Release 2c updates an older version of SoftFloat that has for most purposes
|
||||
been supplanted by Release 3 or later. For the latest version of SoftFloat,
|
||||
see Web page `http://www.jhauser.us/arithmetic/SoftFloat.html'.
|
||||
|
||||
SoftFloat is distributed in the form of C source code. For Release 2c,
|
||||
compiling the SoftFloat sources generates two things:
|
||||
|
||||
-- A SoftFloat object file (typically `softfloat.o') containing the complete
|
||||
set of IEC/IEEE floating-point routines.
|
||||
|
||||
-- A `timesoftfloat' program for evaluating the speed of the SoftFloat
|
||||
routines. (The SoftFloat module is linked into this program.)
|
||||
|
||||
This version of the SoftFloat package is documented in four text files:
|
||||
|
||||
SoftFloat.txt Documentation for using the SoftFloat functions.
|
||||
SoftFloat-source.txt Documentation for compiling SoftFloat.
|
||||
SoftFloat-history.txt History of major changes to SoftFloat.
|
||||
timesoftfloat.txt Documentation for using `timesoftfloat'.
|
||||
|
||||
Other files in the package comprise the source code for SoftFloat.
|
||||
|
||||
Please be aware that some work is involved in porting this software to other
|
||||
targets. It is not just a matter of getting `make' to complete without
|
||||
error messages. You should not attempt to compile this release of SoftFloat
|
||||
without first reading both `SoftFloat.txt' and `SoftFloat-source.txt'.
|
||||
Depending on your needs, you may find that newer versions of SoftFloat are
|
||||
less work to port.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Legal Notice
|
||||
|
||||
SoftFloat was written by John R. Hauser. Release 2c of SoftFloat was made
|
||||
possible in part by the International Computer Science Institute, located
|
||||
at Suite 600, 1947 Center Street, Berkeley, California 94704. Funding
|
||||
was partially provided by the National Science Foundation under grant
|
||||
MIP-9311980. The original version of this code was written as part of a
|
||||
project to build a fixed-point vector processor in collaboration with the
|
||||
University of California at Berkeley, overseen by Profs. Nelson Morgan and
|
||||
John Wawrzynek.
|
||||
|
||||
THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
|
||||
has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
|
||||
TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
|
||||
PERSONS AND ORGANIZATIONS WHO CAN AND WILL TOLERATE ALL LOSSES, COSTS, OR
|
||||
OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE WITHOUT RECOMPENSE FROM JOHN
|
||||
HAUSER OR THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE, AND WHO FURTHERMORE
|
||||
EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
|
||||
INSTITUTE (possibly via similar legal notice) AGAINST ALL LOSSES, COSTS, OR
|
||||
OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE,
|
||||
OR INCURRED BY ANYONE DUE TO A DERIVATIVE WORK THEY CREATE USING ANY PART OF
|
||||
THE SOFTWARE.
|
||||
|
||||
The following are expressly permitted, even for commercial purposes:
|
||||
(1) distribution of SoftFloat in whole or in part, as long as this and
|
||||
other legal notices remain and are prominent, and provided also that, for a
|
||||
partial distribution, prominent notice is given that it is a subset of the
|
||||
original; and
|
||||
(2) inclusion or use of SoftFloat in whole or in part in a derivative
|
||||
work, provided that the use restrictions above are met and the minimal
|
||||
documentation requirements stated in the source code are satisfied.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Contact Information
|
||||
|
||||
At the time of this writing, the most up-to-date information about SoftFloat
|
||||
and the latest release can be found at the Web page `http://www.jhauser.us/
|
||||
arithmetic/SoftFloat.html'.
|
||||
|
||||
|
65
i386c/ia32/instructions/fpu/softfloat/SoftFloat-history.txt
Normal file
65
i386c/ia32/instructions/fpu/softfloat/SoftFloat-history.txt
Normal file
@ -0,0 +1,65 @@
|
||||
|
||||
History of Major Changes to Berkeley SoftFloat, up to Release 2c
|
||||
|
||||
John R. Hauser
|
||||
2015 January 31
|
||||
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Release 2c (2015 January)
|
||||
|
||||
-- Fixed mistakes affecting some 64-bit processors.
|
||||
|
||||
-- Further improved the documentation and the wording for the legal
|
||||
restrictions on using SoftFloat.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Release 2b (2002 May)
|
||||
|
||||
-- Made minor updates to the documentation, including improved wording for
|
||||
the legal restrictions on using SoftFloat.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Release 2a (1998 December)
|
||||
|
||||
-- Added functions to convert between 64-bit integers (int64) and all
|
||||
supported floating-point formats.
|
||||
|
||||
-- Fixed a bug in all 64-bit-version square root functions except
|
||||
`float32_sqrt' that caused the result sometimes to be off by 1 unit in
|
||||
the last place (1 ulp) from what it should be. (Bug discovered by Paul
|
||||
Donahue.)
|
||||
|
||||
-- Improved the Makefiles.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Release 2 (1997 June)
|
||||
|
||||
-- Created the 64-bit (bits64) version, adding the floatx80 and float128
|
||||
formats.
|
||||
|
||||
-- Changed the source directory structure, splitting the sources into a
|
||||
`bits32' and a `bits64' version. Renamed `environment.h' to `milieu.h'
|
||||
to avoid confusion with environment variables.
|
||||
|
||||
-- Fixed a small error that caused `float64_round_to_int' often to round the
|
||||
wrong way in nearest/even mode when the operand was between 2^20 and 2^21
|
||||
and halfway between two integers.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Release 1a (1996 July)
|
||||
|
||||
-- Corrected a mistake that caused borderline underflow cases not to raise
|
||||
the underflow flag when they should have. (Problem reported by Doug
|
||||
Priest.)
|
||||
|
||||
-- Added the `float_detect_tininess' variable to control whether tininess is
|
||||
detected before or after rounding.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Release 1 (1996 July)
|
||||
|
||||
-- Original release.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
400
i386c/ia32/instructions/fpu/softfloat/SoftFloat-source.txt
Normal file
400
i386c/ia32/instructions/fpu/softfloat/SoftFloat-source.txt
Normal file
@ -0,0 +1,400 @@
|
||||
|
||||
Berkeley SoftFloat Release 2c Source Documentation
|
||||
|
||||
John R. Hauser
|
||||
2015 January 30
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Introduction
|
||||
|
||||
Berkeley SoftFloat is a software implementation of binary floating-point
|
||||
that conforms to the IEEE Standard for Floating-Point Arithmetic.
|
||||
Release 2c of SoftFloat can support four floating-point formats: 32-bit
|
||||
single-precision, 64-bit double-precision, 80-bit double-extended-precision,
|
||||
and 128-bit quadruple-precision. All operations required by the older 1985
|
||||
version of the IEEE Standard are implemented, except for conversions to and
|
||||
from decimal. SoftFloat is distributed in the form of C source code, so a
|
||||
C compiler is needed to compile the code. Support for the 80-bit double-
|
||||
extended-precision and 128-bit quadruple-precision formats is dependent on
|
||||
the C compiler implementing a 64-bit integer type.
|
||||
|
||||
This document gives information needed for compiling and/or porting this
|
||||
SoftFloat release.
|
||||
|
||||
The source code for SoftFloat is intended to be relatively machine-
|
||||
independent and should be compilable using most any ISO/ANSI C compiler. At
|
||||
the time of this writing, SoftFloat has been successfully compiled with the
|
||||
GNU C Compiler (`gcc') for several platforms.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Limitations
|
||||
|
||||
As supplied, SoftFloat requires an ISO/ANSI-style C compiler. No attempt
|
||||
has been made to accomodate compilers that are not ISO-conformant. Older
|
||||
"K&R-style" compilers are not adequate for compiling SoftFloat. All testing
|
||||
I have done so far has been with the GNU C Compiler. Compilation with other
|
||||
compilers should be possible but has not been tested by me.
|
||||
|
||||
The SoftFloat sources assume that source code file names can be longer than
|
||||
8 characters. In order to compile under an MS-DOS-type system, many of the
|
||||
source files will need to be renamed, and the source and Makefiles edited
|
||||
appropriately. Once compiled, the SoftFloat binary does not depend on the
|
||||
existence of long file names.
|
||||
|
||||
The underlying machine is assumed to be binary with a word size that is a
|
||||
power of 2. Bytes are 8 bits. Arithmetic on signed integers must modularly
|
||||
wrap around on overflows (as is already required for unsigned integers
|
||||
in C).
|
||||
|
||||
Support for the 80-bit double-extended-precision and 128-bit quadruple-
|
||||
precision formats depends on the C compiler implementing a 64-bit integer
|
||||
type. If the largest integer type supported by the C compiler is 32 bits,
|
||||
SoftFloat is limited to the 32-bit single-precision and 64-bit double-
|
||||
precision formats.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Contents
|
||||
|
||||
Introduction
|
||||
Limitations
|
||||
Contents
|
||||
Legal Notice
|
||||
SoftFloat Source Directory Structure
|
||||
SoftFloat Source Files
|
||||
processors/*.h
|
||||
softfloat/bits*/*/softfloat.h
|
||||
softfloat/bits*/*/milieu.h
|
||||
softfloat/bits*/*/softfloat-specialize
|
||||
softfloat/bits*/softfloat-macros
|
||||
softfloat/bits*/softfloat.c
|
||||
Steps to Creating a `softfloat.o'
|
||||
Making `softfloat.o' a Library
|
||||
Testing SoftFloat
|
||||
Timing SoftFloat
|
||||
Compiler Options and Efficiency
|
||||
Processor-Specific Optimization of `softfloat.c' Using `softfloat-macros'
|
||||
Contact Information
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Legal Notice
|
||||
|
||||
SoftFloat was written by John R. Hauser. Release 2c of SoftFloat was made
|
||||
possible in part by the International Computer Science Institute, located
|
||||
at Suite 600, 1947 Center Street, Berkeley, California 94704. Funding
|
||||
was partially provided by the National Science Foundation under grant
|
||||
MIP-9311980. The original version of this code was written as part of a
|
||||
project to build a fixed-point vector processor in collaboration with the
|
||||
University of California at Berkeley, overseen by Profs. Nelson Morgan and
|
||||
John Wawrzynek.
|
||||
|
||||
THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
|
||||
has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
|
||||
TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
|
||||
PERSONS AND ORGANIZATIONS WHO CAN AND WILL TOLERATE ALL LOSSES, COSTS, OR
|
||||
OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE WITHOUT RECOMPENSE FROM JOHN
|
||||
HAUSER OR THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE, AND WHO FURTHERMORE
|
||||
EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
|
||||
INSTITUTE (possibly via similar legal notice) AGAINST ALL LOSSES, COSTS, OR
|
||||
OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE,
|
||||
OR INCURRED BY ANYONE DUE TO A DERIVATIVE WORK THEY CREATE USING ANY PART OF
|
||||
THE SOFTWARE.
|
||||
|
||||
The following are expressly permitted, even for commercial purposes:
|
||||
(1) distribution of SoftFloat in whole or in part, as long as this and
|
||||
other legal notices remain and are prominent, and provided also that, for a
|
||||
partial distribution, prominent notice is given that it is a subset of the
|
||||
original; and
|
||||
(2) inclusion or use of SoftFloat in whole or in part in a derivative
|
||||
work, provided that the use restrictions above are met and the minimal
|
||||
documentation requirements stated in the source code are satisfied.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
SoftFloat Source Directory Structure
|
||||
|
||||
Because SoftFloat is targeted to multiple platforms, its source code
|
||||
is slightly scattered between target-specific and target-independent
|
||||
directories and files. The directory structure is as follows:
|
||||
|
||||
processors
|
||||
softfloat
|
||||
bits64
|
||||
templates
|
||||
386-Win32-GCC
|
||||
SPARC-Solaris-GCC
|
||||
bits32
|
||||
templates
|
||||
386-Win32-GCC
|
||||
SPARC-Solaris-GCC
|
||||
|
||||
The two topmost directories and their contents are:
|
||||
|
||||
softfloat - Most of the source code needed for SoftFloat.
|
||||
processors - Target-specific header files that are not specific to
|
||||
SoftFloat.
|
||||
|
||||
The `softfloat' directory is further split into two parts:
|
||||
|
||||
bits64 - SoftFloat implementation using 64-bit integers.
|
||||
bits32 - SoftFloat implementation using only 32-bit integers.
|
||||
|
||||
Within these directories are subdirectories for each of the targeted
|
||||
platforms. The SoftFloat source code is distributed with targets
|
||||
`386-Win32-GCC' and `SPARC-Solaris-GCC' (and perhaps others) already
|
||||
prepared for both the 32-bit and 64-bit implementations. Source files
|
||||
that are not within these target-specific subdirectories are intended to be
|
||||
target-independent.
|
||||
|
||||
The naming convention used for the target-specific directories is
|
||||
`<processor>-<executable-type>-<compiler>'. The names of the supplied
|
||||
target directories should be interpreted as follows:
|
||||
|
||||
<processor>:
|
||||
386 - Intel 386-compatible processor.
|
||||
SPARC - SPARC processor (as used by Sun computers).
|
||||
<executable-type>:
|
||||
Win32 - Microsoft Win32 executable.
|
||||
Solaris - Sun Solaris executable.
|
||||
<compiler>:
|
||||
GCC - GNU C Compiler.
|
||||
|
||||
You do not need to maintain this convention if you do not want to.
|
||||
|
||||
Alongside the supplied target-specific directories is a `templates'
|
||||
directory containing a set of "generic" target-specific source files. A
|
||||
new target directory can be created by copying the `templates' directory and
|
||||
editing the files inside. (Complete instructions for porting SoftFloat to
|
||||
a new target are in the section _Steps to Creating a `softfloat.o'_.) Note
|
||||
that the `templates' directory will not work as a target directory without
|
||||
some editing. To avoid confusion, it would be wise to refrain from editing
|
||||
the files inside `templates' directly.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
SoftFloat Source Files
|
||||
|
||||
The purpose of each source file is described below. In the following,
|
||||
the `*' symbol is used in place of the name of a specific target, such as
|
||||
`386-Win32-GCC' or `SPARC-Solaris-GCC', or in place of some other text, as
|
||||
in `bits*' for either `bits32' or `bits64'.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
processors/*.h
|
||||
|
||||
The target-specific `processors' header file defines integer types
|
||||
of various sizes, and also defines certain C preprocessor macros that
|
||||
characterize the target. The two examples supplied are `386-GCC.h' and
|
||||
`SPARC-GCC.h'. The naming convention used for processor header files is
|
||||
`<processor>-<compiler>.h'.
|
||||
|
||||
If 64-bit integers are supported by the compiler, the macro name `BITS64'
|
||||
should be defined here along with the corresponding 64-bit integer
|
||||
types. In addition, the function-like macro `LIT64' must be defined for
|
||||
constructing 64-bit integer literals (constants). The `LIT64' macro is used
|
||||
consistently in the SoftFloat code to annotate 64-bit literals.
|
||||
|
||||
If `BITS64' is not defined, only the 32-bit version of SoftFloat can be
|
||||
compiled. If `BITS64' _is_ defined, either can be compiled.
|
||||
|
||||
If an inlining attribute (such as an `inline' keyword) is provided by the
|
||||
compiler, the macro `INLINE' should be defined to the appropriate keyword.
|
||||
If not, `INLINE' can be set to the keyword `static'. The `INLINE' macro
|
||||
appears in the SoftFloat source code before every function that should
|
||||
be inlined by the compiler. SoftFloat depends on inlining to obtain
|
||||
good speed. Even if inlining cannot be forced with a language keyword,
|
||||
the compiler may still be able to perform inlining on its own as an
|
||||
optimization. If a command-line option is needed to convince the compiler
|
||||
to perform this optimization, this should be assured in the Makefile. (See
|
||||
the section _Compiler Options and Efficiency_ below.)
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
softfloat/bits*/*/softfloat.h
|
||||
|
||||
The target-specific `softfloat.h' header file defines the SoftFloat
|
||||
interface as seen by clients.
|
||||
|
||||
Unlike the actual function definitions in `softfloat.c', the declarations
|
||||
in `softfloat.h' do not use any of the types defined by the `processors'
|
||||
header file. This is done so that clients will not have to include the
|
||||
`processors' header file in order to use SoftFloat. Nevertheless, the
|
||||
target-specific declarations in `softfloat.h' must match what `softfloat.c'
|
||||
expects. For example, if `int32' is defined as `int' in the `processors'
|
||||
header file, then in `softfloat.h' the output of `float32_to_int32' should
|
||||
be stated as `int', although in `softfloat.c' it is given in target-
|
||||
independent form as `int32'.
|
||||
|
||||
For the `bits64' implementation of SoftFloat, the macro names `FLOATX80'
|
||||
and `FLOAT128' must be defined in order for the 80-bit double-extended-
|
||||
precision and 128-bit quadruple-precision formats to be enabled in the
|
||||
code. Conversely, either or both of these larger formats can be disabled by
|
||||
simply removing the `#define' of the respective macro. When a format is not
|
||||
enabled, none of the functions that either input or output the format are
|
||||
defined, and no space is taken up in `softfloat.o' by such functions. There
|
||||
is no provision for disabling the usual 32-bit single-precision and 64-bit
|
||||
double-precision formats.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
softfloat/bits*/*/milieu.h
|
||||
|
||||
The target-specific `milieu.h' header file provides declarations that are
|
||||
needed to compile SoftFloat. In addition, deviations from ISO/ANSI C by
|
||||
the compiler (such as names not properly declared in system header files)
|
||||
are corrected in this header if possible.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
softfloat/bits*/*/softfloat-specialize
|
||||
|
||||
This target-specific C source fragment defines:
|
||||
|
||||
-- whether tininess for underflow is detected before or after rounding by
|
||||
default;
|
||||
-- what (if anything) special happens when exceptions are raised;
|
||||
-- how signaling NaNs are distinguished from quiet NaNs;
|
||||
-- the default generated quiet NaNs; and
|
||||
-- how NaNs are propagated from function inputs to output.
|
||||
|
||||
These details are not decided by the IEEE Standard. This fragment is
|
||||
included verbatim within `softfloat.c' when SoftFloat is compiled.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
softfloat/bits*/softfloat-macros
|
||||
|
||||
This target-independent C source fragment defines a number of arithmetic
|
||||
functions used as primitives within the `softfloat.c' source. Most of
|
||||
the functions defined here are intended to be inlined for efficiency.
|
||||
This fragment is included verbatim within `softfloat.c' when SoftFloat is
|
||||
compiled.
|
||||
|
||||
Target-specific variations on this file are possible. See the section
|
||||
_Processor-Specific Optimization of `softfloat.c' Using `softfloat-macros'_
|
||||
below.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
softfloat/bits*/softfloat.c
|
||||
|
||||
The target-independent `softfloat.c' source file contains the body of the
|
||||
SoftFloat implementation.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
The inclusion of the files above within each other (using `#include') can be
|
||||
shown graphically as follows:
|
||||
|
||||
softfloat/bits*/softfloat.c
|
||||
softfloat/bits*/*/milieu.h
|
||||
processors/*.h
|
||||
softfloat/bits*/*/softfloat.h
|
||||
softfloat/bits*/*/softfloat-specialize
|
||||
softfloat/bits*/softfloat-macros
|
||||
|
||||
Note in particular that `softfloat.c' does not include the `processors'
|
||||
header file directly. Rather, `softfloat.c' includes the target-specific
|
||||
`milieu.h' header file, which in turn includes the appropriate processor
|
||||
header file.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Steps to Creating a `softfloat.o'
|
||||
|
||||
Porting and/or compiling SoftFloat involves the following steps:
|
||||
|
||||
1. If one does not already exist, create an appropriate `.h' file in the
|
||||
`processors' directory.
|
||||
|
||||
2. If `BITS64' is defined in the `processors' header file, choose whether
|
||||
to compile the 32-bit or 64-bit implementation of SoftFloat. If
|
||||
`BITS64' is not defined, your only choice is the 32-bit implementation.
|
||||
The remaining steps occur within either the `bits32' or `bits64'
|
||||
subdirectories.
|
||||
|
||||
3. If one does not already exist, create an appropriate target-specific
|
||||
subdirectory by copying the given `templates' directory.
|
||||
|
||||
4. In the target-specific subdirectory, edit the files `softfloat-specialize'
|
||||
and `softfloat.h' to define the desired exception handling functions
|
||||
and mode control values. In the `softfloat.h' header file, ensure also
|
||||
that all declarations give the proper target-specific type (such as
|
||||
`int' or `long') corresponding to the target-independent type used in
|
||||
`softfloat.c' (such as `int32'). None of the type names declared in the
|
||||
`processors' header file should appear in `softfloat.h'.
|
||||
|
||||
5. In the target-specific subdirectory, edit the files `milieu.h' and
|
||||
`Makefile' to reflect the current environment.
|
||||
|
||||
6. In the target-specific subdirectory, execute `make'.
|
||||
|
||||
For the targets that are supplied, if the expected compiler is available
|
||||
(usually `gcc'), it should only be necessary to execute `make' in the
|
||||
target-specific subdirectory.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Making `softfloat.o' a Library
|
||||
|
||||
SoftFloat is not made into a software library by the supplied Makefile.
|
||||
If desired, `softfloat.o' can easily be put into its own library (typically
|
||||
`softfloat.a' or `libsoftfloat.a') using the usual system tool (in UNIX,
|
||||
`ar').
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Testing SoftFloat
|
||||
|
||||
SoftFloat can be tested using the `testsoftfloat' program by the same
|
||||
author. The `testsoftfloat' program is part of the TestFloat package
|
||||
available at the Web page `http://www.jhauser.us/arithmetic/TestFloat.html'.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Timing SoftFloat
|
||||
|
||||
A program called `timesoftfloat' for timing the SoftFloat functions is
|
||||
included with the SoftFloat source code. Compiling `timesoftfloat' should
|
||||
pose no difficulties once `softfloat.o' exists. The supplied Makefile
|
||||
will create a `timesoftfloat' executable by default after generating
|
||||
`softfloat.o'. See `timesoftfloat.txt' for documentation about using
|
||||
`timesoftfloat'.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Compiler Options and Efficiency
|
||||
|
||||
In order to get good speed with SoftFloat, it is important that the compiler
|
||||
inline the routines that have been marked `INLINE' in the code. Even if
|
||||
inlining cannot be forced by an appropriate definition of the `INLINE'
|
||||
macro, the compiler may still be able to perform inlining on its own as
|
||||
an optimization. In that case, the Makefile should be edited to give the
|
||||
compiler whatever option is required to cause it to inline small functions.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Processor-Specific Optimization of `softfloat.c' Using `softfloat-macros'
|
||||
|
||||
The `softfloat-macros' source fragment defines arithmetic functions used
|
||||
as primitives by `softfloat.c'. This file has been written in a target-
|
||||
independent form. For a given target, it may be possible to improve on
|
||||
these functions using target-specific and/or non-ISO-C features (such
|
||||
as `asm' statements). For example, one of the "macro" functions takes
|
||||
two word-size integers and returns their full product in two words.
|
||||
This operation can be done directly in hardware on many processors; but
|
||||
because it is not available through standard C, the function defined in
|
||||
`softfloat-macros' uses four multiplications to achieve the same result.
|
||||
|
||||
To address these shortcomings, a customized version of `softfloat-macros'
|
||||
can be created in any of the target-specific subdirectories. A simple
|
||||
modification to the target's Makefile should be sufficient to ensure that
|
||||
the custom version is used instead of the generic one.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Contact Information
|
||||
|
||||
At the time of this writing, the most up-to-date information about SoftFloat
|
||||
and the latest release can be found at the Web page `http://www.jhauser.us/
|
||||
arithmetic/SoftFloat.html'.
|
||||
|
389
i386c/ia32/instructions/fpu/softfloat/SoftFloat.txt
Normal file
389
i386c/ia32/instructions/fpu/softfloat/SoftFloat.txt
Normal file
@ -0,0 +1,389 @@
|
||||
|
||||
Berkeley SoftFloat Release 2c General Documentation
|
||||
|
||||
John R. Hauser
|
||||
2015 January 30
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Introduction
|
||||
|
||||
Berkeley SoftFloat is a software implementation of binary floating-point
|
||||
that conforms to the IEEE Standard for Floating-Point Arithmetic. For
|
||||
Release 2c of SoftFloat, as many as four formats are supported: 32-bit
|
||||
single-precision, 64-bit double-precision, 80-bit double-extended-precision,
|
||||
and 128-bit quadruple-precision. All operations required by the older 1985
|
||||
version of the IEEE Standard are implemented, except for conversions to and
|
||||
from decimal.
|
||||
|
||||
This document gives information about the types defined and the routines
|
||||
implemented by this release of SoftFloat. It does not attempt to define or
|
||||
explain the IEEE Floating-Point Standard. Details about the standard are
|
||||
available elsewhere.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Limitations
|
||||
|
||||
SoftFloat is written in C and is designed to work with other C code. The
|
||||
SoftFloat header files assume an ISO/ANSI-style C compiler. No attempt
|
||||
has been made to accomodate compilers that are not ISO-conformant. In
|
||||
particular, the distributed header files will not be acceptable to any
|
||||
compiler that does not recognize function prototypes.
|
||||
|
||||
Support for the 80-bit double-extended-precision and 128-bit quadruple-
|
||||
precision formats depends on a C compiler that implements 64-bit integer
|
||||
arithmetic. If the largest integer format supported by the C compiler is
|
||||
32 bits, SoftFloat is limited to only 32-bit single-precision and 64-bit
|
||||
double-precision. When that is the case, all references in this document
|
||||
to 80-bit double-extended-precision, 128-bit quadruple-precision, and 64-bit
|
||||
integers should be ignored.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Contents
|
||||
|
||||
Introduction
|
||||
Limitations
|
||||
Contents
|
||||
Legal Notice
|
||||
Types and Functions
|
||||
Rounding Modes
|
||||
Double-Extended-Precision Rounding Precision
|
||||
Exceptions and Exception Flags
|
||||
Function Details
|
||||
Conversion Functions
|
||||
Basic Arithmetic Functions
|
||||
Remainder Functions
|
||||
Round-to-Integer Functions
|
||||
Comparison Functions
|
||||
Signaling NaN Test Functions
|
||||
Raise-Exception Function
|
||||
Contact Information
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Legal Notice
|
||||
|
||||
SoftFloat was written by John R. Hauser. Release 2c of SoftFloat was made
|
||||
possible in part by the International Computer Science Institute, located
|
||||
at Suite 600, 1947 Center Street, Berkeley, California 94704. Funding
|
||||
was partially provided by the National Science Foundation under grant
|
||||
MIP-9311980. The original version of this code was written as part of a
|
||||
project to build a fixed-point vector processor in collaboration with the
|
||||
University of California at Berkeley, overseen by Profs. Nelson Morgan and
|
||||
John Wawrzynek.
|
||||
|
||||
THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
|
||||
has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
|
||||
TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
|
||||
PERSONS AND ORGANIZATIONS WHO CAN AND WILL TOLERATE ALL LOSSES, COSTS, OR
|
||||
OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE WITHOUT RECOMPENSE FROM JOHN
|
||||
HAUSER OR THE INTERNATIONAL COMPUTER SCIENCE INSTITUTE, AND WHO FURTHERMORE
|
||||
EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
|
||||
INSTITUTE (possibly via similar legal notice) AGAINST ALL LOSSES, COSTS, OR
|
||||
OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE,
|
||||
OR INCURRED BY ANYONE DUE TO A DERIVATIVE WORK THEY CREATE USING ANY PART OF
|
||||
THE SOFTWARE.
|
||||
|
||||
The following are expressly permitted, even for commercial purposes:
|
||||
(1) distribution of SoftFloat in whole or in part, as long as this and
|
||||
other legal notices remain and are prominent, and provided also that, for a
|
||||
partial distribution, prominent notice is given that it is a subset of the
|
||||
original; and
|
||||
(2) inclusion or use of SoftFloat in whole or in part in a derivative
|
||||
work, provided that the use restrictions above are met and the minimal
|
||||
documentation requirements stated in the source code are satisfied.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Types and Functions
|
||||
|
||||
When 64-bit integers are supported by the compiler, the `softfloat.h' header
|
||||
file defines four types: `float32' (32-bit single-precision), `float64'
|
||||
(64-bit double-precision), `floatx80' (80-bit double-extended-precision),
|
||||
and `float128' (128-bit quadruple-precision). The `float32' and `float64'
|
||||
types are defined in terms of 32-bit and 64-bit integer types, respectively,
|
||||
while the `float128' type is defined as a structure of two 64-bit integers,
|
||||
taking into account the byte order of the particular machine being used.
|
||||
The `floatx80' type is defined as a structure containing one 16-bit and one
|
||||
64-bit integer, with the machine's byte order again determining the order
|
||||
within the structure.
|
||||
|
||||
When 64-bit integers are _not_ supported by the compiler, the `softfloat.h'
|
||||
header file defines only two types: `float32' and `float64'. Because
|
||||
the ISO/ANSI C Standard guarantees at least one built-in integer type of
|
||||
32 bits, the `float32' type is identified with an appropriate integer type.
|
||||
The `float64' type is defined as a structure of two 32-bit integers, with
|
||||
the machine's byte order determining the order of the fields.
|
||||
|
||||
In either case, the types in `softfloat.h' are defined such that if a system
|
||||
implements the usual C `float' and `double' types according to the IEEE
|
||||
Standard, then the `float32' and `float64' types should be indistinguishable
|
||||
in memory from the native `float' and `double' types. (On the other hand,
|
||||
when `float32' or `float64' values are placed in processor registers by
|
||||
the compiler, the type of registers used may differ from those used for the
|
||||
native `float' and `double' types.)
|
||||
|
||||
SoftFloat implements the following arithmetic operations:
|
||||
|
||||
-- Conversions among all the floating-point formats, and also between
|
||||
integers (32-bit and 64-bit) and any of the floating-point formats.
|
||||
|
||||
-- The usual add, subtract, multiply, divide, and square root operations for
|
||||
all floating-point formats.
|
||||
|
||||
-- For each format, the floating-point remainder operation defined by the
|
||||
IEEE Standard.
|
||||
|
||||
-- For each floating-point format, a "round to integer" operation that
|
||||
rounds to the nearest integer value in the same format. (The floating-
|
||||
point formats can hold integer values, of course.)
|
||||
|
||||
-- Comparisons between two values in the same floating-point format.
|
||||
|
||||
The only functions required by the 1985 IEEE Standard that are not provided
|
||||
are conversions to and from decimal.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Rounding Modes
|
||||
|
||||
All four rounding modes prescribed by the 1985 IEEE Standard are implemented
|
||||
for all operations that require rounding. The rounding mode is selected
|
||||
by the global variable `float_rounding_mode'. This variable may be set
|
||||
to one of the values `float_round_nearest_even', `float_round_to_zero',
|
||||
`float_round_down', or `float_round_up'. The rounding mode is initialized
|
||||
to nearest/even.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Double-Extended-Precision Rounding Precision
|
||||
|
||||
For 80-bit double-extended-precision (`floatx80') only, the rounding
|
||||
precision of the basic arithmetic operations is controlled by the global
|
||||
variable `floatx80_rounding_precision'. The operations affected are:
|
||||
|
||||
floatx80_add floatx80_sub floatx80_mul floatx80_div floatx80_sqrt
|
||||
|
||||
When `floatx80_rounding_precision' is set to its default value of 80,
|
||||
these operations are rounded (as usual) to the full precision of the 80-bit
|
||||
double-extended-precision format. Setting `floatx80_rounding_precision' to
|
||||
32 or to 64 causes the operations listed to be rounded to reduced precision
|
||||
equivalent to 32-bit single-precision (`float32') or to 64-bit double-
|
||||
precision (`float64'), respectively. When rounding to reduced precision,
|
||||
additional bits in the result significand beyond the rounding point are set
|
||||
to zero. The consequences of setting `floatx80_rounding_precision' to a
|
||||
value other than 32, 64, or 80 is not specified. Operations other than the
|
||||
ones listed above are not affected by `floatx80_rounding_precision'.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Exceptions and Exception Flags
|
||||
|
||||
All five exception flags required by the IEEE Standard are implemented.
|
||||
Each flag is stored as a separate bit in the global variable
|
||||
`float_exception_flags'. The positions of the exception flag bits within
|
||||
this variable are determined by the bit masks `float_flag_inexact',
|
||||
`float_flag_underflow', `float_flag_overflow', `float_flag_divbyzero', and
|
||||
`float_flag_invalid'. The exception flags variable is initialized to all 0,
|
||||
meaning no exceptions.
|
||||
|
||||
An individual exception flag can be cleared with the statement
|
||||
|
||||
float_exception_flags &= ~ float_flag_<exception>;
|
||||
|
||||
where `<exception>' is the appropriate name. To raise a floating-point
|
||||
exception, the SoftFloat function `float_raise' should be used (see below).
|
||||
|
||||
In the terminology of the IEEE Standard, SoftFloat can detect tininess
|
||||
for underflow either before or after rounding. The choice is made by
|
||||
the global variable `float_detect_tininess', which can be set to either
|
||||
`float_tininess_before_rounding' or `float_tininess_after_rounding'.
|
||||
Detecting tininess after rounding is better because it results in fewer
|
||||
spurious underflow signals. The other option is provided for compatibility
|
||||
with some systems. Like most systems, SoftFloat always detects loss of
|
||||
accuracy for underflow as an inexact result.
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Function Details
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Conversion Functions
|
||||
|
||||
All conversions among the floating-point formats are supported, as are all
|
||||
conversions between a floating-point format and 32-bit and 64-bit signed
|
||||
integers. The complete set of conversion functions is:
|
||||
|
||||
int32_to_float32 int64_to_float32
|
||||
int32_to_float64 int64_to_float64
|
||||
int32_to_floatx80 int64_to_floatx80
|
||||
int32_to_float128 int64_to_float128
|
||||
|
||||
float32_to_int32 float32_to_int64
|
||||
float64_to_int32 float64_to_int64
|
||||
floatx80_to_int32 floatx80_to_int64
|
||||
float128_to_int32 float128_to_int64
|
||||
|
||||
float32_to_float64 float32_to_floatx80 float32_to_float128
|
||||
float64_to_float32 float64_to_floatx80 float64_to_float128
|
||||
floatx80_to_float32 floatx80_to_float64 floatx80_to_float128
|
||||
float128_to_float32 float128_to_float64 float128_to_floatx80
|
||||
|
||||
Each conversion function takes one operand of the appropriate type and
|
||||
returns one result. Conversions from a smaller to a larger floating-point
|
||||
format are always exact and so require no rounding. Conversions from 32-bit
|
||||
integers to 64-bit double-precision and larger formats are also exact, and
|
||||
likewise for conversions from 64-bit integers to 80-bit double-extended-
|
||||
precision and 128-bit quadruple-precision.
|
||||
|
||||
Conversions from floating-point to integer raise the invalid exception if
|
||||
the source value cannot be rounded to a representable integer of the desired
|
||||
size (32 or 64 bits). If the floating-point operand is a NaN, the largest
|
||||
positive integer is returned. Otherwise, if the conversion overflows, the
|
||||
largest integer with the same sign as the operand is returned.
|
||||
|
||||
On conversions to integer, if the floating-point operand is not already
|
||||
an integer value, the operand is rounded according to the current rounding
|
||||
mode as specified by `float_rounding_mode'. Because C (and perhaps other
|
||||
languages) require that conversions to integers be rounded toward zero, the
|
||||
following functions are provided for improved speed and convenience:
|
||||
|
||||
float32_to_int32_round_to_zero float32_to_int64_round_to_zero
|
||||
float64_to_int32_round_to_zero float64_to_int64_round_to_zero
|
||||
floatx80_to_int32_round_to_zero floatx80_to_int64_round_to_zero
|
||||
float128_to_int32_round_to_zero float128_to_int64_round_to_zero
|
||||
|
||||
These variant functions ignore `float_rounding_mode' and always round toward
|
||||
zero.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Basic Arithmetic Functions
|
||||
|
||||
The following basic arithmetic functions are provided:
|
||||
|
||||
float32_add float32_sub float32_mul float32_div float32_sqrt
|
||||
float64_add float64_sub float64_mul float64_div float64_sqrt
|
||||
floatx80_add floatx80_sub floatx80_mul floatx80_div floatx80_sqrt
|
||||
float128_add float128_sub float128_mul float128_div float128_sqrt
|
||||
|
||||
Each function takes two operands, except for `sqrt' which takes only one.
|
||||
The operands and result are all of the same type.
|
||||
|
||||
Rounding of the 80-bit double-extended-precision (`floatx80') functions is
|
||||
affected by the `floatx80_rounding_precision' variable, as explained above
|
||||
in the section _Double-Extended-Precision Rounding Precision_.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Remainder Functions
|
||||
|
||||
For each format, SoftFloat implements the remainder function according to
|
||||
the IEEE Standard. The remainder functions are:
|
||||
|
||||
float32_rem
|
||||
float64_rem
|
||||
floatx80_rem
|
||||
float128_rem
|
||||
|
||||
Each remainder function takes two operands. The operands and result are all
|
||||
of the same type. Given operands x and y, the remainder functions return
|
||||
the value x - n*y, where n is the integer closest to x/y. If x/y is exactly
|
||||
halfway between two integers, n is the even integer closest to x/y. The
|
||||
remainder functions are always exact and so require no rounding.
|
||||
|
||||
Depending on the relative magnitudes of the operands, the remainder
|
||||
functions can take considerably longer to execute than the other SoftFloat
|
||||
functions. This is inherent in the remainder operation itself and is not a
|
||||
flaw in the SoftFloat implementation.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Round-to-Integer Functions
|
||||
|
||||
For each format, SoftFloat implements the round-to-integer function
|
||||
specified by the IEEE Standard. The functions are:
|
||||
|
||||
float32_round_to_int
|
||||
float64_round_to_int
|
||||
floatx80_round_to_int
|
||||
float128_round_to_int
|
||||
|
||||
Each function takes a single floating-point operand and returns a result of
|
||||
the same type. (Note that the result is not an integer type.) The operand
|
||||
is rounded to an exact integer according to the current rounding mode, and
|
||||
the resulting integer value is returned in the same floating-point format.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Comparison Functions
|
||||
|
||||
The following floating-point comparison functions are provided:
|
||||
|
||||
float32_eq float32_le float32_lt
|
||||
float64_eq float64_le float64_lt
|
||||
floatx80_eq floatx80_le floatx80_lt
|
||||
float128_eq float128_le float128_lt
|
||||
|
||||
Each function takes two operands of the same type and returns a 1 or 0
|
||||
representing either _true_ or _false_. The abbreviation `eq' stands for
|
||||
"equal" (=); `le' stands for "less than or equal" (<=); and `lt' stands for
|
||||
"less than" (<).
|
||||
|
||||
The usual greater-than (>), greater-than-or-equal (>=), and not-equal (!=)
|
||||
functions are easily obtained using the functions provided. The not-equal
|
||||
function is just the logical complement of the equal function. The greater-
|
||||
than-or-equal function is identical to the less-than-or-equal function with
|
||||
the operands reversed, and the greater-than function is identical to the
|
||||
less-than function with the operands reversed.
|
||||
|
||||
The IEEE Standard specifies that the less-than-or-equal and less-than
|
||||
functions raise the invalid exception if either input is any kind of NaN.
|
||||
The equal functions, on the other hand, are defined not to raise the invalid
|
||||
exception on quiet NaNs. For completeness, SoftFloat provides the following
|
||||
additional functions:
|
||||
|
||||
float32_eq_signaling float32_le_quiet float32_lt_quiet
|
||||
float64_eq_signaling float64_le_quiet float64_lt_quiet
|
||||
floatx80_eq_signaling floatx80_le_quiet floatx80_lt_quiet
|
||||
float128_eq_signaling float128_le_quiet float128_lt_quiet
|
||||
|
||||
The `signaling' equal functions are identical to the standard functions
|
||||
except that the invalid exception is raised for any NaN input. Likewise,
|
||||
the `quiet' comparison functions are identical to their counterparts except
|
||||
that the invalid exception is not raised for quiet NaNs.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Signaling NaN Test Functions
|
||||
|
||||
The following functions test whether a floating-point value is a signaling
|
||||
NaN:
|
||||
|
||||
float32_is_signaling_nan
|
||||
float64_is_signaling_nan
|
||||
floatx80_is_signaling_nan
|
||||
float128_is_signaling_nan
|
||||
|
||||
The functions take one operand and return 1 if the operand is a signaling
|
||||
NaN and 0 otherwise.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Raise-Exception Function
|
||||
|
||||
SoftFloat provides a function for raising floating-point exceptions:
|
||||
|
||||
float_raise
|
||||
|
||||
The function takes a mask indicating the set of exceptions to raise. No
|
||||
result is returned. In addition to setting the specified exception flags,
|
||||
this function may cause a trap or abort appropriate for the current system.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
Contact Information
|
||||
|
||||
At the time of this writing, the most up-to-date information about SoftFloat
|
||||
and the latest release can be found at the Web page `http://www.jhauser.us/
|
||||
arithmetic/SoftFloat.html'.
|
||||
|
@ -1,100 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
extF80M_add(
|
||||
const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr, sw_extFloat80_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signB;
|
||||
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
|
||||
sw_extFloat80_t
|
||||
(*magsFuncPtr)(
|
||||
uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
|
||||
#endif
|
||||
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
||||
if ( signA == signB ) {
|
||||
*zPtr = softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
} else {
|
||||
*zPtr = softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
}
|
||||
#else
|
||||
magsFuncPtr =
|
||||
(signA == signB) ? softfloat_addMagsExtF80 : softfloat_subMagsExtF80;
|
||||
*zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
extF80M_add(
|
||||
const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr, sw_extFloat80_t *zPtr )
|
||||
{
|
||||
|
||||
softfloat_addExtF80M(
|
||||
(const struct extFloat80M *) aPtr,
|
||||
(const struct extFloat80M *) bPtr,
|
||||
(struct extFloat80M *) zPtr,
|
||||
false
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,194 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
extF80M_div(
|
||||
const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr, sw_extFloat80_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = extF80_div( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
extF80M_div(
|
||||
const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr, sw_extFloat80_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
struct extFloat80M *zSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t expA;
|
||||
uint_fast16_t uiB64;
|
||||
int32_t expB;
|
||||
bool signZ;
|
||||
uint64_t sigA, x64;
|
||||
int32_t expZ;
|
||||
int shiftDist;
|
||||
uint32_t y[3], recip32, sigB[3];
|
||||
int ix;
|
||||
uint32_t q, qs[2];
|
||||
uint_fast16_t uiZ64;
|
||||
uint64_t uiZ0;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
zSPtr = (struct extFloat80M *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
uiB64 = bSPtr->signExp;
|
||||
expB = expExtF80UI64( uiB64 );
|
||||
signZ = signExtF80UI64( uiA64 ) ^ signExtF80UI64( uiB64 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
|
||||
if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
|
||||
if ( expA == 0x7FFF ) {
|
||||
if ( expB == 0x7FFF ) goto invalid;
|
||||
goto infinity;
|
||||
}
|
||||
goto zero;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sigA = aSPtr->signif;
|
||||
x64 = bSPtr->signif;
|
||||
if ( ! expB ) expB = 1;
|
||||
if ( ! (x64 & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! x64 ) {
|
||||
if ( ! sigA ) goto invalid;
|
||||
softfloat_raiseFlags( softfloat_flag_infinite );
|
||||
goto infinity;
|
||||
}
|
||||
expB += softfloat_normExtF80SigM( &x64 );
|
||||
}
|
||||
if ( ! expA ) expA = 1;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
expA += softfloat_normExtF80SigM( &sigA );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA - expB + 0x3FFF;
|
||||
shiftDist = 29;
|
||||
if ( sigA < x64 ) {
|
||||
--expZ;
|
||||
shiftDist = 30;
|
||||
}
|
||||
softfloat_shortShiftLeft64To96M( sigA, shiftDist, y );
|
||||
recip32 = softfloat_approxRecip32_1( x64>>32 );
|
||||
sigB[indexWord( 3, 0 )] = (uint32_t) x64<<30;
|
||||
x64 >>= 2;
|
||||
sigB[indexWord( 3, 2 )] = x64>>32;
|
||||
sigB[indexWord( 3, 1 )] = x64;
|
||||
ix = 2;
|
||||
for (;;) {
|
||||
x64 = (uint64_t) y[indexWordHi( 3 )] * recip32;
|
||||
q = (x64 + 0x80000000)>>32;
|
||||
--ix;
|
||||
if ( ix < 0 ) break;
|
||||
softfloat_remStep96MBy32( y, 29, sigB, q, y );
|
||||
if ( y[indexWordHi( 3 )] & 0x80000000 ) {
|
||||
--q;
|
||||
softfloat_add96M( y, sigB, y );
|
||||
}
|
||||
qs[ix] = q;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ((q + 1) & 0x3FFFFF) < 2 ) {
|
||||
softfloat_remStep96MBy32( y, 29, sigB, q, y );
|
||||
if ( y[indexWordHi( 3 )] & 0x80000000 ) {
|
||||
--q;
|
||||
softfloat_add96M( y, sigB, y );
|
||||
} else if ( softfloat_compare96M( sigB, y ) <= 0 ) {
|
||||
++q;
|
||||
softfloat_sub96M( y, sigB, y );
|
||||
}
|
||||
if (
|
||||
y[indexWordLo( 3 )] || y[indexWord( 3, 1 )] || y[indexWord( 3, 2 )]
|
||||
) {
|
||||
q |= 1;
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
x64 = (uint64_t) q<<9;
|
||||
y[indexWord( 3, 0 )] = x64;
|
||||
x64 = ((uint64_t) qs[0]<<6) + (x64>>32);
|
||||
y[indexWord( 3, 1 )] = x64;
|
||||
y[indexWord( 3, 2 )] = (qs[1]<<3) + (x64>>32);
|
||||
softfloat_roundPackMToExtF80M(
|
||||
signZ, expZ, y, extF80_roundingPrecision, zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_invalidExtF80M( zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
infinity:
|
||||
uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
|
||||
uiZ0 = UINT64_C( 0x8000000000000000 );
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ64 = packToExtF80UI64( signZ, 0 );
|
||||
uiZ0 = 0;
|
||||
uiZ:
|
||||
zSPtr->signExp = uiZ64;
|
||||
zSPtr->signif = uiZ0;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,98 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool extF80M_eq( const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr )
|
||||
{
|
||||
|
||||
return extF80_eq( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool extF80M_eq( const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint64_t uiA0;
|
||||
uint_fast16_t uiB64;
|
||||
uint64_t uiB0;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
if (
|
||||
softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
|
||||
|| softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( uiA0 == uiB0 ) {
|
||||
return (uiA64 == uiB64) || ! uiA0;
|
||||
} else {
|
||||
if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
|
||||
return ! softfloat_compareNonnormExtF80M( aSPtr, bSPtr );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,92 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool extF80M_eq_signaling( const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr )
|
||||
{
|
||||
|
||||
return extF80_eq_signaling( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool extF80M_eq_signaling( const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint64_t uiA0;
|
||||
uint_fast16_t uiB64;
|
||||
uint64_t uiB0;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( uiA0 == uiB0 ) {
|
||||
return (uiA64 == uiB64) || ! uiA0;
|
||||
} else {
|
||||
if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
|
||||
return ! softfloat_compareNonnormExtF80M( aSPtr, bSPtr );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,57 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool extF80M_isSignalingNaN( const sw_extFloat80_t *aPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint64_t uiA0;
|
||||
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
if ( (aSPtr->signExp & 0x7FFF) != 0x7FFF ) return false;
|
||||
uiA0 = aSPtr->signif;
|
||||
return
|
||||
! (uiA0 & UINT64_C( 0x4000000000000000 ))
|
||||
&& (uiA0 & UINT64_C( 0x3FFFFFFFFFFFFFFF));
|
||||
|
||||
}
|
||||
|
@ -1,106 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool extF80M_le( const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr )
|
||||
{
|
||||
|
||||
return extF80_le( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool extF80M_le( const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint64_t uiA0;
|
||||
uint_fast16_t uiB64;
|
||||
uint64_t uiB0;
|
||||
bool signA, ltMags;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
if ( (uiA64 ^ uiB64) & 0x8000 ) {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are different.
|
||||
*--------------------------------------------------------------------*/
|
||||
return signA || ! (uiA0 | uiB0);
|
||||
} else {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are the same.
|
||||
*--------------------------------------------------------------------*/
|
||||
if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
|
||||
return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) <= 0);
|
||||
}
|
||||
if ( uiA64 == uiB64 ) {
|
||||
if ( uiA0 == uiB0 ) return true;
|
||||
ltMags = (uiA0 < uiB0);
|
||||
} else {
|
||||
ltMags = (uiA64 < uiB64);
|
||||
}
|
||||
return signA ^ ltMags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,112 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool extF80M_le_quiet( const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr )
|
||||
{
|
||||
|
||||
return extF80_le_quiet( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool extF80M_le_quiet( const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint64_t uiA0;
|
||||
uint_fast16_t uiB64;
|
||||
uint64_t uiB0;
|
||||
bool signA, ltMags;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
if (
|
||||
softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
|
||||
|| softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
if ( (uiA64 ^ uiB64) & 0x8000 ) {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are different.
|
||||
*--------------------------------------------------------------------*/
|
||||
return signA || ! (uiA0 | uiB0);
|
||||
} else {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are the same.
|
||||
*--------------------------------------------------------------------*/
|
||||
if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
|
||||
return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) <= 0);
|
||||
}
|
||||
if ( uiA64 == uiB64 ) {
|
||||
if ( uiA0 == uiB0 ) return true;
|
||||
ltMags = (uiA0 < uiB0);
|
||||
} else {
|
||||
ltMags = (uiA64 < uiB64);
|
||||
}
|
||||
return signA ^ ltMags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,106 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool extF80M_lt( const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr )
|
||||
{
|
||||
|
||||
return extF80_lt( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool extF80M_lt( const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint64_t uiA0;
|
||||
uint_fast16_t uiB64;
|
||||
uint64_t uiB0;
|
||||
bool signA, ltMags;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
if ( (uiA64 ^ uiB64) & 0x8000 ) {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are different.
|
||||
*--------------------------------------------------------------------*/
|
||||
return signA && ((uiA0 | uiB0) != 0);
|
||||
} else {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are the same.
|
||||
*--------------------------------------------------------------------*/
|
||||
if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
|
||||
return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) < 0);
|
||||
}
|
||||
if ( uiA64 == uiB64 ) {
|
||||
if ( uiA0 == uiB0 ) return false;
|
||||
ltMags = (uiA0 < uiB0);
|
||||
} else {
|
||||
ltMags = (uiA64 < uiB64);
|
||||
}
|
||||
return signA ^ ltMags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,112 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool extF80M_lt_quiet( const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr )
|
||||
{
|
||||
|
||||
return extF80_lt_quiet( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool extF80M_lt_quiet( const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint64_t uiA0;
|
||||
uint_fast16_t uiB64;
|
||||
uint64_t uiB0;
|
||||
bool signA, ltMags;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
if (
|
||||
softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
|
||||
|| softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
if ( (uiA64 ^ uiB64) & 0x8000 ) {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are different.
|
||||
*--------------------------------------------------------------------*/
|
||||
return signA && ((uiA0 | uiB0) != 0);
|
||||
} else {
|
||||
/*--------------------------------------------------------------------
|
||||
| Signs are the same.
|
||||
*--------------------------------------------------------------------*/
|
||||
if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
|
||||
return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) < 0);
|
||||
}
|
||||
if ( uiA64 == uiB64 ) {
|
||||
if ( uiA0 == uiB0 ) return false;
|
||||
ltMags = (uiA0 < uiB0);
|
||||
} else {
|
||||
ltMags = (uiA64 < uiB64);
|
||||
}
|
||||
return signA ^ ltMags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,139 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
extF80M_mul(
|
||||
const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr, sw_extFloat80_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = extF80_mul( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
extF80M_mul(
|
||||
const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr, sw_extFloat80_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
struct extFloat80M *zSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t expA;
|
||||
uint_fast16_t uiB64;
|
||||
int32_t expB;
|
||||
bool signZ;
|
||||
uint_fast16_t exp, uiZ64;
|
||||
uint64_t uiZ0, sigA, sigB;
|
||||
int32_t expZ;
|
||||
uint32_t sigProd[4], *extSigZPtr;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
zSPtr = (struct extFloat80M *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
uiB64 = bSPtr->signExp;
|
||||
expB = expExtF80UI64( uiB64 );
|
||||
signZ = signExtF80UI64( uiA64 ) ^ signExtF80UI64( uiB64 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
|
||||
if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
|
||||
if (
|
||||
(! aSPtr->signif && (expA != 0x7FFF))
|
||||
|| (! bSPtr->signif && (expB != 0x7FFF))
|
||||
) {
|
||||
softfloat_invalidExtF80M( zSPtr );
|
||||
return;
|
||||
}
|
||||
uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
|
||||
uiZ0 = UINT64_C( 0x8000000000000000 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expA ) expA = 1;
|
||||
sigA = aSPtr->signif;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
expA += softfloat_normExtF80SigM( &sigA );
|
||||
}
|
||||
if ( ! expB ) expB = 1;
|
||||
sigB = bSPtr->signif;
|
||||
if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigB ) goto zero;
|
||||
expB += softfloat_normExtF80SigM( &sigB );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA + expB - 0x3FFE;
|
||||
softfloat_mul64To128M( sigA, sigB, sigProd );
|
||||
if ( sigProd[indexWordLo( 4 )] ) sigProd[indexWord( 4, 1 )] |= 1;
|
||||
extSigZPtr = &sigProd[indexMultiwordHi( 4, 3 )];
|
||||
if ( sigProd[indexWordHi( 4 )] < 0x80000000 ) {
|
||||
--expZ;
|
||||
softfloat_add96M( extSigZPtr, extSigZPtr, extSigZPtr );
|
||||
}
|
||||
softfloat_roundPackMToExtF80M(
|
||||
signZ, expZ, extSigZPtr, extF80_roundingPrecision, zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ64 = packToExtF80UI64( signZ, 0 );
|
||||
uiZ0 = 0;
|
||||
uiZ:
|
||||
zSPtr->signExp = uiZ64;
|
||||
zSPtr->signif = uiZ0;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,204 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
extF80M_rem(
|
||||
const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr, sw_extFloat80_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = extF80_rem( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
extF80M_rem(
|
||||
const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr, sw_extFloat80_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
struct extFloat80M *zSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t expA, expB;
|
||||
uint64_t x64;
|
||||
bool signRem;
|
||||
uint64_t sigA;
|
||||
int32_t expDiff;
|
||||
uint32_t rem[3], x[3], sig32B, q, recip32, rem2[3], *remPtr, *altRemPtr;
|
||||
uint32_t *newRemPtr, wordMeanRem;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
zSPtr = (struct extFloat80M *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
expB = expExtF80UI64( bSPtr->signExp );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
|
||||
if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
|
||||
if ( expA == 0x7FFF ) goto invalid;
|
||||
/*--------------------------------------------------------------------
|
||||
| If we get here, then argument b is an infinity and `expB' is 0x7FFF;
|
||||
| Doubling `expB' is an easy way to ensure that `expDiff' later is
|
||||
| less than -1, which will result in returning a canonicalized version
|
||||
| of argument a.
|
||||
*--------------------------------------------------------------------*/
|
||||
expB += expB;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expB ) expB = 1;
|
||||
x64 = bSPtr->signif;
|
||||
if ( ! (x64 & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! x64 ) goto invalid;
|
||||
expB += softfloat_normExtF80SigM( &x64 );
|
||||
}
|
||||
signRem = signExtF80UI64( uiA64 );
|
||||
if ( ! expA ) expA = 1;
|
||||
sigA = aSPtr->signif;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) {
|
||||
expA = 0;
|
||||
goto copyA;
|
||||
}
|
||||
expA += softfloat_normExtF80SigM( &sigA );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expDiff = expA - expB;
|
||||
if ( expDiff < -1 ) goto copyA;
|
||||
rem[indexWord( 3, 2 )] = sigA>>34;
|
||||
rem[indexWord( 3, 1 )] = sigA>>2;
|
||||
rem[indexWord( 3, 0 )] = (uint32_t) sigA<<30;
|
||||
x[indexWord( 3, 0 )] = (uint32_t) x64<<30;
|
||||
sig32B = x64>>32;
|
||||
x64 >>= 2;
|
||||
x[indexWord( 3, 2 )] = x64>>32;
|
||||
x[indexWord( 3, 1 )] = x64;
|
||||
if ( expDiff < 1 ) {
|
||||
if ( expDiff ) {
|
||||
--expB;
|
||||
softfloat_add96M( x, x, x );
|
||||
q = 0;
|
||||
} else {
|
||||
q = (softfloat_compare96M( x, rem ) <= 0);
|
||||
if ( q ) softfloat_sub96M( rem, x, rem );
|
||||
}
|
||||
} else {
|
||||
recip32 = softfloat_approxRecip32_1( sig32B );
|
||||
expDiff -= 30;
|
||||
for (;;) {
|
||||
x64 = (uint64_t) rem[indexWordHi( 3 )] * recip32;
|
||||
if ( expDiff < 0 ) break;
|
||||
q = (x64 + 0x80000000)>>32;
|
||||
softfloat_remStep96MBy32( rem, 29, x, q, rem );
|
||||
if ( rem[indexWordHi( 3 )] & 0x80000000 ) {
|
||||
softfloat_add96M( rem, x, rem );
|
||||
}
|
||||
expDiff -= 29;
|
||||
}
|
||||
/*--------------------------------------------------------------------
|
||||
| (`expDiff' cannot be less than -29 here.)
|
||||
*--------------------------------------------------------------------*/
|
||||
q = (uint32_t) (x64>>32)>>(~expDiff & 31);
|
||||
softfloat_remStep96MBy32( rem, expDiff + 30, x, q, rem );
|
||||
if ( rem[indexWordHi( 3 )] & 0x80000000 ) {
|
||||
remPtr = rem;
|
||||
altRemPtr = rem2;
|
||||
softfloat_add96M( remPtr, x, altRemPtr );
|
||||
goto selectRem;
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
remPtr = rem;
|
||||
altRemPtr = rem2;
|
||||
do {
|
||||
++q;
|
||||
newRemPtr = altRemPtr;
|
||||
softfloat_sub96M( remPtr, x, newRemPtr );
|
||||
altRemPtr = remPtr;
|
||||
remPtr = newRemPtr;
|
||||
} while ( ! (remPtr[indexWordHi( 3 )] & 0x80000000) );
|
||||
selectRem:
|
||||
softfloat_add96M( remPtr, altRemPtr, x );
|
||||
wordMeanRem = x[indexWordHi( 3 )];
|
||||
if (
|
||||
(wordMeanRem & 0x80000000)
|
||||
|| (! wordMeanRem && (q & 1) && ! x[indexWord( 3, 0 )]
|
||||
&& ! x[indexWord( 3, 1 )])
|
||||
) {
|
||||
remPtr = altRemPtr;
|
||||
}
|
||||
if ( remPtr[indexWordHi( 3 )] & 0x80000000 ) {
|
||||
signRem = ! signRem;
|
||||
softfloat_negX96M( remPtr );
|
||||
}
|
||||
softfloat_normRoundPackMToExtF80M( signRem, expB + 2, remPtr, 80, zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_invalidExtF80M( zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
copyA:
|
||||
if ( expA < 1 ) {
|
||||
sigA >>= 1 - expA;
|
||||
expA = 0;
|
||||
}
|
||||
zSPtr->signExp = packToExtF80UI64( signRem, expA );
|
||||
zSPtr->signif = sigA;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,176 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
extF80M_roundToInt(
|
||||
const sw_extFloat80_t *aPtr,
|
||||
uint_fast8_t roundingMode,
|
||||
bool exact,
|
||||
sw_extFloat80_t *zPtr
|
||||
)
|
||||
{
|
||||
|
||||
*zPtr = extF80_roundToInt( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
extF80M_roundToInt(
|
||||
const sw_extFloat80_t *aPtr,
|
||||
uint_fast8_t roundingMode,
|
||||
bool exact,
|
||||
sw_extFloat80_t *zPtr
|
||||
)
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
struct extFloat80M *zSPtr;
|
||||
uint_fast16_t uiA64, signUI64;
|
||||
int32_t exp;
|
||||
uint64_t sigA;
|
||||
uint_fast16_t uiZ64;
|
||||
uint64_t sigZ, lastBitMask, roundBitsMask;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
zSPtr = (struct extFloat80M *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sigA = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( !(sigA & UINT64_C( 0x8000000000000000 )) && (exp != 0x7FFF) ) {
|
||||
if ( !sigA ) {
|
||||
uiZ64 = signUI64;
|
||||
sigZ = 0;
|
||||
goto uiZ;
|
||||
}
|
||||
exp += softfloat_normExtF80SigM( &sigA );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp <= 0x3FFE ) {
|
||||
if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
switch ( roundingMode ) {
|
||||
case softfloat_round_near_even:
|
||||
if ( !(sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) break;
|
||||
case softfloat_round_near_maxMag:
|
||||
if ( exp == 0x3FFE ) goto mag1;
|
||||
break;
|
||||
case softfloat_round_min:
|
||||
if ( signUI64 ) goto mag1;
|
||||
break;
|
||||
case softfloat_round_max:
|
||||
if ( !signUI64 ) goto mag1;
|
||||
break;
|
||||
#ifdef SOFTFLOAT_ROUND_ODD
|
||||
case softfloat_round_odd:
|
||||
goto mag1;
|
||||
#endif
|
||||
}
|
||||
uiZ64 = signUI64;
|
||||
sigZ = 0;
|
||||
goto uiZ;
|
||||
mag1:
|
||||
uiZ64 = signUI64 | 0x3FFF;
|
||||
sigZ = UINT64_C( 0x8000000000000000 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( 0x403E <= exp ) {
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_propagateNaNExtF80M( aSPtr, 0, zSPtr );
|
||||
return;
|
||||
}
|
||||
sigZ = UINT64_C( 0x8000000000000000 );
|
||||
} else {
|
||||
sigZ = sigA;
|
||||
}
|
||||
uiZ64 = signUI64 | exp;
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ64 = signUI64 | exp;
|
||||
lastBitMask = (uint64_t) 1<<(0x403E - exp);
|
||||
roundBitsMask = lastBitMask - 1;
|
||||
sigZ = sigA;
|
||||
if ( roundingMode == softfloat_round_near_maxMag ) {
|
||||
sigZ += lastBitMask>>1;
|
||||
} else if ( roundingMode == softfloat_round_near_even ) {
|
||||
sigZ += lastBitMask>>1;
|
||||
if ( !(sigZ & roundBitsMask) ) sigZ &= ~lastBitMask;
|
||||
} else if (
|
||||
roundingMode == (signUI64 ? softfloat_round_min : softfloat_round_max)
|
||||
) {
|
||||
sigZ += roundBitsMask;
|
||||
}
|
||||
sigZ &= ~roundBitsMask;
|
||||
if ( !sigZ ) {
|
||||
++uiZ64;
|
||||
sigZ = UINT64_C( 0x8000000000000000 );
|
||||
}
|
||||
if ( sigZ != sigA ) {
|
||||
#ifdef SOFTFLOAT_ROUND_ODD
|
||||
if ( roundingMode == softfloat_round_odd ) sigZ |= lastBitMask;
|
||||
#endif
|
||||
if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
uiZ:
|
||||
zSPtr->signExp = uiZ64;
|
||||
zSPtr->signif = sigZ;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,180 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void extF80M_sqrt( const sw_extFloat80_t *aPtr, sw_extFloat80_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = extF80_sqrt( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void extF80M_sqrt( const sw_extFloat80_t *aPtr, sw_extFloat80_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
struct extFloat80M *zSPtr;
|
||||
uint_fast16_t uiA64, signUI64;
|
||||
int32_t expA;
|
||||
uint64_t rem64;
|
||||
int32_t expZ;
|
||||
uint32_t rem96[3], sig32A, recipSqrt32, sig32Z, q;
|
||||
uint64_t sig64Z, x64;
|
||||
uint32_t rem32, term[4], rem[4], extSigZ[3];
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
zSPtr = (struct extFloat80M *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
rem64 = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA == 0x7FFF ) {
|
||||
if ( rem64 & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_propagateNaNExtF80M( aSPtr, 0, zSPtr );
|
||||
return;
|
||||
}
|
||||
if ( signUI64 ) goto invalid;
|
||||
rem64 = UINT64_C( 0x8000000000000000 );
|
||||
goto copyA;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expA ) expA = 1;
|
||||
if ( ! (rem64 & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! rem64 ) {
|
||||
uiA64 = signUI64;
|
||||
goto copyA;
|
||||
}
|
||||
expA += softfloat_normExtF80SigM( &rem64 );
|
||||
}
|
||||
if ( signUI64 ) goto invalid;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = ((expA - 0x3FFF)>>1) + 0x3FFF;
|
||||
expA &= 1;
|
||||
softfloat_shortShiftLeft64To96M( rem64, 30 - expA, rem96 );
|
||||
sig32A = rem64>>32;
|
||||
recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
|
||||
sig32Z = ((uint64_t) sig32A * recipSqrt32)>>32;
|
||||
if ( expA ) sig32Z >>= 1;
|
||||
rem64 =
|
||||
((uint64_t) rem96[indexWord( 3, 2 )]<<32 | rem96[indexWord( 3, 1 )])
|
||||
- (uint64_t) sig32Z * sig32Z;
|
||||
rem96[indexWord( 3, 2 )] = rem64>>32;
|
||||
rem96[indexWord( 3, 1 )] = rem64;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
|
||||
sig64Z = ((uint64_t) sig32Z<<32) + ((uint64_t) q<<3);
|
||||
term[indexWord( 3, 2 )] = 0;
|
||||
/*------------------------------------------------------------------------
|
||||
| (Repeating this loop is a rare occurrence.)
|
||||
*------------------------------------------------------------------------*/
|
||||
for (;;) {
|
||||
x64 = ((uint64_t) sig32Z<<32) + sig64Z;
|
||||
term[indexWord( 3, 1 )] = x64>>32;
|
||||
term[indexWord( 3, 0 )] = x64;
|
||||
softfloat_remStep96MBy32(
|
||||
rem96, 29, term, q, &rem[indexMultiwordHi( 4, 3 )] );
|
||||
rem32 = rem[indexWord( 4, 3 )];
|
||||
if ( ! (rem32 & 0x80000000) ) break;
|
||||
--q;
|
||||
sig64Z -= 1<<3;
|
||||
}
|
||||
rem64 = (uint64_t) rem32<<32 | rem[indexWord( 4, 2 )];
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = (((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32) + 2;
|
||||
if ( rem64>>34 ) q += recipSqrt32;
|
||||
x64 = (uint64_t) q<<7;
|
||||
extSigZ[indexWord( 3, 0 )] = x64;
|
||||
x64 = (sig64Z<<1) + (x64>>32);
|
||||
extSigZ[indexWord( 3, 2 )] = x64>>32;
|
||||
extSigZ[indexWord( 3, 1 )] = x64;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (q & 0xFFFFFF) <= 2 ) {
|
||||
q &= ~(uint32_t) 0xFFFF;
|
||||
extSigZ[indexWordLo( 3 )] = q<<7;
|
||||
x64 = sig64Z + (q>>27);
|
||||
term[indexWord( 4, 3 )] = 0;
|
||||
term[indexWord( 4, 2 )] = x64>>32;
|
||||
term[indexWord( 4, 1 )] = x64;
|
||||
term[indexWord( 4, 0 )] = q<<5;
|
||||
rem[indexWord( 4, 0 )] = 0;
|
||||
softfloat_remStep128MBy32( rem, 28, term, q, rem );
|
||||
q = rem[indexWordHi( 4 )];
|
||||
if ( q & 0x80000000 ) {
|
||||
softfloat_sub1X96M( extSigZ );
|
||||
} else {
|
||||
if ( q || rem[indexWord( 4, 1 )] || rem[indexWord( 4, 2 )] ) {
|
||||
extSigZ[indexWordLo( 3 )] |= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
softfloat_roundPackMToExtF80M(
|
||||
0, expZ, extSigZ, extF80_roundingPrecision, zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_invalidExtF80M( zSPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
copyA:
|
||||
zSPtr->signExp = uiA64;
|
||||
zSPtr->signif = rem64;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,100 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
extF80M_sub(
|
||||
const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr, sw_extFloat80_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr, *bSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signB;
|
||||
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
|
||||
sw_extFloat80_t
|
||||
(*magsFuncPtr)(
|
||||
uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
|
||||
#endif
|
||||
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
bSPtr = (const struct extFloat80M *) bPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
uiA0 = aSPtr->signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
uiB64 = bSPtr->signExp;
|
||||
uiB0 = bSPtr->signif;
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
||||
if ( signA == signB ) {
|
||||
*zPtr = softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
} else {
|
||||
*zPtr = softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
}
|
||||
#else
|
||||
magsFuncPtr =
|
||||
(signA == signB) ? softfloat_subMagsExtF80 : softfloat_addMagsExtF80;
|
||||
*zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
extF80M_sub(
|
||||
const sw_extFloat80_t *aPtr, const sw_extFloat80_t *bPtr, sw_extFloat80_t *zPtr )
|
||||
{
|
||||
|
||||
softfloat_addExtF80M(
|
||||
(const struct extFloat80M *) aPtr,
|
||||
(const struct extFloat80M *) bPtr,
|
||||
(struct extFloat80M *) zPtr,
|
||||
true
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,125 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void extF80M_to_f128M( const sw_extFloat80_t *aPtr, sw_float128_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = extF80_to_f128( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void extF80M_to_f128M( const sw_extFloat80_t *aPtr, sw_float128_t *zPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint32_t *zWPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint32_t uiZ96;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
zWPtr = (uint32_t *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zWPtr[indexWord( 4, 0 )] = 0;
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
|
||||
softfloat_commonNaNToF128M( &commonNaN, zWPtr );
|
||||
return;
|
||||
}
|
||||
uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp ) --exp;
|
||||
if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sig ) {
|
||||
uiZ96 = packToF128UI96( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
exp += softfloat_normExtF80SigM( &sig );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zWPtr[indexWord( 4, 1 )] = (uint32_t) sig<<17;
|
||||
sig >>= 15;
|
||||
zWPtr[indexWord( 4, 2 )] = sig;
|
||||
if ( exp < 0 ) {
|
||||
zWPtr[indexWordHi( 4 )] = sig>>32;
|
||||
softfloat_shiftRight96M(
|
||||
&zWPtr[indexMultiwordHi( 4, 3 )],
|
||||
-exp,
|
||||
&zWPtr[indexMultiwordHi( 4, 3 )]
|
||||
);
|
||||
exp = 0;
|
||||
sig = (uint64_t) zWPtr[indexWordHi( 4 )]<<32;
|
||||
}
|
||||
zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp, sig>>32 );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
zWPtr[indexWord( 4, 3 )] = uiZ96;
|
||||
zWPtr[indexWord( 4, 2 )] = 0;
|
||||
zWPtr[indexWord( 4, 1 )] = 0;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,112 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
sw_float16_t extF80M_to_f16( const sw_extFloat80_t *aPtr )
|
||||
{
|
||||
|
||||
return extF80_to_f16( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
sw_float16_t extF80M_to_f16( const sw_extFloat80_t *aPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint16_t uiZ, sig16;
|
||||
union ui16_f16 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF16UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF16UI( sign, 0x1F, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sig ) {
|
||||
uiZ = packToF16UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
exp += softfloat_normExtF80SigM( &sig );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig16 = softfloat_shortShiftRightJam64( sig, 49 );
|
||||
exp -= 0x3FF1;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
|
||||
if ( exp < -0x40 ) exp = -0x40;
|
||||
}
|
||||
return softfloat_roundPackToF16( sign, exp, sig16 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,112 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
sw_float32_t extF80M_to_f32( const sw_extFloat80_t *aPtr )
|
||||
{
|
||||
|
||||
return extF80_to_f32( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
sw_float32_t extF80M_to_f32( const sw_extFloat80_t *aPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint32_t uiZ, sig32;
|
||||
union ui32_f32 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF32UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF32UI( sign, 0xFF, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sig ) {
|
||||
uiZ = packToF32UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
exp += softfloat_normExtF80SigM( &sig );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig32 = softfloat_shortShiftRightJam64( sig, 33 );
|
||||
exp -= 0x3F81;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
|
||||
if ( exp < -0x1000 ) exp = -0x1000;
|
||||
}
|
||||
return softfloat_roundPackToF32( sign, exp, sig32 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,112 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
sw_float64_t extF80M_to_f64( const sw_extFloat80_t *aPtr )
|
||||
{
|
||||
|
||||
return extF80_to_f64( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
sw_float64_t extF80M_to_f64( const sw_extFloat80_t *aPtr )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint64_t uiZ;
|
||||
union ui64_f64 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF64UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF64UI( sign, 0x7FF, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sig ) {
|
||||
uiZ = packToF64UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
exp += softfloat_normExtF80SigM( &sig );
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig = softfloat_shortShiftRightJam64( sig, 1 );
|
||||
exp -= 0x3C01;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
|
||||
if ( exp < -0x1000 ) exp = -0x1000;
|
||||
}
|
||||
return softfloat_roundPackToF64( sign, exp, sig );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,100 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
int_fast32_t
|
||||
extF80M_to_i32(
|
||||
const sw_extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_i32( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int_fast32_t
|
||||
extF80M_to_i32(
|
||||
const sw_extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x4032 - exp;
|
||||
if ( shiftDist <= 0 ) {
|
||||
if ( sig>>32 ) goto invalid;
|
||||
if ( -32 < shiftDist ) {
|
||||
sig <<= -shiftDist;
|
||||
} else {
|
||||
if ( (uint32_t) sig ) goto invalid;
|
||||
}
|
||||
} else {
|
||||
sig = softfloat_shiftRightJam64( sig, shiftDist );
|
||||
}
|
||||
return softfloat_roundToI32( sign, sig, roundingMode, exact );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i32_fromNaN
|
||||
: sign ? i32_fromNegOverflow : i32_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,120 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
int_fast32_t extF80M_to_i32_r_minMag( const sw_extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_i32_r_minMag( *aPtr, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int_fast32_t extF80M_to_i32_r_minMag( const sw_extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
bool sign, raiseInexact;
|
||||
int32_t z;
|
||||
uint64_t shiftedSig;
|
||||
uint32_t absZ;
|
||||
union { uint32_t ui; int32_t i; } u;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! sig && (exp != 0x7FFF) ) return 0;
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
raiseInexact = exact;
|
||||
z = 0;
|
||||
} else {
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
raiseInexact = false;
|
||||
if ( shiftDist < 0 ) {
|
||||
if ( sig>>32 || (shiftDist <= -31) ) goto invalid;
|
||||
shiftedSig = (uint64_t) (uint32_t) sig<<-shiftDist;
|
||||
if ( shiftedSig>>32 ) goto invalid;
|
||||
absZ = shiftedSig;
|
||||
} else {
|
||||
shiftedSig = sig;
|
||||
if ( shiftDist ) shiftedSig >>= shiftDist;
|
||||
if ( shiftedSig>>32 ) goto invalid;
|
||||
absZ = shiftedSig;
|
||||
if ( exact && shiftDist ) {
|
||||
raiseInexact = ((uint64_t) absZ<<shiftDist != sig);
|
||||
}
|
||||
}
|
||||
if ( sign ) {
|
||||
if ( 0x80000000 < absZ ) goto invalid;
|
||||
u.ui = -absZ;
|
||||
z = u.i;
|
||||
} else {
|
||||
if ( 0x80000000 <= absZ ) goto invalid;
|
||||
z = absZ;
|
||||
}
|
||||
}
|
||||
if ( raiseInexact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
return z;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i32_fromNaN
|
||||
: sign ? i32_fromNegOverflow : i32_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,97 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
int_fast64_t
|
||||
extF80M_to_i64(
|
||||
const sw_extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_i64( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int_fast64_t
|
||||
extF80M_to_i64(
|
||||
const sw_extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
uint32_t extSig[3];
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( shiftDist < 0 ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? i64_fromNaN
|
||||
: sign ? i64_fromNegOverflow : i64_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
extSig[indexWord( 3, 2 )] = sig>>32;
|
||||
extSig[indexWord( 3, 1 )] = sig;
|
||||
extSig[indexWord( 3, 0 )] = 0;
|
||||
if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
|
||||
return softfloat_roundMToI64( sign, extSig, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,115 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
int_fast64_t extF80M_to_i64_r_minMag( const sw_extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_i64_r_minMag( *aPtr, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int_fast64_t extF80M_to_i64_r_minMag( const sw_extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
bool sign, raiseInexact;
|
||||
int64_t z;
|
||||
uint64_t absZ;
|
||||
union { uint64_t ui; int64_t i; } u;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! sig && (exp != 0x7FFF) ) return 0;
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
raiseInexact = exact;
|
||||
z = 0;
|
||||
} else {
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
raiseInexact = false;
|
||||
if ( shiftDist < 0 ) {
|
||||
if ( shiftDist <= -63 ) goto invalid;
|
||||
shiftDist = -shiftDist;
|
||||
absZ = sig<<shiftDist;
|
||||
if ( absZ>>shiftDist != sig ) goto invalid;
|
||||
} else {
|
||||
absZ = sig;
|
||||
if ( shiftDist ) absZ >>= shiftDist;
|
||||
if ( exact && shiftDist ) raiseInexact = (absZ<<shiftDist != sig);
|
||||
}
|
||||
if ( sign ) {
|
||||
if ( UINT64_C( 0x8000000000000000 ) < absZ ) goto invalid;
|
||||
u.ui = -absZ;
|
||||
z = u.i;
|
||||
} else {
|
||||
if ( UINT64_C( 0x8000000000000000 ) <= absZ ) goto invalid;
|
||||
z = absZ;
|
||||
}
|
||||
}
|
||||
if ( raiseInexact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
return z;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ? i64_fromNaN
|
||||
: sign ? i64_fromNegOverflow : i64_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,101 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
uint_fast32_t
|
||||
extF80M_to_ui32(
|
||||
const sw_extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_ui32( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint_fast32_t
|
||||
extF80M_to_ui32(
|
||||
const sw_extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x4032 - exp;
|
||||
if ( shiftDist <= 0 ) {
|
||||
if ( sig>>32 ) goto invalid;
|
||||
if ( -32 < shiftDist ) {
|
||||
sig <<= -shiftDist;
|
||||
} else {
|
||||
if ( (uint32_t) sig ) goto invalid;
|
||||
}
|
||||
} else {
|
||||
sig = softfloat_shiftRightJam64( sig, shiftDist );
|
||||
}
|
||||
return softfloat_roundToUI32( sign, sig, roundingMode, exact );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui32_fromNaN
|
||||
: sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,111 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
uint_fast32_t extF80M_to_ui32_r_minMag( const sw_extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_ui32_r_minMag( *aPtr, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint_fast32_t extF80M_to_ui32_r_minMag( const sw_extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
bool sign;
|
||||
uint64_t shiftedSig;
|
||||
uint32_t z;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! sig && (exp != 0x7FFF) ) return 0;
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
if ( shiftDist < 0 ) {
|
||||
if ( sign || sig>>32 || (shiftDist <= -31) ) goto invalid;
|
||||
shiftedSig = (uint64_t) (uint32_t) sig<<-shiftDist;
|
||||
if ( shiftedSig>>32 ) goto invalid;
|
||||
z = shiftedSig;
|
||||
} else {
|
||||
shiftedSig = sig;
|
||||
if ( shiftDist ) shiftedSig >>= shiftDist;
|
||||
if ( shiftedSig>>32 ) goto invalid;
|
||||
z = shiftedSig;
|
||||
if ( sign && z ) goto invalid;
|
||||
if ( exact && shiftDist && ((uint64_t) z<<shiftDist != sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui32_fromNaN
|
||||
: sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,97 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
uint_fast64_t
|
||||
extF80M_to_ui64(
|
||||
const sw_extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_ui64( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint_fast64_t
|
||||
extF80M_to_ui64(
|
||||
const sw_extFloat80_t *aPtr, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
uint32_t extSig[3];
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( shiftDist < 0 ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui64_fromNaN
|
||||
: sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
extSig[indexWord( 3, 2 )] = sig>>32;
|
||||
extSig[indexWord( 3, 1 )] = sig;
|
||||
extSig[indexWord( 3, 0 )] = 0;
|
||||
if ( shiftDist ) softfloat_shiftRightJam96M( extSig, shiftDist, extSig );
|
||||
return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,108 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
uint_fast64_t extF80M_to_ui64_r_minMag( const sw_extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
|
||||
return extF80_to_ui64_r_minMag( *aPtr, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint_fast64_t extF80M_to_ui64_r_minMag( const sw_extFloat80_t *aPtr, bool exact )
|
||||
{
|
||||
const struct extFloat80M *aSPtr;
|
||||
uint_fast16_t uiA64;
|
||||
int32_t exp;
|
||||
uint64_t sig;
|
||||
int32_t shiftDist;
|
||||
bool sign;
|
||||
uint64_t z;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aSPtr = (const struct extFloat80M *) aPtr;
|
||||
uiA64 = aSPtr->signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = aSPtr->signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! sig && (exp != 0x7FFF) ) return 0;
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
if ( shiftDist < 0 ) {
|
||||
if ( sign || (shiftDist <= -63) ) goto invalid;
|
||||
shiftDist = -shiftDist;
|
||||
z = sig<<shiftDist;
|
||||
if ( z>>shiftDist != sig ) goto invalid;
|
||||
} else {
|
||||
z = sig;
|
||||
if ( shiftDist ) z >>= shiftDist;
|
||||
if ( sign && z ) goto invalid;
|
||||
if ( exact && shiftDist && (z<<shiftDist != sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
}
|
||||
return z;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui64_fromNaN
|
||||
: sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,80 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
sw_extFloat80_t extF80_add( sw_extFloat80_t a, sw_extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signB;
|
||||
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
|
||||
sw_extFloat80_t
|
||||
(*magsFuncPtr)(
|
||||
uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
|
||||
#endif
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
||||
if ( signA == signB ) {
|
||||
return softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
} else {
|
||||
return softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
}
|
||||
#else
|
||||
magsFuncPtr =
|
||||
(signA == signB) ? softfloat_addMagsExtF80 : softfloat_subMagsExtF80;
|
||||
return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -1,203 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
sw_extFloat80_t extF80_div( sw_extFloat80_t a, sw_extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
int_fast32_t expA;
|
||||
uint_fast64_t sigA;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signB;
|
||||
int_fast32_t expB;
|
||||
uint_fast64_t sigB;
|
||||
bool signZ;
|
||||
struct exp32_sig64 normExpSig;
|
||||
int_fast32_t expZ;
|
||||
struct uint128 rem;
|
||||
uint_fast32_t recip32;
|
||||
uint_fast64_t sigZ;
|
||||
int ix;
|
||||
uint_fast64_t q64;
|
||||
uint_fast32_t q;
|
||||
struct uint128 term;
|
||||
uint_fast64_t sigZExtra;
|
||||
struct uint128 uiZ;
|
||||
uint_fast16_t uiZ64;
|
||||
uint_fast64_t uiZ0;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
sigA = uiA0;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
expB = expExtF80UI64( uiB64 );
|
||||
sigB = uiB0;
|
||||
signZ = signA ^ signB;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA == 0x7FFF ) {
|
||||
if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
|
||||
if ( expB == 0x7FFF ) {
|
||||
if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
|
||||
goto invalid;
|
||||
}
|
||||
goto infinity;
|
||||
}
|
||||
if ( expB == 0x7FFF ) {
|
||||
if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
|
||||
goto zero;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expB ) expB = 1;
|
||||
if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigB ) {
|
||||
if ( ! sigA ) goto invalid;
|
||||
softfloat_raiseFlags( softfloat_flag_infinite );
|
||||
goto infinity;
|
||||
}
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
|
||||
expB += normExpSig.exp;
|
||||
sigB = normExpSig.sig;
|
||||
}
|
||||
if ( ! expA ) expA = 1;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
|
||||
expA += normExpSig.exp;
|
||||
sigA = normExpSig.sig;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA - expB + 0x3FFF;
|
||||
if ( sigA < sigB ) {
|
||||
--expZ;
|
||||
rem = softfloat_shortShiftLeft128( 0, sigA, 32 );
|
||||
} else {
|
||||
rem = softfloat_shortShiftLeft128( 0, sigA, 31 );
|
||||
}
|
||||
recip32 = softfloat_approxRecip32_1( sigB>>32 );
|
||||
sigZ = 0;
|
||||
ix = 2;
|
||||
for (;;) {
|
||||
q64 = (uint_fast64_t) (uint32_t) (rem.v64>>2) * recip32;
|
||||
q = (q64 + 0x80000000)>>32;
|
||||
--ix;
|
||||
if ( ix < 0 ) break;
|
||||
rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
|
||||
term = softfloat_mul64ByShifted32To128( sigB, q );
|
||||
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
|
||||
--q;
|
||||
rem = softfloat_add128( rem.v64, rem.v0, sigB>>32, sigB<<32 );
|
||||
}
|
||||
sigZ = (sigZ<<29) + q;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ((q + 1) & 0x3FFFFF) < 2 ) {
|
||||
rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
|
||||
term = softfloat_mul64ByShifted32To128( sigB, q );
|
||||
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
term = softfloat_shortShiftLeft128( 0, sigB, 32 );
|
||||
if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
|
||||
--q;
|
||||
rem = softfloat_add128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
} else if ( softfloat_le128( term.v64, term.v0, rem.v64, rem.v0 ) ) {
|
||||
++q;
|
||||
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
}
|
||||
if ( rem.v64 | rem.v0 ) q |= 1;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sigZ = (sigZ<<6) + (q>>23);
|
||||
sigZExtra = (uint64_t) ((uint_fast64_t) q<<41);
|
||||
return
|
||||
softfloat_roundPackToExtF80(
|
||||
signZ, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
propagateNaN:
|
||||
uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
|
||||
uiZ64 = uiZ.v64;
|
||||
uiZ0 = uiZ.v0;
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
uiZ64 = defaultNaNExtF80UI64;
|
||||
uiZ0 = defaultNaNExtF80UI0;
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
infinity:
|
||||
uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
|
||||
uiZ0 = UINT64_C( 0x8000000000000000 );
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ64 = packToExtF80UI64( signZ, 0 );
|
||||
uiZ0 = 0;
|
||||
uiZ:
|
||||
uZ.s.signExp = uiZ64;
|
||||
uZ.s.signif = uiZ0;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
@ -1,73 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_eq( sw_extFloat80_t a, sw_extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
if (
|
||||
softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
|
||||
|| softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return
|
||||
(uiA0 == uiB0)
|
||||
&& ((uiA64 == uiB64) || (! uiA0 && ! ((uiA64 | uiB64) & 0x7FFF)));
|
||||
|
||||
}
|
||||
|
@ -1,67 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_eq_signaling( sw_extFloat80_t a, sw_extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
return
|
||||
(uiA0 == uiB0)
|
||||
&& ((uiA64 == uiB64) || (! uiA0 && ! ((uiA64 | uiB64) & 0x7FFF)));
|
||||
|
||||
}
|
||||
|
@ -1,51 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_isSignalingNaN( sw_extFloat80_t a )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
|
||||
uA.f = a;
|
||||
return softfloat_isSigNaNExtF80UI( uA.s.signExp, uA.s.signif );
|
||||
|
||||
}
|
||||
|
@ -1,73 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_le( sw_extFloat80_t a, sw_extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signA, signB;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
return
|
||||
(signA != signB)
|
||||
? signA || ! (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
|
||||
: ((uiA64 == uiB64) && (uiA0 == uiB0))
|
||||
|| (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
|
||||
|
||||
}
|
||||
|
@ -1,78 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_le_quiet( sw_extFloat80_t a, sw_extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signA, signB;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
if (
|
||||
softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
|
||||
|| softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
return
|
||||
(signA != signB)
|
||||
? signA || ! (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
|
||||
: ((uiA64 == uiB64) && (uiA0 == uiB0))
|
||||
|| (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
|
||||
|
||||
}
|
||||
|
@ -1,73 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_lt( sw_extFloat80_t a, sw_extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signA, signB;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
return
|
||||
(signA != signB)
|
||||
? signA && (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
|
||||
: ((uiA64 != uiB64) || (uiA0 != uiB0))
|
||||
&& (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
|
||||
|
||||
}
|
||||
|
@ -1,78 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
bool extF80_lt_quiet( sw_extFloat80_t a, sw_extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signA, signB;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
|
||||
if (
|
||||
softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
|
||||
|| softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
return
|
||||
(signA != signB)
|
||||
? signA && (((uiA64 | uiB64) & 0x7FFF) | uiA0 | uiB0)
|
||||
: ((uiA64 != uiB64) || (uiA0 != uiB0))
|
||||
&& (signA ^ softfloat_lt128( uiA64, uiA0, uiB64, uiB0 ));
|
||||
|
||||
}
|
||||
|
@ -1,158 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
sw_extFloat80_t extF80_mul( sw_extFloat80_t a, sw_extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
int_fast32_t expA;
|
||||
uint_fast64_t sigA;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signB;
|
||||
int_fast32_t expB;
|
||||
uint_fast64_t sigB;
|
||||
bool signZ;
|
||||
uint_fast64_t magBits;
|
||||
struct exp32_sig64 normExpSig;
|
||||
int_fast32_t expZ;
|
||||
struct uint128 sig128Z, uiZ;
|
||||
uint_fast16_t uiZ64;
|
||||
uint_fast64_t uiZ0;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
sigA = uiA0;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
expB = expExtF80UI64( uiB64 );
|
||||
sigB = uiB0;
|
||||
signZ = signA ^ signB;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA == 0x7FFF ) {
|
||||
if (
|
||||
(sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
|| ((expB == 0x7FFF) && (sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
|
||||
) {
|
||||
goto propagateNaN;
|
||||
}
|
||||
magBits = expB | sigB;
|
||||
goto infArg;
|
||||
}
|
||||
if ( expB == 0x7FFF ) {
|
||||
if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
|
||||
magBits = expA | sigA;
|
||||
goto infArg;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expA ) expA = 1;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
|
||||
expA += normExpSig.exp;
|
||||
sigA = normExpSig.sig;
|
||||
}
|
||||
if ( ! expB ) expB = 1;
|
||||
if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigB ) goto zero;
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
|
||||
expB += normExpSig.exp;
|
||||
sigB = normExpSig.sig;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA + expB - 0x3FFE;
|
||||
sig128Z = softfloat_mul64To128( sigA, sigB );
|
||||
if ( sig128Z.v64 < UINT64_C( 0x8000000000000000 ) ) {
|
||||
--expZ;
|
||||
sig128Z =
|
||||
softfloat_add128(
|
||||
sig128Z.v64, sig128Z.v0, sig128Z.v64, sig128Z.v0 );
|
||||
}
|
||||
return
|
||||
softfloat_roundPackToExtF80(
|
||||
signZ, expZ, sig128Z.v64, sig128Z.v0, extF80_roundingPrecision );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
propagateNaN:
|
||||
uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
|
||||
uiZ64 = uiZ.v64;
|
||||
uiZ0 = uiZ.v0;
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
infArg:
|
||||
if ( ! magBits ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
uiZ64 = defaultNaNExtF80UI64;
|
||||
uiZ0 = defaultNaNExtF80UI0;
|
||||
} else {
|
||||
uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
|
||||
uiZ0 = UINT64_C( 0x8000000000000000 );
|
||||
}
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ64 = packToExtF80UI64( signZ, 0 );
|
||||
uiZ0 = 0;
|
||||
uiZ:
|
||||
uZ.s.signExp = uiZ64;
|
||||
uZ.s.signif = uiZ0;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
@ -1,225 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
sw_extFloat80_t extF80_rem( sw_extFloat80_t a, sw_extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
int_fast32_t expA;
|
||||
uint_fast64_t sigA;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
int_fast32_t expB;
|
||||
uint_fast64_t sigB;
|
||||
struct exp32_sig64 normExpSig;
|
||||
int_fast32_t expDiff;
|
||||
struct uint128 rem, shiftedSigB;
|
||||
uint_fast32_t q, recip32;
|
||||
uint_fast64_t q64;
|
||||
struct uint128 term, altRem, meanRem;
|
||||
bool signRem;
|
||||
struct uint128 uiZ;
|
||||
uint_fast16_t uiZ64;
|
||||
uint_fast64_t uiZ0;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
sigA = uiA0;
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
expB = expExtF80UI64( uiB64 );
|
||||
sigB = uiB0;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA == 0x7FFF ) {
|
||||
if (
|
||||
(sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
|| ((expB == 0x7FFF) && (sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
|
||||
) {
|
||||
goto propagateNaN;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if ( expB == 0x7FFF ) {
|
||||
if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
|
||||
/*--------------------------------------------------------------------
|
||||
| Argument b is an infinity. Doubling `expB' is an easy way to ensure
|
||||
| that `expDiff' later is less than -1, which will result in returning
|
||||
| a canonicalized version of argument a.
|
||||
*--------------------------------------------------------------------*/
|
||||
expB += expB;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expB ) expB = 1;
|
||||
if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigB ) goto invalid;
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigB );
|
||||
expB += normExpSig.exp;
|
||||
sigB = normExpSig.sig;
|
||||
}
|
||||
if ( ! expA ) expA = 1;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) {
|
||||
expA = 0;
|
||||
goto copyA;
|
||||
}
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
|
||||
expA += normExpSig.exp;
|
||||
sigA = normExpSig.sig;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expDiff = expA - expB;
|
||||
if ( expDiff < -1 ) goto copyA;
|
||||
rem = softfloat_shortShiftLeft128( 0, sigA, 32 );
|
||||
shiftedSigB = softfloat_shortShiftLeft128( 0, sigB, 32 );
|
||||
if ( expDiff < 1 ) {
|
||||
if ( expDiff ) {
|
||||
--expB;
|
||||
shiftedSigB = softfloat_shortShiftLeft128( 0, sigB, 33 );
|
||||
q = 0;
|
||||
} else {
|
||||
q = (sigB <= sigA);
|
||||
if ( q ) {
|
||||
rem =
|
||||
softfloat_sub128(
|
||||
rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
recip32 = softfloat_approxRecip32_1( sigB>>32 );
|
||||
expDiff -= 30;
|
||||
for (;;) {
|
||||
q64 = (uint_fast64_t) (uint32_t) (rem.v64>>2) * recip32;
|
||||
if ( expDiff < 0 ) break;
|
||||
q = (q64 + 0x80000000)>>32;
|
||||
rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
|
||||
term = softfloat_mul64ByShifted32To128( sigB, q );
|
||||
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
|
||||
rem =
|
||||
softfloat_add128(
|
||||
rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
|
||||
}
|
||||
expDiff -= 29;
|
||||
}
|
||||
/*--------------------------------------------------------------------
|
||||
| (`expDiff' cannot be less than -29 here.)
|
||||
*--------------------------------------------------------------------*/
|
||||
q = (uint32_t) (q64>>32)>>(~expDiff & 31);
|
||||
rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, expDiff + 30 );
|
||||
term = softfloat_mul64ByShifted32To128( sigB, q );
|
||||
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
|
||||
altRem =
|
||||
softfloat_add128(
|
||||
rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
|
||||
goto selectRem;
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
do {
|
||||
altRem = rem;
|
||||
++q;
|
||||
rem =
|
||||
softfloat_sub128(
|
||||
rem.v64, rem.v0, shiftedSigB.v64, shiftedSigB.v0 );
|
||||
} while ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) );
|
||||
selectRem:
|
||||
meanRem = softfloat_add128( rem.v64, rem.v0, altRem.v64, altRem.v0 );
|
||||
if (
|
||||
(meanRem.v64 & UINT64_C( 0x8000000000000000 ))
|
||||
|| (! (meanRem.v64 | meanRem.v0) && (q & 1))
|
||||
) {
|
||||
rem = altRem;
|
||||
}
|
||||
signRem = signA;
|
||||
if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
|
||||
signRem = ! signRem;
|
||||
rem = softfloat_sub128( 0, 0, rem.v64, rem.v0 );
|
||||
}
|
||||
return
|
||||
softfloat_normRoundPackToExtF80(
|
||||
signRem, rem.v64 | rem.v0 ? expB + 32 : 0, rem.v64, rem.v0, 80 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
propagateNaN:
|
||||
uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
|
||||
uiZ64 = uiZ.v64;
|
||||
uiZ0 = uiZ.v0;
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
uiZ64 = defaultNaNExtF80UI64;
|
||||
uiZ0 = defaultNaNExtF80UI0;
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
copyA:
|
||||
if ( expA < 1 ) {
|
||||
sigA >>= 1 - expA;
|
||||
expA = 0;
|
||||
}
|
||||
uiZ64 = packToExtF80UI64( signA, expA );
|
||||
uiZ0 = sigA;
|
||||
uiZ:
|
||||
uZ.s.signExp = uiZ64;
|
||||
uZ.s.signif = uiZ0;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
@ -1,154 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
sw_extFloat80_t
|
||||
extF80_roundToInt( sw_extFloat80_t a, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64, signUI64;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sigA;
|
||||
uint_fast16_t uiZ64;
|
||||
uint_fast64_t sigZ;
|
||||
struct exp32_sig64 normExpSig;
|
||||
struct uint128 uiZ;
|
||||
uint_fast64_t lastBitMask, roundBitsMask;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
signUI64 = uiA64 & packToExtF80UI64( 1, 0 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sigA = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( !(sigA & UINT64_C( 0x8000000000000000 )) && (exp != 0x7FFF) ) {
|
||||
if ( !sigA ) {
|
||||
uiZ64 = signUI64;
|
||||
sigZ = 0;
|
||||
goto uiZ;
|
||||
}
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
|
||||
exp += normExpSig.exp;
|
||||
sigA = normExpSig.sig;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( 0x403E <= exp ) {
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
uiZ = softfloat_propagateNaNExtF80UI( uiA64, sigA, 0, 0 );
|
||||
uiZ64 = uiZ.v64;
|
||||
sigZ = uiZ.v0;
|
||||
goto uiZ;
|
||||
}
|
||||
sigZ = UINT64_C( 0x8000000000000000 );
|
||||
} else {
|
||||
sigZ = sigA;
|
||||
}
|
||||
uiZ64 = signUI64 | exp;
|
||||
goto uiZ;
|
||||
}
|
||||
if ( exp <= 0x3FFE ) {
|
||||
if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
switch ( roundingMode ) {
|
||||
case softfloat_round_near_even:
|
||||
if ( !(sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) break;
|
||||
case softfloat_round_near_maxMag:
|
||||
if ( exp == 0x3FFE ) goto mag1;
|
||||
break;
|
||||
case softfloat_round_min:
|
||||
if ( signUI64 ) goto mag1;
|
||||
break;
|
||||
case softfloat_round_max:
|
||||
if ( !signUI64 ) goto mag1;
|
||||
break;
|
||||
#ifdef SOFTFLOAT_ROUND_ODD
|
||||
case softfloat_round_odd:
|
||||
goto mag1;
|
||||
#endif
|
||||
}
|
||||
uiZ64 = signUI64;
|
||||
sigZ = 0;
|
||||
goto uiZ;
|
||||
mag1:
|
||||
uiZ64 = signUI64 | 0x3FFF;
|
||||
sigZ = UINT64_C( 0x8000000000000000 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ64 = signUI64 | exp;
|
||||
lastBitMask = (uint_fast64_t) 1<<(0x403E - exp);
|
||||
roundBitsMask = lastBitMask - 1;
|
||||
sigZ = sigA;
|
||||
if ( roundingMode == softfloat_round_near_maxMag ) {
|
||||
sigZ += lastBitMask>>1;
|
||||
} else if ( roundingMode == softfloat_round_near_even ) {
|
||||
sigZ += lastBitMask>>1;
|
||||
if ( !(sigZ & roundBitsMask) ) sigZ &= ~lastBitMask;
|
||||
} else if (
|
||||
roundingMode == (signUI64 ? softfloat_round_min : softfloat_round_max)
|
||||
) {
|
||||
sigZ += roundBitsMask;
|
||||
}
|
||||
sigZ &= ~roundBitsMask;
|
||||
if ( !sigZ ) {
|
||||
++uiZ64;
|
||||
sigZ = UINT64_C( 0x8000000000000000 );
|
||||
}
|
||||
if ( sigZ != sigA ) {
|
||||
#ifdef SOFTFLOAT_ROUND_ODD
|
||||
if ( roundingMode == softfloat_round_odd ) sigZ |= lastBitMask;
|
||||
#endif
|
||||
if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
uiZ:
|
||||
uZ.s.signExp = uiZ64;
|
||||
uZ.s.signif = sigZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
@ -1,176 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
sw_extFloat80_t extF80_sqrt( sw_extFloat80_t a )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
int_fast32_t expA;
|
||||
uint_fast64_t sigA;
|
||||
struct uint128 uiZ;
|
||||
uint_fast16_t uiZ64;
|
||||
uint_fast64_t uiZ0;
|
||||
struct exp32_sig64 normExpSig;
|
||||
int_fast32_t expZ;
|
||||
uint_fast32_t sig32A, recipSqrt32, sig32Z;
|
||||
struct uint128 rem;
|
||||
uint_fast64_t q, x64, sigZ;
|
||||
struct uint128 y, term;
|
||||
uint_fast64_t sigZExtra;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
expA = expExtF80UI64( uiA64 );
|
||||
sigA = uiA0;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA == 0x7FFF ) {
|
||||
if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, 0, 0 );
|
||||
uiZ64 = uiZ.v64;
|
||||
uiZ0 = uiZ.v0;
|
||||
goto uiZ;
|
||||
}
|
||||
if ( ! signA ) return a;
|
||||
goto invalid;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( signA ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
goto invalid;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! expA ) expA = 1;
|
||||
if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
|
||||
if ( ! sigA ) goto zero;
|
||||
normExpSig = softfloat_normSubnormalExtF80Sig( sigA );
|
||||
expA += normExpSig.exp;
|
||||
sigA = normExpSig.sig;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
| (`sig32Z' is guaranteed to be a lower bound on the square root of
|
||||
| `sig32A', which makes `sig32Z' also a lower bound on the square root of
|
||||
| `sigA'.)
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = ((expA - 0x3FFF)>>1) + 0x3FFF;
|
||||
expA &= 1;
|
||||
sig32A = sigA>>32;
|
||||
recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
|
||||
sig32Z = ((uint_fast64_t) sig32A * recipSqrt32)>>32;
|
||||
if ( expA ) {
|
||||
sig32Z >>= 1;
|
||||
rem = softfloat_shortShiftLeft128( 0, sigA, 61 );
|
||||
} else {
|
||||
rem = softfloat_shortShiftLeft128( 0, sigA, 62 );
|
||||
}
|
||||
rem.v64 -= (uint_fast64_t) sig32Z * sig32Z;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = ((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32;
|
||||
x64 = (uint_fast64_t) sig32Z<<32;
|
||||
sigZ = x64 + (q<<3);
|
||||
y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
|
||||
/*------------------------------------------------------------------------
|
||||
| (Repeating this loop is a rare occurrence.)
|
||||
*------------------------------------------------------------------------*/
|
||||
for (;;) {
|
||||
term = softfloat_mul64ByShifted32To128( x64 + sigZ, q );
|
||||
rem = softfloat_sub128( y.v64, y.v0, term.v64, term.v0 );
|
||||
if ( ! (rem.v64 & UINT64_C( 0x8000000000000000 )) ) break;
|
||||
--q;
|
||||
sigZ -= 1<<3;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = (((rem.v64>>2) * recipSqrt32)>>32) + 2;
|
||||
x64 = sigZ;
|
||||
sigZ = (sigZ<<1) + (q>>25);
|
||||
sigZExtra = (uint64_t) (q<<39);
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (q & 0xFFFFFF) <= 2 ) {
|
||||
q &= ~(uint_fast64_t) 0xFFFF;
|
||||
sigZExtra = (uint64_t) (q<<39);
|
||||
term = softfloat_mul64ByShifted32To128( x64 + (q>>27), q );
|
||||
x64 = (uint32_t) (q<<5) * (uint_fast64_t) (uint32_t) q;
|
||||
term = softfloat_add128( term.v64, term.v0, 0, x64 );
|
||||
rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 28 );
|
||||
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
|
||||
if ( rem.v64 & UINT64_C( 0x8000000000000000 ) ) {
|
||||
if ( ! sigZExtra ) --sigZ;
|
||||
--sigZExtra;
|
||||
} else {
|
||||
if ( rem.v64 | rem.v0 ) sigZExtra |= 1;
|
||||
}
|
||||
}
|
||||
return
|
||||
softfloat_roundPackToExtF80(
|
||||
0, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
uiZ64 = defaultNaNExtF80UI64;
|
||||
uiZ0 = defaultNaNExtF80UI0;
|
||||
goto uiZ;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ64 = packToExtF80UI64( signA, 0 );
|
||||
uiZ0 = 0;
|
||||
uiZ:
|
||||
uZ.s.signExp = uiZ64;
|
||||
uZ.s.signif = uiZ0;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
@ -1,80 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
sw_extFloat80_t extF80_sub( sw_extFloat80_t a, sw_extFloat80_t b )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool signA;
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uB;
|
||||
uint_fast16_t uiB64;
|
||||
uint_fast64_t uiB0;
|
||||
bool signB;
|
||||
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
|
||||
sw_extFloat80_t
|
||||
(*magsFuncPtr)(
|
||||
uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
|
||||
#endif
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
signA = signExtF80UI64( uiA64 );
|
||||
uB.f = b;
|
||||
uiB64 = uB.s.signExp;
|
||||
uiB0 = uB.s.signif;
|
||||
signB = signExtF80UI64( uiB64 );
|
||||
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
||||
if ( signA == signB ) {
|
||||
return softfloat_subMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
} else {
|
||||
return softfloat_addMagsExtF80( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
}
|
||||
#else
|
||||
magsFuncPtr =
|
||||
(signA == signB) ? softfloat_subMagsExtF80 : softfloat_addMagsExtF80;
|
||||
return (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -1,75 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
sw_float128_t extF80_to_f128( sw_extFloat80_t a )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
uint_fast16_t exp;
|
||||
uint_fast64_t frac;
|
||||
struct commonNaN commonNaN;
|
||||
struct uint128 uiZ;
|
||||
bool sign;
|
||||
struct uint128 frac128;
|
||||
union ui128_f128 uZ;
|
||||
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
frac = uiA0 & UINT64_C( 0x7FFFFFFFFFFFFFFF );
|
||||
if ( (exp == 0x7FFF) && frac ) {
|
||||
softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF128UI( &commonNaN );
|
||||
} else {
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
frac128 = softfloat_shortShiftLeft128( 0, frac, 49 );
|
||||
uiZ.v64 = packToF128UI64( sign, exp, frac128.v64 );
|
||||
uiZ.v0 = frac128.v0;
|
||||
}
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
@ -1,96 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
sw_float16_t extF80_to_f16( sw_extFloat80_t a )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint_fast16_t uiZ, sig16;
|
||||
union ui16_f16 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uiA0;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF16UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF16UI( sign, 0x1F, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig16 = softfloat_shortShiftRightJam64( sig, 49 );
|
||||
if ( ! (exp | sig16) ) {
|
||||
uiZ = packToF16UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
exp -= 0x3FF1;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
|
||||
if ( exp < -0x40 ) exp = -0x40;
|
||||
}
|
||||
return softfloat_roundPackToF16( sign, exp, sig16 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
@ -1,96 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
sw_float32_t extF80_to_f32( sw_extFloat80_t a )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint_fast32_t uiZ, sig32;
|
||||
union ui32_f32 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uiA0;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF32UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF32UI( sign, 0xFF, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig32 = softfloat_shortShiftRightJam64( sig, 33 );
|
||||
if ( ! (exp | sig32) ) {
|
||||
uiZ = packToF32UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
exp -= 0x3F81;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
|
||||
if ( exp < -0x1000 ) exp = -0x1000;
|
||||
}
|
||||
return softfloat_roundPackToF32( sign, exp, sig32 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
@ -1,96 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
sw_float64_t extF80_to_f64( sw_extFloat80_t a )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
uint_fast64_t uiA0;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
struct commonNaN commonNaN;
|
||||
uint_fast64_t uiZ;
|
||||
union ui64_f64 uZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
uiA0 = uA.s.signif;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uiA0;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ! (exp | sig) ) {
|
||||
uiZ = packToF64UI( sign, 0, 0 );
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp == 0x7FFF ) {
|
||||
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
|
||||
softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
|
||||
uiZ = softfloat_commonNaNToF64UI( &commonNaN );
|
||||
} else {
|
||||
uiZ = packToF64UI( sign, 0x7FF, 0 );
|
||||
}
|
||||
goto uiZ;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sig = softfloat_shortShiftRightJam64( sig, 1 );
|
||||
exp -= 0x3C01;
|
||||
if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
|
||||
if ( exp < -0x1000 ) exp = -0x1000;
|
||||
}
|
||||
return softfloat_roundPackToF64( sign, exp, sig );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiZ:
|
||||
uZ.ui = uiZ;
|
||||
return uZ.f;
|
||||
|
||||
}
|
||||
|
@ -1,83 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
int_fast32_t
|
||||
extF80_to_i32( sw_extFloat80_t a, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
#if (i32_fromNaN != i32_fromPosOverflow) || (i32_fromNaN != i32_fromNegOverflow)
|
||||
if ( (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
|
||||
#if (i32_fromNaN == i32_fromPosOverflow)
|
||||
sign = 0;
|
||||
#elif (i32_fromNaN == i32_fromNegOverflow)
|
||||
sign = 1;
|
||||
#else
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return i32_fromNaN;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x4032 - exp;
|
||||
if ( shiftDist <= 0 ) shiftDist = 1;
|
||||
sig = softfloat_shiftRightJam64( sig, shiftDist );
|
||||
return softfloat_roundToI32( sign, sig, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
@ -1,97 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
int_fast32_t extF80_to_i32_r_minMag( sw_extFloat80_t a, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
bool sign;
|
||||
int_fast32_t absZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
if ( exact && (exp | sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
if ( shiftDist < 33 ) {
|
||||
if (
|
||||
(uiA64 == packToExtF80UI64( 1, 0x401E ))
|
||||
&& (sig < UINT64_C( 0x8000000100000000 ))
|
||||
) {
|
||||
if ( exact && (sig & UINT64_C( 0x00000000FFFFFFFF )) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return -0x7FFFFFFF - 1;
|
||||
}
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? i32_fromNaN
|
||||
: sign ? i32_fromNegOverflow : i32_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
absZ = sig>>shiftDist;
|
||||
if ( exact && ((uint_fast64_t) (uint_fast32_t) absZ<<shiftDist != sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return sign ? -absZ : absZ;
|
||||
|
||||
}
|
||||
|
@ -1,89 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
int_fast64_t
|
||||
extF80_to_i64( sw_extFloat80_t a, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
uint_fast64_t sigExtra;
|
||||
struct uint64_extra sig64Extra;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( shiftDist <= 0 ) {
|
||||
/*--------------------------------------------------------------------
|
||||
*--------------------------------------------------------------------*/
|
||||
if ( shiftDist ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? i64_fromNaN
|
||||
: sign ? i64_fromNegOverflow : i64_fromPosOverflow;
|
||||
}
|
||||
/*--------------------------------------------------------------------
|
||||
*--------------------------------------------------------------------*/
|
||||
sigExtra = 0;
|
||||
} else {
|
||||
/*--------------------------------------------------------------------
|
||||
*--------------------------------------------------------------------*/
|
||||
sig64Extra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
|
||||
sig = sig64Extra.v;
|
||||
sigExtra = sig64Extra.extra;
|
||||
}
|
||||
return softfloat_roundToI64( sign, sig, sigExtra, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
@ -1,94 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
int_fast64_t extF80_to_i64_r_minMag( sw_extFloat80_t a, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
bool sign;
|
||||
int_fast64_t absZ;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
if ( exact && (exp | sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
if ( shiftDist <= 0 ) {
|
||||
if (
|
||||
(uiA64 == packToExtF80UI64( 1, 0x403E ))
|
||||
&& (sig == UINT64_C( 0x8000000000000000 ))
|
||||
) {
|
||||
return -INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1;
|
||||
}
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? i64_fromNaN
|
||||
: sign ? i64_fromNegOverflow : i64_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
absZ = sig>>shiftDist;
|
||||
if ( exact && (uint64_t) (sig<<(-shiftDist & 63)) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return sign ? -absZ : absZ;
|
||||
|
||||
}
|
||||
|
@ -1,83 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
uint_fast32_t
|
||||
extF80_to_ui32( sw_extFloat80_t a, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
#if (ui32_fromNaN != ui32_fromPosOverflow) || (ui32_fromNaN != ui32_fromNegOverflow)
|
||||
if ( (exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
|
||||
#if (ui32_fromNaN == ui32_fromPosOverflow)
|
||||
sign = 0;
|
||||
#elif (ui32_fromNaN == ui32_fromNegOverflow)
|
||||
sign = 1;
|
||||
#else
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return ui32_fromNaN;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x4032 - exp;
|
||||
if ( shiftDist <= 0 ) shiftDist = 1;
|
||||
sig = softfloat_shiftRightJam64( sig, shiftDist );
|
||||
return softfloat_roundToUI32( sign, sig, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
@ -1,88 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
uint_fast32_t extF80_to_ui32_r_minMag( sw_extFloat80_t a, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
bool sign;
|
||||
uint_fast32_t z;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
if ( exact && (exp | sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
if ( sign || (shiftDist < 32) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui32_fromNaN
|
||||
: sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
z = sig>>shiftDist;
|
||||
if ( exact && ((uint_fast64_t) z<<shiftDist != sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return z;
|
||||
|
||||
}
|
||||
|
@ -1,84 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
|
||||
University of California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
uint_fast64_t
|
||||
extF80_to_ui64( sw_extFloat80_t a, uint_fast8_t roundingMode, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
bool sign;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
uint_fast64_t sigExtra;
|
||||
struct uint64_extra sig64Extra;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( shiftDist < 0 ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui64_fromNaN
|
||||
: sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sigExtra = 0;
|
||||
if ( shiftDist ) {
|
||||
sig64Extra = softfloat_shiftRightJam64Extra( sig, 0, shiftDist );
|
||||
sig = sig64Extra.v;
|
||||
sigExtra = sig64Extra.extra;
|
||||
}
|
||||
return softfloat_roundToUI64( sign, sig, sigExtra, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
@ -1,88 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
uint_fast64_t extF80_to_ui64_r_minMag( sw_extFloat80_t a, bool exact )
|
||||
{
|
||||
union { struct extFloat80M s; sw_extFloat80_t f; } uA;
|
||||
uint_fast16_t uiA64;
|
||||
int_fast32_t exp;
|
||||
uint_fast64_t sig;
|
||||
int_fast32_t shiftDist;
|
||||
bool sign;
|
||||
uint_fast64_t z;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uA.f = a;
|
||||
uiA64 = uA.s.signExp;
|
||||
exp = expExtF80UI64( uiA64 );
|
||||
sig = uA.s.signif;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
shiftDist = 0x403E - exp;
|
||||
if ( 64 <= shiftDist ) {
|
||||
if ( exact && (exp | sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
sign = signExtF80UI64( uiA64 );
|
||||
if ( sign || (shiftDist < 0) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return
|
||||
(exp == 0x7FFF) && (sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
|
||||
? ui64_fromNaN
|
||||
: sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
z = sig>>shiftDist;
|
||||
if ( exact && (z<<shiftDist != sig) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
return z;
|
||||
|
||||
}
|
||||
|
@ -1,97 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
f128M_add( const sw_float128_t *aPtr, const sw_float128_t *bPtr, sw_float128_t *zPtr )
|
||||
{
|
||||
const uint64_t *aWPtr, *bWPtr;
|
||||
uint_fast64_t uiA64, uiA0;
|
||||
bool signA;
|
||||
uint_fast64_t uiB64, uiB0;
|
||||
bool signB;
|
||||
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 2)
|
||||
sw_float128_t
|
||||
(*magsFuncPtr)(
|
||||
uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
|
||||
#endif
|
||||
|
||||
aWPtr = (const uint64_t *) aPtr;
|
||||
bWPtr = (const uint64_t *) bPtr;
|
||||
uiA64 = aWPtr[indexWord( 2, 1 )];
|
||||
uiA0 = aWPtr[indexWord( 2, 0 )];
|
||||
signA = signF128UI64( uiA64 );
|
||||
uiB64 = bWPtr[indexWord( 2, 1 )];
|
||||
uiB0 = bWPtr[indexWord( 2, 0 )];
|
||||
signB = signF128UI64( uiB64 );
|
||||
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
|
||||
if ( signA == signB ) {
|
||||
*zPtr = softfloat_addMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
} else {
|
||||
*zPtr = softfloat_subMagsF128( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
}
|
||||
#else
|
||||
magsFuncPtr =
|
||||
(signA == signB) ? softfloat_addMagsF128 : softfloat_subMagsF128;
|
||||
*zPtr = (*magsFuncPtr)( uiA64, uiA0, uiB64, uiB0, signA );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
f128M_add( const sw_float128_t *aPtr, const sw_float128_t *bPtr, sw_float128_t *zPtr )
|
||||
{
|
||||
|
||||
softfloat_addF128M(
|
||||
(const uint32_t *) aPtr,
|
||||
(const uint32_t *) bPtr,
|
||||
(uint32_t *) zPtr,
|
||||
false
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,187 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
f128M_div( const sw_float128_t *aPtr, const sw_float128_t *bPtr, sw_float128_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = f128_div( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
f128M_div( const sw_float128_t *aPtr, const sw_float128_t *bPtr, sw_float128_t *zPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t *zWPtr, uiA96;
|
||||
bool signA;
|
||||
int32_t expA;
|
||||
uint32_t uiB96;
|
||||
bool signB;
|
||||
int32_t expB;
|
||||
bool signZ;
|
||||
uint32_t y[5], sigB[4];
|
||||
int32_t expZ;
|
||||
uint32_t recip32;
|
||||
int ix;
|
||||
uint64_t q64;
|
||||
uint32_t q, qs[3], uiZ96;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
zWPtr = (uint32_t *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
signA = signF128UI96( uiA96 );
|
||||
expA = expF128UI96( uiA96 );
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
signB = signF128UI96( uiB96 );
|
||||
expB = expF128UI96( uiB96 );
|
||||
signZ = signA ^ signB;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
|
||||
if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
|
||||
if ( expA == 0x7FFF ) {
|
||||
if ( expB == 0x7FFF ) goto invalid;
|
||||
goto infinity;
|
||||
}
|
||||
goto zero;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expA = softfloat_shiftNormSigF128M( aWPtr, 13, y );
|
||||
expB = softfloat_shiftNormSigF128M( bWPtr, 13, sigB );
|
||||
if ( expA == -128 ) {
|
||||
if ( expB == -128 ) goto invalid;
|
||||
goto zero;
|
||||
}
|
||||
if ( expB == -128 ) {
|
||||
softfloat_raiseFlags( softfloat_flag_infinite );
|
||||
goto infinity;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA - expB + 0x3FFE;
|
||||
if ( softfloat_compare128M( y, sigB ) < 0 ) {
|
||||
--expZ;
|
||||
softfloat_add128M( y, y, y );
|
||||
}
|
||||
recip32 =
|
||||
softfloat_approxRecip32_1(
|
||||
((uint64_t) sigB[indexWord( 4, 3 )]<<32 | sigB[indexWord( 4, 2 )])
|
||||
>>30
|
||||
);
|
||||
ix = 3;
|
||||
for (;;) {
|
||||
q64 = (uint64_t) y[indexWordHi( 4 )] * recip32;
|
||||
q = (q64 + 0x80000000)>>32;
|
||||
--ix;
|
||||
if ( ix < 0 ) break;
|
||||
softfloat_remStep128MBy32( y, 29, sigB, q, y );
|
||||
if ( y[indexWordHi( 4 )] & 0x80000000 ) {
|
||||
--q;
|
||||
softfloat_add128M( y, sigB, y );
|
||||
}
|
||||
qs[ix] = q;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( ((q + 1) & 7) < 2 ) {
|
||||
softfloat_remStep128MBy32( y, 29, sigB, q, y );
|
||||
if ( y[indexWordHi( 4 )] & 0x80000000 ) {
|
||||
--q;
|
||||
softfloat_add128M( y, sigB, y );
|
||||
} else if ( softfloat_compare128M( sigB, y ) <= 0 ) {
|
||||
++q;
|
||||
softfloat_sub128M( y, sigB, y );
|
||||
}
|
||||
if (
|
||||
y[indexWordLo( 4 )] || y[indexWord( 4, 1 )]
|
||||
|| (y[indexWord( 4, 2 )] | y[indexWord( 4, 3 )])
|
||||
) {
|
||||
q |= 1;
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q64 = (uint64_t) q<<28;
|
||||
y[indexWord( 5, 0 )] = q64;
|
||||
q64 = ((uint64_t) qs[0]<<25) + (q64>>32);
|
||||
y[indexWord( 5, 1 )] = q64;
|
||||
q64 = ((uint64_t) qs[1]<<22) + (q64>>32);
|
||||
y[indexWord( 5, 2 )] = q64;
|
||||
q64 = ((uint64_t) qs[2]<<19) + (q64>>32);
|
||||
y[indexWord( 5, 3 )] = q64;
|
||||
y[indexWord( 5, 4 )] = q64>>32;
|
||||
softfloat_roundPackMToF128M( signZ, expZ, y, zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_invalidF128M( zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
infinity:
|
||||
uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
|
||||
goto uiZ96;
|
||||
zero:
|
||||
uiZ96 = packToF128UI96( signZ, 0, 0 );
|
||||
uiZ96:
|
||||
zWPtr[indexWordHi( 4 )] = uiZ96;
|
||||
zWPtr[indexWord( 4, 2 )] = 0;
|
||||
zWPtr[indexWord( 4, 1 )] = 0;
|
||||
zWPtr[indexWord( 4, 0 )] = 0;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,100 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool f128M_eq( const sw_float128_t *aPtr, const sw_float128_t *bPtr )
|
||||
{
|
||||
|
||||
return f128_eq( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool f128M_eq( const sw_float128_t *aPtr, const sw_float128_t *bPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t wordA, wordB, uiA96, uiB96;
|
||||
bool possibleOppositeZeros;
|
||||
uint32_t mashWord;
|
||||
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
wordA = aWPtr[indexWord( 4, 2 )];
|
||||
wordB = bWPtr[indexWord( 4, 2 )];
|
||||
if ( wordA != wordB ) goto false_checkSigNaNs;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
possibleOppositeZeros = false;
|
||||
if ( uiA96 != uiB96 ) {
|
||||
possibleOppositeZeros = (((uiA96 | uiB96) & 0x7FFFFFFF) == 0);
|
||||
if ( ! possibleOppositeZeros ) goto false_checkSigNaNs;
|
||||
}
|
||||
mashWord = wordA | wordB;
|
||||
wordA = aWPtr[indexWord( 4, 1 )];
|
||||
wordB = bWPtr[indexWord( 4, 1 )];
|
||||
if ( wordA != wordB ) goto false_checkSigNaNs;
|
||||
mashWord |= wordA | wordB;
|
||||
wordA = aWPtr[indexWord( 4, 0 )];
|
||||
wordB = bWPtr[indexWord( 4, 0 )];
|
||||
if ( wordA != wordB ) goto false_checkSigNaNs;
|
||||
if ( possibleOppositeZeros && ((mashWord | wordA | wordB) != 0) ) {
|
||||
goto false_checkSigNaNs;
|
||||
}
|
||||
if ( ! softfloat_isNaNF128M( aWPtr ) && ! softfloat_isNaNF128M( bWPtr ) ) {
|
||||
return true;
|
||||
}
|
||||
false_checkSigNaNs:
|
||||
if (
|
||||
f128M_isSignalingNaN( (const sw_float128_t *) aWPtr )
|
||||
|| f128M_isSignalingNaN( (const sw_float128_t *) bWPtr )
|
||||
) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,92 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool f128M_eq_signaling( const sw_float128_t *aPtr, const sw_float128_t *bPtr )
|
||||
{
|
||||
|
||||
return f128_eq_signaling( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool f128M_eq_signaling( const sw_float128_t *aPtr, const sw_float128_t *bPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t wordA, wordB, uiA96, uiB96;
|
||||
bool possibleOppositeZeros;
|
||||
uint32_t mashWord;
|
||||
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
wordA = aWPtr[indexWord( 4, 2 )];
|
||||
wordB = bWPtr[indexWord( 4, 2 )];
|
||||
if ( wordA != wordB ) return false;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
possibleOppositeZeros = false;
|
||||
if ( uiA96 != uiB96 ) {
|
||||
possibleOppositeZeros = (((uiA96 | uiB96) & 0x7FFFFFFF) == 0);
|
||||
if ( ! possibleOppositeZeros ) return false;
|
||||
}
|
||||
mashWord = wordA | wordB;
|
||||
wordA = aWPtr[indexWord( 4, 1 )];
|
||||
wordB = bWPtr[indexWord( 4, 1 )];
|
||||
if ( wordA != wordB ) return false;
|
||||
mashWord |= wordA | wordB;
|
||||
wordA = aWPtr[indexWord( 4, 0 )];
|
||||
wordB = bWPtr[indexWord( 4, 0 )];
|
||||
return
|
||||
(wordA == wordB)
|
||||
&& (! possibleOppositeZeros || ((mashWord | wordA | wordB) == 0));
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,60 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "primitives.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool f128M_isSignalingNaN( const sw_float128_t *aPtr )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t uiA96;
|
||||
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
if ( (uiA96 & 0x7FFF8000) != 0x7FFF0000 ) return false;
|
||||
return
|
||||
((uiA96 & 0x00007FFF) != 0)
|
||||
|| ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
|
||||
| aWPtr[indexWord( 4, 0 )])
|
||||
!= 0);
|
||||
|
||||
}
|
||||
|
@ -1,93 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool f128M_le( const sw_float128_t *aPtr, const sw_float128_t *bPtr )
|
||||
{
|
||||
|
||||
return f128_le( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool f128M_le( const sw_float128_t *aPtr, const sw_float128_t *bPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t uiA96, uiB96;
|
||||
bool signA, signB;
|
||||
uint32_t wordA, wordB;
|
||||
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
signA = signF128UI96( uiA96 );
|
||||
signB = signF128UI96( uiB96 );
|
||||
if ( signA != signB ) {
|
||||
if ( signA ) return true;
|
||||
if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return false;
|
||||
wordA = aWPtr[indexWord( 4, 2 )];
|
||||
wordB = bWPtr[indexWord( 4, 2 )];
|
||||
if ( wordA | wordB ) return false;
|
||||
wordA = aWPtr[indexWord( 4, 1 )];
|
||||
wordB = bWPtr[indexWord( 4, 1 )];
|
||||
if ( wordA | wordB ) return false;
|
||||
wordA = aWPtr[indexWord( 4, 0 )];
|
||||
wordB = bWPtr[indexWord( 4, 0 )];
|
||||
return ((wordA | wordB) == 0);
|
||||
}
|
||||
if ( signA ) {
|
||||
aWPtr = (const uint32_t *) bPtr;
|
||||
bWPtr = (const uint32_t *) aPtr;
|
||||
}
|
||||
return (softfloat_compare128M( aWPtr, bWPtr ) <= 0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,96 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool f128M_le_quiet( const sw_float128_t *aPtr, const sw_float128_t *bPtr )
|
||||
{
|
||||
|
||||
return f128_le_quiet( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool f128M_le_quiet( const sw_float128_t *aPtr, const sw_float128_t *bPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t uiA96, uiB96;
|
||||
bool signA, signB;
|
||||
uint32_t wordA, wordB;
|
||||
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
|
||||
if ( f128M_isSignalingNaN( aPtr ) || f128M_isSignalingNaN( bPtr ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
signA = signF128UI96( uiA96 );
|
||||
signB = signF128UI96( uiB96 );
|
||||
if ( signA != signB ) {
|
||||
if ( signA ) return true;
|
||||
if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return false;
|
||||
wordA = aWPtr[indexWord( 4, 2 )];
|
||||
wordB = bWPtr[indexWord( 4, 2 )];
|
||||
if ( wordA | wordB ) return false;
|
||||
wordA = aWPtr[indexWord( 4, 1 )];
|
||||
wordB = bWPtr[indexWord( 4, 1 )];
|
||||
if ( wordA | wordB ) return false;
|
||||
wordA = aWPtr[indexWord( 4, 0 )];
|
||||
wordB = bWPtr[indexWord( 4, 0 )];
|
||||
return ((wordA | wordB) == 0);
|
||||
}
|
||||
if ( signA ) {
|
||||
aWPtr = (const uint32_t *) bPtr;
|
||||
bWPtr = (const uint32_t *) aPtr;
|
||||
}
|
||||
return (softfloat_compare128M( aWPtr, bWPtr ) <= 0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,93 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool f128M_lt( const sw_float128_t *aPtr, const sw_float128_t *bPtr )
|
||||
{
|
||||
|
||||
return f128_lt( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool f128M_lt( const sw_float128_t *aPtr, const sw_float128_t *bPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t uiA96, uiB96;
|
||||
bool signA, signB;
|
||||
uint32_t wordA, wordB;
|
||||
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
return false;
|
||||
}
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
signA = signF128UI96( uiA96 );
|
||||
signB = signF128UI96( uiB96 );
|
||||
if ( signA != signB ) {
|
||||
if ( signB ) return false;
|
||||
if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return true;
|
||||
wordA = aWPtr[indexWord( 4, 2 )];
|
||||
wordB = bWPtr[indexWord( 4, 2 )];
|
||||
if ( wordA | wordB ) return true;
|
||||
wordA = aWPtr[indexWord( 4, 1 )];
|
||||
wordB = bWPtr[indexWord( 4, 1 )];
|
||||
if ( wordA | wordB ) return true;
|
||||
wordA = aWPtr[indexWord( 4, 0 )];
|
||||
wordB = bWPtr[indexWord( 4, 0 )];
|
||||
return ((wordA | wordB) != 0);
|
||||
}
|
||||
if ( signA ) {
|
||||
aWPtr = (const uint32_t *) bPtr;
|
||||
bWPtr = (const uint32_t *) aPtr;
|
||||
}
|
||||
return (softfloat_compare128M( aWPtr, bWPtr ) < 0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,96 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
bool f128M_lt_quiet( const sw_float128_t *aPtr, const sw_float128_t *bPtr )
|
||||
{
|
||||
|
||||
return f128_lt_quiet( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool f128M_lt_quiet( const sw_float128_t *aPtr, const sw_float128_t *bPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t uiA96, uiB96;
|
||||
bool signA, signB;
|
||||
uint32_t wordA, wordB;
|
||||
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
if ( softfloat_isNaNF128M( aWPtr ) || softfloat_isNaNF128M( bWPtr ) ) {
|
||||
if ( f128M_isSignalingNaN( aPtr ) || f128M_isSignalingNaN( bPtr ) ) {
|
||||
softfloat_raiseFlags( softfloat_flag_invalid );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
signA = signF128UI96( uiA96 );
|
||||
signB = signF128UI96( uiB96 );
|
||||
if ( signA != signB ) {
|
||||
if ( signB ) return false;
|
||||
if ( (uiA96 | uiB96) & 0x7FFFFFFF ) return true;
|
||||
wordA = aWPtr[indexWord( 4, 2 )];
|
||||
wordB = bWPtr[indexWord( 4, 2 )];
|
||||
if ( wordA | wordB ) return true;
|
||||
wordA = aWPtr[indexWord( 4, 1 )];
|
||||
wordB = bWPtr[indexWord( 4, 1 )];
|
||||
if ( wordA | wordB ) return true;
|
||||
wordA = aWPtr[indexWord( 4, 0 )];
|
||||
wordB = bWPtr[indexWord( 4, 0 )];
|
||||
return ((wordA | wordB) != 0);
|
||||
}
|
||||
if ( signA ) {
|
||||
aWPtr = (const uint32_t *) bPtr;
|
||||
bWPtr = (const uint32_t *) aPtr;
|
||||
}
|
||||
return (softfloat_compare128M( aWPtr, bWPtr ) < 0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,158 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
f128M_mul( const sw_float128_t *aPtr, const sw_float128_t *bPtr, sw_float128_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = f128_mul( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
f128M_mul( const sw_float128_t *aPtr, const sw_float128_t *bPtr, sw_float128_t *zPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t *zWPtr;
|
||||
uint32_t uiA96;
|
||||
int32_t expA;
|
||||
uint32_t uiB96;
|
||||
int32_t expB;
|
||||
bool signZ;
|
||||
const uint32_t *ptr;
|
||||
uint32_t uiZ96, sigA[4];
|
||||
uint_fast8_t shiftDist;
|
||||
uint32_t sigB[4];
|
||||
int32_t expZ;
|
||||
uint32_t sigProd[8], *extSigZPtr;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
zWPtr = (uint32_t *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
expA = expF128UI96( uiA96 );
|
||||
uiB96 = bWPtr[indexWordHi( 4 )];
|
||||
expB = expF128UI96( uiB96 );
|
||||
signZ = signF128UI96( uiA96 ) ^ signF128UI96( uiB96 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
|
||||
if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
|
||||
ptr = aWPtr;
|
||||
if ( ! expA ) goto possiblyInvalid;
|
||||
if ( ! expB ) {
|
||||
ptr = bWPtr;
|
||||
possiblyInvalid:
|
||||
if (
|
||||
! fracF128UI96( ptr[indexWordHi( 4 )] )
|
||||
&& ! (ptr[indexWord( 4, 2 )] | ptr[indexWord( 4, 1 )]
|
||||
| ptr[indexWord( 4, 0 )])
|
||||
) {
|
||||
softfloat_invalidF128M( zWPtr );
|
||||
return;
|
||||
}
|
||||
}
|
||||
uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
|
||||
goto uiZ96;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA ) {
|
||||
sigA[indexWordHi( 4 )] = fracF128UI96( uiA96 ) | 0x00010000;
|
||||
sigA[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
|
||||
sigA[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
|
||||
sigA[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
|
||||
} else {
|
||||
expA = softfloat_shiftNormSigF128M( aWPtr, 0, sigA );
|
||||
if ( expA == -128 ) goto zero;
|
||||
}
|
||||
if ( expB ) {
|
||||
sigB[indexWordHi( 4 )] = fracF128UI96( uiB96 ) | 0x00010000;
|
||||
sigB[indexWord( 4, 2 )] = bWPtr[indexWord( 4, 2 )];
|
||||
sigB[indexWord( 4, 1 )] = bWPtr[indexWord( 4, 1 )];
|
||||
sigB[indexWord( 4, 0 )] = bWPtr[indexWord( 4, 0 )];
|
||||
} else {
|
||||
expB = softfloat_shiftNormSigF128M( bWPtr, 0, sigB );
|
||||
if ( expB == -128 ) goto zero;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = expA + expB - 0x4000;
|
||||
softfloat_mul128MTo256M( sigA, sigB, sigProd );
|
||||
if (
|
||||
sigProd[indexWord( 8, 2 )]
|
||||
|| (sigProd[indexWord( 8, 1 )] | sigProd[indexWord( 8, 0 )])
|
||||
) {
|
||||
sigProd[indexWord( 8, 3 )] |= 1;
|
||||
}
|
||||
extSigZPtr = &sigProd[indexMultiwordHi( 8, 5 )];
|
||||
shiftDist = 16;
|
||||
if ( extSigZPtr[indexWordHi( 5 )] & 2 ) {
|
||||
++expZ;
|
||||
shiftDist = 15;
|
||||
}
|
||||
softfloat_shortShiftLeft160M( extSigZPtr, shiftDist, extSigZPtr );
|
||||
softfloat_roundPackMToF128M( signZ, expZ, extSigZPtr, zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
zero:
|
||||
uiZ96 = packToF128UI96( signZ, 0, 0 );
|
||||
uiZ96:
|
||||
zWPtr[indexWordHi( 4 )] = uiZ96;
|
||||
zWPtr[indexWord( 4, 2 )] = 0;
|
||||
zWPtr[indexWord( 4, 1 )] = 0;
|
||||
zWPtr[indexWord( 4, 0 )] = 0;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,92 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
f128M_mulAdd(
|
||||
const sw_float128_t *aPtr,
|
||||
const sw_float128_t *bPtr,
|
||||
const sw_float128_t *cPtr,
|
||||
sw_float128_t *zPtr
|
||||
)
|
||||
{
|
||||
const uint64_t *aWPtr, *bWPtr, *cWPtr;
|
||||
uint_fast64_t uiA64, uiA0;
|
||||
uint_fast64_t uiB64, uiB0;
|
||||
uint_fast64_t uiC64, uiC0;
|
||||
|
||||
aWPtr = (const uint64_t *) aPtr;
|
||||
bWPtr = (const uint64_t *) bPtr;
|
||||
cWPtr = (const uint64_t *) cPtr;
|
||||
uiA64 = aWPtr[indexWord( 2, 1 )];
|
||||
uiA0 = aWPtr[indexWord( 2, 0 )];
|
||||
uiB64 = bWPtr[indexWord( 2, 1 )];
|
||||
uiB0 = bWPtr[indexWord( 2, 0 )];
|
||||
uiC64 = cWPtr[indexWord( 2, 1 )];
|
||||
uiC0 = cWPtr[indexWord( 2, 0 )];
|
||||
*zPtr = softfloat_mulAddF128( uiA64, uiA0, uiB64, uiB0, uiC64, uiC0, 0 );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
f128M_mulAdd(
|
||||
const sw_float128_t *aPtr,
|
||||
const sw_float128_t *bPtr,
|
||||
const sw_float128_t *cPtr,
|
||||
sw_float128_t *zPtr
|
||||
)
|
||||
{
|
||||
|
||||
softfloat_mulAddF128M(
|
||||
(const uint32_t *) aPtr,
|
||||
(const uint32_t *) bPtr,
|
||||
(const uint32_t *) cPtr,
|
||||
(uint32_t *) zPtr,
|
||||
0
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,182 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
|
||||
All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
f128M_rem( const sw_float128_t *aPtr, const sw_float128_t *bPtr, sw_float128_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = f128_rem( *aPtr, *bPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
f128M_rem( const sw_float128_t *aPtr, const sw_float128_t *bPtr, sw_float128_t *zPtr )
|
||||
{
|
||||
const uint32_t *aWPtr, *bWPtr;
|
||||
uint32_t *zWPtr, uiA96;
|
||||
int32_t expA, expB;
|
||||
uint32_t x[4], rem1[5], *remPtr;
|
||||
bool signRem;
|
||||
int32_t expDiff;
|
||||
uint32_t q, recip32;
|
||||
uint64_t q64;
|
||||
uint32_t rem2[5], *altRemPtr, *newRemPtr, wordMeanRem;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
bWPtr = (const uint32_t *) bPtr;
|
||||
zWPtr = (uint32_t *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
expA = expF128UI96( uiA96 );
|
||||
expB = expF128UI96( bWPtr[indexWordHi( 4 )] );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
|
||||
if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
|
||||
if ( expA == 0x7FFF ) goto invalid;
|
||||
goto copyA;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( expA < expB - 1 ) goto copyA;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expB = softfloat_shiftNormSigF128M( bWPtr, 13, x );
|
||||
if ( expB == -128 ) goto invalid;
|
||||
remPtr = &rem1[indexMultiwordLo( 5, 4 )];
|
||||
expA = softfloat_shiftNormSigF128M( aWPtr, 13, remPtr );
|
||||
if ( expA == -128 ) goto copyA;
|
||||
signRem = signF128UI96( uiA96 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expDiff = expA - expB;
|
||||
if ( expDiff < 1 ) {
|
||||
if ( expDiff < -1 ) goto copyA;
|
||||
if ( expDiff ) {
|
||||
--expB;
|
||||
softfloat_add128M( x, x, x );
|
||||
q = 0;
|
||||
} else {
|
||||
q = (softfloat_compare128M( x, remPtr ) <= 0);
|
||||
if ( q ) softfloat_sub128M( remPtr, x, remPtr );
|
||||
}
|
||||
} else {
|
||||
recip32 =
|
||||
softfloat_approxRecip32_1(
|
||||
((uint64_t) x[indexWord( 4, 3 )]<<32 | x[indexWord( 4, 2 )])
|
||||
>>30
|
||||
);
|
||||
expDiff -= 30;
|
||||
for (;;) {
|
||||
q64 = (uint64_t) remPtr[indexWordHi( 4 )] * recip32;
|
||||
if ( expDiff < 0 ) break;
|
||||
q = (q64 + 0x80000000)>>32;
|
||||
softfloat_remStep128MBy32( remPtr, 29, x, q, remPtr );
|
||||
if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
|
||||
softfloat_add128M( remPtr, x, remPtr );
|
||||
}
|
||||
expDiff -= 29;
|
||||
}
|
||||
/*--------------------------------------------------------------------
|
||||
| (`expDiff' cannot be less than -29 here.)
|
||||
*--------------------------------------------------------------------*/
|
||||
q = (uint32_t) (q64>>32)>>(~expDiff & 31);
|
||||
softfloat_remStep128MBy32( remPtr, expDiff + 30, x, q, remPtr );
|
||||
if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
|
||||
altRemPtr = &rem2[indexMultiwordLo( 5, 4 )];
|
||||
softfloat_add128M( remPtr, x, altRemPtr );
|
||||
goto selectRem;
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
altRemPtr = &rem2[indexMultiwordLo( 5, 4 )];
|
||||
do {
|
||||
++q;
|
||||
newRemPtr = altRemPtr;
|
||||
softfloat_sub128M( remPtr, x, newRemPtr );
|
||||
altRemPtr = remPtr;
|
||||
remPtr = newRemPtr;
|
||||
} while ( ! (remPtr[indexWordHi( 4 )] & 0x80000000) );
|
||||
selectRem:
|
||||
softfloat_add128M( remPtr, altRemPtr, x );
|
||||
wordMeanRem = x[indexWordHi( 4 )];
|
||||
if (
|
||||
(wordMeanRem & 0x80000000)
|
||||
|| (! wordMeanRem && (q & 1) && ! x[indexWord( 4, 0 )]
|
||||
&& ! (x[indexWord( 4, 2 )] | x[indexWord( 4, 1 )]))
|
||||
) {
|
||||
remPtr = altRemPtr;
|
||||
}
|
||||
if ( remPtr[indexWordHi( 4 )] & 0x80000000 ) {
|
||||
signRem = ! signRem;
|
||||
softfloat_negX128M( remPtr );
|
||||
}
|
||||
remPtr -= indexMultiwordLo( 5, 4 );
|
||||
remPtr[indexWordHi( 5 )] = 0;
|
||||
softfloat_normRoundPackMToF128M( signRem, expB + 18, remPtr, zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_invalidF128M( zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
copyA:
|
||||
zWPtr[indexWordHi( 4 )] = uiA96;
|
||||
zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
|
||||
zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
|
||||
zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,223 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void
|
||||
f128M_roundToInt(
|
||||
const sw_float128_t *aPtr,
|
||||
uint_fast8_t roundingMode,
|
||||
bool exact,
|
||||
sw_float128_t *zPtr
|
||||
)
|
||||
{
|
||||
|
||||
*zPtr = f128_roundToInt( *aPtr, roundingMode, exact );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
f128M_roundToInt(
|
||||
const sw_float128_t *aPtr,
|
||||
uint_fast8_t roundingMode,
|
||||
bool exact,
|
||||
sw_float128_t *zPtr
|
||||
)
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t *zWPtr;
|
||||
uint32_t ui96;
|
||||
int32_t exp;
|
||||
uint32_t sigExtra;
|
||||
bool sign;
|
||||
uint_fast8_t bitPos;
|
||||
bool roundNear;
|
||||
unsigned int index, lastIndex;
|
||||
bool extra;
|
||||
uint32_t wordA, bit, wordZ;
|
||||
uint_fast8_t carry;
|
||||
uint32_t extrasMask;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
zWPtr = (uint32_t *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
ui96 = aWPtr[indexWordHi( 4 )];
|
||||
exp = expF128UI96( ui96 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( exp < 0x3FFF ) {
|
||||
zWPtr[indexWord( 4, 2 )] = 0;
|
||||
zWPtr[indexWord( 4, 1 )] = 0;
|
||||
zWPtr[indexWord( 4, 0 )] = 0;
|
||||
sigExtra = aWPtr[indexWord( 4, 2 )];
|
||||
if ( !sigExtra ) {
|
||||
sigExtra = aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )];
|
||||
}
|
||||
if ( !sigExtra && !(ui96 & 0x7FFFFFFF) ) goto ui96;
|
||||
if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
sign = signF128UI96( ui96 );
|
||||
switch ( roundingMode ) {
|
||||
case softfloat_round_near_even:
|
||||
if ( !fracF128UI96( ui96 ) && !sigExtra ) break;
|
||||
case softfloat_round_near_maxMag:
|
||||
if ( exp == 0x3FFE ) goto mag1;
|
||||
break;
|
||||
case softfloat_round_min:
|
||||
if ( sign ) goto mag1;
|
||||
break;
|
||||
case softfloat_round_max:
|
||||
if ( !sign ) goto mag1;
|
||||
break;
|
||||
#ifdef SOFTFLOAT_ROUND_ODD
|
||||
case softfloat_round_odd:
|
||||
goto mag1;
|
||||
#endif
|
||||
}
|
||||
ui96 = packToF128UI96( sign, 0, 0 );
|
||||
goto ui96;
|
||||
mag1:
|
||||
ui96 = packToF128UI96( sign, 0x3FFF, 0 );
|
||||
goto ui96;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( 0x406F <= exp ) {
|
||||
if (
|
||||
(exp == 0x7FFF)
|
||||
&& (fracF128UI96( ui96 )
|
||||
|| (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
|
||||
| aWPtr[indexWord( 4, 0 )]))
|
||||
) {
|
||||
softfloat_propagateNaNF128M( aWPtr, 0, zWPtr );
|
||||
return;
|
||||
}
|
||||
zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
|
||||
zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
|
||||
zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
|
||||
goto ui96;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
bitPos = 0x406F - exp;
|
||||
roundNear =
|
||||
(roundingMode == softfloat_round_near_maxMag)
|
||||
|| (roundingMode == softfloat_round_near_even);
|
||||
bitPos -= roundNear;
|
||||
index = indexWordLo( 4 );
|
||||
lastIndex = indexWordHi( 4 );
|
||||
extra = 0;
|
||||
for (;;) {
|
||||
wordA = aWPtr[index];
|
||||
if ( bitPos < 32 ) break;
|
||||
if ( wordA ) extra = 1;
|
||||
zWPtr[index] = 0;
|
||||
index += wordIncr;
|
||||
bitPos -= 32;
|
||||
}
|
||||
bit = (uint32_t) 1<<bitPos;
|
||||
if ( roundNear ) {
|
||||
wordZ = wordA + bit;
|
||||
carry = (wordZ < wordA);
|
||||
bit <<= 1;
|
||||
extrasMask = bit - 1;
|
||||
if ( exact && (extra || (wordA & extrasMask)) ) {
|
||||
softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
}
|
||||
if (
|
||||
(roundingMode == softfloat_round_near_even)
|
||||
&& !extra && !(wordZ & extrasMask)
|
||||
) {
|
||||
if ( !bit ) {
|
||||
zWPtr[index] = wordZ;
|
||||
index += wordIncr;
|
||||
wordZ = aWPtr[index] + carry;
|
||||
carry &= !wordZ;
|
||||
zWPtr[index] = wordZ & ~1;
|
||||
goto propagateCarry;
|
||||
}
|
||||
wordZ &= ~bit;
|
||||
}
|
||||
} else {
|
||||
wordZ = wordA;
|
||||
carry = 0;
|
||||
extrasMask = bit - 1;
|
||||
if ( extra || (wordA & extrasMask) ) {
|
||||
if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
|
||||
if (
|
||||
roundingMode
|
||||
== (signF128UI96( ui96 ) ? softfloat_round_min
|
||||
: softfloat_round_max)
|
||||
) {
|
||||
wordZ += bit;
|
||||
carry = (wordZ < wordA);
|
||||
#ifdef SOFTFLOAT_ROUND_ODD
|
||||
} else if ( roundingMode == softfloat_round_odd ) {
|
||||
wordZ |= bit;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
wordZ &= ~extrasMask;
|
||||
zWPtr[index] = wordZ;
|
||||
propagateCarry:
|
||||
while ( index != lastIndex ) {
|
||||
index += wordIncr;
|
||||
wordZ = aWPtr[index] + carry;
|
||||
zWPtr[index] = wordZ;
|
||||
carry &= !wordZ;
|
||||
}
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
ui96:
|
||||
zWPtr[indexWordHi( 4 )] = ui96;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,228 +0,0 @@
|
||||
|
||||
/*============================================================================
|
||||
|
||||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
|
||||
Package, Release 3e, by John R. Hauser.
|
||||
|
||||
Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
|
||||
California. All rights reserved.
|
||||
|
||||
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. Neither the name of the University 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 REGENTS 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 REGENTS 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 <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "platform.h"
|
||||
#include "internals.h"
|
||||
#include "specialize.h"
|
||||
#include "softfloat.h"
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
void f128M_sqrt( const sw_float128_t *aPtr, sw_float128_t *zPtr )
|
||||
{
|
||||
|
||||
*zPtr = f128_sqrt( *aPtr );
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void f128M_sqrt( const sw_float128_t *aPtr, sw_float128_t *zPtr )
|
||||
{
|
||||
const uint32_t *aWPtr;
|
||||
uint32_t *zWPtr;
|
||||
uint32_t uiA96;
|
||||
bool signA;
|
||||
int32_t rawExpA;
|
||||
uint32_t rem[6];
|
||||
int32_t expA, expZ;
|
||||
uint64_t rem64;
|
||||
uint32_t sig32A, recipSqrt32, sig32Z, qs[3], q;
|
||||
uint64_t sig64Z;
|
||||
uint32_t term[5];
|
||||
uint64_t x64;
|
||||
uint32_t y[5], rem32;
|
||||
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
aWPtr = (const uint32_t *) aPtr;
|
||||
zWPtr = (uint32_t *) zPtr;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
uiA96 = aWPtr[indexWordHi( 4 )];
|
||||
signA = signF128UI96( uiA96 );
|
||||
rawExpA = expF128UI96( uiA96 );
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( rawExpA == 0x7FFF ) {
|
||||
if (
|
||||
fracF128UI96( uiA96 )
|
||||
|| (aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
|
||||
| aWPtr[indexWord( 4, 0 )])
|
||||
) {
|
||||
softfloat_propagateNaNF128M( aWPtr, 0, zWPtr );
|
||||
return;
|
||||
}
|
||||
if ( ! signA ) goto copyA;
|
||||
goto invalid;
|
||||
}
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
expA = softfloat_shiftNormSigF128M( aWPtr, 13 - (rawExpA & 1), rem );
|
||||
if ( expA == -128 ) goto copyA;
|
||||
if ( signA ) goto invalid;
|
||||
/*------------------------------------------------------------------------
|
||||
| (`sig32Z' is guaranteed to be a lower bound on the square root of
|
||||
| `sig32A', which makes `sig32Z' also a lower bound on the square root of
|
||||
| `sigA'.)
|
||||
*------------------------------------------------------------------------*/
|
||||
expZ = ((expA - 0x3FFF)>>1) + 0x3FFE;
|
||||
expA &= 1;
|
||||
rem64 = (uint64_t) rem[indexWord( 4, 3 )]<<32 | rem[indexWord( 4, 2 )];
|
||||
if ( expA ) {
|
||||
if ( ! rawExpA ) {
|
||||
softfloat_shortShiftRight128M( rem, 1, rem );
|
||||
rem64 >>= 1;
|
||||
}
|
||||
sig32A = rem64>>29;
|
||||
} else {
|
||||
sig32A = rem64>>30;
|
||||
}
|
||||
recipSqrt32 = softfloat_approxRecipSqrt32_1( expA, sig32A );
|
||||
sig32Z = ((uint64_t) sig32A * recipSqrt32)>>32;
|
||||
if ( expA ) sig32Z >>= 1;
|
||||
qs[2] = sig32Z;
|
||||
rem64 -= (uint64_t) sig32Z * sig32Z;
|
||||
rem[indexWord( 4, 3 )] = rem64>>32;
|
||||
rem[indexWord( 4, 2 )] = rem64;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
|
||||
sig64Z = ((uint64_t) sig32Z<<32) + ((uint64_t) q<<3);
|
||||
term[indexWord( 4, 3 )] = 0;
|
||||
term[indexWord( 4, 0 )] = 0;
|
||||
/*------------------------------------------------------------------------
|
||||
| (Repeating this loop is a rare occurrence.)
|
||||
*------------------------------------------------------------------------*/
|
||||
for (;;) {
|
||||
x64 = ((uint64_t) sig32Z<<32) + sig64Z;
|
||||
term[indexWord( 4, 2 )] = x64>>32;
|
||||
term[indexWord( 4, 1 )] = x64;
|
||||
softfloat_remStep128MBy32( rem, 29, term, q, y );
|
||||
rem32 = y[indexWord( 4, 3 )];
|
||||
if ( ! (rem32 & 0x80000000) ) break;
|
||||
--q;
|
||||
sig64Z -= 1<<3;
|
||||
}
|
||||
qs[1] = q;
|
||||
rem64 = (uint64_t) rem32<<32 | y[indexWord( 4, 2 )];
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = ((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32;
|
||||
if ( rem64>>34 ) q += recipSqrt32;
|
||||
sig64Z <<= 1;
|
||||
/*------------------------------------------------------------------------
|
||||
| (Repeating this loop is a rare occurrence.)
|
||||
*------------------------------------------------------------------------*/
|
||||
for (;;) {
|
||||
x64 = sig64Z + (q>>26);
|
||||
term[indexWord( 4, 2 )] = x64>>32;
|
||||
term[indexWord( 4, 1 )] = x64;
|
||||
term[indexWord( 4, 0 )] = q<<6;
|
||||
softfloat_remStep128MBy32(
|
||||
y, 29, term, q, &rem[indexMultiwordHi( 6, 4 )] );
|
||||
rem32 = rem[indexWordHi( 6 )];
|
||||
if ( ! (rem32 & 0x80000000) ) break;
|
||||
--q;
|
||||
}
|
||||
qs[0] = q;
|
||||
rem64 = (uint64_t) rem32<<32 | rem[indexWord( 6, 4 )];
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
q = (((uint32_t) (rem64>>2) * (uint64_t) recipSqrt32)>>32) + 2;
|
||||
if ( rem64>>34 ) q += recipSqrt32;
|
||||
x64 = (uint64_t) q<<27;
|
||||
y[indexWord( 5, 0 )] = x64;
|
||||
x64 = ((uint64_t) qs[0]<<24) + (x64>>32);
|
||||
y[indexWord( 5, 1 )] = x64;
|
||||
x64 = ((uint64_t) qs[1]<<21) + (x64>>32);
|
||||
y[indexWord( 5, 2 )] = x64;
|
||||
x64 = ((uint64_t) qs[2]<<18) + (x64>>32);
|
||||
y[indexWord( 5, 3 )] = x64;
|
||||
y[indexWord( 5, 4 )] = x64>>32;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
if ( (q & 0xF) <= 2 ) {
|
||||
q &= ~3;
|
||||
y[indexWordLo( 5 )] = q<<27;
|
||||
term[indexWord( 5, 4 )] = 0;
|
||||
term[indexWord( 5, 3 )] = 0;
|
||||
term[indexWord( 5, 2 )] = 0;
|
||||
term[indexWord( 5, 1 )] = q>>6;
|
||||
term[indexWord( 5, 0 )] = q<<26;
|
||||
softfloat_sub160M( y, term, term );
|
||||
rem[indexWord( 6, 1 )] = 0;
|
||||
rem[indexWord( 6, 0 )] = 0;
|
||||
softfloat_remStep160MBy32(
|
||||
&rem[indexMultiwordLo( 6, 5 )],
|
||||
14,
|
||||
term,
|
||||
q,
|
||||
&rem[indexMultiwordLo( 6, 5 )]
|
||||
);
|
||||
rem32 = rem[indexWord( 6, 4 )];
|
||||
if ( rem32 & 0x80000000 ) {
|
||||
softfloat_sub1X160M( y );
|
||||
} else {
|
||||
if (
|
||||
rem32 || rem[indexWord( 6, 0 )] || rem[indexWord( 6, 1 )]
|
||||
|| (rem[indexWord( 6, 3 )] | rem[indexWord( 6, 2 )])
|
||||
) {
|
||||
y[indexWordLo( 5 )] |= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
softfloat_roundPackMToF128M( 0, expZ, y, zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
invalid:
|
||||
softfloat_invalidF128M( zWPtr );
|
||||
return;
|
||||
/*------------------------------------------------------------------------
|
||||
*------------------------------------------------------------------------*/
|
||||
copyA:
|
||||
zWPtr[indexWordHi( 4 )] = uiA96;
|
||||
zWPtr[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
|
||||
zWPtr[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
|
||||
zWPtr[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user