public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/modula-2] M2Quads.mod allow TSIZE and TBITSIZE to calculate size of pointers.
@ 2022-03-04 18:30 Gaius Mulley
  0 siblings, 0 replies; only message in thread
From: Gaius Mulley @ 2022-03-04 18:30 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:c684b7809ef1db61e6e649b5b5771e0ff28371b8

commit c684b7809ef1db61e6e649b5b5771e0ff28371b8
Author: q <gaius.mulley@southwales.ac.uk>
Date:   Fri Mar 4 18:27:11 2022 +0000

    M2Quads.mod allow TSIZE and TBITSIZE to calculate size of pointers.
    
    This patch allows TSIZE (ptr^) irrespective of the value of ptr.
    It also allows TBITSIZE (ptr^).  It extends the solution in the
    implementation of SIZE for both TBITSIZE and TSIZE.
    
    gcc/m2/ChangeLog:
    
            * gm2-compiler/M2Quads.mod (BuildSizeCheckEnd): Extended to
            include TSize and TBitSize.  (BuildTSizeFunction) Call
            BuildSizeCheckEnd.  (BuildTBitSizeFunction) Call BuildSizeCheckEnd.
    
    gcc/testsuite/gm2/ChangeLog:
    
            * pim/run/pass/testsize4.mod:  (New file).
            * pim/run/pass/testtbitsize.mod:  (New file).
    
    Signed-off-by: <gaius.mulley@southwales.ac.uk>

Diff:
---
 gcc/m2/gm2-compiler/M2Quads.mod                 | 12 ++++----
 gcc/testsuite/gm2/pim/run/pass/testsize4.mod    | 37 +++++++++++++++++++++++++
 gcc/testsuite/gm2/pim/run/pass/testtbitsize.mod | 34 +++++++++++++++++++++++
 gm2tools/Makefile.in                            |  2 +-
 4 files changed, 79 insertions(+), 6 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod
index cb84066b1f2..a388c2ace94 100644
--- a/gcc/m2/gm2-compiler/M2Quads.mod
+++ b/gcc/m2/gm2-compiler/M2Quads.mod
@@ -4332,10 +4332,10 @@ VAR
    ProcSym, Type, tok: CARDINAL ;
 BEGIN
    PopTFtok (ProcSym, Type, tok) ;
-   IF ProcSym=Size
+   IF (ProcSym=Size) OR (ProcSym=TSize) OR (ProcSym=TBitSize)
    THEN
       QuadrupleGeneration := FALSE ;
-      BuildingSize := TRUE ;
+      BuildingSize := TRUE
    ELSIF ProcSym=High
    THEN
       QuadrupleGeneration := FALSE ;
@@ -4352,10 +4352,10 @@ END BuildSizeCheckStart ;
 
 PROCEDURE BuildSizeCheckEnd (ProcSym: CARDINAL) ;
 BEGIN
-   IF ProcSym=Size
+   IF (ProcSym=Size) OR (ProcSym=TSize) OR (ProcSym=TBitSize)
    THEN
       QuadrupleGeneration := TRUE ;
-      BuildingSize := FALSE ;
+      BuildingSize := FALSE
    ELSIF ProcSym=High
    THEN
       QuadrupleGeneration := TRUE ;
@@ -9551,6 +9551,7 @@ BEGIN
    PopT (NoOfParam) ;
    ProcSym := OperandT (NoOfParam + 1) ;
    functok := OperandTtok (NoOfParam) ;
+   BuildSizeCheckEnd (ProcSym) ;   (* quadruple generation now on *)
    IF NoOfParam = 1
    THEN
       paramtok := OperandTtok (1) ;
@@ -9562,7 +9563,7 @@ BEGIN
       ELSIF IsVar (OperandT (1))
       THEN
          ReturnVar := MakeTemporary (resulttok, ImmediateValue) ;
-         GenQuadO (resulttok, SizeOp, ReturnVar, NulSym, GetSType(OperandT(1)), FALSE)
+         GenQuadO (resulttok, SizeOp, ReturnVar, NulSym, GetSType (OperandT (1)), FALSE)
       ELSE
          MetaErrorT1 (resulttok,
                       '{%E}SYSTEM procedure function {%kTSIZE} expects a variable as its first parameter, seen {%E1d}',
@@ -9637,6 +9638,7 @@ BEGIN
    PopT (NoOfParam) ;
    ProcSym := OperandT (NoOfParam + 1) ;
    functok := OperandTtok (NoOfParam) ;
+   BuildSizeCheckEnd (ProcSym) ;   (* quadruple generation now on *)
    IF NoOfParam = 1
    THEN
       paramtok := OperandTtok (1) ;
diff --git a/gcc/testsuite/gm2/pim/run/pass/testsize4.mod b/gcc/testsuite/gm2/pim/run/pass/testsize4.mod
new file mode 100644
index 00000000000..5f9c8018e63
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/run/pass/testsize4.mod
@@ -0,0 +1,37 @@
+(* Copyright (C) 2022 Free Software Foundation, Inc. *)
+(* This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with gm2; see the file COPYING.  If not, write to the Free Software
+Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
+
+MODULE testsize4 ;
+
+FROM SYSTEM IMPORT TSIZE ;
+FROM libc IMPORT printf ;
+
+TYPE
+   ptr = POINTER TO CARDINAL ;
+
+VAR
+   foo: ptr ;
+   bar: CARDINAL ;
+BEGIN
+   foo := NIL ;
+   (* should be able to dereference an initialized pointer using TSIZE.  *)
+   bar := TSIZE (foo^) ;
+   printf ("result of TSIZE (foo^) is %d\n", bar) ;
+   (* and SIZE.  *)
+   bar := SIZE (foo^) ;
+   printf ("result of SIZE (foo^) is %d\n", bar)
+END testsize4.
diff --git a/gcc/testsuite/gm2/pim/run/pass/testtbitsize.mod b/gcc/testsuite/gm2/pim/run/pass/testtbitsize.mod
new file mode 100644
index 00000000000..1e893c73abc
--- /dev/null
+++ b/gcc/testsuite/gm2/pim/run/pass/testtbitsize.mod
@@ -0,0 +1,34 @@
+(* Copyright (C) 2022 Free Software Foundation, Inc. *)
+(* This file is part of GNU Modula-2.
+
+GNU Modula-2 is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with gm2; see the file COPYING.  If not, write to the Free Software
+Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *)
+
+MODULE testtbitsize ;
+
+FROM SYSTEM IMPORT TBITSIZE ;
+FROM libc IMPORT printf ;
+
+TYPE
+   ptr = POINTER TO CARDINAL ;
+
+VAR
+   foo: ptr ;
+   bar: CARDINAL ;
+BEGIN
+   foo := NIL ;
+   (* should be able to dereference an initialized pointer using TBITSIZE.  *)
+   bar := TBITSIZE (foo^) ;
+   printf ("result of TBITSIZE (foo^) is %d\n", bar)
+END testtbitsize.
diff --git a/gm2tools/Makefile.in b/gm2tools/Makefile.in
index d228a6a9b39..386f2e4163a 100644
--- a/gm2tools/Makefile.in
+++ b/gm2tools/Makefile.in
@@ -639,8 +639,8 @@ distclean-generic:
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
-@NATIVE_FALSE@install-exec-local:
 @NATIVE_FALSE@uninstall-local:
+@NATIVE_FALSE@install-exec-local:
 clean: clean-am
 
 clean-am: clean-binPROGRAMS clean-generic mostlyclean-am


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-04 18:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-04 18:30 [gcc/devel/modula-2] M2Quads.mod allow TSIZE and TBITSIZE to calculate size of pointers Gaius Mulley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).