ソースを参照

* take into account the fact that bitpacked ordinal fields are all encoded
as bytes in the LLVM type, so typecast them to the correct type (which is
the size that will be used by hlcg.a_load*subsetref*)

git-svn-id: trunk@32565 -

Jonas Maebe 9 年 前
コミット
8df979e5e8
1 ファイル変更15 行追加1 行削除
  1. 15 1
      compiler/llvm/nllvmmem.pas

+ 15 - 1
compiler/llvm/nllvmmem.pas

@@ -66,6 +66,7 @@ implementation
     function tllvmsubscriptnode.handle_platform_subscript: boolean;
     function tllvmsubscriptnode.handle_platform_subscript: boolean;
       var
       var
         newbase: tregister;
         newbase: tregister;
+        fielddef: tdef;
       begin
       begin
         if not(location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
         if not(location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
           internalerror(2014011905);
           internalerror(2014011905);
@@ -74,7 +75,20 @@ implementation
             { typecast the result to the expected type, but don't actually index
             { typecast the result to the expected type, but don't actually index
               (that still has to be done by the generic code, so return false) }
               (that still has to be done by the generic code, so return false) }
             newbase:=hlcg.getaddressregister(current_asmdata.CurrAsmList,cpointerdef.getreusable(resultdef));
             newbase:=hlcg.getaddressregister(current_asmdata.CurrAsmList,cpointerdef.getreusable(resultdef));
-            hlcg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,left.resultdef,cpointerdef.getreusable(resultdef),location.reference,newbase);
+            if is_ordinal(resultdef) and
+               (resultdef.packedbitsize mod 8<>0) then
+              fielddef:=
+                cgsize_orddef(
+                  int_cgsize(
+                    packedbitsloadsize(resultdef.packedbitsize)
+                  )
+                )
+            else
+              fielddef:=resultdef;
+            hlcg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,
+              left.resultdef,
+              cpointerdef.getreusable(fielddef),
+              location.reference,newbase);
             reference_reset_base(location.reference,newbase,0,location.reference.alignment);
             reference_reset_base(location.reference,newbase,0,location.reference.alignment);
             result:=false;
             result:=false;
           end
           end