Browse Source

* don't overwrite the reg to load in a parameter in tcg.a_load_reg_cgpara()
if the value has to be shifted first (it could be a regvar)
* also take the cgpara's shiftval into account when loading a constant

git-svn-id: trunk@20961 -

Jonas Maebe 13 years ago
parent
commit
b512744bfb
1 changed files with 8 additions and 1 deletions
  1. 8 1
      compiler/cgobj.pas

+ 8 - 1
compiler/cgobj.pas

@@ -896,11 +896,16 @@ implementation
     procedure tcg.a_load_reg_cgpara(list : TAsmList;size : tcgsize;r : tregister;const cgpara : TCGPara);
       var
          ref : treference;
+         tmpreg : tregister;
       begin
          cgpara.check_simple_location;
          paramanager.alloccgpara(list,cgpara);
          if cgpara.location^.shiftval<0 then
-           a_op_const_reg(list,OP_SHL,cgpara.location^.size,-cgpara.location^.shiftval,r);
+           begin
+             tmpreg:=getintregister(list,cgpara.location^.size);
+             a_op_const_reg_reg(list,OP_SHL,cgpara.location^.size,-cgpara.location^.shiftval,r,tmpreg);
+             r:=tmpreg;
+           end;
          case cgpara.location^.loc of
             LOC_REGISTER,LOC_CREGISTER:
               a_load_reg_reg(list,size,cgpara.location^.size,r,cgpara.location^.register);
@@ -930,6 +935,8 @@ implementation
       begin
          cgpara.check_simple_location;
          paramanager.alloccgpara(list,cgpara);
+         if cgpara.location^.shiftval<0 then
+           a:=a shl -cgpara.location^.shiftval;
          case cgpara.location^.loc of
             LOC_REGISTER,LOC_CREGISTER:
               a_load_const_reg(list,cgpara.location^.size,a,cgpara.location^.register);