* fixed bitpacked array index calculation for llvm: the element bitsize was

only used for masking out the bits of the loaded data, not for calculating
    the offset

git-svn-id: trunk@33957 -
This commit is contained in:
Jonas Maebe 2016-06-12 09:20:54 +00:00
parent 14ab43626f
commit 8bc39ba7a3

View File

@ -237,6 +237,11 @@ implementation
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SUB,ptruinttype,tarraydef(left.resultdef).lowrange-constarrayoffset,maybe_const_reg,hreg);
constarrayoffset:=0;
{ multiply index with bitsize of every element }
hreg2:=hlcg.getintregister(current_asmdata.CurrAsmList,ptruinttype);
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_MUL,ptruinttype,l,hreg,hreg2);
hreg:=hreg2;
{ keep alignment for index }
sref.ref.alignment:=left.resultdef.alignment;
intloadsize:=packedbitsloadsize(l);
@ -256,14 +261,11 @@ implementation
sref.ref,ptruinttype,offsetreg,true));
arraytopointerconverted:=true;
reference_reset_base(sref.ref,basereg,0,sref.ref.alignment);
{ calculate the bit index inside that chunk }
{ calculate the bit index inside that chunk: mask out
the chunk index part }
hreg2:=hlcg.getintregister(current_asmdata.CurrAsmList,ptruinttype);
{ multiple index with bitsize of every element }
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_MUL,ptruinttype,l,hreg,hreg2);
hreg:=hlcg.getintregister(current_asmdata.CurrAsmList,ptruinttype);
{ mask out the chunk index part }
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_AND,ptruinttype,(1 shl (3+alignpower))-1,hreg2,hreg);
sref.bitindexreg:=hreg;
hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_AND,ptruinttype,(1 shl (3+alignpower))-1,hreg,hreg2);
sref.bitindexreg:=hreg2;
sref.startbit:=0;
sref.bitlen:=resultdef.packedbitsize;
if (left.location.loc=LOC_REFERENCE) then