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/tendra4/src/installers/power/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
    Copyright (c) 1993 Open Software Foundation, Inc.
3
 
4
 
5
    All Rights Reserved
6
 
7
 
8
    Permission to use, copy, modify, and distribute this software
9
    and its documentation for any purpose and without fee is hereby
10
    granted, provided that the above copyright notice appears in all
11
    copies and that both the copyright notice and this permission
12
    notice appear in supporting documentation.
13
 
14
 
15
    OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
16
    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17
    PARTICULAR PURPOSE.
18
 
19
 
20
    IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
21
    CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
22
    LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
23
    NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
24
    WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
*/
26
 
27
/*
28
    		 Crown Copyright (c) 1997
29
 
30
    This TenDRA(r) Computer Program is subject to Copyright
31
    owned by the United Kingdom Secretary of State for Defence
32
    acting through the Defence Evaluation and Research Agency
33
    (DERA).  It is made available to Recipients with a
34
    royalty-free licence for its use, reproduction, transfer
35
    to other parties and amendment for any purpose not excluding
36
    product development provided that any such use et cetera
37
    shall be deemed to be acceptance of the following conditions:-
38
 
39
        (1) Its Recipients shall ensure that this Notice is
40
        reproduced upon any copies or amended versions of it;
41
 
42
        (2) Any amended version of it shall be clearly marked to
43
        show both the nature of and the organisation responsible
44
        for the relevant amendment or amendments;
45
 
46
        (3) Its onward transfer from a recipient to another
47
        party shall be deemed to be that party's acceptance of
48
        these conditions;
49
 
50
        (4) DERA gives no warranty or assurance as to its
51
        quality or suitability for any purpose and DERA accepts
52
        no liability whatsoever in relation to any use to which
53
        it may be put.
54
*/
55
 
56
 
57
 
58
/**********************************************************************
59
$Author: release $
60
$Date: 1998/02/04 15:48:41 $
61
$Revision: 1.2 $
62
$Log: codehere.c,v $
63
 * Revision 1.2  1998/02/04  15:48:41  release
64
 * Added OSF copyright message.
65
 *
66
 * Revision 1.1.1.1  1998/01/17  15:55:56  release
67
 * First version to be checked into rolling release.
68
 *
69
 * Revision 1.2  1996/10/04  15:59:47  pwe
70
 * add banners and mod for PWE ownership
71
 *
72
**********************************************************************/
73
 
74
 
75
#include "config.h"
76
#include "memtdf.h"
77
#include "codegen.h"
78
#include "geninst.h"
79
#include "makecode.h"
80
#include "myassert.h"
81
#include "comment.h"
82
#include "tempdecs.h"
83
#include "regable.h"
84
#include "codehere.h"
85
 
86
/* regofval returns R_NO_REG unlesss e is a name tag
87
   which is obtaining something which is inreg */
88
 
89
int regofval PROTO_N ((e)) PROTO_T (exp e)
90
{
91
  exp dc = son(e);
92
 
93
  /*********************************/
94
  /*        _________              */
95
  /* e--->  | name  |              */
96
  /*        ~~~~|~~~~              */
97
  /*        ____|____              */
98
  /* dc-->  | ident |              */ 
99
  /*        ~~~~~~~~~              */
100
  /*********************************/
101
  if (name(e) == name_tag)
102
  {
103
    ASSERT(name(dc) == ident_tag);
104
    if (props(dc) & defer_bit)
105
    {
106
      return regofval(son(dc));
107
    }
108
    if (props(dc) & inreg_bits)
109
    {
110
      /* HACK: The no(dc) is a register number 0-31 i.e positive
111
       * so by negating it if it isvar we can pass back more info
112
       */
113
      return ((isvar(dc)) ? (-no(dc)) : (no(dc)));
114
    }
115
    return R_NO_REG;
116
  }
117
  else
118
  {
119
    return R_NO_REG;
120
  }
121
}
122
/* fregofval same as regofval, but used for float regs */
123
int fregofval PROTO_N ((e)) PROTO_T (exp e)
124
{
125
  exp dc = son(e);
126
 
127
  if (name(e) == name_tag)
128
  {
129
    /*********************************/
130
    /*        _________              */
131
    /* e--->  | name  |              */
132
    /*        ~~~~|~~~~              */
133
    /*        ____|____              */
134
    /* dc-->  | ident |              */ 
135
    /*        ~~~~|~~~~              */
136
    /*********************************/
137
    ASSERT(name(dc) == ident_tag);
138
 
139
    if ((props(dc) & infreg_bits) != 0)
140
    {
141
      return no(dc);
142
    }
143
    return R_NO_REG;
144
  }
145
  else
146
  {
147
    return R_NO_REG;
148
  }
149
}
150
 
151
/* is_reg_operand returns R_NO_REG unless the exp e
152
   is in a register already. This can be due to the 
153
   fact that it is an ident in a register,
154
   or that it has been tracked in the register tracking
155
   mechanism. */
156
static int is_reg_operand PROTO_N ((e)) PROTO_T (exp e)
157
{
158
  int x = regofval(e);  
159
 
160
  if (x >= 0 && x < R_NO_REG)
161
  {
162
    /* This is the case where we are getting the
163
       contents of an ident which is not a variable,
164
       and lives in a register.*/
165
    /*********************************/
166
    /*        _________              */
167
    /* e--->  | name  |              */
168
    /*        ~~~~|~~~~              */
169
    /*        ____|____              */
170
    /*        | ident |  isvar=0     */ 
171
    /*        ~~~~|~~~~  inreg       */
172
    /*********************************/
173
    return x;
174
  }
175
 
176
  if (name(e) == cont_tag)
177
  {
178
    x = regofval(son(e));
179
    if (x < 0)
180
    {
181
      /* This is the case when we have the contents of
182
	 a variable which is inreg. Thus no one could
183
	 have taken the address of this ident, since
184
	 that would mean it was not inreg. Therefore
185
	 we have a variable living in a register. */
186
      /*********************************/
187
      /*        _________              */
188
      /* e--->  | cont  |              */
189
      /*        ~~~~|~~~~              */
190
      /*        ____|____              */
191
      /*        | name  |              */ 
192
      /*        ~~~~|~~~~              */
193
      /*        ____|____              */
194
      /*        | ident |  isvar=1     */
195
      /*        ~~~~|~~~~  inreg       */
196
      /*********************************/
197
      return (-x);
198
    }
199
  }
200
  return ans_reg(iskept_reg(e));
201
}
202
 
203
 
204
/* 
205
 * make_code_here
206
 * Calls make_code and tie up any internal exit labels 
207
 */
208
static int make_code_here PROTO_N ((e,sp,dest)) PROTO_T (exp e X space sp X where dest)
209
{
210
  makeans mka;
211
 
212
  mka = make_code(e, sp, dest, 0);
213
  if (mka.lab != 0)
214
  {
215
    clear_all();
216
    set_label(mka.lab);
217
  }
218
  return mka.regmove;
219
}
220
 
221
 
222
 
223
/* reg_operand evaluates the exp e into a register,
224
   and returns that register. is_reg_operand is used
225
   in order to activate the register tracking scheme,
226
   or to see if the exp is something simple. */
227
int reg_operand PROTO_N ((e,sp)) PROTO_T (exp e X space sp)
228
{
229
  int reg;
230
 
231
  reg = is_reg_operand(e);
232
 
233
  if (IS_R_NO_REG(reg))
234
  {
235
    /* We allow make_code_here to evaluate e into a register 
236
       of its choice by setting someregalt. */
237
    ans aa;
238
    where w;
239
 
240
    if(RETURNS_R_RESULT(e))
241
    {
242
      reg = R_RESULT;
243
      setregalt(aa,R_RESULT);
244
    }
245
    else
246
    {
247
      reg = -1;
248
      setsomeregalt(aa, &reg);
249
    }
250
 
251
    w.answhere = aa;
252
    w.ashwhere = ashof(sh(e));
253
    make_code_here(e, sp, w);
254
    keepreg(e, reg);
255
    return reg;
256
  }
257
  else
258
  {
259
    /* The exp e was found in a register by 
260
       is_reg_operand */
261
    ASSERT(IS_FIXREG(reg));
262
    return reg;
263
  }
264
}
265
 
266
 
267
/* like reg_operand, but to specified reg 
268
 */
269
void reg_operand_here PROTO_N ((e,sp,this_reg)) PROTO_T (exp e X space sp X int this_reg)
270
{
271
  int reg;
272
 
273
  ASSERT(!IS_R_NO_REG(this_reg));
274
  ASSERT(IS_FIXREG(this_reg));
275
 
276
  /* First check to see if e is lying around 
277
     in exact reg we want */
278
  reg = ans_reg(iskept_inreg(e, this_reg));
279
 
280
  if (reg == this_reg)
281
  {
282
    return;
283
  }			/* it's there, nothing to do */
284
 
285
 
286
  /* Now check to see if e is lying around in any reg */
287
 
288
  reg = is_reg_operand(e);
289
 
290
  if (IS_R_NO_REG(reg))
291
  {
292
    /* not found, evaluate to this_reg */
293
    where w;
294
 
295
    w.ashwhere = ashof(sh(e));
296
    setregalt(w.answhere, this_reg);
297
    make_code_here(e, sp, w);
298
  }
299
  else
300
  {
301
    /* e was found in a reg, move to this_reg if needed */
302
    ASSERT(IS_FIXREG(reg));
303
 
304
    if (reg != this_reg)
305
    {
306
      mov_rr_ins(reg, this_reg);comment(NIL);
307
    }
308
  }
309
  keepreg(e, this_reg);
310
}
311
 
312
 
313
int freg_operand PROTO_N ((e,sp,reg)) PROTO_T (exp e X space sp X int reg)
314
{
315
  int x = fregofval(e);
316
  ans aa;
317
  where w;
318
  freg fr;
319
 
320
  w.ashwhere = ashof(sh(e));
321
  fr.dble = (w.ashwhere.ashsize == 64) ? 1 : 0;
322
 
323
  if (x >= 0 && x < R_NO_REG)
324
  {
325
    return x;
326
  }
327
 
328
  if (name(e) == cont_tag)
329
  {
330
    x = fregofval(son(e));
331
    if (x < R_NO_REG)
332
    {
333
      return x;
334
    }
335
  }
336
  else if (RETURNS_FR_RESULT(e))
337
  {
338
    fr.fr = FR_RESULT;
339
    setfregalt(aa, fr);
340
    COMMENT("freg_operand: call of float point result proc");
341
    w.answhere = aa;
342
    /* w.ashwhere already correctly set up above */
343
    make_code(e, sp, w, 0);
344
    return FR_RESULT;
345
  }
346
 
347
  aa = iskept(e);
348
 
349
  if (aa.discrim == infreg)/* lets move this out */
350
  {
351
    freg f;
352
    f = fregalt(aa);
353
 
354
    if (f.dble == fr.dble)
355
    {
356
      return f.fr;
357
    }
358
  }
359
 
360
  /* +++ use somefreg */
361
  fr.fr = reg;
362
  setfregalt(aa, fr);
363
  w.answhere = aa;
364
  make_code_here(e, sp, w);
365
  keepexp(e, aa);
366
  return reg;
367
}
368
 
369
 
370
 
371
/*
372
 * The procedure code_here calls make_code and ensures that
373
 * any internal exit labels are tied up after the call.
374
 * Optimises the case where the value of 'e' is in a register.
375
 */
376
int code_here PROTO_N ((e,sp,dest)) PROTO_T (exp e X space sp X where dest)
377
{
378
  int reg;
379
 
380
  reg = is_reg_operand(e);
381
 
382
  if (IS_R_NO_REG(reg))
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
}