Pārlūkot izejas kodu

* 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 gadi atpakaļ
vecāks
revīzija
1bd43869d0

+ 2 - 2
compiler/powerpc64/agppcgas.pas

@@ -91,7 +91,7 @@ begin
   with ref do begin
     if ((offset < -32768) or (offset > 32767)) and
       (refaddr = addr_no) then
-      ; //internalerror(19991);
+      internalerror(2006052501);
     if (refaddr = addr_no) then
       s := ''
     else begin
@@ -128,7 +128,7 @@ begin
       if (offset = 0) then
         s := s + gas_regname(base) + ',' + gas_regname(index)
       else
-        internalerror(19992);
+        internalerror(2006052502);
     end;
   end;
   getreferencestring := s;

+ 9 - 3
compiler/powerpc64/cgcpu.pas

@@ -743,8 +743,8 @@ begin
     internalerror(2002090902);
   { 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 }
-  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)
   else
     loadConstantNormal(list, size, a, reg);
@@ -2029,6 +2029,10 @@ end;
 
 
 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
   tmpreg: tregister;
   name : string;
@@ -2041,7 +2045,9 @@ begin
   {$ENDIF EXTDEBUG}
 
   { 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);
     if (ref.base = NR_NO) then
       ref.base := tmpreg

+ 11 - 34
compiler/powerpc64/nppcadd.pas

@@ -110,19 +110,12 @@ procedure tppcaddnode.load_left_right(cmpop, load_constants: boolean);
         begin
           location_force_reg(current_asmdata.CurrAsmList, n.location,
             def_cgsize(n.resulttype.def), false);
-          if not cmpop then
-          begin
-            location.register := n.location.register;
-          end;
         end;
       LOC_CONSTANT:
         begin
-          if load_constants then
-          begin
+          if load_constants then begin
             location_force_reg(current_asmdata.CurrAsmList, n.location,
               def_cgsize(n.resulttype.def), false);
-            if not cmpop then
-              location.register := n.location.register;
           end;
         end;
       else
@@ -133,9 +126,7 @@ procedure tppcaddnode.load_left_right(cmpop, load_constants: boolean);
 begin
   load_node(left);
   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);
   end;
 end;
@@ -429,32 +420,21 @@ begin
   location_force_fpureg(current_asmdata.CurrAsmList, right.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));
-    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.resflags := getresflags;
   end;
 
   // emit the actual operation
-  if not cmpop then
-  begin
+  if not cmpop then begin
     current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,
       location.register, left.location.register,
       right.location.register))
-  end
-  else
-  begin
+  end else begin
     current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,
       newreg(R_SPECIALREGISTER, location.resflags.cr, R_SUBNONE),
         left.location.register, right.location.register))
@@ -495,8 +475,7 @@ begin
 
   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);
   {$ifdef extdebug}
   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
     (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);
 
   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
       addn, muln, xorn, orn, andn:
         begin