~ubuntu-branches/ubuntu/dapper/fpc/dapper

« back to all changes in this revision

Viewing changes to compiler/powerpc/agppcmpw.pas

  • Committer: Bazaar Package Importer
  • Author(s): Carlos Laviola
  • Date: 2005-05-30 11:59:10 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050530115910-x5pbzm4qqta4i94h
Tags: 2.0.0-2
debian/fp-compiler.postinst.in: forgot to reapply the patch that
correctly creates the slave link to pc(1).  (Closes: #310907)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
{
2
 
    $Id: agppcmpw.pas,v 1.34 2004/03/17 12:03:31 olle Exp $
 
2
    $Id: agppcmpw.pas,v 1.44 2005/02/14 17:13:10 peter Exp $
3
3
    Copyright (c) 2002 by Florian Klaempfl
4
4
 
5
5
    This unit implements an asmoutput class for PowerPC with MPW syntax
48
48
      private
49
49
        procedure WriteInstruction(hp : tai);
50
50
        procedure WriteProcedureHeader(var hp:tai);
51
 
        procedure WriteDataExportHeader(var s:string; isGlobal, isConst:boolean);
 
51
        procedure WriteDataHeader(var s:string; isExported, isConst:boolean);
 
52
        cur_CSECT_name: String;
 
53
        cur_CSECT_class: String;
52
54
      end;
53
55
 
54
56
 
55
57
  implementation
56
58
 
57
59
    uses
58
 
{$ifdef delphi}
59
 
      sysutils,
60
 
{$endif}
61
60
      cutils,globtype,systems,cclasses,
62
61
      verbose,finput,fmodule,script,cpuinfo,
63
 
      cgbase,
 
62
      cgbase,cgutils,
64
63
      itcpugas
65
64
      ;
66
65
 
70
69
      {Whether internal procedure references should be xxx[PR]: }
71
70
      use_PR = false;
72
71
 
73
 
      const_storage_class = '[RW]';
74
 
 
75
 
 
 
72
      const_storage_class = '';
 
73
      var_storage_class = '';
 
74
 
 
75
      secnames : array[TAsmSectionType] of string[10] = (
 
76
        '',      {none}
 
77
        'csect', {code}
 
78
        'csect', {data}
 
79
        'csect', {read only data}
 
80
        'csect', {bss}
 
81
        'csect','csect','csect','csect','','','','','','','',''
 
82
      );
76
83
 
77
84
{$ifdef GDB}
78
85
var
85
92
      firstLineInFunction: longint;
86
93
{$endif}
87
94
 
 
95
    type
 
96
      t64bitarray = array[0..7] of byte;
 
97
      t32bitarray = array[0..3] of byte;
 
98
 
88
99
    function ReplaceForbiddenChars(var s: string):Boolean;
89
100
         {Returns wheater a replacement has occured.}
90
101
 
406
417
         double2str:=lower(hs);
407
418
      end;
408
419
 
 
420
  { convert floating point values }
 
421
  { to correct endian             }
 
422
  procedure swap64bitarray(var t: t64bitarray);
 
423
    var
 
424
     b: byte;
 
425
    begin
 
426
      b:= t[7];
 
427
      t[7] := t[0];
 
428
      t[0] := b;
 
429
 
 
430
      b := t[6];
 
431
      t[6] := t[1];
 
432
      t[1] := b;
 
433
 
 
434
      b:= t[5];
 
435
      t[5] := t[2];
 
436
      t[2] := b;
 
437
 
 
438
      b:= t[4];
 
439
      t[4] := t[3];
 
440
      t[3] := b;
 
441
   end;
 
442
 
 
443
   procedure swap32bitarray(var t: t32bitarray);
 
444
    var
 
445
     b: byte;
 
446
    begin
 
447
      b:= t[1];
 
448
      t[1]:= t[2];
 
449
      t[2]:= b;
 
450
 
 
451
      b:= t[0];
 
452
      t[0]:= t[3];
 
453
      t[3]:= b;
 
454
    end;
 
455
 
409
456
   function fixline(s:string):string;
410
457
   {
411
458
     return s with all leading and ending spaces and tabs removed
425
472
       fixline:=Copy(s,j,i-j+1);
426
473
     end;
427
474
 
 
475
    Function PadTabs(const p:string;addch:char):string;
 
476
    var
 
477
      s : string;
 
478
      i : longint;
 
479
    begin
 
480
      i:=length(p);
 
481
      if addch<>#0 then
 
482
       begin
 
483
         inc(i);
 
484
         s:=p+addch;
 
485
       end
 
486
      else
 
487
       s:=p;
 
488
      if i<8 then
 
489
       PadTabs:=s+#9#9
 
490
      else
 
491
       PadTabs:=s+#9;
 
492
    end;
428
493
 
429
494
{****************************************************************************
430
495
                               PowerPC MPW Assembler
565
630
      until not GetAdjacentTaiSymbol(hp);
566
631
    end;
567
632
 
568
 
    procedure TPPCMPWAssembler.WriteDataExportHeader(var s:string; isGlobal, isConst:boolean);
 
633
    procedure TPPCMPWAssembler.WriteDataHeader(var s:string; isExported, isConst:boolean);
569
634
    // Returns in s the changed string
570
635
    var
571
636
      sym: string;
575
640
      sym:= s;
576
641
      replaced:= ReplaceForbiddenChars(s);
577
642
 
578
 
      if isGlobal then
 
643
      if isExported then
579
644
        begin
580
645
          AsmWrite(#9'export'#9);
581
646
          AsmWrite(s);
582
647
          if isConst then
583
648
            AsmWrite(const_storage_class)
584
649
          else
585
 
            AsmWrite('[RW]');
 
650
            AsmWrite(var_storage_class);
586
651
          if replaced then
587
652
              begin
588
653
                AsmWrite(' => ''');
594
659
 
595
660
      if not macos_direct_globals then
596
661
        begin
 
662
          {The actual section is here interrupted, by inserting a "tc" entry}
597
663
          AsmWriteLn(#9'toc');
598
664
 
599
665
          AsmWrite(#9'tc'#9);
603
669
          if isConst then
604
670
            AsmWrite(const_storage_class)
605
671
          else
606
 
            AsmWrite('[RW]');
 
672
            AsmWrite(var_storage_class);
607
673
          AsmLn;
608
674
 
 
675
          {The interrupted section is here continued.}
609
676
          AsmWrite(#9'csect'#9);
610
 
          AsmWrite(s);
611
 
          if isConst then
612
 
            AsmWrite(const_storage_class)
613
 
          else
614
 
            AsmWrite('[RW]');
 
677
          AsmWriteln(cur_CSECT_name+cur_CSECT_class);
 
678
          AsmWrite(PadTabs(s+':',#0));
615
679
        end
616
680
      else
617
681
        begin
624
688
    end;
625
689
 
626
690
    var
627
 
      LasTSec : TSection;
 
691
      LasTSec : TAsmSectionType;
628
692
      lastfileinfo : tfileposinfo;
629
693
      infile,
630
694
      lastinfile   : tinputfile;
633
697
      ait_const2str:array[ait_const_32bit..ait_const_8bit] of string[8]=
634
698
        (#9'dc.l'#9,#9'dc.w'#9,#9'dc.b'#9);
635
699
 
636
 
    Function PadTabs(const p:string;addch:char):string;
637
 
    var
638
 
      s : string;
639
 
      i : longint;
640
 
    begin
641
 
      i:=length(p);
642
 
      if addch<>#0 then
643
 
       begin
644
 
         inc(i);
645
 
         s:=p+addch;
646
 
       end
647
 
      else
648
 
       s:=p;
649
 
      if i<8 then
650
 
       PadTabs:=s+#9#9
651
 
      else
652
 
       PadTabs:=s+#9;
653
 
    end;
654
700
 
655
701
{$ifdef GDB}
656
702
    procedure TPPCMPWAssembler.WriteFileLineInfo(var fileinfo : tfileposinfo);
710
756
              AsmWriteLn(#9'.stabd'#9+tostr(n_line)+',0,'+tostr(fileinfo.line));
711
757
            *)
712
758
            if isInFunction then
713
 
              AsmWriteln(#9'line '+ tostr(fileinfo.line - firstLineInFunction - 1));
 
759
              AsmWriteln(#9'line '+ tostr(fileinfo.line - firstLineInFunction + 1));
714
760
          end;
715
761
          stabslastfileinfo:=fileinfo;
716
762
        end;
748
794
      quoted   : boolean;
749
795
      sep      : char;
750
796
      replaced : boolean;
 
797
      sin      : single;
 
798
      d        : double;
751
799
 
752
800
    begin
753
801
      if not assigned(p) then
834
882
              begin
835
883
                 {if LasTSec<>sec_none then
836
884
                  AsmWriteLn('_'+target_asm.secnames[LasTSec]+#9#9'ENDS');}
837
 
                 if tai_section(hp).sec<>sec_none then
 
885
 
 
886
                 if tai_section(hp).sectype<>sec_none then
838
887
                  begin
 
888
                    if tai_section(hp).sectype in [sec_data,sec_rodata,sec_bss] then
 
889
                      cur_CSECT_class:= '[RW]'
 
890
                    else if tai_section(hp).sectype in [sec_code] then
 
891
                      cur_CSECT_class:= ''
 
892
                    else
 
893
                      cur_CSECT_class:= '[RO]';
 
894
 
 
895
                    s:= tai_section(hp).name^;
 
896
                    if s = '' then
 
897
                      InternalError(2004101001);    {Nameless sections should not occur on MPW}
 
898
                    ReplaceForbiddenChars(s);
 
899
                    cur_CSECT_name:= s;
 
900
 
839
901
                    AsmLn;
840
 
                    AsmWriteLn(#9+target_asm.secnames[tai_section(hp).sec]);
 
902
                    AsmWriteLn(#9+secnames[tai_section(hp).sectype]+' '+cur_CSECT_name+cur_CSECT_class);
841
903
{$ifdef GDB}
842
 
                  lastfileinfo.line:=-1;
 
904
                    lastfileinfo.line:=-1;
843
905
{$endif GDB}
844
906
                  end;
845
 
                 LasTSec:=tai_section(hp).sec;
 
907
                 LasTSec:=tai_section(hp).sectype;
846
908
               end;
847
909
            ait_align:
848
910
              begin
853
915
                   otherwise internalerror(2002110302);
854
916
                 end;
855
917
              end;
856
 
            ait_datablock:
 
918
            ait_datablock: {Storage for global variables.}
857
919
              begin
858
920
                 s:= tai_datablock(hp).sym.name;
859
921
 
860
 
                 WriteDataExportHeader(s, tai_datablock(hp).is_global, false);
861
 
 
 
922
                 WriteDataHeader(s, tai_datablock(hp).is_global, false);
862
923
                 if not macos_direct_globals then
863
924
                   begin
864
925
                     AsmWriteLn(#9'ds.b '+tostr(tai_datablock(hp).size));
869
930
                     {TODO: ? PadTabs(s,#0) }
870
931
                   end;
871
932
              end;
872
 
            ait_const_32bit,
873
 
            ait_const_8bit,
874
 
            ait_const_16bit :
875
 
              begin
876
 
                 AsmWrite(ait_const2str[hp.typ]+tostr(tai_const(hp).value));
877
 
                 consttyp:=hp.typ;
878
 
                 l:=0;
879
 
                 repeat
880
 
                   found:=(not (tai(hp.next)=nil)) and (tai(hp.next).typ=consttyp);
881
 
                   if found then
882
 
                    begin
883
 
                      hp:=tai(hp.next);
884
 
                      s:=','+tostr(tai_const(hp).value);
885
 
                      AsmWrite(s);
886
 
                      inc(l,length(s));
887
 
                    end;
888
 
                 until (not found) or (l>line_length);
889
 
                 AsmLn;
890
 
               end;
891
 
            ait_const_symbol:
892
 
              begin
893
 
                s:= tai_const_symbol(hp).sym.name;
894
 
                ReplaceForbiddenChars(s);
895
933
 
896
 
                AsmWrite(#9'dc.l'#9);
897
 
                if tai_const_symbol(hp).sym.typ = AT_FUNCTION then
 
934
           ait_const_128bit:
 
935
              begin
 
936
                internalerror(200404291);
 
937
              end;
 
938
           ait_const_64bit:
 
939
              begin
 
940
                if assigned(tai_const(hp).sym) then
 
941
                  internalerror(200404292);
 
942
                AsmWrite(ait_const2str[ait_const_32bit]);
 
943
                if target_info.endian = endian_little then
898
944
                  begin
899
 
                    if use_PR then
900
 
                      AsmWrite('.');
901
 
 
902
 
                    AsmWrite(s);
903
 
 
904
 
                    if use_PR then
905
 
                      AsmWriteLn('[PR]')
906
 
                    else
907
 
                      AsmWriteLn('[DS]')
 
945
                    AsmWrite(tostr(longint(lo(tai_const(hp).value))));
 
946
                    AsmWrite(',');
 
947
                    AsmWrite(tostr(longint(hi(tai_const(hp).value))));
908
948
                  end
909
949
                else
910
950
                  begin
911
 
                    AsmWrite(s);
912
 
                    if not macos_direct_globals then
913
 
                      AsmWriteLn(const_storage_class);
914
 
                  end;
915
 
 
916
 
                (* TODO: the following might need to be included. Temporaily we
917
 
                generate an error
918
 
 
919
 
                if tai_const_symbol(hp).offset>0 then
920
 
                  AsmWrite('+'+tostr(tai_const_symbol(hp).offset))
921
 
                else if tai_const_symbol(hp).offset<0 then
922
 
                  AsmWrite(tostr(tai_const_symbol(hp).offset));
923
 
                *)
924
 
 
925
 
                if tai_const_symbol(hp).offset <> 0 then
926
 
                  InternalError(2002110101);
927
 
 
928
 
                AsmLn;
929
 
              end;
930
 
            ait_real_32bit:
931
 
              AsmWriteLn(#9'dc.l'#9'"'+single2str(tai_real_32bit(hp).value)+'"');
932
 
            ait_real_64bit:
933
 
              AsmWriteLn(#9'dc.d'#9'"'+double2str(tai_real_64bit(hp).value)+'"');
 
951
                    AsmWrite(tostr(longint(hi(tai_const(hp).value))));
 
952
                    AsmWrite(',');
 
953
                    AsmWrite(tostr(longint(lo(tai_const(hp).value))));
 
954
                  end;
 
955
                AsmLn;
 
956
              end;
 
957
 
 
958
           ait_const_uleb128bit,
 
959
           ait_const_sleb128bit,
 
960
           ait_const_32bit,
 
961
           ait_const_16bit,
 
962
           ait_const_8bit,
 
963
           ait_const_rva_symbol,
 
964
           ait_const_indirect_symbol :
 
965
             begin
 
966
               AsmWrite(ait_const2str[hp.typ]);
 
967
               consttyp:=hp.typ;
 
968
               l:=0;
 
969
               repeat
 
970
                 if assigned(tai_const(hp).sym) then
 
971
                   begin
 
972
                     if assigned(tai_const(hp).endsym) then
 
973
                       begin
 
974
                         if (tai_const(hp).endsym.typ = AT_FUNCTION) and use_PR then
 
975
                           AsmWrite('.');
 
976
 
 
977
                         s:=tai_const(hp).endsym.name;
 
978
                         ReplaceForbiddenChars(s);
 
979
                         AsmWrite(s);
 
980
                         inc(l,length(s));
 
981
 
 
982
                         if tai_const(hp).endsym.typ = AT_FUNCTION then
 
983
                           begin
 
984
                             if use_PR then
 
985
                               AsmWrite('[PR]')
 
986
                             else
 
987
                               AsmWrite('[DS]');
 
988
                           end;
 
989
 
 
990
                         AsmWrite('-');
 
991
                         inc(l,5); {Approx 5 extra, no need to be exactly}
 
992
                       end;
 
993
 
 
994
                     if (tai_const(hp).sym.typ = AT_FUNCTION) and use_PR then
 
995
                       AsmWrite('.');
 
996
 
 
997
                     s:= tai_const(hp).sym.name;
 
998
                     ReplaceForbiddenChars(s);
 
999
                     AsmWrite(s);
 
1000
                     inc(l,length(s));
 
1001
 
 
1002
                     if tai_const(hp).sym.typ = AT_FUNCTION then
 
1003
                       begin
 
1004
                         if use_PR then
 
1005
                           AsmWrite('[PR]')
 
1006
                         else
 
1007
                           AsmWrite('[DS]');
 
1008
                       end;
 
1009
                     inc(l,5); {Approx 5 extra, no need to be exactly}
 
1010
 
 
1011
                     if tai_const(hp).value > 0 then
 
1012
                       s:= '+'+tostr(tai_const(hp).value)
 
1013
                     else if tai_const(hp).value < 0 then
 
1014
                       s:= '-'+tostr(tai_const(hp).value)
 
1015
                     else
 
1016
                       s:= '';
 
1017
                     if s<>'' then
 
1018
                       begin
 
1019
                         AsmWrite(s);
 
1020
                         inc(l,length(s));
 
1021
                       end;
 
1022
                   end
 
1023
                 else
 
1024
                   begin
 
1025
                     s:= tostr(tai_const(hp).value);
 
1026
                     AsmWrite(s);
 
1027
                     inc(l,length(s));
 
1028
                   end;
 
1029
 
 
1030
                 if (l>line_length) or
 
1031
                    (hp.next=nil) or
 
1032
                    (tai(hp.next).typ<>consttyp) then
 
1033
                   break;
 
1034
                 hp:=tai(hp.next);
 
1035
                 AsmWrite(',');
 
1036
               until false;
 
1037
               AsmLn;
 
1038
             end;
 
1039
 
 
1040
            ait_real_64bit :
 
1041
              begin
 
1042
                AsmWriteLn(target_asm.comment+'value: '+double2str(tai_real_64bit(hp).value));
 
1043
                d:=tai_real_64bit(hp).value;
 
1044
                { swap the values to correct endian if required }
 
1045
                if source_info.endian <> target_info.endian then
 
1046
                  swap64bitarray(t64bitarray(d));
 
1047
                AsmWrite(#9'dc.b'#9);
 
1048
                  begin
 
1049
                    for i:=0 to 7 do
 
1050
                      begin
 
1051
                        if i<>0 then
 
1052
                          AsmWrite(',');
 
1053
                        AsmWrite(tostr(t64bitarray(d)[i]));
 
1054
                      end;
 
1055
                  end;
 
1056
                AsmLn;
 
1057
              end;
 
1058
 
 
1059
            ait_real_32bit :
 
1060
              begin
 
1061
                AsmWriteLn(target_asm.comment+'value: '+single2str(tai_real_32bit(hp).value));
 
1062
                sin:=tai_real_32bit(hp).value;
 
1063
                { swap the values to correct endian if required }
 
1064
                if source_info.endian <> target_info.endian then
 
1065
                  swap32bitarray(t32bitarray(sin));
 
1066
                AsmWrite(#9'dc.b'#9);
 
1067
                for i:=0 to 3 do
 
1068
                  begin
 
1069
                    if i<>0 then
 
1070
                      AsmWrite(',');
 
1071
                    AsmWrite(tostr(t32bitarray(sin)[i]));
 
1072
                  end;
 
1073
                AsmLn;
 
1074
              end;
 
1075
 
934
1076
            ait_string:
935
1077
              begin
936
1078
                {NOTE When a single quote char is encountered, it is
980
1122
                      end; { end for j:=0 ... }
981
1123
 
982
1124
                  { do last line of lines }
983
 
                                                                        if counter < tai_string(hp).len then
984
 
                                                                                AsmWrite(#9'dc.b'#9);
985
 
                                                                        quoted:=false;
986
 
                                                                        for i:=counter to tai_string(hp).len-1 do
987
 
                                                                                begin
988
 
                                                                                        { it is an ascii character. }
989
 
                                                                                        if (ord(tai_string(hp).str[i])>31) and
990
 
                                                                                                 (ord(tai_string(hp).str[i])<128) and
991
 
                                                                                                 (tai_string(hp).str[i]<>'''') and
992
 
                                                                                                 (tai_string(hp).str[i]<>'\') then
993
 
                                                                                                begin
994
 
                                                                                                        if not(quoted) then
995
 
                                                                                                                begin
996
 
                                                                                                                        if i>counter then
997
 
                                                                                                                                AsmWrite(',');
998
 
                                                                                                                        AsmWrite('''');
999
 
                                                                                                                end;
1000
 
                                                                                                        AsmWrite(tai_string(hp).str[i]);
1001
 
                                                                                                        quoted:=true;
1002
 
                                                                                                end { if > 31 and < 128 and " }
1003
 
                                                                                        else
1004
 
                                                                                                begin
1005
 
                                                                                                        if quoted then
1006
 
                                                                                                                AsmWrite('''');
1007
 
                                                                                                        if i>counter then
1008
 
                                                                                                                AsmWrite(',');
1009
 
                                                                                                        quoted:=false;
1010
 
                                                                                                        AsmWrite(tostr(ord(tai_string(hp).str[i])));
1011
 
                                                                                                end;
1012
 
                                                                                end; { end for i:=0 to... }
1013
 
                                                                        if quoted then
1014
 
                                                                                AsmWrite('''');
 
1125
                  if counter < tai_string(hp).len then
 
1126
                    AsmWrite(#9'dc.b'#9);
 
1127
                  quoted:=false;
 
1128
                  for i:=counter to tai_string(hp).len-1 do
 
1129
                    begin
 
1130
                      { it is an ascii character. }
 
1131
                      if (ord(tai_string(hp).str[i])>31) and
 
1132
                         (ord(tai_string(hp).str[i])<128) and
 
1133
                         (tai_string(hp).str[i]<>'''') and
 
1134
                         (tai_string(hp).str[i]<>'\') then
 
1135
                        begin
 
1136
                          if not(quoted) then
 
1137
                            begin
 
1138
                              if i>counter then
 
1139
                                AsmWrite(',');
 
1140
                              AsmWrite('''');
 
1141
                            end;
 
1142
                          AsmWrite(tai_string(hp).str[i]);
 
1143
                          quoted:=true;
 
1144
                        end { if > 31 and < 128 and " }
 
1145
                      else
 
1146
                        begin
 
1147
                          if quoted then
 
1148
                            AsmWrite('''');
 
1149
                          if i>counter then
 
1150
                            AsmWrite(',');
 
1151
                          quoted:=false;
 
1152
                          AsmWrite(tostr(ord(tai_string(hp).str[i])));
 
1153
                        end;
 
1154
                    end; { end for i:=0 to... }
 
1155
                  if quoted then
 
1156
                    AsmWrite('''');
1015
1157
                end;
1016
 
                                                                AsmLn;
 
1158
                AsmLn;
1017
1159
              end;
1018
1160
            ait_label:
1019
1161
              begin
1020
1162
                 if tai_label(hp).l.is_used then
1021
1163
                  begin
1022
1164
                    s:= tai_label(hp).l.name;
1023
 
                    ReplaceForbiddenChars(s);
1024
1165
                    if s[1] = '@' then
1025
 
                      //Local labels:
1026
 
                      AsmWriteLn(s+':')
 
1166
                      begin
 
1167
                        ReplaceForbiddenChars(s);
 
1168
                        //Local labels:
 
1169
                        AsmWriteLn(s+':')
 
1170
                      end
1027
1171
                    else
1028
1172
                      begin
1029
1173
                        //Procedure entry points:
1030
1174
                        if not macos_direct_globals then
1031
1175
                          begin
1032
 
                            AsmWriteLn(#9'toc');
1033
 
                            AsmWrite(#9'tc'#9); AsmWrite(s);
1034
 
                            AsmWrite('[TC], '); AsmWrite(s);
1035
 
                            AsmWriteLn(const_storage_class);
1036
 
 
1037
 
                            AsmWrite(#9'csect'#9); AsmWrite(s);
1038
 
                            AsmWriteLn(const_storage_class);
 
1176
                            WriteDataHeader(s, tai_label(hp).is_global, true);
1039
1177
                          end
1040
1178
                        else
1041
1179
                          begin
 
1180
                            ReplaceForbiddenChars(s);
1042
1181
                            AsmWrite(#9'csect'#9); AsmWrite(s);
1043
1182
                            AsmWriteLn('[TC]');
1044
1183
 
1059
1198
                  else if tai_symbol(hp).sym.typ=AT_DATA then
1060
1199
                    begin
1061
1200
                       s:= tai_symbol(hp).sym.name;
1062
 
 
1063
 
                       WriteDataExportHeader(s, tai_symbol(hp).is_global, true);
1064
 
 
 
1201
                       WriteDataHeader(s, tai_symbol(hp).is_global, true);
1065
1202
                       if macos_direct_globals then
1066
1203
                         begin
1067
1204
                           AsmWrite(s);
1094
1231
 
1095
1232
              ait_stab_function_name: ;
1096
1233
{$endif GDB}
1097
 
              ait_cut :
 
1234
              ait_cutobject :
1098
1235
                begin
1099
 
                     { only reset buffer if nothing has changed }
1100
 
                       if AsmSize=AsmStartSize then
1101
 
                        AsmClear
1102
 
                       else
1103
 
                        begin
1104
 
                          {
1105
 
                          if LasTSec<>sec_none then
1106
 
                           AsmWriteLn('_'+target_asm.secnames[LasTSec]+#9#9'ends');
1107
 
                          AsmLn;
1108
 
                          }
1109
 
                          AsmWriteLn(#9'end');
1110
 
                          AsmClose;
1111
 
                          DoAssemble;
1112
 
                          AsmCreate(tai_cut(hp).place);
1113
 
                        end;
1114
 
                     { avoid empty files }
1115
 
                       while assigned(hp.next) and (tai(hp.next).typ in [ait_cut,ait_section,ait_comment]) do
1116
 
                        begin
1117
 
                          if tai(hp.next).typ=ait_section then
1118
 
                           begin
1119
 
                             lasTSec:=tai_section(hp.next).sec;
1120
 
                           end;
1121
 
                          hp:=tai(hp.next);
1122
 
                        end;
1123
 
                       WriteAsmFileHeader;
1124
 
 
1125
 
                       if lasTSec<>sec_none then
1126
 
                         AsmWriteLn(#9+target_asm.secnames[lasTSec]);
1127
 
                       {   AsmWriteLn('_'+target_asm.secnames[lasTSec]+#9#9+
1128
 
                                     'SEGMENT'#9'PARA PUBLIC USE32 '''+
1129
 
                                     target_asm.secnames[lasTSec]+'''');
1130
 
                       }
1131
 
                       AsmStartSize:=AsmSize;
1132
 
                 end;
1133
 
               ait_marker :
 
1236
                  InternalError(2004101101);  {Smart linking is done transparently by the MPW linker.}
 
1237
                end;
 
1238
              ait_marker :
1134
1239
                 begin
1135
1240
                   if tai_marker(hp).kind=InlineStart then
1136
1241
                     inc(InlineLevel)
1203
1308
                  begin
1204
1309
                    AsmWrite(#9'import'#9);
1205
1310
                    AsmWrite(s);
1206
 
                    AsmWrite('[RW]');
 
1311
                    AsmWrite(var_storage_class);
1207
1312
                    if replaced then
1208
1313
                      begin
1209
1314
                        AsmWrite(' <= ''');
1217
1322
                    AsmWrite(s);
1218
1323
                    AsmWrite('[TC],');
1219
1324
                    AsmWrite(s);
1220
 
                    AsmWriteLn('[RW]');
 
1325
                    AsmWriteLn(var_storage_class);
1221
1326
                  end
1222
1327
                else
1223
1328
                  InternalError(2003090901);
1228
1333
    procedure TPPCMPWAssembler.WriteExternals;
1229
1334
      begin
1230
1335
        currentasmlist:=self;
1231
 
        objectlibrary.symbolsearch.foreach_static({$ifdef fpcprocvar}@{$endif}writeexternal,nil);
 
1336
        objectlibrary.symbolsearch.foreach_static(@writeexternal,nil);
1232
1337
      end;
1233
1338
 
1234
1339
 
1311
1416
      WriteAsmFileHeader;
1312
1417
      WriteExternals;
1313
1418
 
1314
 
    { PowerPC MPW ASM doesn't support stabs, as we know.
1315
 
      WriteTree(debuglist);}
1316
 
 
 
1419
      { PowerPC MPW ASM doesn't support stabs, at the moment:}
 
1420
(*
 
1421
      If (cs_debuginfo in aktmoduleswitches) then
 
1422
        WriteTree(debuglist);
 
1423
*)
1317
1424
      WriteTree(codesegment);
1318
1425
      WriteTree(datasegment);
1319
1426
      WriteTree(consts);
1345
1452
            asmbin : 'PPCAsm';
1346
1453
            asmcmd : '-case on $ASM -o $OBJ';
1347
1454
            supported_target : system_any; { what should I write here ?? }
1348
 
            outputbinary: false;
1349
 
            allowdirect : true;
1350
 
            needar : true;
1351
 
            labelprefix_only_inside_procedure : true;
 
1455
            flags : [af_allowdirect,af_needar,af_smartlink_sections,af_labelprefix_only_inside_procedure];
1352
1456
            labelprefix : '@';
1353
1457
            comment : '; ';
1354
 
            secnames : ('',
1355
 
              'csect','csect [TC]','csect [TC]',  {TODO: Perhaps use other section types.}
1356
 
              '','','','','','',
1357
 
              '','','')
1358
1458
          );
1359
1459
 
1360
1460
initialization
1362
1462
end.
1363
1463
{
1364
1464
  $Log: agppcmpw.pas,v $
1365
 
  Revision 1.34  2004/03/17 12:03:31  olle
1366
 
    * bugfix for multiline string constants
1367
 
 
1368
 
  Revision 1.33  2004/03/02 00:57:01  olle
1369
 
    + adding missing log msg: misc fixes
1370
 
 
1371
 
  Revision 1.32  2004/03/02 00:36:33  olle
1372
 
 
1373
 
  Revision 1.31  2004/02/27 10:21:05  florian
1374
 
    * top_symbol killed
1375
 
    + refaddr to treference added
1376
 
    + refsymbol to treference added
1377
 
    * top_local stuff moved to an extra record to save memory
1378
 
    + aint introduced
1379
 
    * tppufile.get/putint64/aint implemented
1380
 
 
1381
 
  Revision 1.30  2004/02/04 15:28:24  olle
1382
 
    * made more in phase with agppcgas.pas
1383
 
 
1384
 
  Revision 1.29  2004/01/12 00:08:03  olle
1385
 
    * gen of conditional instr updated according to agppcgas
1386
 
    * gen of PPCAsm command fixed
1387
 
 
1388
 
  Revision 1.28  2003/11/12 16:05:40  florian
1389
 
    * assembler readers OOPed
1390
 
    + typed currency constants
1391
 
    + typed 128 bit float constants if the CPU supports it
1392
 
 
1393
 
  Revision 1.27  2003/10/25 10:37:26  florian
1394
 
    * fixed compilation of ppc compiler
1395
 
 
1396
 
  Revision 1.26  2003/10/01 20:34:49  peter
1397
 
    * procinfo unit contains tprocinfo
1398
 
    * cginfo renamed to cgbase
1399
 
    * moved cgmessage to verbose
1400
 
    * fixed ppc and sparc compiles
1401
 
 
1402
 
  Revision 1.25  2003/09/12 12:30:27  olle
1403
 
    * max lenght of symbols increased to 255
1404
 
    * emitted strings can now contain backslashes
1405
 
 
1406
 
  Revision 1.24  2003/09/03 19:35:24  peter
1407
 
    * powerpc compiles again
1408
 
 
1409
 
  Revision 1.23  2003/08/24 21:40:12  olle
1410
 
    * minor adjustment
1411
 
 
1412
 
  Revision 1.21  2003/08/18 11:47:15  olle
1413
 
    + added asm directive ALIGNING OFF to avoid unexpected aligning by the assembler
1414
 
 
1415
 
  Revision 1.20  2002/10/01 05:17:27  olle
1416
 
    * minor fix
1417
 
 
1418
 
  Revision 1.19  2003/04/06 21:01:40  olle
1419
 
    + line numbers are now emitted in the assembler code
1420
 
    * bug in export and import directive fixed
1421
 
    * made code more in sync with aggas.pas
1422
 
 
1423
 
  Revision 1.18  2003/01/13 17:17:50  olle
1424
 
    * changed global var access, TOC now contain pointers to globals
1425
 
    * fixed handling of function pointers
1426
 
 
1427
 
  Revision 1.17  2003/01/08 18:43:57  daniel
1428
 
   * Tregister changed into a record
1429
 
 
1430
 
  Revision 1.16  2002/11/28 10:56:07  olle
1431
 
    * changed proc ref from .xxx[PR] (refering to its section)
1432
 
      to .xxx (refering to its label) to allow for multiple ref to a proc.
1433
 
 
1434
 
  Revision 1.15  2002/11/17 16:31:59  carl
1435
 
    * memory optimization (3-4%) : cleanup of tai fields,
1436
 
       cleanup of tdef and tsym fields.
1437
 
    * make it work for m68k
1438
 
 
1439
 
  Revision 1.14  2002/11/07 15:50:23  jonas
1440
 
    * fixed bctr(l) problems
1441
 
 
1442
 
  Revision 1.13  2002/11/04 18:24:53  olle
1443
 
    * globals are located in TOC and relative r2, instead of absolute
1444
 
    * symbols which only differs in case are treated as a single symbol
1445
 
    + tai_const_symbol supported
1446
 
    * only refs_full accepted
1447
 
 
1448
 
  Revision 1.12  2002/10/23 15:31:01  olle
1449
 
    * branch b does not jump to dotted symbol now
1450
 
 
1451
 
  Revision 1.11  2002/10/19 23:52:40  olle
1452
 
    * import directive changed
1453
 
 
1454
 
  Revision 1.10  2002/10/10 19:39:37  florian
1455
 
    * changes from Olle to get simple programs compiled and assembled
1456
 
 
1457
 
  Revision 1.9  2002/10/07 21:19:53  florian
1458
 
    * more mpw fixes
1459
 
 
1460
 
  Revision 1.8  2002/10/06 22:46:20  florian
1461
 
    * fixed function exporting
1462
 
 
1463
 
  Revision 1.7  2002/10/02 22:14:15  florian
1464
 
    * improve function imports
1465
 
 
1466
 
  Revision 1.6  2002/09/27 21:09:49  florian
1467
 
    + readed because previous version was broken
1468
 
 
1469
 
  Revision 1.2  2002/08/31 12:43:31  florian
1470
 
    * ppc compilation fixed
1471
 
 
1472
 
  Revision 1.1  2002/08/20 21:40:44  florian
1473
 
    + target macos for ppc added
1474
 
    + frame work for mpw assembler output
 
1465
  Revision 1.44  2005/02/14 17:13:10  peter
 
1466
    * truncate log
 
1467
 
 
1468
  Revision 1.43  2005/02/08 22:46:00  olle
 
1469
    * fixed erroneous asm line directive
 
1470
 
1475
1471
}