Subversion Repositories tendra.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/**********************************************************************
32
$Author: release $
33
$Date: 1998/01/17 15:56:05 $
34
$Revision: 1.1.1.1 $
35
$Log: guard.c,v $
36
 * Revision 1.1.1.1  1998/01/17  15:56:05  release
37
 * First version to be checked into rolling release.
38
 *
39
 * Revision 1.3  1995/09/12  10:59:23  currie
40
 * gcc pedanttry
41
 *
42
 * Revision 1.2  1995/08/16  16:06:42  currie
43
 * Shortened some .h names
44
 *
45
 * Revision 1.1  1995/04/13  09:08:06  currie
46
 * Initial revision
47
 *
48
***********************************************************************/
49
/****************************************************************
50
		 guard.c
51
 
52
	These routines protect registers from future use. The type
53
involved is space which consists of two long ints with bit patterns
54
taken to represent usage of temporary fixed and floating
55
point registers. These bits are used in the procedure
56
getregs which understands a clear bit to mean that the corresponding
57
register is free for use.
58
	The procedures are widely used in make_code which may use
59
getreg to choose a register to contain the result of an expression.
60
If this expression is the first operand of a binary operation (say) then the register
61
is guarded, producing another space which will be used by make_code for the
62
second operand.
63
 
64
******************************************************************/
65
 
66
 
67
#include "config.h"
68
#include "procrectypes.h"
69
#include "addrtypes.h"
70
#include "basicread.h"
71
#include "guard.h"
72
 
73
 
74
/*******************************************************************
75
The integer parameter to procedures guardreg and guardfreg
76
is taken to be a register which needs to be protected. For floating point
77
registers a factor of 2 is involved. The corresponding bit in the appropriate field of the
78
space i.e fixed or float, is therefore set.
79
********************************************************************/
80
 
81
space guardreg
82
    PROTO_N ( (r, sp) )
83
    PROTO_T ( int r X space sp )
84
{
85
  if ((r >= 2 && r <= 15) || (r >= 24 && r <= 25) || r==31) {
86
				/* r is a fixed point t reg */
87
    sp.fixed |= (1 << r);
88
  }				/* set bit in the fixed field of sp */
89
  return sp;
90
}
91
 
92
space guardfreg
93
    PROTO_N ( (r, sp) )
94
    PROTO_T ( int r X space sp )
95
{
96
  if (r<=9) {
97
				/* r is a floating point t reg */
98
    sp.flt |= (1 << r);
99
  }				/* set bit in the flt field of sp */
100
  return sp;
101
}
102
 
103
 
104
/********************************************************************
105
The procedure guard may also protect a register involved in
106
addressing depending on the value of the parameter of type where. This is a
107
union of a fixpnt reg , a float reg and an instore value. In the latter case the
108
register involved in the addressing can be deduced from the base field of the
109
instore value. These types are defined in addressingtypes.h.
110
*********************************************************************/
111
 
112
space guard
113
    PROTO_N ( (w, sp) )
114
    PROTO_T ( where w X space sp )
115
{
116
  switch (w.answhere.discrim) {
117
    case inreg:
118
      {
119
	int   r = regalt (w.answhere);
120
	if ((r >= 2 && r <= 15) || (r >= 24 && r <= 25) || r==31) {
121
	  sp.fixed |= (1 << r);
122
	}			/* guard reg */
123
	return sp;
124
      }
125
    case infreg:
126
      {
127
	int   r = fregalt (w.answhere).fr;
128
	if (r<=9) {
129
	  sp.flt |= (1 << r);
130
	}			/* guard freg */
131
	return sp;
132
      }
133
    case notinreg:
134
      {
135
	int   r = insalt (w.answhere).b.base;
136
	if ((r >= 2 && r <= 15) || (r >= 24 && r <= 25) || r==31) {
137
	  sp.fixed |= (1 << r);
138
	}
139
	/* guard fixed point t reg used as base of address */
140
	return sp;
141
      }
142
    default: {
143
	failer ("Guard ? reg ");
144
      }
145
  }
146
  return sp;
147
}