Browse Source

* cleaner allocation of scratch registers, removed unnecessary cg methods which emitted code using a fixed register
+ generation of lots of additional debug/trace messages with $EXTDEBUG
* code cleanup (intendation)

git-svn-id: trunk@3584 -

tom_at_work 19 năm trước cách đây
mục cha
commit
5240913a80

+ 21 - 40
compiler/powerpc64/agppcgas.pas

@@ -61,10 +61,10 @@ uses
 {****************************************************************************}
 {****************************************************************************}
 
 
 constructor TPPCGNUAssembler.create(smart: boolean);
 constructor TPPCGNUAssembler.create(smart: boolean);
-  begin
-    inherited create(smart);
-    InstrWriter := TPPCInstrWriter.create(self);
-  end;
+begin
+  inherited create(smart);
+  InstrWriter := TPPCInstrWriter.create(self);
+end;
 
 
 
 
 procedure TPPCGNUAssembler.WriteExtraHeader;
 procedure TPPCGNUAssembler.WriteExtraHeader;
@@ -88,18 +88,15 @@ function getreferencestring(var ref: treference): string;
 var
 var
   s: string;
   s: string;
 begin
 begin
-  with ref do
-  begin
+  with ref do begin
     if ((offset < -32768) or (offset > 32767)) and
     if ((offset < -32768) or (offset > 32767)) and
       (refaddr = addr_no) then
       (refaddr = addr_no) then
       ; //internalerror(19991);
       ; //internalerror(19991);
     if (refaddr = addr_no) then
     if (refaddr = addr_no) then
       s := ''
       s := ''
-    else
-    begin
+    else begin
       s := '(';
       s := '(';
-      if assigned(symbol) then
-      begin
+      if assigned(symbol) then begin
         s := s + symbol.name;
         s := s + symbol.name;
         if assigned(relsymbol) then
         if assigned(relsymbol) then
           s := s + '-' + relsymbol.name;
           s := s + '-' + relsymbol.name;
@@ -107,33 +104,27 @@ begin
     end;
     end;
     if offset < 0 then
     if offset < 0 then
       s := s + tostr(offset)
       s := s + tostr(offset)
-    else if (offset > 0) then
-    begin
+    else if (offset > 0) then begin
       if assigned(symbol) then
       if assigned(symbol) then
         s := s + '+' + tostr(offset)
         s := s + '+' + tostr(offset)
       else
       else
         s := s + tostr(offset);
         s := s + tostr(offset);
     end;
     end;
 
 
-    if (refaddr in [addr_low, addr_high, addr_higher, addr_highest, addr_higha, addr_highera, addr_highesta]) then
-    begin
+    if (refaddr in [addr_low, addr_high, addr_higher, addr_highest, addr_higha, addr_highera, addr_highesta]) then begin
       s := s + ')';
       s := s + ')';
       if (target_info.system <> system_powerpc_darwin) then
       if (target_info.system <> system_powerpc_darwin) then
         s := s + refaddr2str[refaddr];
         s := s + refaddr2str[refaddr];
     end;
     end;
     if (refaddr = addr_pic) then s := s + ')';
     if (refaddr = addr_pic) then s := s + ')';
 
 
-    if (index = NR_NO) and (base <> NR_NO) then
-    begin
-      if offset = 0 then
-      begin
+    if (index = NR_NO) and (base <> NR_NO) then begin
+      if offset = 0 then begin
         if not (assigned(symbol)) then
         if not (assigned(symbol)) then
           s := s + '0';
           s := s + '0';
       end;
       end;
       s := s + '(' + gas_regname(base) + ')';
       s := s + '(' + gas_regname(base) + ')';
-    end
-    else if (index <> NR_NO) and (base <> NR_NO) then
-    begin
+    end else if (index <> NR_NO) and (base <> NR_NO) then begin
       if (offset = 0) then
       if (offset = 0) then
         s := s + gas_regname(base) + ',' + gas_regname(index)
         s := s + gas_regname(base) + ',' + gas_regname(index)
       else
       else
@@ -181,16 +172,14 @@ begin
     top_const:
     top_const:
       getopstr := tostr(longint(o.val));
       getopstr := tostr(longint(o.val));
     top_ref:
     top_ref:
-      if o.ref^.refaddr = addr_full then
-      begin
+      if o.ref^.refaddr = addr_full then begin
         hs := o.ref^.symbol.name;
         hs := o.ref^.symbol.name;
         if o.ref^.offset > 0 then
         if o.ref^.offset > 0 then
           hs := hs + '+' + tostr(o.ref^.offset)
           hs := hs + '+' + tostr(o.ref^.offset)
         else if o.ref^.offset < 0 then
         else if o.ref^.offset < 0 then
           hs := hs + tostr(o.ref^.offset);
           hs := hs + tostr(o.ref^.offset);
         getopstr := hs;
         getopstr := hs;
-      end
-      else
+      end else
         getopstr := getreferencestring(o.ref^);
         getopstr := getreferencestring(o.ref^);
   else
   else
     internalerror(2002070604);
     internalerror(2002070604);
@@ -270,8 +259,7 @@ begin
           end;
           end;
         end
         end
           { we have a trap instruction }
           { we have a trap instruction }
-      else
-      begin
+      else begin
         internalerror(2002070601);
         internalerror(2002070601);
         { not yet implemented !!!!!!!!!!!!!!!!!!!!! }
         { not yet implemented !!!!!!!!!!!!!!!!!!!!! }
         { case tempstr := 'tw';}
         { case tempstr := 'tw';}
@@ -292,12 +280,10 @@ var
   sep: string[3];
   sep: string[3];
 begin
 begin
   op := taicpu(hp).opcode;
   op := taicpu(hp).opcode;
-  if is_calljmp(op) then
-  begin
+  if is_calljmp(op) then begin
     { direct BO/BI in op[0] and op[1] not supported, put them in condition! }
     { direct BO/BI in op[0] and op[1] not supported, put them in condition! }
     case op of
     case op of
-      A_BL :
-        s := #9 + gas_op2str[op] + #9;
+      A_BL,
       A_B, A_BA, A_BLA:
       A_B, A_BA, A_BLA:
         s := #9 + gas_op2str[op] + #9;
         s := #9 + gas_op2str[op] + #9;
       A_BCTR, A_BCTRL, A_BLR, A_BLRL:
       A_BCTR, A_BCTRL, A_BLR, A_BLRL:
@@ -311,28 +297,23 @@ begin
       end;
       end;
     end;
     end;
 
 
-    if (taicpu(hp).ops > 0) and (taicpu(hp).oper[0]^.typ <> top_none) then
-    begin
+    if (taicpu(hp).ops > 0) and (taicpu(hp).oper[0]^.typ <> top_none) then begin
       { first write the current contents of s, because the symbol }
       { first write the current contents of s, because the symbol }
       { may be 255 characters                                     }
       { may be 255 characters                                     }
       owner.AsmWrite(s);
       owner.AsmWrite(s);
       s := getopstr_jmp(taicpu(hp).oper[0]^);
       s := getopstr_jmp(taicpu(hp).oper[0]^);
     end;
     end;
-  end
-  else
+  end else begin
     { process operands }
     { process operands }
-  begin
     s := #9 + gas_op2str[op];
     s := #9 + gas_op2str[op];
-    if taicpu(hp).ops <> 0 then
-    begin
+    if taicpu(hp).ops <> 0 then begin
       {
       {
         if not is_calljmp(op) then
         if not is_calljmp(op) then
           sep:=','
           sep:=','
         else
         else
       }
       }
       sep := #9;
       sep := #9;
-      for i := 0 to taicpu(hp).ops - 1 do
-      begin
+      for i := 0 to taicpu(hp).ops - 1 do begin
         // debug code
         // debug code
         // writeln(s);
         // writeln(s);
         // writeln(taicpu(hp).fileinfo.line);
         // writeln(taicpu(hp).fileinfo.line);

+ 55 - 20
compiler/powerpc64/cgcpu.pas

@@ -195,6 +195,26 @@ begin
     result := result + ref.symbol.name;
     result := result + ref.symbol.name;
 end;
 end;
 
 
+function cgsize2string(const size : TCgSize) : string;
+const
+  cgsize_strings : array[TCgSize] of string[6] = (
+    'OS_NO', 'OS_8', 'OS_16', 'OS_32', 'OS_64', 'OS_128', 'OS_S8', 'OS_S16', 'OS_S32',
+    'OS_S64', 'OS_S128', 'OS_F32', 'OS_F64', 'OS_F80', 'OS_C64', 'OS_F128',
+    'OS_M8', 'OS_M16', 'OS_M32', 'OS_M64', 'OS_M128', 'OS_MS8', 'OS_MS16', 'OS_MS32',
+    'OS_MS64', 'OS_MS128');
+begin
+  result := cgsize_strings[size];
+end;
+
+function is_signed_cgsize(const size : TCgSize) : Boolean;
+begin
+  case size of
+    OS_S8,OS_S16,OS_S32,OS_S64 : result := true;
+    OS_8,OS_16,OS_32,OS_64 : result := false;
+    else
+      internalerror(2006050701);
+  end;
+end;
 
 
 { helper function which calculate "magic" values for replacement of unsigned
 { helper function which calculate "magic" values for replacement of unsigned
  division by constant operation by multiplication. See the PowerPC compiler
  division by constant operation by multiplication. See the PowerPC compiler
@@ -581,19 +601,21 @@ end;
 procedure tcgppc.a_call_reg(list: TAsmList; reg: tregister);
 procedure tcgppc.a_call_reg(list: TAsmList; reg: tregister);
 var
 var
   tmpref: treference;
   tmpref: treference;
+  tempreg : TRegister;
 begin
 begin
   if (not (cs_opt_size in aktoptimizerswitches)) then begin
   if (not (cs_opt_size in aktoptimizerswitches)) then begin
+    tempreg := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
     { load actual function entry (reg contains the reference to the function descriptor)
     { load actual function entry (reg contains the reference to the function descriptor)
-    into R0 }
+    into tempreg }
     reference_reset_base(tmpref, reg, 0);
     reference_reset_base(tmpref, reg, 0);
-    a_load_ref_reg(list, OS_ADDR, OS_ADDR, tmpref, NR_R0);
+    a_load_ref_reg(list, OS_ADDR, OS_ADDR, tmpref, tempreg);
 
 
     { save TOC pointer in stackframe }
     { save TOC pointer in stackframe }
     reference_reset_base(tmpref, NR_STACK_POINTER_REG, LA_RTOC_ELF);
     reference_reset_base(tmpref, NR_STACK_POINTER_REG, LA_RTOC_ELF);
     a_load_reg_ref(list, OS_ADDR, OS_ADDR, NR_RTOC, tmpref);
     a_load_reg_ref(list, OS_ADDR, OS_ADDR, NR_RTOC, tmpref);
 
 
     { move actual function pointer to CTR register }
     { move actual function pointer to CTR register }
-    list.concat(taicpu.op_reg(A_MTCTR, NR_R0));
+    list.concat(taicpu.op_reg(A_MTCTR, tempreg));
 
 
     { load new TOC pointer from function descriptor into RTOC register }
     { load new TOC pointer from function descriptor into RTOC register }
     reference_reset_base(tmpref, reg, tcgsize2size[OS_ADDR]);
     reference_reset_base(tmpref, reg, tcgsize2size[OS_ADDR]);
@@ -601,15 +623,18 @@ begin
 
 
     { load new environment pointer from function descriptor into R11 register }
     { load new environment pointer from function descriptor into R11 register }
     reference_reset_base(tmpref, reg, 2*tcgsize2size[OS_ADDR]);
     reference_reset_base(tmpref, reg, 2*tcgsize2size[OS_ADDR]);
+    a_reg_alloc(list, NR_R11);
     a_load_ref_reg(list, OS_ADDR, OS_ADDR, tmpref, NR_R11);
     a_load_ref_reg(list, OS_ADDR, OS_ADDR, tmpref, NR_R11);
-
     { call function }
     { call function }
     list.concat(taicpu.op_none(A_BCTRL));
     list.concat(taicpu.op_none(A_BCTRL));
+    a_reg_dealloc(list, NR_R11);
   end else begin
   end else begin
     { call ptrgl helper routine which expects the pointer to the function descriptor
     { call ptrgl helper routine which expects the pointer to the function descriptor
     in R11 }
     in R11 }
+    a_reg_alloc(list, NR_R11);
     a_load_reg_reg(list, OS_ADDR, OS_ADDR, reg, NR_R11);
     a_load_reg_reg(list, OS_ADDR, OS_ADDR, reg, NR_R11);
     a_call_name_direct(list, '.ptrgl', false, false);
     a_call_name_direct(list, '.ptrgl', false, false);
+    a_reg_dealloc(list, NR_R11);
   end;
   end;
 
 
   { we need to load the old RTOC from stackframe because we changed it}
   { we need to load the old RTOC from stackframe because we changed it}
@@ -695,9 +720,11 @@ procedure tcgppc.a_load_const_reg(list: TAsmList; size: TCGSize; a: aint;
            32 bits should contain -1
            32 bits should contain -1
           - loading the lower 32 bits resulted in 0 in the upper 32 bits, and the upper
           - loading the lower 32 bits resulted in 0 in the upper 32 bits, and the upper
            32 bits should contain 0 }
            32 bits should contain 0 }
+        a_reg_alloc(list, NR_R0);
         load32bitconstantR0(list, size, hi(a));
         load32bitconstantR0(list, size, hi(a));
         { combine both registers }
         { combine both registers }
         list.concat(taicpu.op_reg_reg_const_const(A_RLDIMI, reg, NR_R0, 32, 0));
         list.concat(taicpu.op_reg_reg_const_const(A_RLDIMI, reg, NR_R0, 32, 0));
+        a_reg_dealloc(list, NR_R0);
       end;
       end;
     end;
     end;
   end;
   end;
@@ -709,7 +736,7 @@ var
 
 
 begin
 begin
   {$IFDEF EXTDEBUG}
   {$IFDEF EXTDEBUG}
-  astring := 'a_load_const reg ' + inttostr(hi(a)) + ' ' + inttostr(lo(a)) + ' ' + inttostr(ord(size)) + ' ' + inttostr(tcgsize2size[size]);
+  astring := 'a_load_const_reg ' + inttostr(hi(a)) + ' ' + inttostr(lo(a)) + ' ' + inttostr(ord(size)) + ' ' + inttostr(tcgsize2size[size]);
   list.concat(tai_comment.create(strpnew(astring)));
   list.concat(tai_comment.create(strpnew(astring)));
   {$ENDIF EXTDEBUG}
   {$ENDIF EXTDEBUG}
   if not (size in [OS_8, OS_S8, OS_16, OS_S16, OS_32, OS_S32, OS_64, OS_S64]) then
   if not (size in [OS_8, OS_S8, OS_16, OS_S16, OS_32, OS_S32, OS_64, OS_S64]) then
@@ -1151,6 +1178,11 @@ var
   scratch_register: TRegister;
   scratch_register: TRegister;
   signed: boolean;
   signed: boolean;
 begin
 begin
+
+  {$IFDEF EXTDEBUG}
+  list.concat(tai_comment.create(strpnew('a_cmp_const_reg_label ' + inttostr(ord(size)) + ' ' + inttostr(tcgsize2size[size]))));
+  {$ENDIF EXTDEBUG}
+
   signed := cmp_op in [OC_GT, OC_LT, OC_GTE, OC_LTE];
   signed := cmp_op in [OC_GT, OC_LT, OC_GTE, OC_LTE];
   { in the following case, we generate more efficient code when }
   { in the following case, we generate more efficient code when }
   { signed is true                                              }
   { signed is true                                              }
@@ -1162,14 +1194,14 @@ begin
       list.concat(taicpu.op_reg_reg_const(A_CMPDI, NR_CR0, reg, a))
       list.concat(taicpu.op_reg_reg_const(A_CMPDI, NR_CR0, reg, a))
     else begin
     else begin
       scratch_register := rg[R_INTREGISTER].getregister(list, R_SUBWHOLE);
       scratch_register := rg[R_INTREGISTER].getregister(list, R_SUBWHOLE);
-      a_load_const_reg(list, OS_64, a, scratch_register);
+      a_load_const_reg(list, OS_INT, a, scratch_register);
       list.concat(taicpu.op_reg_reg_reg(A_CMPD, NR_CR0, reg, scratch_register));
       list.concat(taicpu.op_reg_reg_reg(A_CMPD, NR_CR0, reg, scratch_register));
     end
     end
   else if (aword(a) <= $FFFF) then
   else if (aword(a) <= $FFFF) then
     list.concat(taicpu.op_reg_reg_const(A_CMPLDI, NR_CR0, reg, aword(a)))
     list.concat(taicpu.op_reg_reg_const(A_CMPLDI, NR_CR0, reg, aword(a)))
   else begin
   else begin
     scratch_register := rg[R_INTREGISTER].getregister(list, R_SUBWHOLE);
     scratch_register := rg[R_INTREGISTER].getregister(list, R_SUBWHOLE);
-    a_load_const_reg(list, OS_64, a, scratch_register);
+    a_load_const_reg(list, OS_INT, a, scratch_register);
     list.concat(taicpu.op_reg_reg_reg(A_CMPLD, NR_CR0, reg,
     list.concat(taicpu.op_reg_reg_reg(A_CMPLD, NR_CR0, reg,
       scratch_register));
       scratch_register));
   end;
   end;
@@ -1181,6 +1213,10 @@ procedure tcgppc.a_cmp_reg_reg_label(list: TAsmList; size: tcgsize;
 var
 var
   op: tasmop;
   op: tasmop;
 begin
 begin
+  {$IFDEF extdebug}
+  list.concat(tai_comment.create(strpnew('a_cmp_reg_reg_label, size ' + cgsize2string(size) + ' op ' + inttostr(ord(cmp_op)))));
+  {$ENDIF extdebug}
+
   if cmp_op in [OC_GT, OC_LT, OC_GTE, OC_LTE] then
   if cmp_op in [OC_GT, OC_LT, OC_GTE, OC_LTE] then
     if (size in [OS_64, OS_S64]) then
     if (size in [OS_64, OS_S64]) then
       op := A_CMPD
       op := A_CMPD
@@ -2069,18 +2105,18 @@ begin
    adjust the offset accordingly }
    adjust the offset accordingly }
   case op of
   case op of
     A_LD, A_LDU, A_STD, A_STDU, A_LWA :
     A_LD, A_LDU, A_STD, A_STDU, A_LWA :
-     if ((ref.offset mod 4) <> 0) then begin
-       tmpreg := rg[R_INTREGISTER].getregister(list, R_SUBWHOLE);
-
-       if (ref.base <> NR_NO) then begin
-         a_op_const_reg_reg(list, OP_ADD, OS_ADDR, ref.offset mod 4, ref.base, tmpreg);
-         ref.base := tmpreg;
-       end else begin
-         list.concat(taicpu.op_reg_const(A_LI, tmpreg, ref.offset mod 4));
-         ref.base := tmpreg;
-       end;
-       ref.offset := (ref.offset div 4) * 4;
-     end;
+       if ((ref.offset mod 4) <> 0) then begin
+        tmpreg := rg[R_INTREGISTER].getregister(list, R_SUBWHOLE);
+
+        if (ref.base <> NR_NO) then begin
+          a_op_const_reg_reg(list, OP_ADD, OS_ADDR, ref.offset mod 4, ref.base, tmpreg);
+          ref.base := tmpreg;
+        end else begin
+          list.concat(taicpu.op_reg_const(A_LI, tmpreg, ref.offset mod 4));
+          ref.base := tmpreg;
+        end;
+        ref.offset := (ref.offset div 4) * 4;
+      end;
   end;
   end;
   {$IFDEF EXTDEBUG}
   {$IFDEF EXTDEBUG}
   list.concat(tai_comment.create(strpnew('a_load_store1 ' + BoolToStr(ref.refaddr = addr_pic))));
   list.concat(tai_comment.create(strpnew('a_load_store1 ' + BoolToStr(ref.refaddr = addr_pic))));
@@ -2230,7 +2266,6 @@ begin
   cg.a_load_ref_reg(list, OS_INT, OS_INT, ref, reg);
   cg.a_load_ref_reg(list, OS_INT, OS_INT, ref, reg);
 end;
 end;
 
 
-
 begin
 begin
   cg := tcgppc.create;
   cg := tcgppc.create;
 end.
 end.

+ 9 - 9
compiler/powerpc64/cpubase.pas

@@ -81,7 +81,7 @@ type
     a_extlwi, a_extlwi_, a_extrwi, a_extrwi_, a_inslwi, a_inslwi_, a_insrwi,
     a_extlwi, a_extlwi_, a_extrwi, a_extrwi_, a_inslwi, a_inslwi_, a_insrwi,
     a_insrwi_, a_rotlwi, a_rotlwi_, a_rotlw, a_rotlw_, a_slwi, a_slwi_,
     a_insrwi_, a_rotlwi, a_rotlwi_, a_rotlw, a_rotlw_, a_slwi, a_slwi_,
     a_srwi, a_srwi_, a_clrlwi, a_clrlwi_, a_clrrwi, a_clrrwi_, a_clrslwi,
     a_srwi, a_srwi_, a_clrlwi, a_clrlwi_, a_clrrwi, a_clrrwi_, a_clrslwi,
-    a_clrslwi_, a_blr, a_bctr, a_blrl, a_bctrl, a_crset, a_crclr, a_crmove,
+    a_clrslwi_, a_bf, a_bt, a_blr, a_bctr, a_blrl, a_bctrl, a_crset, a_crclr, a_crmove,
     a_crnot, a_mt {move to special prupose reg}, a_mf
     a_crnot, a_mt {move to special prupose reg}, a_mf
       {move from special purpose reg},
       {move from special purpose reg},
     a_nop, a_li, a_lis, a_la, a_mr, a_mr_, a_not, a_mtcr, a_mtlr, a_mflr,
     a_nop, a_li, a_lis, a_la, a_mr, a_mr_, a_not, a_mtcr, a_mtlr, a_mflr,
@@ -212,7 +212,7 @@ const
     true, false,
     true, false,
     true, false, false, true, false, false, true, false);
     true, false, false, true, false, false, true, false);
 
 
-  AsmCondFlag2Str: array[TAsmCondFlag] of string[4] = ({cf_none}'',
+  AsmCondFlag2Str : array[TAsmCondFlag] of string[4] = ({cf_none}'',
     { conditions when not using ctr decrement etc}
     { conditions when not using ctr decrement etc}
     'lt', 'le', 'eq', 'ge', 'gt', 'nl', 'ne', 'ng', 'so', 'ns', 'un', 'nu',
     'lt', 'le', 'eq', 'ge', 'gt', 'nl', 'ne', 'ng', 'so', 'ns', 'un', 'nu',
     't', 'f', 'dnz', 'dnzt', 'dnzf', 'dz', 'dzt', 'dzf');
     't', 'f', 'dnz', 'dnzt', 'dnzf', 'dz', 'dzt', 'dzf');
@@ -398,7 +398,7 @@ function is_condreg(r: tregister): boolean;
 function inverse_cond(const c: TAsmCond): Tasmcond;
 function inverse_cond(const c: TAsmCond): Tasmcond;
 {$IFDEF USEINLINE}inline;{$ENDIF USEINLINE}
 {$IFDEF USEINLINE}inline;{$ENDIF USEINLINE}
 function conditions_equal(const c1, c2: TAsmCond): boolean;
 function conditions_equal(const c1, c2: TAsmCond): boolean;
-    function dwarf_reg(r:tregister):byte;
+function dwarf_reg(r:tregister):byte;
 
 
 implementation
 implementation
 
 
@@ -546,12 +546,12 @@ begin
     result := generic_regname(r);
     result := generic_regname(r);
 end;
 end;
 
 
-    function dwarf_reg(r:tregister):byte;
-      begin
-        result:=regdwarf_table[findreg_by_number(r)];
-        if result=-1 then
-          internalerror(200603251);
-      end;
+function dwarf_reg(r:tregister):byte;
+begin
+  result:=regdwarf_table[findreg_by_number(r)];
+  if result=-1 then
+    internalerror(200603251);
+end;
 
 
 
 
 end.
 end.

+ 1 - 2
compiler/powerpc64/cpupara.pas

@@ -278,7 +278,6 @@ var
   parashift : byte;
   parashift : byte;
 
 
 begin
 begin
-//writeln('begin create_paraloc_info');
 {$IFDEF extdebug}
 {$IFDEF extdebug}
   if po_explicitparaloc in p.procoptions then
   if po_explicitparaloc in p.procoptions then
     internalerror(200411141);
     internalerror(200411141);
@@ -292,8 +291,8 @@ begin
 
 
   for i := 0 to paras.count - 1 do begin
   for i := 0 to paras.count - 1 do begin
     parashift := 0;
     parashift := 0;
-
     hp := tparavarsym(paras[i]);
     hp := tparavarsym(paras[i]);
+
     paradef := hp.vartype.def;
     paradef := hp.vartype.def;
     { Syscall for Morphos can have already a paraloc set; not supported on ppc64 }
     { Syscall for Morphos can have already a paraloc set; not supported on ppc64 }
     if (vo_has_explicit_paraloc in hp.varoptions) then begin
     if (vo_has_explicit_paraloc in hp.varoptions) then begin

+ 2 - 3
compiler/powerpc64/itcpugas.pas

@@ -73,7 +73,7 @@ const
     'extlwi', 'extlwi.', 'extrwi', 'extrwi.', 'inslwi', 'inslwi.', 'insrwi',
     'extlwi', 'extlwi.', 'extrwi', 'extrwi.', 'inslwi', 'inslwi.', 'insrwi',
     'insrwi.', 'rotlwi', 'rotlwi.', 'rotlw', 'rotlw.', 'slwi', 'slwi.',
     'insrwi.', 'rotlwi', 'rotlwi.', 'rotlw', 'rotlw.', 'slwi', 'slwi.',
     'srwi', 'srwi.', 'clrlwi', 'clrlwi.', 'clrrwi', 'clrrwi.', 'clrslwi',
     'srwi', 'srwi.', 'clrlwi', 'clrlwi.', 'clrrwi', 'clrrwi.', 'clrslwi',
-    'clrslwi.', 'blr', 'bctr', 'blrl', 'bctrl', 'crset', 'crclr', 'crmove',
+    'clrslwi.', 'bf', 'bt', 'blr', 'bctr', 'blrl', 'bctrl', 'crset', 'crclr', 'crmove',
     'crnot', 'mt', 'mf', 'nop', 'li', 'lis', 'la', 'mr', 'mr.', 'not', 'mtcr',
     'crnot', 'mt', 'mf', 'nop', 'li', 'lis', 'la', 'mr', 'mr.', 'not', 'mtcr',
       'mtlr', 'mflr',
       'mtlr', 'mflr',
     'mtctr', 'mfctr',
     'mtctr', 'mfctr',
@@ -124,8 +124,7 @@ begin
   p := 0;
   p := 0;
   i := regnumber_count_bsstart;
   i := regnumber_count_bsstart;
   repeat
   repeat
-    if (p + i <= high(tregisterindex)) and (gas_regname_table[gas_regname_index[p
-      + i]] <= s) then
+    if (p + i <= high(tregisterindex)) and (gas_regname_table[gas_regname_index[p + i]] <= s) then
       p := p + i;
       p := p + i;
     i := i shr 1;
     i := i shr 1;
   until i = 0;
   until i = 0;

+ 20 - 10
compiler/powerpc64/nppcadd.pas

@@ -176,6 +176,11 @@ begin
   // get the constant on the right if there is one
   // get the constant on the right if there is one
   if (left.location.loc = LOC_CONSTANT) then
   if (left.location.loc = LOC_CONSTANT) then
     swapleftright;
     swapleftright;
+
+  {$IFDEF EXTDEBUG}
+  current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew('tppcaddnode.emit_compare ' + inttostr(ord(opsize)) + ' ' + inttostr(tcgsize2size[opsize]))));
+  {$ENDIF EXTDEBUG}
+
   // can we use an immediate, or do we have to load the
   // can we use an immediate, or do we have to load the
   // constant in a register first?
   // constant in a register first?
   if (right.location.loc = LOC_CONSTANT) then begin
   if (right.location.loc = LOC_CONSTANT) then begin
@@ -198,13 +203,14 @@ begin
     else begin
     else begin
       useconst := false;
       useconst := false;
       tmpreg := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
       tmpreg := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
-      cg.a_load_const_reg(current_asmdata.CurrAsmList, OS_INT,
-        right.location.value, tmpreg);
+      cg.a_load_const_reg(current_asmdata.CurrAsmList, OS_INT, right.location.value, tmpreg);
     end
     end
   end else
   end else
     useconst := false;
     useconst := false;
+
   location.loc := LOC_FLAGS;
   location.loc := LOC_FLAGS;
   location.resflags := getresflags;
   location.resflags := getresflags;
+
   if not unsigned then
   if not unsigned then
     if useconst then
     if useconst then
       op := A_CMPDI
       op := A_CMPDI
@@ -492,10 +498,10 @@ begin
   if not (cmpop) and
   if not (cmpop) and
     (location.register = NR_NO) then
     (location.register = NR_NO) then
     location.register := cg.getintregister(current_asmdata.CurrAsmList, OS_64);
     location.register := cg.getintregister(current_asmdata.CurrAsmList, OS_64);
-
+  {$ifdef extdebug}
   astring := 'addsmallset0 ' + inttostr(aword(1) shl aword(right.location.value)) + ' ' + inttostr(right.location.value);
   astring := 'addsmallset0 ' + inttostr(aword(1) shl aword(right.location.value)) + ' ' + inttostr(right.location.value);
   current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew(astring)));
   current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew(astring)));
-
+  {$endif extdebug}
 
 
   case nodetype of
   case nodetype of
     addn:
     addn:
@@ -508,10 +514,10 @@ begin
           if assigned(tsetelementnode(right).right) then
           if assigned(tsetelementnode(right).right) then
             internalerror(43244);
             internalerror(43244);
           if (right.location.loc = LOC_CONSTANT) then begin
           if (right.location.loc = LOC_CONSTANT) then begin
-
+            {$ifdef extdebug}
             astring := 'addsmallset1 ' + inttostr(aword(1) shl aword(right.location.value)) + ' ' + inttostr(right.location.value);
             astring := 'addsmallset1 ' + inttostr(aword(1) shl aword(right.location.value)) + ' ' + inttostr(right.location.value);
             current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew(astring)));
             current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew(astring)));
-
+            {$endif extdebug}
 
 
             cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_OR, OS_64,
             cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_OR, OS_64,
               aint(1) shl aint(right.location.value),
               aint(1) shl aint(right.location.value),
@@ -526,9 +532,10 @@ begin
               cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_OR, OS_64, tmpreg,
               cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_OR, OS_64, tmpreg,
                 left.location.register, location.register)
                 left.location.register, location.register)
             end else begin
             end else begin
+              {$ifdef extdebug}
               astring := 'addsmallset2 ' + inttostr(left.location.value);
               astring := 'addsmallset2 ' + inttostr(left.location.value);
               current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew(astring)));
               current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew(astring)));
-
+              {$endif extdebug}
               cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_OR, OS_64,
               cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_OR, OS_64,
                 left.location.value, tmpreg, location.register);
                 left.location.value, tmpreg, location.register);
             end;
             end;
@@ -572,7 +579,7 @@ begin
         end;
         end;
       end;
       end;
     equaln,
     equaln,
-      unequaln:
+    unequaln:
       begin
       begin
         emit_compare(true);
         emit_compare(true);
         opdone := true;
         opdone := true;
@@ -717,8 +724,7 @@ begin
     not (cmpop) then
     not (cmpop) then
     location.register := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
     location.register := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
 
 
-  if not (cs_check_overflow in aktlocalswitches) or
-    (cmpop) or
+  if not (cs_check_overflow in aktlocalswitches) or (cmpop) or
     (nodetype in [orn, andn, xorn]) then
     (nodetype in [orn, andn, xorn]) then
   begin
   begin
     case nodetype of
     case nodetype of
@@ -775,6 +781,10 @@ begin
         end;
         end;
       ltn, lten, gtn, gten, equaln, unequaln:
       ltn, lten, gtn, gten, equaln, unequaln:
         begin
         begin
+          {$ifdef extdebug}
+          current_asmdata.CurrAsmList.concat(tai_comment.create('tppcaddnode.pass2'));
+          {$endif extdebug}
+
           emit_compare(unsigned);
           emit_compare(unsigned);
         end;
         end;
     end;
     end;