aboutsummaryrefslogtreecommitdiff
path: root/gcc/algol68/a68-postulates.cc
blob: f291205114d483dd24feb0f1a51148c76a1ae7b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* Postulates needed for improving equivalence of modes.
   Copyright (C) 2001-2023 J. Marcel van der Veer.
   Copyright (C) 2025 Jose E. Marchesi.

   Original implementation by J. Marcel van der Veer.
   Adapted for GCC by Jose E. Marchesi.

   GCC 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 3, or (at your option)
   any later version.

   GCC 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 GCC; see the file COPYING3.  If not see
   <http://www.gnu.org/licenses/>.  */

#include "config.h"
#include "system.h"
#include "coretypes.h"

#include "a68.h"

/* Initialise use of postulate-lists.  */

void
a68_init_postulates (void)
{
  A68 (top_postulate) = NO_POSTULATE;
  A68 (top_postulate_list) = NO_POSTULATE;
}

/* Make old postulates available for new use.  */

void
a68_free_postulate_list (POSTULATE_T *start, POSTULATE_T *stop)
{
  if (start == stop)
    return;

  POSTULATE_T *last = start;
  for (; NEXT (last) != stop; FORWARD (last))
    ;

  NEXT (last) = A68 (top_postulate_list);
  A68 (top_postulate_list) = start;
}

/* Add postulates to postulate-list.  */

void
a68_make_postulate (POSTULATE_T **p, MOID_T *a, MOID_T *b)
{
  POSTULATE_T *new_one;

  if (A68 (top_postulate_list) != NO_POSTULATE)
    {
      new_one = A68 (top_postulate_list);
      A68 (top_postulate_list) = A68 (top_postulate_list)->next;
    }
  else
    {
      new_one = (POSTULATE_T *) ggc_cleared_alloc<POSTULATE_T> ();
      A68 (new_postulates)++;
    }

  new_one->a = a;
  new_one->b = b;
  new_one->next = *p;
  *p = new_one;
}

/* Where postulates are in the list.  */

POSTULATE_T
*a68_is_postulated_pair (POSTULATE_T *p, MOID_T *a, MOID_T *b)
{
  for (; p != NO_POSTULATE; p = p->next)
    {
      if (p->a == a && p->b == b)
	return p;
    }

  return NO_POSTULATE;
}

/* Where postulate is in the list.  */

POSTULATE_T
*a68_is_postulated (POSTULATE_T *p, MOID_T *a)
{
  for (; p != NO_POSTULATE; p = p->next)
    {
      if (p->a == a)
	return p;
    }

  return NO_POSTULATE;
}