Skip to content

Commit

Permalink
Add support for fp16/fp16alt to double and double to fp16/fp16alt. Fl…
Browse files Browse the repository at this point in the history
…oatlib.c + t-elf to have it compile. This is a bit of a hack and could be done in a more generic manner
  • Loading branch information
Eric Flamand committed Nov 15, 2019
1 parent 05da5fb commit 035a62a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
46 changes: 46 additions & 0 deletions libgcc/config/riscv/floatlib.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifdef __gap9__

/* Convert half to double */
double __extendhfdf2 (float16 a1)

{
register float F;
__asm ("fcvt.s.h %0, %1" : "=r" (F) : "r" (a1) );
return F;
}

/* */

/* Convert alternative half to double */
double __extendohfdf2 (float16alt a1)

{
float F;
__asm ("fcvt.s.ah %0, %1" : "=r" (F) : "r" (a1) );
return F;
}


/* Truncate double to half*/
float16 __truncdfhf2 (double a1)

{
register float F = a1;
float16 R;
__asm ("fcvt.h.s %0, %1" : "=r" (R) : "r" (F) );
return R;

}

/* Truncate double to alternative half*/
float16alt __truncdfohf2 (double a1)

{
register float F = a1;
float16alt R;
__asm ("fcvt.ah.s %0, %1" : "=r" (R) : "r" (F) );
return R;

}

#endif
1 change: 1 addition & 0 deletions libgcc/config/riscv/t-elf
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ LIB2ADD += $(srcdir)/config/riscv/save-restore.S \
$(srcdir)/config/riscv/multi3.S \
$(srcdir)/config/riscv/div.S \
$(srcdir)/config/riscv/atomic.c \
$(srcdir)/config/riscv/floatlib.c \

0 comments on commit 035a62a

Please sign in to comment.