Re: Replacing keyword in RISC-V Fortran

2021-10-25 Thread Arjen Markus via Fortran
I am not sure I understand your question correctly, but Fortran uses the
KIND mechanism to declare the precise characteristics of floating-point
variables and constants. Typically, these are identifying integer numbers
for single precision, double precision and quadruple precision. A custom
floating-point type would mean an additional KIND number with the relevant
runtime support and support from the various intrinsic functions and
modules In the directory gcc/fortran I find several source files that use
the typedef gfc_real_info and the array of kinds gfc_rel_kinds to deal with
floating-point data of various kinds. Would that help? (Caveat: I am a mere
beginner, and perhaps not even that, when it comes to the internals of the
GCC compiler suite)

Regards,

Arjen

Op za 23 okt. 2021 om 03:28 schreef Amit Hmath via Fortran <
fortran@gcc.gnu.org>:

> Hello All,
>
> I am working on a custom float in RISC-V 32, one can replace keyword
> "float" with  custom keyword like "fp_custom" at line # 482
> riscv-gcc/gcc/c-family/c-common.c. But in the case of Fortran,  can you
> please tell which files to modify to replace the "float" keyword?
>
> And also, in case of c/c++ one can do custom encoding and decoding of
> custom floats in gcc/real.c how about in fortran for custom real data type,
> which file(s) one has to modify?
>
> Many Thanks,
> -Amit
>


Re: [PATCH,Fortran 1/7] Fortran: make some trans* functions static

2021-10-25 Thread Bernhard Reutner-Fischer via Fortran
On Mon, 25 Oct 2021 08:43:09 +0200
Tobias Burnus  wrote:

> Hi Thomas,
> 
> On 25.10.21 07:47, Thomas Koenig via Fortran wrote:
> > what you're doing seems a useful clean-up, thanks.
> >
> > One point for discussion:  
> >> -match
> >> +static match
> >>   gfc_match_label (void)  
> > I have generally understood that the gfc_ prefix is for global variables
> > and functions only.  We do not always adhere to it (also since some
> > global functions were made static previously), but I think we should
> > stick to it, unless other people think otherwise :-)  
> 
> I concur – but there is also a good reason for always having a prefix:
> It makes it more unlikely that there are name clashes between the
> middle/backend end and the FE. – And those should be strictly avoided as
> it makes debugging (in the debugger) harder. (And in particular, same
> file names should be avoided.)
> 
> I think there is also some attempt to avoid same names in multiple FE,
> but that's not as strict as long as different binaries are produced and
> 'git grep' does also show the directory.
> 
> For the readability, it could be sometimes useful to know whether a
> function is a FE function or not.
> 
> Thus, I am not sure whether it is better to always have the prefix or
> not – there are arguments for either.

I would put it the other way round:
At least global functions (and variables) should use the gfc_ prefix to
ease debugging and grep.

That said, I deliberately did not rename any of the functions, also to
avoid needless churn.
thanks,


Re: [PATCH,Fortran 0/7] delete some unused decls, make static

2021-10-25 Thread Bernhard Reutner-Fischer via Fortran
On Mon, 25 Oct 2021 00:30:16 +0200
Bernhard Reutner-Fischer  wrote:

> Hi!
> 
> Quickly skimming through the frontend headers.
> There are a couple of declarations for functions that do not have
> definitions. And there are a couple of functions that can be static.

> Bootstraps fine, regression tests running over night.
> Ok for trunk if it passes?

Tested with no regressions on x86_64-unknown-linux {-m32,-m64}.
Ok for trunk?


[Fortran] Fix broken use of alloca in C interoperability testcase

2021-10-25 Thread Sandra Loosemore
This patch is for PR102910.  There's no reason why the testcase in 
question needs to use alloca, but I wasn't aware there were portability 
issues with it until I saw this issue.


I think this fix is probably obvious and will commit it tomorrow unless 
I get some feedback on it meanwhile.


-Sandra
commit 75b603334401d079391ca950dd2e22663cdb3080
Author: Sandra Loosemore 
Date:   Mon Oct 25 11:08:28 2021 -0700

[Fortran] Fix broken use of alloca in C interoperability testcase

2021-10-25  Sandra Loosemore  

	gcc/testsuite/

	PR testsuite/102910
	* gfortran.dg/c-interop/cf-descriptor-5-c.c: Use a static buffer
	instead of alloca.

diff --git a/gcc/testsuite/gfortran.dg/c-interop/cf-descriptor-5-c.c b/gcc/testsuite/gfortran.dg/c-interop/cf-descriptor-5-c.c
index 12464b5..320a354 100644
--- a/gcc/testsuite/gfortran.dg/c-interop/cf-descriptor-5-c.c
+++ b/gcc/testsuite/gfortran.dg/c-interop/cf-descriptor-5-c.c
@@ -1,6 +1,5 @@
 #include 
 #include 
-#include 
 
 #include 
 #include "dump-descriptors.h"
@@ -8,12 +7,18 @@
 extern void ctest (int n);
 extern void ftest (CFI_cdesc_t *a, int n);
 
+#define BUFSIZE 512
+static char adata[BUFSIZE];
+
 void
 ctest (int n)
 {
   CFI_CDESC_T(0) adesc;
   CFI_cdesc_t *a = (CFI_cdesc_t *) &adesc;
-  char *adata = (char *) alloca (n);
+
+  /* Use a fixed-size static buffer instead of allocating one dynamically.  */
+  if (n > BUFSIZE)
+abort ();
 
   /* Fill in adesc.  */
   check_CFI_status ("CFI_establish",