Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra5/src/installers/hppa/common/codehere.c – Rev 2

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | 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
$Log: codehere.c,v $
33
 * Revision 1.1.1.1  1998/01/17  15:56:02  release
34
 * First version to be checked into rolling release.
35
 *
36
 * Revision 1.2  1995/12/18  13:10:58  wfs
37
 * Put hppatrans uder cvs control. Major Changes made since last release
38
 * include:
39
 * (i) PIC code generation.
40
 * (ii) Profiling.
41
 * (iii) Dynamic Initialization.
42
 * (iv) Debugging of Exception Handling and Diagnostics.
43
 *
44
 * Revision 5.2  1995/10/09  13:06:48  wfs
45
 * Cosmetic changes.
46
 *
47
 * Revision 5.1  1995/09/25  09:44:17  wfs
48
 * *** empty log message ***
49
 *
50
 * Revision 5.0  1995/08/25  13:42:58  wfs
51
 * Preperation for August 25 Glue release
52
 *
53
 * Revision 3.5  1995/08/25  09:10:21  wfs
54
 * *** empty log message ***
55
 *
56
 * Revision 3.5  1995/08/25  09:10:21  wfs
57
 * *** empty log message ***
58
 *
59
 * Revision 3.4  1995/08/25  09:04:24  wfs
60
 * internal register synonyms changed to be closer to the hppa's
61
 * register names
62
 *
63
 * Revision 3.1  95/04/10  16:25:50  16:25:50  wfs (William Simmonds)
64
 * Apr95 tape version.
65
 * 
66
 * Revision 3.0  95/03/30  11:14:28  11:14:28  wfs (William Simmonds)
67
 * Mar95 tape version with CRCR95_178 bug fix.
68
 * 
69
 * Revision 2.0  95/03/15  15:25:17  15:25:17  wfs (William Simmonds)
70
 * spec 3.1 changes implemented, tests outstanding.
71
 * 
72
 * Revision 1.2  95/01/17  17:20:33  17:20:33  wfs (William Simmonds)
73
 * Changed name of an included header file.
74
 * 
75
 * Revision 1.1  95/01/11  13:02:40  13:02:40  wfs (William Simmonds)
76
 * Initial revision
77
 * 
78
*/
79
 
80
 
81
#define HPPATRANS_CODE
82
/******************************************************************
83
		code_here
84
 
85
This contains procedures :-
86
 
87
regofval, fregofval : to see if an exp is a load_tag that has been allocated to a register.
88
 
89
regoperand, freoperand : to evaluate an exp into a register using make_code
90
 
91
code_here :  calls make_code and ensures that any internal exit labels are tied up after the call
92
 
93
 
94
	The procedures regoperand and fregoperand evaluate their
95
exp parameter into a single register using make_code. This register is
96
returned. An initial test with regofval checks to see if the exp is already
97
in a register.
98
 
99
******************************************************************/
100
 
101
 
102
#include "config.h"
103
#include "myassert.h"
104
#include "common_types.h"
105
#include "addrtypes.h"
106
#include "proctypes.h"
107
#include "labels.h"
108
#include "expmacs.h"
109
#include "tags.h"
110
#include "makecode.h"
111
#include "exp.h"
112
#include "bitsmacs.h"
113
#include "locate.h"
114
#include "regexps.h"
115
#include "regmacs.h"
116
#include "inst_fmt.h"
117
#include "hppains.h"
118
#include "shapemacs.h"
119
#include "special.h"
120
#include "regable.h"
121
#include "guard.h"
122
#include "move.h"
123
#include "comment.h"
124
 
125
#include "codehere.h"
126
 
127
 
128
/*********************************************************************
129
regofval
130
The procedure regofval checks to see if an exp is a load_tag
131
that has been allocated into a fixpnt register and if so return it or else R_NO_REG.
132
*********************************************************************/
133
int regofval 
134
    PROTO_N ( ( e ) )
135
    PROTO_T ( exp e )
136
{
137
  exp dc = son(e);
138
 
139
  if (name(e) == name_tag && name(dc) == ident_tag)	/* ident tag */
140
  {
141
    if ((props(dc) & defer_bit) != 0)
142
    {
143
      return regofval(son(dc));
144
    }
145
    if ((props(dc) & inreg_bits) != 0)
146
    {
147
      return ((isvar(dc)) ? (-no(dc)) : (no(dc)));
148
    }
149
    return R_NO_REG;
150
  }
151
  else if ( (name(e) == val_tag && no(e) == 0) 
152
#if 0
153
	    || name(e) == clear_tag || name(e)== top_tag 
154
#endif
155
	  )
156
  {
157
    return 0;
158
  }
159
  else
160
  {
161
    return R_NO_REG;
162
  }
163
}
164
 
165
int fregofval 
166
    PROTO_N ( ( e ) )
167
    PROTO_T ( exp e )
168
{
169
  exp dc = son(e);
170
 
171
  if (name(e) == name_tag && name(dc) == ident_tag)
172
  {
173
    if ((props(dc) & infreg_bits) != 0)
174
    {
175
      return no(dc);
176
    }
177
    return R_NO_REG;
178
  }
179
  else
180
  {
181
    return R_NO_REG;
182
  }
183
}
184
 
185
 
186
/* calls make_code and tie up any internal exit labels */
187
static int make_code_here 
188
    PROTO_N ( ( e, sp, dest ) )
189
    PROTO_T ( exp e X space sp X where dest )
190
{
191
  makeans mka;
192
 
193
  mka = make_code(e, sp, dest, 0);
194
  if (mka.lab != 0)
195
  {
196
    clear_all();
197
    outlab("L$$",mka.lab);
198
  }
199
  return mka.regmove;
200
}
201
 
202
 
203
/* return reg if 'e' e can easily go to one reg only */
204
static int is_reg_operand 
205
    PROTO_N ( ( e, sp ) )
206
    PROTO_T ( exp e X space sp )
207
{
208
  int x = regofval(e);
209
  ans aa;
210
 
211
  if (x >= 0 && x < R_NO_REG)
212
    return x;			/* x is a register for e */
213
 
214
  if (name(e) == cont_tag)
215
  {
216
    x = regofval(son(e));
217
    if (x < 0)
218
      return (-x);
219
  }
220
 
221
  aa = iskept(e);
222
 
223
  if (discrim ( aa ) == inreg && regalt(aa) != 0)
224
  {				/* the same expression has already been
225
				 * evaluated into a reg */
226
    return regalt(aa);
227
  }
228
 
229
  if (discrim ( aa ) == notinreg)
230
  {
231
    instore is;
232
 
233
    is = insalt(aa);
234
    if (is.adval && is.b.offset == 0)
235
    {
236
      int r = is.b.base;
237
 
238
      /* the same expression has already been evaluated into a reg */
239
      return r;
240
    }
241
  }
242
 
243
  return R_NO_REG;		/* exprssion can go to many regs just as
244
				 * easily */
245
}
246
 
247
 
248
int reg_operand 
249
    PROTO_N ( ( e, sp ) )
250
    PROTO_T ( exp e X space sp )
251
{
252
  int reg;
253
 
254
  reg = is_reg_operand(e, sp);
255
 
256
  if (reg == R_NO_REG || reg == GR0)
257
  {
258
    /* allow make_code_here to evaluate e into reg of its choice */
259
    ans aa;
260
    where w;
261
 
262
    reg = -1;
263
    setsomeregalt(aa, &reg);
264
    w.answhere = aa;
265
    w.ashwhere = ashof(sh(e));
266
    make_code_here(e, sp, w);
267
    assert(reg!=-1);
268
    keepreg(e, reg);
269
    return reg;
270
  }
271
  else
272
  {
273
    /* e was found easily in a reg */
274
    assert(IS_FIXREG(reg));
275
    return reg;
276
  }
277
}
278
 
279
/* like reg_operand(), but to specified reg */
280
void reg_operand_here 
281
    PROTO_N ( ( e, sp, this_reg ) )
282
    PROTO_T ( exp e X space sp X int this_reg )
283
{
284
  int reg;
285
 
286
  assert(IS_FIXREG(this_reg) && this_reg != GR0);	/* variable fix reg */
287
 
288
 
289
  reg = is_reg_operand(e, sp);
290
 
291
  if (reg == R_NO_REG || reg == GR0)
292
  {
293
    /* evaluate to this_reg */
294
 
295
    where w;
296
 
297
    w.ashwhere = ashof(sh(e));
298
    setregalt(w.answhere, this_reg);
299
    make_code_here(e, sp, w);
300
  }
301
  else
302
  {
303
    /* e was found easily in a reg, move to this_reg if needed */
304
    assert(IS_FIXREG(reg));
305
 
306
    if (reg != this_reg)
307
       rr_ins(i_copy,reg,this_reg);
308
  }
309
 
310
  keepreg(e, this_reg);
311
}
312
 
313
 
314
int freg_operand 
315
    PROTO_N ( ( e, sp, reg ) )
316
    PROTO_T ( exp e X space sp X int reg )
317
{
318
  int x = fregofval(e);
319
  ans aa;
320
  where w;
321
  freg fr;
322
 
323
  w.ashwhere = ashof(sh(e));
324
  fr.dble = (w.ashwhere.ashsize == 64) ? 1 : 0;
325
 
326
  if (x >= 0 && x < R_NO_REG)
327
  {
328
    return x;
329
  }
330
 
331
  if (name(e) == cont_tag)
332
  {
333
    x = fregofval(son(e));
334
    if (x < R_NO_REG)
335
    {
336
      return (x);
337
    }
338
  }
339
  else if (name(e) == apply_tag)
340
  {
341
    fr.fr = R_FR4;
342
    setfregalt(aa, fr);
343
    comment("freg_operand: call of float point result proc");
344
    w.answhere = aa;
345
    /* w.ashwhere already correctly set up above */
346
    make_code(e, sp, w, 0);
347
    return R_FR4;   /* float point proc calls give result in %fr4 */
348
  }
349
 
350
  aa = iskept(e);
351
  if (discrim ( aa ) == infreg)
352
  {
353
    /* e already evaluated in fl reg */
354
    return regalt(aa) /* cheat */ ;
355
  }
356
 
357
  fr.fr = reg;
358
  setfregalt(aa, fr);
359
  w.answhere = aa;
360
  make_code_here(e, sp, w);
361
  keepexp(e, aa);
362
  return reg;
363
}
364
 
365
 
366
 
367
/*
368
 * The procedure code_here calls make_code and ensures that
369
 * any internal exit labels are tied up after the call.
370
 * Optimises the case where the value of 'e' is in a register.
371
 */
372
int code_here 
373
    PROTO_N ( ( e, sp, dest ) )
374
    PROTO_T ( exp e X space sp X where dest )
375
{
376
  int reg;
377
 
378
 
379
  reg = is_reg_operand(e, sp);
380
 
381
 
382
  if (reg == R_NO_REG || reg == GR0)
383
  {
384
    return make_code_here(e, sp, dest);
385
  }
386
  else
387
  {
388
    /* +++ do in make_code maybe */
389
    /* +++ for reals as well */
390
    /* e was found easily in a reg */
391
    ans aa;
392
 
393
    assert(IS_FIXREG(reg));
394
    assert(ashof(sh(e)).ashsize <= 32);
395
 
396
    setregalt(aa, reg);
397
    move(aa, dest, guardreg(reg, sp).fixed, 1);
398
 
399
    return reg;
400
  }
401
}
402
 
403
 
404
 
405
 
406
 
407
 
408
 
409
 
410
 
411
 
412
 
413
 
414
 
415
 
416
 
417
 
418
 
419