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
/*
33
			    VERSION INFORMATION
34
			    ===================
35
 
36
--------------------------------------------------------------------------
37
$Header: /u/g/release/CVSROOT/Source/src/installers/sparc/common/spec_tok.c,v 1.1.1.1 1998/01/17 15:55:55 release Exp $
38
--------------------------------------------------------------------------
39
$Log: spec_tok.c,v $
40
 * Revision 1.1.1.1  1998/01/17  15:55:55  release
41
 * First version to be checked into rolling release.
42
 *
43
 * Revision 1.17  1997/10/10  18:33:06  pwe
44
 * prep ANDF-DE revision
45
 *
46
 * Revision 1.16  1997/08/23  13:54:40  pwe
47
 * initial ANDF-DE
48
 *
49
 * Revision 1.15  1997/04/04  15:23:10  pwe
50
 * tidy re old DWARF interface
51
 *
52
 * Revision 1.14  1997/02/18  11:48:30  pwe
53
 * NEWDIAGS for debugging optimised code
54
 *
55
 * Revision 1.13  1996/09/06  17:18:15  pwe
56
 * explicit next_callee_offset to correct double alignment
57
 *
58
 * Revision 1.12  1996/08/27  14:09:15  pwe
59
 * ensure all varargs are stored, and ptr is not64bit
60
 *
61
 * Revision 1.11  1996/08/23  12:07:57  pwe
62
 * treat complex parameter as struct
63
 *
64
 * Revision 1.10  1996/08/20  12:21:30  pwe
65
 * structures (etc) in varargs
66
 *
67
 * Revision 1.9  1996/08/15  16:27:03  pwe
68
 * add missing file headers
69
 *
70
 * Revision 1.8  1995/10/18  14:09:02  john
71
 * Fix to ANSI va_start
72
 *
73
 * Revision 1.7  1995/09/20  12:30:55  john
74
 * Portability fix
75
 *
76
 * Revision 1.6  1995/09/15  16:18:10  john
77
 * New token
78
 *
79
*/
80
 
81
/*
82
^^^	21/12/92  jmf	Added ~div as special token
83
^^^	26/03/93  jmf	Changes for new spec 2.1
84
^^^	24/05/93  jmf	Added ~alloca as special token, not alloc
85
^^^	10/06/93  jmf	Change long to int, remove extern declarations.
86
^^^	19/08/93  jmf	Put arith_type, promote, sign_promote, convert
87
^^^			into c_arith-type.h in machine directories.
88
^^^	19/08/93  jmf	Set crt_lno in exp_to_source
89
^^^	23/09/93  jmf	Use natmacs.h
90
--------------------------------------------------------------------------
91
*/
92
 
93
 
94
#include "config.h"
95
#include "common_types.h"
96
#include "basicread.h"
97
#include "tags.h"
98
#include "exp.h"
99
#include "expmacs.h"
100
#include "diag_fns.h"
101
#include "flags.h"
102
#include "check.h"
103
#include "me_fns.h"
104
#include "externs.h"
105
#include "installglob.h"
106
#include "messages_r.h"
107
#include "main_reads.h"
108
#include "install_fns.h"
109
#include "c_arith_type.h"
110
#include "natmacs.h"
111
#include "shapemacs.h"
112
#include "translat.h"
113
#include "spec_tok.h"
114
#include "new_tags.h"
115
#include "myassert.h"
116
#include "dg_fns.h"
117
 
118
/* intercepts specially defined tokens */
119
 
120
 
121
tokval special_token
122
    PROTO_N ( (t, pars, sortcode, done) )
123
    PROTO_T ( token t X bitstream pars X int sortcode X int * done )
124
{
125
  tokval tkv;
126
  UNUSED(sortcode);
127
 
128
  if (t -> tok_name == (char*)0) {
129
    SET(tkv); /* call looks at done to see if result is meaningful */
130
    return tkv;
131
  };
132
 
133
  /* Added for VARARGS on sparc etc */
134
 
135
  if (!strcmp(t -> tok_name,"ansi.stdarg.__va_start") ) {
136
    exp arg1;
137
    exp id;
138
    exp env_o;
139
    place old_place;
140
    old_place = keep_place();
141
    set_place(pars);
142
    arg1 = hold_check(d_exp());
143
    set_place(old_place);
144
 
145
    if (name(arg1) != name_tag) failer("Not a tag in va_start");
146
    id = son(arg1);
147
 
148
    env_o = getexp(f_offset(f_callers_alignment(1), f_alignment(sh(arg1))),
149
		   nilexp, 0, id, nilexp, 0, 0, env_offset_tag);
150
    setvis(id);
151
    setenvoff(id);
152
 
153
    tkv.tk_exp = hold_check(f_add_to_ptr(f_current_env(), env_o));
154
    kill_exp(arg1,arg1);
155
    *done = 1;
156
    return tkv;
157
  }
158
 
159
  if (!strcmp(t -> tok_name,"ansi.stdarg.va_arg") ) {
160
    exp arg1;
161
    shape s, s1;
162
    exp id, ass, con;
163
    exp_list el;
164
    place old_place;
165
    old_place = keep_place();
166
    set_place(pars);
167
    arg1 = hold_check(d_exp());
168
    s = d_shape();
169
    set_place(old_place);
170
 
171
    s1 = s;
172
    if (sparccpd(s)) {
173
      s1 = f_pointer (f_alignment (s));
174
    }
175
    id = me_startid (f_pointer(f_var_param_alignment), arg1, 0);
176
    ass = f_assign (me_obtain(id),
177
	    f_add_to_ptr (f_contents (f_pointer(f_var_param_alignment), me_obtain(id)),
178
		f_offset_pad (f_var_param_alignment, f_shape_offset (s1))));
179
    con = f_contents (s1,
180
	    f_add_to_ptr (f_contents (f_pointer(f_var_param_alignment), me_obtain(id)),
181
		f_offset_negate (f_offset_pad (f_var_param_alignment, f_shape_offset (s1)))));
182
    if (sparccpd(s)) {
183
      con = f_contents (s, con);
184
    }
185
    el = new_exp_list(1);
186
    el = add_exp_list(el, ass, 0);
187
 
188
    tkv.tk_exp = hold_check (me_complete_id (id, f_sequence (el, con)));
189
    *done = 1;
190
    return tkv;
191
  }
192
  /* end of addition for VARARGS */
193
 
194
  if (!strcmp(t -> tok_name,"~next_caller_offset") ) {
195
    exp arg1;
196
    shape s1, s2;
197
    place old_place;
198
    old_place = keep_place();
199
    set_place(pars);
200
    arg1 = hold_check(d_exp());
201
    s1 = d_shape();
202
    s2 = d_shape();
203
    set_place(old_place);
204
    caller_offset_used = 1;
205
 
206
    if (sparccpd(s1)) {
207
      s1 = f_pointer (f_alignment (s1));
208
    }
209
 
210
    tkv.tk_exp = hold_check (f_offset_pad (f_parameter_alignment (s2),
211
				f_offset_add (arg1, f_shape_offset (s1))));
212
    *done = 1;
213
    return tkv;
214
  }
215
 
216
  if (!strcmp(t -> tok_name,"~next_callee_offset") ) {
217
    exp arg1;
218
    shape s1, s2;
219
    place old_place;
220
    old_place = keep_place();
221
    set_place(pars);
222
    arg1 = hold_check(d_exp());
223
    s1 = d_shape();
224
    s2 = d_shape();
225
    set_place(old_place);
226
 
227
    tkv.tk_exp = hold_check (f_offset_pad (f_parameter_alignment (s2),
228
				f_offset_pad (f_alignment (s2),
229
				   f_offset_add (arg1, f_shape_offset (s1)))));
230
    *done = 1;
231
    return tkv;
232
  }
233
 
234
 
235
  if (!strcmp(t -> tok_name, "~alloca"))  {
236
    exp arg1;
237
    place old_place;
238
    old_place = keep_place();
239
    set_place(pars);
240
    arg1 = hold_check(d_exp());
241
    set_place(old_place);
242
    tkv.tk_exp = hold_check(me_u3(f_pointer(long_to_al(8)),
243
				  arg1, alloca_tag));
244
    *done = 1;
245
    has_alloca = 1;
246
    return tkv;
247
  };
248
 
249
 if(!strcmp(t->tok_name, "~Sync_handler")){
250
    tkv.tk_exp = getexp(f_top,nilexp,0,nilexp,nilexp,0,0,special_tag);
251
    *done = 1;
252
    return tkv;
253
  }
254
 
255
  if (!strcmp(t->tok_name, "__sparc_special")){
256
    exp arg;
257
    place old_place;
258
    old_place = keep_place();
259
    set_place(pars);
260
    arg = d_exp();
261
    assert(name(arg) == val_tag);
262
    if(no(arg) == 0){
263
      tkv.tk_exp = getexp(f_bottom,nilexp,0,nilexp,nilexp,0,0,special_tag);
264
      *done = 1;
265
    }
266
    else{
267
      failer("Unsupported argument to token __alpha_special");
268
      tkv.tk_exp = getexp(f_top,nilexp,0,nilexp,nilexp,0,0,null_tag);
269
      *done = 1;
270
    }
271
    set_place(old_place);
272
    return tkv;
273
  }
274
 
275
 
276
 
277
  if (!strcmp(t -> tok_name, "~exp_to_source") ||
278
      !strcmp(t -> tok_name, "~diag_id_scope") ||
279
      !strcmp(t -> tok_name, "~diag_type_scope") ||
280
      !strcmp(t -> tok_name, "~diag_tag_scope")
281
#ifdef NEWDIAGS
282
	|| !strcmp(t -> tok_name, "~dg_exp")
283
#endif
284
     )  {
285
 
286
    place old_place;
287
    old_place = keep_place();
288
    set_place(pars);
289
    tkv.tk_exp = hold_check(d_exp());
290
    *done = 1;
291
 
292
    if (!diagnose){
293
      set_place(old_place);
294
      return tkv;
295
    };
296
 
297
    if (!strcmp(t -> tok_name, "~exp_to_source")){
298
#ifdef NEWDIAGS
299
      tkv.tk_exp = read_exp_to_source (tkv.tk_exp);
300
#else
301
      diag_info * di = read_exp_to_source();
302
      exp r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
303
		 1, 0, diagnose_tag);
304
      setfather(r, tkv.tk_exp);
305
      dno(r) = di;
306
      tkv.tk_exp = r;
307
      crt_lno = natint(di -> data.source.end.line_no);
308
      crt_charno = natint(di -> data.source.end.char_off);
309
      crt_flnm = di -> data.source.beg.file->file.ints.chars;
310
#endif
311
      set_place(old_place);
312
      return tkv;
313
    };
314
 
315
    if (!strcmp(t -> tok_name, "~diag_id_scope")){
316
#ifdef NEWDIAGS
317
      tkv.tk_exp = read_diag_id_scope (tkv.tk_exp);
318
#else
319
      diag_info * di = read_diag_id_scope();
320
      exp r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
321
		 2, 0, diagnose_tag);
322
      setfather(r, tkv.tk_exp);
323
      dno(r) = di;
324
      tkv.tk_exp = r;
325
#endif
326
      set_place(old_place);
327
      return tkv;
328
    };
329
 
330
    if (!strcmp(t -> tok_name, "~diag_type_scope")){
331
#ifdef NEWDIAGS
332
      tkv.tk_exp = read_diag_type_scope (tkv.tk_exp);
333
#else
334
      diag_info * di = read_diag_type_scope();
335
      exp r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
336
		 3, 0, diagnose_tag);
337
      setfather(r, tkv.tk_exp);
338
      dno(r) = di;
339
      tkv.tk_exp = r;
340
#endif
341
      set_place(old_place);
342
      return tkv;
343
    };
344
 
345
    if (!strcmp(t -> tok_name, "~diag_tag_scope")){
346
#ifndef NEWDIAGS
347
      diag_info * di = read_diag_tag_scope();
348
      exp r = getexp(sh(tkv.tk_exp), nilexp, 0, tkv.tk_exp, nilexp,
349
		 4, 0, diagnose_tag);
350
      setfather(r, tkv.tk_exp);
351
      dno(r) = di;
352
      tkv.tk_exp = r;
353
#endif
354
      set_place(old_place);
355
      return tkv;
356
    };
357
 
358
#ifdef NEWDIAGS
359
   if (!strcmp(t -> tok_name, "~dg_exp")){
360
      tkv.tk_exp = read_dg_exp (tkv.tk_exp);
361
      set_place(old_place);
362
      return tkv;
363
    };
364
#endif
365
 
366
  }
367
 
368
  if (!strncmp(t -> tok_name, "~asm", 4)) {
369
    int prp;
370
    exp arg1;
371
    place old_place;
372
    old_place = keep_place();
373
    if (!strcmp(t -> tok_name, "~asm")) {
374
      set_place(pars);
375
      arg1 = hold_check (f_make_nof_int (ucharsh, d_string()));
376
      prp = 1;
377
    }
378
    else {
379
      if (!strcmp(t -> tok_name, "~asm_sequence"))
380
	prp = 0;
381
      else
382
      if (!strcmp(t -> tok_name, "~asm_exp_input"))
383
	prp = 2;
384
      else
385
      if (!strcmp(t -> tok_name, "~asm_exp_output"))
386
	prp = 4;
387
      else
388
      if (!strcmp(t -> tok_name, "~asm_exp_address"))
389
	prp = 8;
390
      else
391
	return tkv;
392
      set_place(pars);
393
      arg1 = hold_check (d_exp());
394
    }
395
    set_place(old_place);
396
    tkv.tk_exp = getexp (f_top, nilexp, 0, arg1, nilexp, prp, 0, asm_tag);
397
    setfather (tkv.tk_exp, arg1);
398
    *done = 1;
399
    return tkv;
400
  }
401
 
402
  SET(tkv); /* call looks at done to see if result is meaningful */
403
  return tkv;
404
}