Browse Source

* reenabled generation of TOC labels for symbols with a length under a certain threshold (to avoid too long symbols passed to the cg which will get truncated)
* cleanup

git-svn-id: trunk@3674 -

tom_at_work 19 years ago
parent
commit
1bd43869d0
3 changed files with 22 additions and 39 deletions
  1. 2 2
      compiler/powerpc64/agppcgas.pas
  2. 9 3
      compiler/powerpc64/cgcpu.pas
  3. 11 34
      compiler/powerpc64/nppcadd.pas

+ 2 - 2
compiler/powerpc64/agppcgas.pas

@@ -91,7 +91,7 @@ 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(2006052501);
     if (refaddr = addr_no) then
     if (refaddr = addr_no) then
       s := ''
       s := ''
     else begin
     else begin
@@ -128,7 +128,7 @@ 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
-        internalerror(19992);
+        internalerror(2006052502);
     end;
     end;
   end;
   end;
   getreferencestring := s;
   getreferencestring := s;

+ 9 - 3
compiler/powerpc64/cgcpu.pas

@@ -743,8 +743,8 @@ begin
     internalerror(2002090902);
     internalerror(2002090902);
   { if PIC or basic optimizations are enabled, and the number of instructions which would be
   { if PIC or basic optimizations are enabled, and the number of instructions which would be
    required to load the value is greater than 2, store (and later load) the value from there }
    required to load the value is greater than 2, store (and later load) the value from there }
-  if (false) {(((cs_opt_peephole in aktoptimizerswitches in aktglobalswitches) or (cs_create_pic in aktmoduleswitches)) and
-    (getInstructionLength(a) > 2))} then
+  if (((cs_opt_peephole in aktoptimizerswitches) or (cs_create_pic in aktmoduleswitches)) and
+    (getInstructionLength(a) > 2)) then
     loadConstantPIC(list, size, a, reg)
     loadConstantPIC(list, size, a, reg)
   else
   else
     loadConstantNormal(list, size, a, reg);
     loadConstantNormal(list, size, a, reg);
@@ -2029,6 +2029,10 @@ end;
 
 
 
 
 function tcgppc.fixref(list: TAsmList; var ref: treference; const size : TCgsize): boolean;
 function tcgppc.fixref(list: TAsmList; var ref: treference; const size : TCgsize): boolean;
+  // symbol names must not be larger than this to be able to make a GOT reference out of them,
+  // otherwise they get truncated by the compiler resulting in failing of the assembling stage
+const
+  MAX_GOT_SYMBOL_NAME_LENGTH_HACK = 120;
 var
 var
   tmpreg: tregister;
   tmpreg: tregister;
   name : string;
   name : string;
@@ -2041,7 +2045,9 @@ begin
   {$ENDIF EXTDEBUG}
   {$ENDIF EXTDEBUG}
 
 
   { if we have to create PIC, add the symbol to the TOC/GOT }
   { if we have to create PIC, add the symbol to the TOC/GOT }
-  if (cs_create_pic in aktmoduleswitches) and (assigned(ref.symbol)) then begin
+  {$WARNING Hack for avoiding too long manglednames enabled!!}
+  if (cs_create_pic in aktmoduleswitches) and (assigned(ref.symbol) and
+    (length(ref.symbol.name) < MAX_GOT_SYMBOL_NAME_LENGTH_HACK)) then begin
     tmpreg := load_got_symbol(list, ref.symbol.name);
     tmpreg := load_got_symbol(list, ref.symbol.name);
     if (ref.base = NR_NO) then
     if (ref.base = NR_NO) then
       ref.base := tmpreg
       ref.base := tmpreg

+ 11 - 34
compiler/powerpc64/nppcadd.pas

@@ -110,19 +110,12 @@ procedure tppcaddnode.load_left_right(cmpop, load_constants: boolean);
         begin
         begin
           location_force_reg(current_asmdata.CurrAsmList, n.location,
           location_force_reg(current_asmdata.CurrAsmList, n.location,
             def_cgsize(n.resulttype.def), false);
             def_cgsize(n.resulttype.def), false);
-          if not cmpop then
-          begin
-            location.register := n.location.register;
-          end;
         end;
         end;
       LOC_CONSTANT:
       LOC_CONSTANT:
         begin
         begin
-          if load_constants then
-          begin
+          if load_constants then begin
             location_force_reg(current_asmdata.CurrAsmList, n.location,
             location_force_reg(current_asmdata.CurrAsmList, n.location,
               def_cgsize(n.resulttype.def), false);
               def_cgsize(n.resulttype.def), false);
-            if not cmpop then
-              location.register := n.location.register;
           end;
           end;
         end;
         end;
       else
       else
@@ -133,9 +126,7 @@ procedure tppcaddnode.load_left_right(cmpop, load_constants: boolean);
 begin
 begin
   load_node(left);
   load_node(left);
   load_node(right);
   load_node(right);
-  if not (cmpop) and
-    (location.register = NR_NO) then
-  begin
+  if not (cmpop) then begin
     location.register := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
     location.register := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
   end;
   end;
 end;
 end;
@@ -429,32 +420,21 @@ begin
   location_force_fpureg(current_asmdata.CurrAsmList, right.location, true);
   location_force_fpureg(current_asmdata.CurrAsmList, right.location, true);
   location_force_fpureg(current_asmdata.CurrAsmList, left.location, true);
   location_force_fpureg(current_asmdata.CurrAsmList, left.location, true);
 
 
-  // initialize de result
-  if not cmpop then
-  begin
+  // initialize the result
+  if not cmpop then begin
     location_reset(location, LOC_FPUREGISTER, def_cgsize(resulttype.def));
     location_reset(location, LOC_FPUREGISTER, def_cgsize(resulttype.def));
-    if left.location.loc = LOC_FPUREGISTER then
-      location.register := left.location.register
-    else if right.location.loc = LOC_FPUREGISTER then
-      location.register := right.location.register
-    else
-      location.register := cg.getfpuregister(current_asmdata.CurrAsmList, location.size);
-  end
-  else
-  begin
+    location.register := cg.getfpuregister(current_asmdata.CurrAsmList, location.size);
+  end else begin
     location_reset(location, LOC_FLAGS, OS_NO);
     location_reset(location, LOC_FLAGS, OS_NO);
     location.resflags := getresflags;
     location.resflags := getresflags;
   end;
   end;
 
 
   // emit the actual operation
   // emit the actual operation
-  if not cmpop then
-  begin
+  if not cmpop then begin
     current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,
     current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,
       location.register, left.location.register,
       location.register, left.location.register,
       right.location.register))
       right.location.register))
-  end
-  else
-  begin
+  end else begin
     current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,
     current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,
       newreg(R_SPECIALREGISTER, location.resflags.cr, R_SUBNONE),
       newreg(R_SPECIALREGISTER, location.resflags.cr, R_SUBNONE),
         left.location.register, right.location.register))
         left.location.register, right.location.register))
@@ -495,8 +475,7 @@ begin
 
 
   load_left_right(cmpop, false);
   load_left_right(cmpop, false);
 
 
-  if not (cmpop) and
-    (location.register = NR_NO) then
+  if not (cmpop) then
     location.register := cg.getintregister(current_asmdata.CurrAsmList, OS_64);
     location.register := cg.getintregister(current_asmdata.CurrAsmList, OS_64);
   {$ifdef extdebug}
   {$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);
@@ -720,13 +699,11 @@ begin
   load_left_right(cmpop, (cs_check_overflow in aktlocalswitches) and
   load_left_right(cmpop, (cs_check_overflow in aktlocalswitches) and
     (nodetype in [addn, subn, muln]));
     (nodetype in [addn, subn, muln]));
 
 
-  if (location.register = NR_NO) and
-    not (cmpop) then
+  if 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
-  begin
+    (nodetype in [orn, andn, xorn]) then begin
     case nodetype of
     case nodetype of
       addn, muln, xorn, orn, andn:
       addn, muln, xorn, orn, andn:
         begin
         begin