* write elements of bitpacked arrays grouped per the number of bits that

will be used to load them afterwards instead of always per byte so we
    can use that loadsize as the array element type in llvm declarations
    (-> less casting required)

git-svn-id: branches/hlcgllvm@26977 -
This commit is contained in:
Jonas Maebe 2014-03-06 21:40:04 +00:00
parent e9268a0a14
commit 672c96a811

View File

@ -350,12 +350,10 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
inc(bp.curbitoffset,bp.packedbitsize); inc(bp.curbitoffset,bp.packedbitsize);
end; end;
{$pop}
procedure flush_packed_value(list: tasmlist; var bp: tbitpackedval); procedure flush_packed_value(list: tasmlist; var bp: tbitpackedval);
var var
bitstowrite: longint; bitstowrite: longint;
writeval : byte; writeval : AInt;
begin begin
if (bp.curbitoffset < AIntBits) then if (bp.curbitoffset < AIntBits) then
begin begin
@ -368,27 +366,35 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
bitstowrite:=AIntBits; bitstowrite:=AIntBits;
dec(bp.curbitoffset,AIntBits); dec(bp.curbitoffset,AIntBits);
end; end;
while (bitstowrite>=8) do while (bitstowrite>=bp.loadbitsize) do
begin begin
if (target_info.endian=endian_little) then if (target_info.endian=endian_little) then
begin begin
{ write lowest byte } { write lowest "loadbitsize" bits }
writeval:=byte(bp.curval); writeval:=bp.curval and (aint(-1) shr ((sizeof(aint)*8)-bp.loadbitsize));
bp.curval:=bp.curval shr 8; bp.curval:=bp.curval shr bp.loadbitsize;
end end
else else
begin begin
{ write highest byte } { write highest "loadbitsize" bits }
writeval:=bp.curval shr (AIntBits-8); writeval:=bp.curval shr (AIntBits-bp.loadbitsize);
bp.curval:=(bp.curval and (not($ff shl (AIntBits-8)))) shl 8; bp.curval:=bp.curval shl bp.loadbitsize;
end; end;
list.concat(tai_const.create_8bit(writeval)); case bp.loadbitsize of
dec(bitstowrite,8); 8: list.concat(tai_const.create_8bit(writeval));
16: list.concat(tai_const.create_16bit(writeval));
32: list.concat(tai_const.create_32bit(writeval));
64: list.concat(tai_const.create_64bit(writeval));
else
internalerror(2013111101);
end;
dec(bitstowrite,bp.loadbitsize);
end; end;
bp.curval:=bp.nextval; bp.curval:=bp.nextval;
bp.nextval:=0; bp.nextval:=0;
end; end;
{$pop}
{ parses a packed array constant } { parses a packed array constant }