Subversion Repositories tendra.SVN

Rev

Rev 5 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
 
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
Line 192... Line 222...
192
extern char *proc_name;
222
extern char *proc_name;
193
extern int line;
223
extern int line;
194
extern char export[128];
224
extern char export[128];
195
extern int firstlab,labno;
225
extern int firstlab,labno;
196
int leaf;
226
int leaf;
197
extern baseoff find_tg PROTO_S ((char* s));
227
extern baseoff find_tg(char* s);
198
extern exp find_named_tg PROTO_S ((char *,shape));
228
extern exp find_named_tg(char *,shape);
199
extern shape f_pointer PROTO_S ((alignment));
229
extern shape f_pointer(alignment);
200
extern alignment f_alignment PROTO_S ((shape));
230
extern alignment f_alignment(shape);
201
extern shape f_proc;
231
extern shape f_proc;
202
extern void do_exception PROTO_S ((int));
232
extern void do_exception(int);
203
 
233
 
204
int res_label;
234
int res_label;
205
static int untidy_return_label,return_to_label_label;
235
static int untidy_return_label,return_to_label_label;
206
static bool simpleans;
236
static bool simpleans;
207
static ans procans;
237
static ans procans;
Line 210... Line 240...
210
/*
240
/*
211
*   Temporary space on stack which can be referenced by short instruction
241
*   Temporary space on stack which can be referenced by short instruction
212
*   sequences, the space is initialised by each procedure prelude.
242
*   sequences, the space is initialised by each procedure prelude.
213
 */
243
 */
214
baseoff mem_temp
244
baseoff mem_temp
215
    PROTO_N ( (byte_offset) )
-
 
216
    PROTO_T ( int byte_offset )
245
(int byte_offset)
217
{
246
{
218
   baseoff b;
247
   baseoff b;
219
   b = MEM_TEMP_BOFF;
248
   b = MEM_TEMP_BOFF;
220
 
249
 
221
   /* Only 2 words of temporary memory allocated */
250
   /* Only 2 words of temporary memory allocated */
Line 227... Line 256...
227
 
256
 
228
 
257
 
229
 
258
 
230
/* Save callee-saves ("s") registers on the stack. */
259
/* Save callee-saves ("s") registers on the stack. */
231
void save_sregs
260
void save_sregs
232
    PROTO_Z ()
261
(void)
233
{
262
{
234
   if (fixdump==0)
263
   if (fixdump==0)
235
      return;
264
      return;
236
   else
265
   else
237
   {
266
   {
238
      int o=0,r;
267
      int o=0,r;
239
      for(r=16;r<32;r++)
268
      for (r=16;r<32;r++)
240
      {
269
      {
241
	 if (fixdump&(1<<r))
270
	 if (fixdump& (1<<r))
242
	 {
271
	 {
243
	    st_ir_ins(i_stw,cmplt_,r,fs_,empty_ltrl,o,SP);
272
	    st_ir_ins(i_stw,cmplt_,r,fs_,empty_ltrl,o,SP);
244
	    o+=4;
273
	    o+=4;
245
	 }
274
	 }
246
      }
275
      }
Line 248... Line 277...
248
}
277
}
249
 
278
 
250
 
279
 
251
/* Restore the callee-saves ("s") registers saved on the stack. */
280
/* Restore the callee-saves ("s") registers saved on the stack. */
252
void restore_sregs
281
void restore_sregs
253
    PROTO_Z ()
282
(void)
254
{
283
{
255
   if (fixdump==0)
284
   if (fixdump==0)
256
      return;
285
      return;
257
   else
286
   else
258
   {
287
   {
259
      int o=0,r;
288
      int o=0,r;
260
      for(r=16;r<32;r++)
289
      for (r=16;r<32;r++)
261
      {
290
      {
262
	 if (fixdump&(1<<r))
291
	 if (fixdump& (1<<r))
263
	 {
292
	 {
264
	    ld_ir_ins(i_ldw,cmplt_,fs_,empty_ltrl,o,SP,r);
293
	    ld_ir_ins(i_ldw,cmplt_,fs_,empty_ltrl,o,SP,r);
265
	    o+=4;
294
	    o+=4;
266
	 }
295
	 }
267
      }
296
      }
Line 272... Line 301...
272
/*
301
/*
273
*   Some (more or less) common code for res_tag, return_to_label and
302
*   Some (more or less) common code for res_tag, return_to_label and
274
*   untidy_return.
303
*   untidy_return.
275
 */
304
 */
276
static void code_for_ret
305
static void code_for_ret
277
    PROTO_N ( (which_ret) )
-
 
278
    PROTO_T ( int which_ret )
306
(int which_ret)
279
{
307
{
280
   if (which_ret==UNTIDY)
308
   if (which_ret==UNTIDY)
281
      rr_ins(i_copy,SP,T2);
309
      rr_ins(i_copy,SP,T2);
282
   if (Has_fp)
310
   if (Has_fp)
283
      rr_ins(i_copy,FP,SP);
311
      rr_ins(i_copy,FP,SP);
284
   else
312
   else
285
   {
313
   {
286
      baseoff b;
314
      baseoff b;
287
      b.base=(Has_vsp ? EP : SP); b.offset=-(frame_sz>>3);
315
      b.base= (Has_vsp ? EP : SP); b.offset=- (frame_sz>>3);
288
      ld_ins(i_lo,0,b,SP);
316
      ld_ins(i_lo,0,b,SP);
289
   }
317
   }
290
   restore_sregs();
318
   restore_sregs();
291
   if (which_ret!=TO_LAB)
319
   if (which_ret!=TO_LAB)
292
      ld_ir_ins(i_ldw,cmplt_,fs_,empty_ltrl,-20,SP,RP);
320
      ld_ir_ins(i_ldw,cmplt_,fs_,empty_ltrl,-20,SP,RP);
Line 297... Line 325...
297
      z_ins(i_nop);
325
      z_ins(i_nop);
298
}
326
}
299
 
327
 
300
 
328
 
301
static void add_odd_bits
329
static void add_odd_bits
302
    PROTO_N ( (r) )
-
 
303
    PROTO_T ( outofline *r )
330
(outofline *r)
304
{
331
{
305
   space sp;
332
   space sp;
306
   if (r!=(outofline*)nilexp)
333
   if (r!= (outofline*)nilexp)
307
   {
334
   {
308
      add_odd_bits(r->next);
335
      add_odd_bits(r->next);
309
      if (r->next==(outofline*)nilexp)
336
      if (r->next== (outofline*)nilexp)
310
	 last_odd_bit=1;
337
	 last_odd_bit=1;
311
   }
338
   }
312
   else
339
   else
313
      return;
340
      return;
314
   outlab("L$$",r->labno);
341
   outlab("L$$",r->labno);
315
   sp=r->sp;
342
   sp=r->sp;
316
   clear_all();
343
   clear_all();
317
   make_code(r->body,sp,r->dest, name(sh(r->body))!=bothd ? ptno(r->jr) : res_label);
344
   make_code(r->body,sp,r->dest, name(sh(r->body))!=bothd ? ptno(r->jr): res_label);
318
   if (name(sh(r->body))!=bothd)
345
   if (name(sh(r->body))!=bothd)
319
      ub_ins(cmplt_,ptno(r->jr));
346
      ub_ins(cmplt_,ptno(r->jr));
320
}
347
}
321
 
348
 
322
 
349
 
Line 330... Line 357...
330
 
357
 
331
/*
358
/*
332
*    Procedure definition
359
*    Procedure definition
333
 */
360
 */
334
makeans make_proc_tag_code
361
makeans make_proc_tag_code
335
    PROTO_N ( (e,sp,dest,exitlab) )
-
 
336
    PROTO_T ( exp e X space sp X where dest X int exitlab )
362
(exp e, space sp, where dest, int exitlab)
337
{
363
{
338
   static int p_lab = 0;
364
   static int p_lab = 0;
339
   procrec *pr=&procrecs[no(e)];
365
   procrec *pr=&procrecs[no(e)];
340
   needs *ndpr=&pr->needsproc;
366
   needs *ndpr=&pr->needsproc;
341
   long pprops=(long) (ndpr->propsneeds);
367
   long pprops= (long)(ndpr->propsneeds);
342
   makeans mka;
368
   makeans mka;
343
   bool is_main=STRCMP(proc_name,"main");
369
   bool is_main=STRCMP(proc_name,"main");
344
   bool save_sp;
370
   bool save_sp;
345
 
371
 
346
   set_up_frame(e);
372
   set_up_frame(e);
Line 356... Line 382...
356
   params_offset = pr->params_offset;
382
   params_offset = pr->params_offset;
357
   locals_offset = pr->locals_offset;
383
   locals_offset = pr->locals_offset;
358
   callee_sz = pr->callee_sz;
384
   callee_sz = pr->callee_sz;
359
   simpleans = (pprops & long_result_bit) == 0;
385
   simpleans = (pprops & long_result_bit) == 0;
360
 
386
 
361
   save_sp = ( ((Has_fp && (No_S || (Uses_crt_env && Has_vcallees)))) ||
387
   save_sp = (((Has_fp && (No_S || (Uses_crt_env && Has_vcallees)))) ||
362
	       (Uses_crt_env && (!leaf || proc_has_checkstack(e)
388
	      (Uses_crt_env && (!leaf || proc_has_checkstack(e)
363
				       || Has_checkalloc)));
389
				       || Has_checkalloc)));
364
 
390
 
365
   if (OPTIM)
391
   if (OPTIM)
366
   {
392
   {
367
      lines=BLOCK;
393
      lines=BLOCK;
368
      pCode = (pIn*) malloc(BLOCK*sizeof(pIn));
394
      pCode = (pIn*)malloc(BLOCK*sizeof(pIn));
369
      nLabels=4096;
395
      nLabels=4096;
370
      labIntro = (int*) malloc(nLabels*sizeof(int));
396
      labIntro = (int*)malloc(nLabels*sizeof(int));
371
      for(line=0;line<4096;line++)
397
      for (line=0;line<4096;line++)
372
	 labIntro[line]=-1;
398
	 labIntro[line] =-1;
373
      line=0;
399
      line=0;
374
   }
400
   }
375
   odd_bits = (outofline*)0;
401
   odd_bits = (outofline*)0;
376
   repeat_level=0;
402
   repeat_level=0;
377
 
403
 
378
   mka.lab = exitlab;
404
   mka.lab = exitlab;
379
   mka.regmove = NOREG;
405
   mka.regmove = NOREG;
380
 
406
 
381
   assert(name(e) == proc_tag);	/* procedure definition */
407
   assert(name(e) == proc_tag);	/* procedure definition */
382
 
408
 
383
   export[0]=0;
409
   export[0] =0;
384
   outnl();
410
   outnl();
385
   if (is_main)
411
   if (is_main)
386
   {
412
   {
387
      if (gcc_assembler)
413
      if (gcc_assembler)
388
      {
414
      {
Line 492... Line 518...
492
      {
518
      {
493
	 /* Add on callee_sz passed on stack by caller... */
519
	 /* Add on callee_sz passed on stack by caller... */
494
	 ld_ir_ins(i_ldw,cmplt_,fs_,empty_ltrl,(16<<2),SP,GR1);
520
	 ld_ir_ins(i_ldw,cmplt_,fs_,empty_ltrl,(16<<2),SP,GR1);
495
	 rrr_ins(i_add,c_,SP,GR1,R);
521
	 rrr_ins(i_add,c_,SP,GR1,R);
496
	 /* ...and ensure the stack pointer stays 16 word (64 byte) aligned */
522
	 /* ...and ensure the stack pointer stays 16 word (64 byte) aligned */
497
	 if (SIMM14((frame_sz>>3)+63))
523
	 if (SIMM14((frame_sz>>3) +63))
498
	 {
524
	 {
499
	    ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,(frame_sz>>3)+63,R,R);
525
	    ld_ir_ins(i_ldo,cmplt_,fs_,empty_ltrl,(frame_sz>>3) +63,R,R);
500
	 }
526
	 }
501
	 else
527
	 else
502
	 {
528
	 {
503
	    ir_ins(i_addil,fs_L,empty_ltrl,(frame_sz>>3)+63,R);
529
	    ir_ins(i_addil,fs_L,empty_ltrl,(frame_sz>>3) +63,R);
504
	    ld_ir_ins(i_ldo,cmplt_,fs_R,empty_ltrl,(frame_sz>>3)+63,GR1,R);
530
	    ld_ir_ins(i_ldo,cmplt_,fs_R,empty_ltrl,(frame_sz>>3) +63,GR1,R);
505
	 }
531
	 }
506
	 riir_ins(i_dep,c_,0,31,6,R);
532
	 riir_ins(i_dep,c_,0,31,6,R);
507
      }
533
      }
508
      else
534
      else
509
      {
535
      {
Line 554... Line 580...
554
   if (is_main)
580
   if (is_main)
555
   {
581
   {
556
      int n = new_label();
582
      int n = new_label();
557
      int end = new_label();
583
      int end = new_label();
558
      baseoff b;
584
      baseoff b;
559
      b.base = 0; b.offset = (gcc_assembler ? 0 : 4 );
585
      b.base = 0; b.offset = (gcc_assembler ? 0 : 4);
560
      set_ins((gcc_assembler ? "__CTOR_LIST__" : "__TDF_CTOR_LIST__"),b,GR4);
586
      set_ins((gcc_assembler ? "__CTOR_LIST__" : "__TDF_CTOR_LIST__"),b,GR4);
561
      b.base = GR4;
587
      b.base = GR4;
562
      b.offset = 4;
588
      b.offset = 4;
563
      if (gcc_assembler)
589
      if (gcc_assembler)
564
      {
590
      {
565
	 ld_ins(i_lwm,1,b,GR5);
591
	 ld_ins(i_lwm,1,b,GR5);
566
	 cj_ins(c_eq,GR0,GR5,end);
592
	 cj_ins(c_eq,GR0,GR5,end);
567
	 rrr_ins(i_sh2add,c_,GR5,GR4,GR5);
593
	 rrr_ins(i_sh2add,c_,GR5,GR4,GR5);
568
	 outlab("L$$",n);
594
	 outlab("L$$",n);
569
	 ld_ins(i_lwm,1,b,GR22);
595
	 ld_ins(i_lwm,1,b,GR22);
570
	 call_millicode( MILLI_DYNCALL, RP, "",0 );
596
	 call_millicode(MILLI_DYNCALL, RP, "",0);
571
	 cj_ins(c_l,GR4,GR5,n);
597
	 cj_ins(c_l,GR4,GR5,n);
572
	 outlab("L$$",end);
598
	 outlab("L$$",end);
573
	 if (is_PIC_and_calls)
599
	 if (is_PIC_and_calls)
574
	    ld_ir_ins(i_ldw,cmplt_,fs_,empty_ltrl,-32,SP,GR5);
600
	    ld_ir_ins(i_ldw,cmplt_,fs_,empty_ltrl,-32,SP,GR5);
575
	 call_ins(cmplt_,"__main",RP,"");
601
	 call_ins(cmplt_,"__main",RP,"");
Line 577... Line 603...
577
      else
603
      else
578
      {
604
      {
579
	 ld_ins(i_lwm,1,b,GR22);
605
	 ld_ins(i_lwm,1,b,GR22);
580
	 cj_ins(c_eq,GR0,GR22,end);
606
	 cj_ins(c_eq,GR0,GR22,end);
581
	 outlab("L$$",n);
607
	 outlab("L$$",n);
582
	 call_millicode( MILLI_DYNCALL, RP, "",0 );
608
	 call_millicode(MILLI_DYNCALL, RP, "",0);
583
	 ld_ins(i_lwm,1,b,GR22);
609
	 ld_ins(i_lwm,1,b,GR22);
584
	 cj_ins(c_neq,GR0,GR22,n);
610
	 cj_ins(c_neq,GR0,GR22,n);
585
	 outlab("L$$",end);
611
	 outlab("L$$",end);
586
      }
612
      }
587
   }
613
   }
588
 
614
 
589
   if (Has_vsp)
615
   if (Has_vsp)
590
      rr_ins(i_copy,SP,EP);
616
      rr_ins(i_copy,SP,EP);
591
   if (Has_tos)
617
   if (Has_tos)
592
      st_ins(i_sw,SP,SP_BOFF);
618
      st_ins(i_sw,SP,SP_BOFF);
593
   if ( (Has_fp && (No_S || (Uses_crt_env && Has_vcallees))) )
619
   if ((Has_fp && (No_S || (Uses_crt_env && Has_vcallees))))
594
      st_ins(i_sw,FP,FP_BOFF);
620
      st_ins(i_sw,FP,FP_BOFF);
595
 
621
 
596
   if (!simpleans)
622
   if (!simpleans)
597
   {
623
   {
598
      /* structure or union result */
624
      /* structure or union result */
Line 601... Line 627...
601
      is.adval = 0;
627
      is.adval = 0;
602
      is.b = LONG_RESULT_BOFF;
628
      is.b = LONG_RESULT_BOFF;
603
      setinsalt(procans,is);
629
      setinsalt(procans,is);
604
      st_ins(i_sw,RET0,is.b);
630
      st_ins(i_sw,RET0,is.b);
605
   }
631
   }
606
   else if ((pprops & realresult_bit) != 0)
632
   else if ((pprops & realresult_bit)!= 0)
607
   {
633
   {
608
      /* real result */
634
      /* real result */
609
      freg frg;
635
      freg frg;
610
      frg.fr = R_FR4;
636
      frg.fr = R_FR4;
611
      frg.dble = (pprops & longrealresult_bit) ? 1 : 0;
637
      frg.dble = (pprops & longrealresult_bit)? 1 : 0;
612
      setfregalt(procans,frg);
638
      setfregalt(procans,frg);
613
   }
639
   }
614
   else if ((pprops & has_result_bit) != 0)
640
   else if ((pprops & has_result_bit)!= 0)
615
   {
641
   {
616
      /* fixed register result */
642
      /* fixed register result */
617
      setregalt(procans,RET0);
643
      setregalt(procans,RET0);
618
   }
644
   }
619
   else
645
   else
Line 666... Line 692...
666
      */
692
      */
667
     int i,j;
693
     int i,j;
668
     char *hit;
694
     char *hit;
669
     FILE_POSN Pos;
695
     FILE_POSN Pos;
670
     GET_FILE_POSN(outf,Pos);
696
     GET_FILE_POSN(outf,Pos);
671
     hit = (char*) malloc( (nLabels+8)*sizeof(char) );
697
     hit = (char*)malloc((nLabels+8)*sizeof(char));
672
     for(i=0;i<line;i++)
698
     for (i=0;i<line;i++)
673
     {
699
     {
674
	char s[65];
700
	char s[65];
675
	int lab,to=0,jump;
701
	int lab,to=0,jump;
676
	lab=pCode[i]->lab;
702
	lab=pCode[i] ->lab;
677
	if (lab==res_label && lab>0)
703
	if (lab==res_label && lab>0)
678
	   to=labIntro[lab-firstlab];
704
	   to=labIntro[lab-firstlab];
679
	else
705
	else
680
	if (lab>NA && lab != res_label && pCode[i]->ins != i_lab)
706
	if (lab>NA && lab != res_label && pCode[i] ->ins != i_lab)
681
	{
707
	{
682
	   for (j=0;j<nLabels+8;j++)
708
	   for (j=0;j<nLabels+8;j++)
683
	       hit[j]=0;
709
	       hit[j] =0;
684
	   to=labIntro[lab-firstlab];
710
	   to=labIntro[lab-firstlab];
685
	   while(to+1<line && lab!=res_label && pCode[to+1]->lab>NA
711
	   while (to+1<line && lab!=res_label && pCode[to+1] ->lab>NA
686
			   && pCode[to+1]->ins==i_ub && hit[lab-firstlab]==0)
712
			   && pCode[to+1] ->ins==i_ub && hit[lab-firstlab] ==0)
687
	   {
713
	   {
688
	      hit[lab-firstlab]=1;
714
	      hit[lab-firstlab] =1;
689
	      lab=pCode[to+1]->lab;
715
	      lab=pCode[to+1] ->lab;
690
	      to=labIntro[lab-firstlab];
716
	      to=labIntro[lab-firstlab];
691
	   }
717
	   }
692
	}
718
	}
693
	if (pCode[i]->ins==i_bb)
719
	if (pCode[i] ->ins==i_bb)
694
	{
720
	{
695
	   jump = i-to ;
721
	   jump = i-to;
696
	   if (SIMM11(jump*4))
722
	   if (SIMM11(jump*4))
697
	   {
723
	   {
698
	      ins_p cc;
724
	      ins_p cc;
699
	      int a,b;
725
	      int a,b;
700
	      cc=pCode[i]->cc;
726
	      cc=pCode[i] ->cc;
701
	      SET_FILE_POSN(outf,(pCode[i]->fpos));
727
	      SET_FILE_POSN(outf,(pCode[i] ->fpos));
702
	      a=pCode[i]->op[0];
728
	      a=pCode[i] ->op[0];
703
	      b=pCode[i]->op[1];
729
	      b=pCode[i] ->op[1];
704
	      IGNORE sprintf(s,"\tbb%s,N\t%s,%d,L$$%d\n\tnop",cc,RN(a),b,lab);
730
	      IGNORE sprintf(s,"\tbb%s,N\t%s,%d,L$$%d\n\tnop",cc,RN(a),b,lab);
705
	      j=(int)strlen(s);
731
	      j= (int)strlen(s);
706
	      for(;j<63;j++)
732
	      for (;j<63;j++)
707
		 s[j]=' ';
733
		 s[j] =' ';
708
	      s[63]=0;
734
	      s[63] =0;
709
	      fprintf(outf,"%s\n",s);
735
	      fprintf(outf,"%s\n",s);
710
	   }
736
	   }
711
	   else
737
	   else
712
	   {
738
	   {
713
	      ins_p cc;
739
	      ins_p cc;
714
	      int a,b;
740
	      int a,b;
715
	      if (pCode[i]->cc==bit_is_0)
741
	      if (pCode[i] ->cc==bit_is_0)
716
		 cc=c_OD;
742
		 cc=c_OD;
717
	      else
743
	      else
718
		 cc=c_EV;
744
		 cc=c_EV;
719
	      SET_FILE_POSN(outf,(pCode[i]->fpos));
745
	      SET_FILE_POSN(outf,(pCode[i] ->fpos));
720
	      a=pCode[i]->op[0];
746
	      a=pCode[i] ->op[0];
721
	      b=pCode[i]->op[1];
747
	      b=pCode[i] ->op[1];
722
	      IGNORE sprintf(s,"\textru%s\t%s,%d,1,0\n\tb\tL$$%d\n\tnop",cc,RN(a),b,lab);
748
	      IGNORE sprintf(s,"\textru%s\t%s,%d,1,0\n\tb\tL$$%d\n\tnop",cc,RN(a),b,lab);
723
	      j=(int)strlen(s);
749
	      j= (int)strlen(s);
724
	      for(;j<63;j++)
750
	      for (;j<63;j++)
725
		 s[j]=' ';
751
		 s[j] =' ';
726
	      s[63]=0;
752
	      s[63] =0;
727
	      fprintf(outf,"%s\n",s);
753
	      fprintf(outf,"%s\n",s);
728
	   }
754
	   }
729
	}
755
	}
730
	else
756
	else
731
	if (pCode[i]->ins==i_ub)
757
	if (pCode[i] ->ins==i_ub)
732
	{
758
	{
733
	   jump = i-to ;
759
	   jump = i-to;
734
	   SET_FILE_POSN(outf,(pCode[i]->fpos));
760
	   SET_FILE_POSN(outf,(pCode[i] ->fpos));
735
#if 0
761
#if 0
736
	   if (SIMM19(jump*4))
762
	   if (SIMM19(jump*4))
737
	   {
763
	   {
738
#endif
764
#endif
739
	      IGNORE sprintf(s,"\tb\tL$$%d\n\tnop",lab);
765
	      IGNORE sprintf(s,"\tb\tL$$%d\n\tnop",lab);
740
	      j=(int)strlen(s);
766
	      j= (int)strlen(s);
741
	      for(;j<63;j++)
767
	      for (;j<63;j++)
742
		 s[j]=' ';
768
		 s[j] =' ';
743
	      s[63]='\n';
769
	      s[63] ='\n';
744
	      s[64]=0;
770
	      s[64] =0;
745
	      fprintf(outf,"%s",s);
771
	      fprintf(outf,"%s",s);
746
#if 0
772
#if 0
747
	   }
773
	   }
748
	   else
774
	   else
749
	   {
775
	   {
750
	   }
776
	   }
751
#endif
777
#endif
752
	}
778
	}
753
	else
779
	else
754
	if (pCode[i]->ins==i_cj || pCode[i]->ins==i_cij)
780
	if (pCode[i] ->ins==i_cj || pCode[i] ->ins==i_cij)
755
	{
781
	{
756
	   jump = i-to ;
782
	   jump = i-to;
757
	   if (SIMM11(jump*4))
783
	   if (SIMM11(jump*4))
758
	   {
784
	   {
759
	      ins_p cc;
785
	      ins_p cc;
760
	      int a,b;
786
	      int a,b;
761
	      cc=pCode[i]->cc;
787
	      cc=pCode[i] ->cc;
762
	      SET_FILE_POSN(outf,(pCode[i]->fpos));
788
	      SET_FILE_POSN(outf,(pCode[i] ->fpos));
763
	      a=pCode[i]->op[0];
789
	      a=pCode[i] ->op[0];
764
	      b=pCode[i]->op[1];
790
	      b=pCode[i] ->op[1];
765
	      if (jump<0 && line>i)
791
	      if (jump<0 && line>i)
766
	      {
792
	      {
767
	      if (pCode[i]->ins==i_cj)
793
	      if (pCode[i] ->ins==i_cj)
768
		 IGNORE sprintf(s,"\tcomb%s,N\t%s,%s,L$$%d\n",cc,RN(a),RN(b),lab);
794
		 IGNORE sprintf(s,"\tcomb%s,N\t%s,%s,L$$%d\n",cc,RN(a),RN(b),lab);
769
	      else
795
	      else
770
		 IGNORE sprintf(s,"\tcomib%s,N\t%d,%s,L$$%d\n",cc,a,RN(b),lab);
796
		 IGNORE sprintf(s,"\tcomib%s,N\t%d,%s,L$$%d\n",cc,a,RN(b),lab);
771
	      }
797
	      }
772
	      else
798
	      else
773
	      {
799
	      {
774
	      if (pCode[i]->ins==i_cj)
800
	      if (pCode[i] ->ins==i_cj)
775
		 IGNORE sprintf(s,"\tcomb%s,N\t%s,%s,L$$%d\n\tnop",cc,RN(a),RN(b),lab);
801
		 IGNORE sprintf(s,"\tcomb%s,N\t%s,%s,L$$%d\n\tnop",cc,RN(a),RN(b),lab);
776
	      else
802
	      else
777
		 IGNORE sprintf(s,"\tcomib%s,N\t%d,%s,L$$%d\n\tnop",cc,a,RN(b),lab);
803
		 IGNORE sprintf(s,"\tcomib%s,N\t%d,%s,L$$%d\n\tnop",cc,a,RN(b),lab);
778
	      }
804
	      }
779
	      j=(int)strlen(s);
805
	      j= (int)strlen(s);
780
	      for(;j<63;j++)
806
	      for (;j<63;j++)
781
		 s[j]=' ';
807
		 s[j] =' ';
782
	      s[63]=0;
808
	      s[63] =0;
783
	      fprintf(outf,"%s\n",s);
809
	      fprintf(outf,"%s\n",s);
784
	   }
810
	   }
785
	   else
811
	   else
786
#if 0
812
#if 0
787
	   if (SIMM19(jump*4))
813
	   if (SIMM19(jump*4))
788
#endif
814
#endif
789
	   {
815
	   {
790
	      ins_p cc;
816
	      ins_p cc;
791
	      int a,b;
817
	      int a,b;
792
	      cc=opp(pCode[i]->cc);
818
	      cc=opp(pCode[i] ->cc);
793
	      SET_FILE_POSN(outf,(pCode[i]->fpos));
819
	      SET_FILE_POSN(outf,(pCode[i] ->fpos));
794
	      a=pCode[i]->op[0];
820
	      a=pCode[i] ->op[0];
795
	      b=pCode[i]->op[1];
821
	      b=pCode[i] ->op[1];
796
	      if (pCode[i]->ins==i_cj)
822
	      if (pCode[i] ->ins==i_cj)
797
		 IGNORE sprintf(s,"\tcomclr%s\t%s,%s,0\n\tb\tL$$%d\n\tnop",cc,RN(a),RN(b),lab);
823
		 IGNORE sprintf(s,"\tcomclr%s\t%s,%s,0\n\tb\tL$$%d\n\tnop",cc,RN(a),RN(b),lab);
798
	      else
824
	      else
799
		 IGNORE sprintf(s,"\tcomiclr%s\t%d,%s,0\n\tb\tL$$%d\n\tnop",cc,a,RN(b),lab);
825
		 IGNORE sprintf(s,"\tcomiclr%s\t%d,%s,0\n\tb\tL$$%d\n\tnop",cc,a,RN(b),lab);
800
	      j=(int)strlen(s);
826
	      j= (int)strlen(s);
801
	      for(;j<63;j++)
827
	      for (;j<63;j++)
802
		 s[j]=' ';
828
		 s[j] =' ';
803
	      s[63]=0;
829
	      s[63] =0;
804
	      fprintf(outf,"%s\n",s);
830
	      fprintf(outf,"%s\n",s);
805
	   }
831
	   }
806
#if 0
832
#if 0
807
	   else
833
	   else
808
	   {
834
	   {
809
	      ins_p cc;
835
	      ins_p cc;
810
	      int a,b;
836
	      int a,b;
811
	      cc=pCode[i]->cc;
837
	      cc=pCode[i] ->cc;
812
	      SET_FILE_POSN(outf,(pCode[i]->fpos));
838
	      SET_FILE_POSN(outf,(pCode[i] ->fpos));
813
	      a=pCode[i]->op[0];
839
	      a=pCode[i] ->op[0];
814
	      b=pCode[i]->op[1];
840
	      b=pCode[i] ->op[1];
815
	      if (pCode[i]->ins==i_cj)
841
	      if (pCode[i] ->ins==i_cj)
816
		 IGNORE sprintf(s,"\tcomb%s,N\t%s,%s,.+16\n\tnop\n\tLB\tL$$%d\n",cc,RN(a),RN(b),lab);
842
		 IGNORE sprintf(s,"\tcomb%s,N\t%s,%s,.+16\n\tnop\n\tLB\tL$$%d\n",cc,RN(a),RN(b),lab);
817
	      else
843
	      else
818
		 IGNORE sprintf(s,"\tcomib%s,N\t%d,%s,.+16\n\tnop\n\tLB\tL$$%d\n",cc,a,RN(b),lab);
844
		 IGNORE sprintf(s,"\tcomib%s,N\t%d,%s,.+16\n\tnop\n\tLB\tL$$%d\n",cc,a,RN(b),lab);
819
	      j=(int)strlen(s);
845
	      j= (int)strlen(s);
820
	      for(;j<63;j++)
846
	      for (;j<63;j++)
821
		 s[j]=' ';
847
		 s[j] =' ';
822
	      s[63]=0;
848
	      s[63] =0;
823
	      fprintf(outf,"%s\n",s);
849
	      fprintf(outf,"%s\n",s);
824
	   }
850
	   }
825
#endif
851
#endif
826
	}
852
	}
827
     }
853
     }
Line 831... Line 857...
831
 
857
 
832
 
858
 
833
 
859
 
834
{
860
{
835
   int i;
861
   int i;
836
   for(i=0;i<line;i++)
862
   for (i=0;i<line;i++)
837
   {
863
   {
838
      pIn j=pCode[line];
864
      pIn j=pCode[line];
839
      free(j);
865
      free(j);
840
   }
866
   }
841
   free(pCode);
867
   free(pCode);
Line 852... Line 878...
852
/*
878
/*
853
*   res_tag, return_to_label or untidy_return
879
*   res_tag, return_to_label or untidy_return
854
 */
880
 */
855
 
881
 
856
makeans make_res_tag_code
882
makeans make_res_tag_code
857
    PROTO_N ( (e,sp,dest,exitlab) )
-
 
858
    PROTO_T ( exp e X space sp X where dest X int exitlab )
883
(exp e, space sp, where dest, int exitlab)
859
{
884
{
860
   makeans mka;
885
   makeans mka;
861
   int nm,*ret_label;
886
   int nm,*ret_label;
862
   mka.lab = exitlab;
887
   mka.lab = exitlab;
863
   mka.regmove = NOREG;
888
   mka.regmove = NOREG;
864
   if (name(e)==res_tag)
889
   if (name(e) ==res_tag)
865
   {
890
   {
866
      nm=RES;
891
      nm=RES;
867
      ret_label=&res_label;
892
      ret_label=&res_label;
868
   }
893
   }
869
   else
894
   else
870
   if (name(e)==return_to_label_tag)
895
   if (name(e) ==return_to_label_tag)
871
   {
896
   {
872
      nm=TO_LAB;
897
      nm=TO_LAB;
873
      ret_label=&return_to_label_label;
898
      ret_label=&return_to_label_label;
874
   }
899
   }
875
   else
900
   else