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/alpha/common/inst_fmt.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
  inst_fmt_2.c
33
 
34
  This file contains a set of procedures to output assembler 
35
  instructions in both binary and symbolic formats and to call 
36
  the code scheduler at appropriate points.
37
*/
38
 
39
/*
40
$Log: inst_fmt.c,v $
41
 * Revision 1.1.1.1  1998/01/17  15:56:00  release
42
 * First version to be checked into rolling release.
43
 *
44
 * Revision 1.17  1997/09/05  12:22:47  john
45
 * Change to jmp
46
 *
47
 * Revision 1.16  1996/02/15  09:53:16  john
48
 * Changed integer_jump_fn
49
 *
50
 * Revision 1.15  1995/12/04  09:12:33  john
51
 * Portability fixes
52
 *
53
 * Revision 1.14  1995/11/13  12:43:30  john
54
 * Minor change
55
 *
56
 * Revision 1.13  1995/10/16  12:07:46  john
57
 * Change to alignment calculation
58
 *
59
 * Revision 1.12  1995/09/04  16:23:37  john
60
 * Fix to general procs
61
 *
62
 * Revision 1.11  1995/08/30  16:14:51  john
63
 * Fix for use of AT register
64
 *
65
 * Revision 1.10  1995/08/21  08:44:49  john
66
 * Changed include files
67
 *
68
 * Revision 1.9  1995/05/25  15:33:10  john
69
 * Cosmetic changes
70
 *
71
 * Revision 1.8  1995/05/23  10:56:51  john
72
 * Changes for 64 bit support
73
 *
74
 * Revision 1.7  1995/05/16  10:52:34  john
75
 * Now uses correct register names (where supported by the assembler).
76
 *
77
 * Revision 1.6  1995/04/10  14:13:18  john
78
 * Minor changes
79
 *
80
 * Revision 1.5  1995/04/07  11:03:45  john
81
 * Changes to assembler output, plus change to floating point operations.
82
 *
83
 * Revision 1.4  1995/03/29  14:07:36  john
84
 * Fixed error in noat block handling
85
 *
86
 * Revision 1.3  1995/03/29  10:30:51  john
87
 * Added resources for scheduler
88
 *
89
 * Revision 1.2  1995/03/28  12:44:30  john
90
 * Changed resources for scheduler
91
 *
92
 * Revision 1.1.1.1  1995/03/23  10:39:11  john
93
 * Entered into CVS
94
 *
95
 * Revision 1.1  1995/03/23  10:06:32  john
96
 * Initial revision
97
 *
98
*/
99
#include "config.h"
100
#include "inst_fmt.h"
101
#include "main.h"
102
#include "fail.h"
103
#include "reg_defs.h"
104
#include "cross.h"
105
#include "regexps.h"
106
#include "alpha_ins.h"
107
#include "xalloc.h"
108
#include "bool.h"
109
#include "ibinasm.h"
110
#include "out_ba.h"
111
#include "syms.h"
112
#include "fail.h"
113
#include "instypes.h"
114
#if DO_SCHEDULE
115
#include "scheduler.h"
116
#include "common.h"
117
#endif
118
#include "procrectypes.h"
119
#include "locate.h"
120
#include "getregs.h"
121
#include "code_here.h"
122
#include "maxminmacs.h"
123
#include "pseudo.h"
124
#if DO_SCHEDULE
125
static int instruction_number=0;
126
#endif
127
int andpeep = 0;
128
extern int extended_comments;
129
bool in_noat_block=FALSE;
130
 
131
 
132
static char *reg_name[]=
133
{"$0","$1","$2","$3","$4","$5","$6","$7","$8","$9","$10","$11","$12","$13"
134
 ,"$14","$fp","$16","$17","$18","$19","$20","$21","$22","$23","$24","$25"
135
 ,"$26","$27","$at","$gp","$sp","$31"
136
};
137
 
138
#define instruction_block_size	500
139
#define schedule_leniency	0
140
 
141
 
142
#define is_32bit_load_store(X) (ins_equal(X,i_ldl)||ins_equal(X,i_stl)\
143
				 || ins_equal(X,i_ldl_l)||ins_equal(X,i_stl_c))
144
 
145
#define is_32bit_fload_fstore(X) (ins_equal(X,i_lds)||ins_equal(X,i_sts)\
146
				  || ins_equal(X,i_ldf)||ins_equal(X,i_stf))
147
 
148
#define is_unaligned_access_instruction(X) (ins_equal(X,i_ldq_u) ||\
149
					    ins_equal(X,i_stq_u))
150
 
151
/*
152
  If the instruction ins has an equivalent which causes the OS to
153
  successfully handle a trap then return it, otherwise return ins.
154
*/
155
instruction trap_ins
156
    PROTO_N ( ( ins,traps ) )
157
    PROTO_T ( instruction ins X bool *traps )
158
{
159
  *traps = TRUE;
160
  if (ins_equal(ins,i_adds))
161
    return i_addssu;
162
  if (ins_equal(ins,i_addt))	
163
    return i_addtsu;
164
  if (ins_equal(ins,i_divs))	
165
    return i_divssu;
166
  if (ins_equal(ins,i_divt))	
167
    return i_divtsu;
168
  if (ins_equal(ins,i_muls))	
169
    return i_mulssu;
170
  if (ins_equal(ins,i_mult))	
171
    return i_multsu;
172
  if (ins_equal(ins,i_subs))	
173
    return i_subssu;
174
  if (ins_equal(ins,i_subt))	
175
    return i_subtsu;
176
  *traps = FALSE;
177
  return ins;
178
}
179
 
180
#if DO_SCHEDULE
181
Instruction get_new_instruction
182
    PROTO_Z ()
183
{
184
  Instruction new_ins = getinst();
185
  if(in_noat_block) setuses(new_ins,resource_noat,class_null);
186
  return new_ins;
187
}
188
#endif
189
 
190
/*
191
  Construct a new statement from the two representations and send 
192
  to the scheduler.
193
*/
194
#if DO_SCHEDULE
195
void output_instruction
196
    PROTO_N ( ( cl,ins_text,ins_bindata ) )
197
    PROTO_T ( Class cl X char *ins_text X char *ins_bindata )
198
{
199
  Instruction new_ins = getinst();
200
  Instruction_data ins_dat = get_new_ins_data();
201
  if(ins_text){
202
    if(!strcmp(ins_text,"\t.set\tat\n") || 
203
       !strcmp(ins_text,"\t.set\tnoat\n")){
204
      setsets(new_ins,resource_noat,class_null);
205
      setsets(new_ins,R28,class_null);
206
    }
207
  }
208
  setclass(new_ins,cl);
209
  set_instruction_text(ins_dat,ins_text);
210
  set_instruction_binasm(ins_dat,ins_bindata);
211
  setdata(new_ins,ins_dat);
212
  process_instruction(new_ins);
213
  return;
214
}
215
 
216
#if SEPARATE_DATA
217
void output_data
218
    PROTO_N ( ( data_txt,data_binasm ) )
219
    PROTO_T ( char *data_txt X char * data_binasm )
220
{
221
  Instruction_data ins_d = get_new_ins_data();
222
  set_instruction_binasm(ins_d,data_binasm);
223
  set_instruction_text(ins_d,data_txt);
224
  out_code(ins_d);
225
  return;
226
}
227
#else
228
void output_data
229
    PROTO_N ( ( data_txt,data_binasm ) )
230
    PROTO_T ( char *data_txt X char *data_binasm )
231
{
232
  output_instruction(class_null,data_txt,data_binasm);
233
  return;
234
}
235
#endif
236
 
237
 
238
#endif
239
 
240
#if DO_SCHEDULE
241
static String *init_String
242
    PROTO_Z ()
243
{
244
  String *res = (String*)xcalloc(1,sizeof(String));
245
  res->head = res->tail = (StringData*)NULL;
246
  return res;
247
}
248
 
249
static void add_char_to_string
250
    PROTO_N ( ( ch,dest ) )
251
    PROTO_T ( char ch X String **dest )
252
{
253
 
254
  StringData *new = (StringData*)xcalloc(1,sizeof(StringData));
255
  new->data = ch;
256
  new->next = (StringData*)NULL;
257
  if((*dest)->head == (StringData*)NULL){
258
    (*dest)->head = new;
259
  }
260
  if((*dest)->tail != (StringData*)NULL){
261
    (*dest)->tail->next = new;
262
  }
263
  (*dest)->tail = new;
264
  return ;
265
}
266
 
267
 
268
 
269
static void add_to_string
270
    PROTO_N ( ( str,dest ) )
271
    PROTO_T ( char *str X String **dest )
272
{
273
  int i = 0;
274
  if(*dest == (String*)NULL){
275
    *dest = (String*)xcalloc(1,sizeof(String));
276
    (*dest)->head = (*dest)->tail = (StringData*)NULL;
277
  }
278
  for(;i<strlen(str);++i){
279
    add_char_to_string(str[i],dest);
280
  }
281
  return;
282
}
283
 
284
static char *copy_from_string
285
    PROTO_N ( ( src ) )
286
    PROTO_T ( String *src )
287
{
288
  StringData *trav = src->head;
289
  int str_size=0,element=0;
290
  char * result;
291
  while(trav){
292
    ++str_size;
293
    trav = trav->next;
294
  }
295
  result = (char*)xcalloc(str_size+1,sizeof(char));
296
  trav = src->head;
297
  while(trav){
298
    result[element] = trav->data;
299
    trav = trav->next;
300
    element ++;
301
  }
302
  return result;
303
}
304
 
305
static void free_string
306
    PROTO_N ( ( str ) )
307
    PROTO_T ( String **str )
308
{
309
  StringData *trav = (*str)->head;
310
  StringData *old;
311
  while(trav){
312
    old = trav;
313
    trav = trav->next;
314
    free(old);
315
  }
316
  free(*str);
317
  return;
318
}
319
 
320
 
321
 
322
 
323
/*
324
  accumulate strings for output.  If the input is NULL then return 
325
  the current string and reset, otherwise return NULL.
326
*/
327
char * outass
328
    PROTO_N ( ( str ) )
329
    PROTO_T ( char *str )
330
{
331
  static String *res;
332
  char * tmp;
333
  static int str_size = 0;
334
  if(str){
335
    str_size += strlen(str);
336
    add_to_string(str,&res);
337
    /*strcat(res,str);*/
338
    return (char*)NULL;
339
  }
340
  str_size = 0;
341
  if ( res == (String*)NULL ){
342
    tmp = (char*)NULL;
343
  }
344
  else{
345
    tmp = copy_from_string(res);
346
    free_string(&res);
347
    res = init_String();
348
  }
349
  /*strcpy(res,"");*/
350
  return tmp;
351
}
352
#endif
353
 
354
 
355
 
356
/*
357
  Increment the current instruction number and, if enough 
358
  instructions have been output, call the scheduler and reset
359
  the count.
360
*/
361
#if DO_SCHEDULE
362
void add_instruction
363
    PROTO_N ( ( ins ) )
364
    PROTO_T ( Instruction ins )
365
{
366
  process_instruction(ins);
367
  ++instruction_number;
368
  if(instruction_number >= (instruction_block_size+schedule_leniency)){
369
    instruction_number = 0;
370
    schedule_block();
371
  }
372
  return;
373
}
374
 
375
Instruction_data get_new_ins_data
376
    PROTO_Z ()
377
{
378
  Instruction_data a;
379
  a.text = (char*)NULL;
380
  a.bindata = (char*)NULL;
381
  return a;
382
}
383
 
384
#endif
385
 
386
 
387
/*
388
  This function performs a load store operation.  
389
*/
390
void load_store
391
    PROTO_N ( ( ins,reg,a ) )
392
    PROTO_T ( instruction ins X int reg X baseoff a )
393
{
394
  char *reg_str,*base_reg_str;
395
  char *ins_name = ins_symbolic_name(ins);
396
#if DO_SCHEDULE
397
  char *outline = (char*)xcalloc(80,sizeof(char));
398
#endif
399
  char *binasm_data;
400
#if DO_SCHEDULE
401
  int mem_size = is_32bit_load_store(ins)?4:8+
402
      (is_unaligned_access_instruction(ins)?UNALIGNED_ACCESS_SIZE_ADJUSTMENT
403
       :0);
404
  int offset = is_unaligned_access_instruction(ins)?
405
      a.offset+UNALIGNED_ACCESS_OFFSET_ADJUSTMENT : a.offset;
406
#endif
407
 
408
  int insid = ins_binid(ins);
409
#if DO_SCHEDULE
410
  Instruction new_ins = get_new_instruction();
411
  Instruction_data ins_dat = get_new_ins_data();
412
  setclass(new_ins,ins_class(ins));
413
  if(ins_equal(ins,i_ldgp)) {
414
    setsets_pc(new_ins,true);
415
  }
416
  if(ins_class(ins) != class_store_data && ins_class(ins) != class_store_addr){
417
    setsets(new_ins,reg,ins_class(ins));
418
  }
419
  else{
420
    setuses(new_ins,reg,ins_class(ins));
421
  }
422
  if(ins_class(ins) == class_iarithmetic){
423
    if(a.base>=0 && a.base <32){
424
      setuses(new_ins,a.base,ins_class(ins));
425
    }
426
    if(a.base<0) setuses(new_ins,R29,ins_class(ins));
427
  }
428
  else{
429
    if(a.base < 0){
430
      if(ins_class(ins) == class_store_data){
431
	setuses(new_ins,R29,class_store_addr);
432
	setuses(new_ins,R28,ins_class(ins));
433
      }
434
      else{
435
	setuses(new_ins,R29,ins_class(ins));
436
      }
437
      setindex_global(new_ins,-a.base-1);
438
      setoffset_global(new_ins,offset);
439
      setsize_global(new_ins,mem_size);
440
    }
441
    else if(a.base >31){
442
      if(ins_class(ins) == class_store_data){
443
	setuses(new_ins,R29,class_store_addr);
444
	setuses(new_ins,R28,ins_class(ins));
445
      }
446
      else{
447
	setuses(new_ins,R29,ins_class(ins));
448
      }
449
      setbase_label(new_ins,a.base);
450
      setoffset_label(new_ins,offset);
451
      setsize_label(new_ins,mem_size);
452
    }
453
    else{
454
      setbase_stack(new_ins,a.base);
455
      setoffset_stack(new_ins,offset);
456
      setsize_stack(new_ins,mem_size);
457
    }
458
  }
459
#endif
460
  reg_str=reg_name[reg];
461
  if(a.base<0){
462
    char *extname=main_globals[-a.base-1]->dec_u.dec_val.dec_id;
463
    if(as_file){
464
      if(a.offset==0){
465
#if !DO_SCHEDULE
466
	(void)fprintf(as_file,"\t%s\t%s, %s\n",ins_name,reg_str,extname);
467
#else
468
	(void)sprintf(outline,"\t%s\t%s, %s\n",ins_name,reg_str,extname);
469
	set_instruction_text(ins_dat,outline);
470
#endif
471
      }
472
      else
473
	if(a.offset>0){
474
#if !DO_SCHEDULE
475
	  (void)fprintf(as_file,"\t%s\t%s,%s+%ld\n",ins_name,reg_str,
476
			extname,a.offset);
477
#else
478
	  (void)sprintf(outline,"\t%s\t%s,%s+%ld\n",ins_name,reg_str,
479
			extname,a.offset);
480
	  set_instruction_text(ins_dat,outline);
481
#endif
482
	}
483
	else{
484
	  if(a.offset<0){
485
#if !DO_SCHEDULE
486
	    (void)fprintf(as_file,"\t%s\t%s,%s%ld\n",ins_name,reg_str,
487
			  extname, a.offset);
488
#else
489
	    (void)sprintf(outline,"\t%s\t%s,%s%ld\n",ins_name,reg_str,
490
			  extname, a.offset);
491
	    set_instruction_text(ins_dat,outline);
492
#endif
493
	  }
494
	}
495
    }
496
    binasm_data = out_iinst(symnos[-a.base-1],insid,reg,xnoreg,FRA,0U,a.offset);
497
#if DO_SCHEDULE
498
    set_instruction_binasm(ins_dat,binasm_data);
499
    setdata(new_ins,ins_dat);
500
    (void)add_instruction(new_ins);
501
#endif
502
  }
503
  else{
504
    if(a.base > 31)	/* label */{
505
      if(as_file){
506
	if(a.offset==0){
507
#if !DO_SCHEDULE
508
	  (void)fprintf(as_file,"\t%s\t%s, $$%d\n",ins_name,reg_str,
509
			a.base);
510
#else
511
	  (void)sprintf(outline,"\t%s\t%s, $$%d\n",ins_name,reg_str,
512
			a.base);
513
	  set_instruction_text(ins_dat,outline);
514
#endif
515
	}
516
	else if(a.offset>0){
517
#if !DO_SCHEDULE
518
	  (void)fprintf(as_file,"\t%s\t%s, $$%d+%ld\n",ins_name,
519
			reg_str,a.base,a.offset);
520
#else
521
	  (void)sprintf(outline,"\t%s\t%s, $$%d+%ld\n",ins_name,
522
			reg_str,a.base,a.offset);
523
	  set_instruction_text(ins_dat,outline);
524
#endif
525
	}
526
	else if(a.offset<0){
527
#if !DO_SCHEDULE
528
	  (void)fprintf(as_file,"\t%s\t%s, $$%d-%ld\n",ins_name,
529
			reg_str,a.base,a.offset);
530
#else
531
	  (void)sprintf(outline,"\t%s\t%s, $$%d-%ld\n",ins_name,
532
			    reg_str,a.base,a.offset);
533
	  set_instruction_text(ins_dat,outline);
534
#endif
535
	}
536
      }
537
      binasm_data = 
538
	out_iinst(tempsnos[a.base-32],insid,reg,xnoreg,FROB,0,a.offset);
539
#if DO_SCHEDULE
540
      set_instruction_binasm(ins_dat,binasm_data);
541
      setdata(new_ins,ins_dat);
542
      (void)add_instruction(new_ins);
543
#endif
544
    }
545
    else{
546
#if DO_SCHEDULE
547
      if(ins_class(ins) == class_store_data){
548
	setuses(new_ins,a.base,class_store_addr);
549
      }
550
      else if(ins_class(ins) == class_load){
551
	setuses(new_ins,a.base,ins_class(ins));
552
      }
553
#endif
554
      base_reg_str=reg_name[a.base];
555
      if(as_file){
556
#if !DO_SCHEDULE
557
	(void)fprintf(as_file,"\t%s\t%s, %ld(%s)\n",ins_name,
558
		      reg_str,a.offset,base_reg_str);
559
#else
560
	(void)sprintf(outline,"\t%s\t%s, %ld(%s)\n",ins_name,
561
		      reg_str,a.offset,base_reg_str);
562
	set_instruction_text(ins_dat,outline);
563
#endif
564
      }
565
      if(ins_equal(ins,i_lda) || ins_equal(ins,i_ldq)){
566
	if((a.base == SP) || ((regexps[a.base].alignment == 8) && 
567
	   (a.offset%8 == 0))){
568
	  regexps[reg].alignment = 8;
569
	}
570
        else if((a.base == SP || regexps[a.base].alignment == 4) && (a.offset %4 == 0)){
571
	  regexps[reg].alignment = 4;
572
	}
573
	else{
574
	  regexps[reg].alignment = 0;
575
	}
576
      }
577
      binasm_data = out_iinst(0,insid,reg,a.base,FROB,0,a.offset);
578
#if DO_SCHEDULE
579
      set_instruction_binasm(ins_dat,binasm_data);
580
      setdata(new_ins,ins_dat);
581
      (void)add_instruction(new_ins);
582
#endif
583
    }
584
  }
585
  clear_reg(reg);
586
  return;
587
}
588
 
589
 
590
 
591
void load_store_immediate
592
    PROTO_N ( ( ins,reg,val ) )
593
    PROTO_T ( instruction ins X int reg X INT64 val )
594
{
595
#if DO_SCHEDULE
596
  Instruction new_ins = get_new_instruction();
597
  Instruction_data ins_dat = get_new_ins_data();
598
  char * outline = (char*)xcalloc(80,sizeof(char));
599
#endif
600
  char * binasm_data;
601
#if DO_SCHEDULE
602
  setclass(new_ins,ins_class(ins));
603
  setsets(new_ins,reg,ins_class(ins));
604
#endif
605
  if(as_file){
606
#if !DO_SCHEDULE
607
    (void)fprintf(as_file,"\t%s\t%s,",ins_symbolic_name(ins),reg_name[reg]);
608
#else
609
    (void)sprintf(outline,"\t%s\t%s,%d\n",ins_symbolic_name(ins),
610
		  reg_name[reg],val);
611
    set_instruction_text(ins_dat,outline);
612
#endif
613
    /*setdata(new_ins,outline);*/
614
#if !DO_SCHEDULE
615
    out_INT64(val);
616
    (void)outstring("\n");
617
#endif
618
  }
619
  binasm_data = out_biinst(0,ins_binid(ins),reg,xnoreg,FRI,0,val);
620
#if DO_SCHEDULE
621
  set_instruction_binasm(ins_dat,binasm_data);
622
  setdata(new_ins,ins_dat);
623
  add_instruction(new_ins);
624
#endif
625
  clear_reg(reg);
626
}
627
 
628
 
629
void load_store_label
630
    PROTO_N ( ( ins,reg,lab ) )
631
    PROTO_T ( instruction ins X int reg X int lab )
632
{
633
#if DO_SCHEDULE
634
  Instruction new_ins = get_new_instruction();
635
  Instruction_data ins_dat = get_new_ins_data();
636
  char *outline = (char*)xcalloc(80,sizeof(char));
637
#endif
638
  char *binasm_data;
639
#if DO_SCHEDULE
640
  setclass(new_ins,ins_class(ins));
641
  if(ins_class(ins) == class_load){
642
    setsets(new_ins,reg,ins_class(ins));
643
  }
644
  else{
645
    setuses(new_ins,reg,ins_class(ins));
646
  }
647
  setlabel(new_ins,lab);
648
#endif
649
  if(as_file){
650
#if !DO_SCHEDULE
651
    (void)fprintf(as_file,"\t%s\t%s, $%d\n",ins_symbolic_name(ins),
652
		  reg_name[reg],lab);
653
#else
654
    (void)sprintf(outline,"\t%s\t%s, $%d\n",ins_symbolic_name(ins),
655
		  reg_name[reg],lab);
656
    set_instruction_text(ins_dat,outline);
657
#endif
658
    /*setdata(new_ins,outline);*/
659
  }	
660
  binasm_data = out_linst(-lab,ins_binid(ins),reg,xnoreg,FRL,0);
661
#if DO_SCHEDULE
662
  set_instruction_binasm(ins_dat,binasm_data);
663
  setdata(new_ins,ins_dat);
664
  add_instruction(new_ins);
665
#endif
666
  return;
667
}
668
 
669
 
670
/*
671
   These functions output assembler for integer control instructions
672
*/
673
void integer_branch
674
    PROTO_N ( ( ins,reg,dest ) )
675
    PROTO_T ( instruction ins X int reg X int dest )
676
{
677
#if DO_SCHEDULE
678
  Instruction new_ins = get_new_instruction();
679
  Instruction_data ins_dat = get_new_ins_data();
680
  char *outline = (char*)xcalloc(80,sizeof(char));
681
#endif
682
  char *binasm_data = (char*)xcalloc(binasm_record_length+1,sizeof(char));
683
#if DO_SCHEDULE
684
  setclass(new_ins,ins_class(ins));
685
  if(ins_equal(ins,i_br)){
686
    setsets(new_ins,reg,ins_class(ins));
687
  }
688
  else{
689
    setuses(new_ins,reg,ins_class(ins));
690
  }
691
  setsets_pc(new_ins,true);
692
  setlabel(new_ins,dest);
693
#endif
694
  if(as_file){
695
#if !DO_SCHEDULE
696
    (void)fprintf(as_file,"\t%s\t%s,$%d\n",ins_symbolic_name(ins),
697
		  reg_name[reg],dest);
698
#else
699
    (void)sprintf(outline,"\t%s\t%s,$%d\n",ins_symbolic_name(ins),
700
		  reg_name[reg],dest);
701
    set_instruction_text(ins_dat,outline);
702
#endif
703
  }
704
  binasm_data = out_linst(-dest,ins_binid(ins),reg,xnoreg,FRL,0);
705
#if DO_SCHEDULE
706
  set_instruction_binasm(ins_dat,binasm_data);
707
  setdata(new_ins,ins_dat);
708
  add_instruction(new_ins);
709
#endif
710
  return;
711
}
712
 
713
 
714
void integer_jump
715
    PROTO_N ( ( ins,dest_reg,source_reg,hint ) )
716
    PROTO_T ( instruction ins X int dest_reg X int source_reg X int hint )
717
{
718
#if DO_SCHEDULE
719
  Instruction new_ins = get_new_instruction();
720
  Instruction_data ins_dat = get_new_ins_data();
721
  char *outline = (char*)xcalloc(80,sizeof(char));
722
#endif
723
  char *binasm_data;
724
#if DO_SCHEDULE
725
  setclass(new_ins,ins_class(ins));
726
  setsets(new_ins,dest_reg,ins_class(ins));
727
  setuses(new_ins,source_reg,ins_class(ins));
728
  setsets_pc(new_ins,true);
729
#endif
730
  if(as_file){
731
    if(hint<0){
732
#if !DO_SCHEDULE
733
      (void)fprintf(as_file,"\t%s\t%s,(%s),$%d\n",
734
		    ins_symbolic_name(ins),reg_name[dest_reg],
735
		    reg_name[source_reg],-hint);
736
#else
737
      (void)sprintf(outline,"\t%s\t%s,(%s),$%d\n",
738
		    ins_symbolic_name(ins),reg_name[dest_reg],
739
		    reg_name[source_reg],-hint);
740
#endif
741
    }
742
    else{
743
#if !DO_SCHEDULE
744
      (void)fprintf(as_file,"\t%s\t%s,(%s),%d\n",ins_symbolic_name(ins),
745
		    reg_name[dest_reg],reg_name[source_reg],hint);
746
#else
747
      (void)sprintf(outline,"\t%s\t%s,(%s),%d\n",ins_symbolic_name(ins),
748
		    reg_name[dest_reg],reg_name[source_reg],hint);
749
#endif
750
    }
751
  }
752
  binasm_data = out_iinst(0,ins_binid(ins),dest_reg,source_reg,FRR,0,hint);
753
#if DO_SCHEDULE
754
  set_instruction_text(ins_dat,outline);
755
  set_instruction_binasm(ins_dat,binasm_data);
756
  setdata(new_ins,ins_dat);
757
  process_instruction(new_ins);
758
  schedule_block();
759
  instruction_number = 0;
760
#endif
761
  return;
762
}
763
 
764
 
765
void integer_jump_fn
766
    PROTO_N ( ( ins,ra,fn,sp ) )
767
    PROTO_T ( instruction ins X int ra X exp fn X space sp )
768
{
769
  baseoff b = boff(fn);
770
  if(b.base<0) {
771
    integer_jump_external(ins,ra,b);
772
  }
773
  else {
774
    int rt;
775
    if(ra != AT) {
776
      rt = AT;
777
    }
778
    else {
779
      rt = getreg(sp.fixed & 0x03f0000);/*leaves out parameter registers*/
780
    }
781
    rt = reg_operand(fn,sp);
782
    operate_fmt(i_bis,rt,rt,PV);
783
    integer_jump(i_jsr,26,rt,0);
784
  }
785
  return;
786
}
787
 
788
 
789
 
790
void integer_jump_external
791
    PROTO_N ( ( ins,ra,b ) )
792
    PROTO_T ( instruction ins X int ra X baseoff b )
793
{
794
  char *extname = main_globals[-b.base-1]->dec_u.dec_val.dec_id;
795
  char *binasm_data;
796
#if DO_SCHEDULE
797
  char *outline = (char*)xcalloc(80,sizeof(char));
798
  Instruction new_ins = get_new_instruction();
799
  Instruction_data ins_dat = get_new_ins_data();
800
  setclass(new_ins,ins_class(ins));
801
  setsets(new_ins,ra,ins_class(ins));
802
  setsets_pc(new_ins,true);
803
  if(b.base < 0){
804
/*    setindex_global(new_ins,-b.base-1);*/
805
/*    setoffset_global(new_ins,b.offset);
806
    setsize_global(new_ins,4);*/
807
  }
808
  else if (b.base>31){
809
/*    setbase_label(new_ins,b.base);
810
    setoffset_label(new_ins,b.offset);
811
    setsize_label(new_ins,4);*/
812
  }
813
  else{
814
    setbase_stack(new_ins,b.base);
815
    setoffset_stack(new_ins,b.offset);
816
    setsize_stack(new_ins,4);
817
  }
818
#endif
819
  clear_all();
820
  andpeep=0;
821
  if(as_file){
822
#if !DO_SCHEDULE
823
    (void)fprintf(as_file,"\t%s\t%s,%s\n",ins_symbolic_name(ins),
824
		  reg_name[ra],extname);
825
#else
826
    (void)sprintf(outline,"\t%s\t%s,%s\n",ins_symbolic_name(ins),
827
		  reg_name[ra],extname);
828
    set_instruction_text(ins_dat,outline);
829
#endif
830
  }
831
  binasm_data = out_iinst(symnos[-b.base-1],ins_binid(ins),ra,xnoreg,FRR,0,0);
832
#if DO_SCHEDULE
833
  set_instruction_binasm(ins_dat,binasm_data);
834
  setdata(new_ins,ins_dat);
835
  add_instruction(new_ins);
836
#endif
837
  return;
838
}
839
 
840
 
841
 
842
/*
843
  3 register operations : instr $src1, [$src2|#src2], dest.
844
  integer arithmetic, logic and shift, byte manipulation.
845
*/
846
void operate_fmt
847
    PROTO_N ( ( ins,src1,src2,dest ) )
848
    PROTO_T ( instruction ins X int src1 X int src2 X int dest )
849
{
850
  char *binasm_data;
851
#if DO_SCHEDULE
852
  char *outline = (char*)xcalloc(80,sizeof(char));
853
  Instruction new_ins = get_new_instruction();
854
  Instruction_data ins_dat = get_new_ins_data();
855
  setclass(new_ins,ins_class(ins));
856
  setsets(new_ins,dest,ins_class(ins));
857
  setuses(new_ins,src1,ins_class(ins));
858
  if(src1 != src2){
859
    setuses(new_ins,src2,ins_class(ins));
860
  }
861
  if(ins_class(ins) == class_subroutine){
862
    setuses(new_ins,R28,ins_class(ins));
863
    setuses(new_ins,R28,ins_class(ins));
864
    setsets_pc(new_ins,true);
865
  }
866
#endif
867
  if(dest!=NO_REG){
868
    if(as_file){
869
#if !DO_SCHEDULE
870
      (void)fprintf(as_file,"\t%s\t%s,%s,%s\n",ins_symbolic_name(ins),
871
		    reg_name[src1],reg_name[src2],reg_name[dest]);
872
#else
873
      (void)sprintf(outline,"\t%s\t%s,%s,%s\n",ins_symbolic_name(ins),
874
		    reg_name[src1],reg_name[src2],reg_name[dest]);
875
#endif
876
    }
877
    clear_reg(dest);
878
    binasm_data = out_rinst(0,ins_binid(ins),src1,src2,FRRR,dest);
879
#if DO_SCHEDULE
880
    set_instruction_text(ins_dat,outline);
881
    set_instruction_binasm(ins_dat,binasm_data);
882
    setdata(new_ins,ins_dat);
883
    add_instruction(new_ins);
884
#endif
885
  }
886
  return;
887
}
888
 
889
 
890
/*
891
  Output an operation where the second paramter is an immediate
892
  value.  If the immediate value is larger than 8 bits then it 
893
  needs to be loaded into a register 
894
*/
895
void operate_fmt_immediate
896
    PROTO_N ( ( ins,src1,src2,dest ) )
897
    PROTO_T ( instruction ins X int src1 X int src2 X int dest )
898
{
899
  char *binasm_data;
900
#if DO_SCHEDULE
901
  char *outline = (char*)xcalloc(40,sizeof(char));
902
  Instruction new_ins = get_new_instruction();
903
  Instruction_data ins_dat = get_new_ins_data();
904
  setclass(new_ins,ins_class(ins));
905
  setsets(new_ins,(Register)dest,ins_class(ins));
906
  setuses(new_ins,(Register)src1,ins_class(ins));
907
  if(ins_class(ins) == class_subroutine){
908
    setuses(new_ins,R28,ins_class(ins));
909
    setsets_pc(new_ins,true);
910
  }
911
#endif
912
  if(abs(src2) > 255){
913
    bool block_status = in_noat_block;
914
    if (!block_status) setnoat();
915
    if(src2<0) {
916
      load_store_immediate(i_ldiq,AT,make_INT64(-1,(unsigned)src2));
917
    }
918
    else {      
919
      load_store_immediate(i_ldiq,AT,make_INT64(0,(unsigned)src2));
920
    }
921
    operate_fmt(ins,src1,AT,dest);
922
    if (!block_status) setat();
923
    return ;
924
  }
925
 
926
  if(dest!=NO_REG){
927
    if(as_file){
928
#if !DO_SCHEDULE
929
      (void)fprintf(as_file,"\t%s\t%s,%d,%s\n",ins_symbolic_name(ins),
930
		    reg_name[src1],src2,reg_name[dest]);
931
#else
932
      (void)sprintf(outline,"\t%s\t%s,%d,%s\n",ins_symbolic_name(ins),
933
		    reg_name[src1],src2,reg_name[dest]);
934
#endif
935
    }
936
    clear_reg(dest);
937
    binasm_data = out_iinst(0,ins_binid(ins),src1,dest,FRIR,0,src2);
938
#if DO_SCHEDULE
939
    set_instruction_text(ins_dat,outline);
940
    set_instruction_binasm(ins_dat,binasm_data);
941
    setdata(new_ins,ins_dat);
942
    add_instruction(new_ins);
943
#endif
944
  }	
945
  return;
946
}
947
 
948
void operate_fmt_big_immediate
949
    PROTO_N ( ( ins,src1,src2,dest ) )
950
    PROTO_T ( instruction ins X int src1 X INT64 src2 X int dest )
951
{
952
  char * binasm_data;
953
#if DO_SCHEDULE
954
  char * outline = (char*)xcalloc(80,sizeof(char));
955
  Instruction new_ins = get_new_instruction();
956
  Instruction_data ins_dat = get_new_ins_data();
957
  setclass(new_ins,ins_class(ins));
958
  setsets(new_ins,dest,ins_class(ins));
959
  setuses(new_ins,src1,ins_class(ins));
960
#endif
961
  if(as_file){
962
#if !DO_SCHEDULE
963
    (void)fprintf(as_file,"\t%s\t%s,",ins_symbolic_name(ins),reg_name[src1]);
964
    out_INT64(src2);
965
    (void)fprintf(as_file,",%s\n",reg_name[dest]);
966
#else
967
    (void)sprintf(outline,"\t%s\t%s,%d,%s\n",ins_symbolic_name(ins),
968
		  reg_name[src1],src2,reg_name[dest]);
969
#endif
970
  }
971
  clear_reg(dest);
972
  binasm_data = out_biinst(0,ins_binid(ins),src1,dest,FRIR,0,src2);
973
#if DO_SCHEDULE
974
  set_instruction_text(ins_dat,outline);
975
  set_instruction_binasm(ins_dat,binasm_data);
976
  setdata(new_ins,ins_dat);
977
  /*setdata(new_ins,outline);*/
978
  add_instruction(new_ins);
979
#endif
980
  return;
981
}
982
 
983
 
984
 
985
/*
986
   floating point load/store
987
*/
988
void float_load_store
989
    PROTO_N ( ( ins,reg,a ) )
990
    PROTO_T ( instruction ins X int reg X baseoff a )
991
{
992
  char * ins_name = ins_symbolic_name(ins);
993
  char * binasm_data;
994
  int ins_id = ins_binid(ins);
995
#if DO_SCHEDULE
996
  char * outline = (char*)xcalloc(80,sizeof(char));
997
  Instruction new_ins = get_new_instruction();
998
  Instruction_data ins_dat = get_new_ins_data();
999
  setclass(new_ins,ins_class(ins));
1000
  if(ins_class(ins) == class_fload){
1001
    setsets(new_ins,reg+float_register,ins_class(ins));
1002
  }
1003
  else{
1004
    setuses(new_ins,reg+float_register,ins_class(ins));
1005
  }
1006
  if(a.base < 0){
1007
    setoffset_global(new_ins,a.offset);
1008
    setsize_global(new_ins,is_32bit_fload_fstore(ins)?4:8);
1009
    setuses(new_ins,AT,ins_class(ins));
1010
  }
1011
  else if(a.base > 31){
1012
    setbase_label(new_ins,a.base);
1013
    setoffset_label(new_ins,a.offset);
1014
    setsize_label(new_ins,is_32bit_fload_fstore(ins)?4:8);
1015
    setuses(new_ins,AT,ins_class(ins));
1016
  }
1017
  else{
1018
    setbase_stack(new_ins,a.base);
1019
    setoffset_stack(new_ins,a.offset);
1020
    setsize_stack(new_ins,is_32bit_fload_fstore(ins)?4:8);
1021
  }
1022
#endif
1023
 
1024
  if(a.base>=0 && a.base <=31){
1025
    char *basereg=reg_name[a.base];
1026
#if DO_SCHEDULE
1027
    if(ins_class(ins) == class_fstore_data){
1028
      setuses(new_ins,a.base,class_fstore_addr);
1029
    }
1030
    else{
1031
      setuses(new_ins,a.base,ins_class(ins));
1032
    }
1033
#endif
1034
    if(as_file){
1035
#if !DO_SCHEDULE
1036
      (void)fprintf(as_file,"\t%s\t$f%d,%ld(%s)\n",ins_name,reg,a.offset,
1037
		    basereg);
1038
#else
1039
      (void)sprintf(outline,"\t%s\t$f%d,%ld(%s)\n",ins_name,reg,a.offset,
1040
		    basereg);
1041
#endif
1042
    }
1043
    binasm_data=out_iinst(0,ins_id,reg+float_register,a.base,FROB,0,a.offset);
1044
  }
1045
  else
1046
    if(a.base<0){
1047
      char *extname = main_globals[-a.base-1]->dec_u.dec_val.dec_id;
1048
      if(as_file){
1049
	if(a.offset==0){
1050
#if !DO_SCHEDULE
1051
	  (void)fprintf(as_file,"\t%s\t$f%d, %s\n",ins_name,reg,extname);
1052
#else
1053
	  (void)sprintf(outline,"\t%s\t$f%d, %s\n",ins_name,reg,extname);
1054
#endif
1055
	}
1056
	else{
1057
	  if(a.offset<0){
1058
#if !DO_SCHEDULE
1059
	      (void)fprintf(as_file,"\t%s\t$f%d, %s%ld\n",ins_name,reg,
1060
			    extname,a.offset);
1061
#else
1062
	      (void)sprintf(outline,"\t%s\t$f%d, %s%ld\n",ins_name,reg,
1063
			    extname,a.offset);
1064
#endif
1065
	    }
1066
	  else{
1067
#if !DO_SCHEDULE
1068
	    (void)fprintf(as_file,"\t%s\t$f%d, %s+%ld\n",ins_name,reg,
1069
			  extname,a.offset);
1070
#else
1071
	    (void)sprintf(outline,"\t%s\t$f%d, %s+%ld\n",ins_name,reg,
1072
			  extname,a.offset);
1073
#endif
1074
	  }
1075
	}
1076
      }
1077
      binasm_data = 
1078
	  out_iinst(symnos[-a.base-1],ins_id,reg+float_register,xnoreg,FROB,0,
1079
		a.offset);
1080
    }
1081
    else{
1082
      if(as_file){
1083
#if !DO_SCHEDULE
1084
	(void)fprintf(as_file,"\t%s\t$f%d, $$%d\n",ins_name,reg,a.base);
1085
#else
1086
	(void)sprintf(outline,"\t%s\t$f%d, $$%d\n",ins_name,reg,a.base);
1087
#endif
1088
      }
1089
      binasm_data = 
1090
	  out_iinst(tempsnos[a.base-32],ins_id,reg+float_register,xnoreg,FROB,
1091
		    0,0);
1092
    }
1093
#if DO_SCHEDULE
1094
  set_instruction_text(ins_dat,outline);
1095
  set_instruction_binasm(ins_dat,binasm_data);
1096
  setdata(new_ins,ins_dat);
1097
  add_instruction(new_ins);
1098
#endif
1099
  clear_reg(reg);
1100
  return;
1101
}
1102
 
1103
 
1104
 
1105
 
1106
/*
1107
   floating point constants are passed as strings, with the 
1108
   formatting being done elsewhere.
1109
*/
1110
void float_load_store_immediate
1111
    PROTO_N ( ( ins,reg,val ) )
1112
    PROTO_T ( instruction ins X int reg X char* val )
1113
{
1114
#if DO_SCHEDULE
1115
  char *outline = (char*)xcalloc(80,sizeof(char));
1116
  Instruction new_ins = get_new_instruction();
1117
  setclass(new_ins,ins_class(ins));
1118
  setsets(new_ins,reg+float_register,ins_class(ins));
1119
#endif
1120
  if(as_file){
1121
#if !DO_SCHEDULE
1122
    (void)fprintf(as_file,"\t%s\t$f%d,%s\n",ins_symbolic_name(ins),reg,val);
1123
#else
1124
    (void)sprintf(outline,"\t%s\t$f%d,%s\n",ins_symbolic_name(ins),reg,val);
1125
#endif
1126
  }
1127
#if DO_SCHEDULE
1128
  add_instruction(new_ins);
1129
#endif
1130
  return;
1131
}
1132
 
1133
 
1134
/*
1135
   floating point branch
1136
*/
1137
void float_branch
1138
    PROTO_N ( ( ins,reg,dest ) )
1139
    PROTO_T ( instruction ins X int reg X int dest )
1140
{
1141
  char * binasm_data;
1142
#if DO_SCHEDULE
1143
  char *outline = (char*)xcalloc(80,sizeof(char));
1144
  Instruction new_ins = get_new_instruction();
1145
  Instruction_data ins_dat = get_new_ins_data();
1146
  setclass(new_ins,ins_class(ins));
1147
  setsets_pc(new_ins,true);
1148
  setlabel(new_ins,dest);
1149
  setuses(new_ins,reg+float_register,ins_class(ins));
1150
#endif
1151
  if(as_file){
1152
#if !DO_SCHEDULE
1153
    (void)fprintf(as_file,"\t%s\t$f%d,$%d\n",ins_symbolic_name(ins),reg,
1154
		  dest);
1155
#else
1156
    (void)sprintf(outline,"\t%s\t$f%d,$%d\n",ins_symbolic_name(ins),reg,
1157
		  dest);
1158
#endif
1159
  }
1160
  binasm_data=out_linst(-dest,ins_binid(ins),reg+float_register,xnoreg,FRL,0);
1161
#if DO_SCHEDULE
1162
  set_instruction_text(ins_dat,outline);
1163
  set_instruction_binasm(ins_dat,binasm_data);
1164
  setdata(new_ins,ins_dat);
1165
  add_instruction(new_ins);
1166
#endif
1167
  return;
1168
}
1169
 
1170
 
1171
 
1172
/*
1173
  floating point operations (except conversions).
1174
*/
1175
void float_op
1176
    PROTO_N ( ( ins,src1,src2,dest ) )
1177
    PROTO_T ( instruction ins X int src1 X int src2 X int dest )
1178
{
1179
  char * binasm_data;
1180
  bool special_trap_ins = FALSE;
1181
  instruction real_ins = trap_all_fops?trap_ins(ins,&special_trap_ins):ins;
1182
#if DO_SCHEDULE
1183
  char *outline = (char*)xcalloc(80,sizeof(char));
1184
  Instruction new_ins = get_new_instruction();
1185
  Instruction_data ins_dat = get_new_ins_data();
1186
  setclass(new_ins,ins_class(real_ins));
1187
  setsets(new_ins,dest+float_register,ins_class(real_ins));
1188
  setuses(new_ins,src1+float_register,ins_class(real_ins));
1189
  if(src1 != src2){
1190
    setuses(new_ins,src2+float_register,ins_class(real_ins));
1191
  }
1192
#endif  
1193
  if(special_trap_ins) no_parameter_instructions(i_trapb);
1194
  if(as_file){
1195
#if !DO_SCHEDULE
1196
    (void)fprintf(as_file,"\t%s\t$f%d,$f%d,$f%d\n",
1197
		  ins_symbolic_name(real_ins),src1,src2,dest);
1198
#else
1199
    (void)sprintf(outline,"\t%s\t$f%d,$f%d,$f%d\n",
1200
		  ins_symbolic_name(real_ins),src1,src2,dest);
1201
#endif
1202
  }
1203
  binasm_data = out_rinst(0,ins_binid(real_ins),src1+float_register,
1204
			  src2+float_register,FRRR,dest+float_register);
1205
  if(special_trap_ins) no_parameter_instructions(i_trapb);
1206
  clear_freg(dest);
1207
#if DO_SCHEDULE
1208
  set_instruction_text(ins_dat,outline);
1209
  set_instruction_binasm(ins_dat,binasm_data);
1210
  setdata(new_ins,ins_dat);
1211
  add_instruction(new_ins);
1212
#endif
1213
  return;
1214
}
1215
 
1216
 
1217
#if 0
1218
void float_op_immediate
1219
    PROTO_N ( ( ins,src1,imm,dest ) )
1220
    PROTO_T ( instruction ins X int src1 X double imm X int dest )
1221
{
1222
  Instruction new_ins = get_new_instruction();
1223
  char *outline = (char*)xcalloc(80,sizeof(char));
1224
  setclass(new_ins,ins_class(ins));
1225
  setsets(new_ins,dest+float_register,ins_class(ins));
1226
  setuses(new_ins,src1+float_register,ins_class(ins));
1227
  if(as_file){
1228
    (void)fprintf(as_file,"\t%s\t$f%d,%lf,$f%d\n",ins_symbolic_name(ins),
1229
		  src1,imm,dest);
1230
    (void)sprintf(outline,"\t%s\t$f%d,%lf,$f%d\n",ins_symbolic_name(ins),
1231
		  src1,imm,dest);
1232
  }
1233
  clear_freg(dest);
1234
  setdata(new_ins,outline);
1235
  add_instruction(new_ins);
1236
  return;
1237
}
1238
#endif
1239
 
1240
 
1241
/*
1242
  floating point conversions.
1243
*/
1244
void float_convert
1245
    PROTO_N ( ( ins,src,dest ) )
1246
    PROTO_T ( instruction ins X int src X int dest )
1247
{
1248
  char * binasm_data;
1249
#if DO_SCHEDULE
1250
  char *outline = (char*)xcalloc(80,sizeof(char));
1251
  Instruction new_ins = get_new_instruction();
1252
  Instruction_data ins_dat = get_new_ins_data();
1253
  setclass(new_ins,ins_class(ins));
1254
  setsets(new_ins,dest+float_register,ins_class(ins));
1255
  setuses(new_ins,src+float_register,ins_class(ins));
1256
#endif
1257
  if(as_file){
1258
#if !DO_SCHEDULE
1259
    (void)fprintf(as_file,"\t%s\t$f%d,$f%d\n",ins_symbolic_name(ins),src,
1260
		  dest);
1261
#else
1262
    (void)sprintf(outline,"\t%s\t$f%d,$f%d\n",ins_symbolic_name(ins),src,
1263
		  dest);
1264
#endif
1265
  }
1266
  binasm_data = out_rinst(0,ins_binid(ins),src+float_register,
1267
			  dest+float_register,FRR,xnoreg);
1268
#if DO_SCHEDULE
1269
  set_instruction_text(ins_dat,outline);
1270
  set_instruction_binasm(ins_dat,binasm_data);
1271
  setdata(new_ins,ins_dat);
1272
  add_instruction(new_ins);
1273
#endif
1274
  return;
1275
}
1276
 
1277
 
1278
 
1279
/*
1280
  miscellaneous instructions
1281
*/
1282
void call_pal
1283
    PROTO_N ( ( ins,pal_ins ) )
1284
    PROTO_T ( instruction ins X instruction pal_ins )
1285
{
1286
  if(as_file){
1287
    (void)fprintf(as_file,"\t%s\t%s\n",ins_symbolic_name(ins),
1288
		  ins_symbolic_name(pal_ins));
1289
  }
1290
  return;
1291
}
1292
 
1293
void fetch
1294
    PROTO_N ( ( ins,a ) )
1295
    PROTO_T ( instruction ins X baseoff a )
1296
{
1297
#if DO_SCHEDULE
1298
  Instruction new_ins = get_new_instruction();
1299
  setclass(new_ins,ins_class(ins));
1300
  setuses(new_ins,a.base,ins_class(ins));
1301
#endif
1302
/*  setmemory_base(new_ins,a.base);
1303
  setmemory_offset(new_ins,a.offset);*/
1304
  if(a.offset!=0)
1305
    failer("fetch offset must be zero");
1306
  if(as_file){
1307
    (void)fprintf(as_file,"\t%s\t%ld($%d)\n",ins_symbolic_name(ins),
1308
		  a.offset,a.base);
1309
  }
1310
#if DO_SCHEDULE
1311
  add_instruction(new_ins);
1312
#endif
1313
  return;
1314
}
1315
 
1316
void no_parameter_instructions
1317
    PROTO_N ( ( ins ) )
1318
    PROTO_T ( instruction ins )
1319
{
1320
#if DO_SCHEDULE
1321
  Instruction new_ins = get_new_instruction();
1322
  Instruction_data ins_data = get_new_ins_data();
1323
  char * outline = (char*)xcalloc(strlen(ins_symbolic_name((ins)))+1,sizeof(char));
1324
  char * binasm_data;
1325
  setclass(new_ins,ins_class(ins));
1326
#endif
1327
  if(as_file){
1328
    (void)fprintf(as_file,"\t%s\n",ins_symbolic_name(ins));
1329
#if DO_SCHEDULE
1330
    (void)sprintf(outline,"\t%s\n",ins_symbolic_name(ins));
1331
    set_instruction_text(ins_data,outline);
1332
#endif
1333
  }
1334
#if DO_SCHEDULE
1335
  binasm_data = out_rinst(0,ins_binid(ins),xnoreg,xnoreg,xnoreg,xnoreg);
1336
  set_instruction_binasm(ins_data,binasm_data);
1337
  setdata(new_ins,ins_data);
1338
  add_instruction(new_ins);
1339
#else
1340
  (void)out_rinst(0,ins_binid(ins),xnoreg,xnoreg,xnoreg,xnoreg);
1341
#endif
1342
  return;
1343
 
1344
}
1345
 
1346
#if DO_SCHEDULE
1347
static void out_as_string
1348
    PROTO_N ( ( fp,str ) )
1349
    PROTO_T ( FILE *fp X char *str )
1350
{
1351
  int i;
1352
  int slen = strlen(str);
1353
  for(i=0;i<strlen(str);++i){
1354
    outchar(str[i]);
1355
  }
1356
  return;
1357
}
1358
#endif
1359
 
1360
 
1361
#if DO_SCHEDULE
1362
void out_code
1363
    PROTO_N ( ( ins_data ) )
1364
    PROTO_T ( Instruction_data ins_data )
1365
{
1366
  int i;
1367
  char * bdata = instruction_binasm(ins_data);
1368
  if(as_file && instruction_text(ins_data)){
1369
    out_as_string(as_file,instruction_text(ins_data));
1370
/*    fprintf(as_file,instruction_text(ins_data));*/
1371
  }
1372
  for(i=0;i<binasm_record_length;++i){
1373
    putc(bdata[i],ba_file);
1374
  }
1375
  /*(void)out_one(instruction_binasm(ins_data));*/
1376
  return;
1377
}
1378
#endif
1379
 
1380
 
1381
 
1382