Procházet zdrojové kódy

* support for dynamic strings and arrays in update_reference_reg_mul()

git-svn-id: trunk@30784 -
Jonas Maebe před 10 roky
rodič
revize
8034ef1f31
1 změnil soubory, kde provedl 13 přidání a 5 odebrání
  1. 13 5
      compiler/llvm/nllvmmem.pas

+ 13 - 5
compiler/llvm/nllvmmem.pas

@@ -184,11 +184,19 @@ implementation
         end;
       hreg:=hlcg.getaddressregister(current_asmdata.CurrAsmList,getpointerdef(resultdef));
       location.reference:=thlcgllvm(hlcg).make_simple_ref(current_asmdata.CurrAsmList,location.reference,left.resultdef);
-      { get address of indexed array element and convert pointer to array into
-        pointer to the elementdef in the process }
-      current_asmdata.CurrAsmList.Concat(taillvm.getelementptr_reg_size_ref_size_reg(hreg,getpointerdef(left.resultdef),
-        location.reference,ptruinttype,maybe_const_reg,true));
-      arraytopointerconverted:=true;
+      if not is_dynamicstring(left.resultdef) and
+         not is_dynamic_array(left.resultdef) then
+        begin
+          { get address of indexed array element and convert pointer to array into
+            pointer to the elementdef in the process }
+          current_asmdata.CurrAsmList.Concat(taillvm.getelementptr_reg_size_ref_size_reg(hreg,getpointerdef(left.resultdef),
+            location.reference,ptruinttype,maybe_const_reg,true));
+          arraytopointerconverted:=true;
+        end
+      else
+        { the array is already a pointer -> just index }
+        current_asmdata.CurrAsmList.Concat(taillvm.getelementptr_reg_size_ref_size_reg(hreg,left.resultdef,
+          location.reference,ptruinttype,maybe_const_reg,false));
       reference_reset_base(location.reference,hreg,0,location.reference.alignment);
       location.reference.alignment:=newalignment(location.reference.alignment,l);
     end;