ソースを参照

* handle flag to reg./ref. conversion correctly for boolean64

git-svn-id: trunk@19914 -
florian 13 年 前
コミット
c4a5499d2a
5 ファイル変更48 行追加15 行削除
  1. 2 1
      .gitattributes
  2. 9 1
      compiler/ncgld.pas
  3. 20 13
      compiler/x86/cgx86.pas
  4. 0 0
      tests/webtbs/tw20874a.pp
  5. 17 0
      tests/webtbs/tw20874b.pp

+ 2 - 1
.gitattributes

@@ -11975,7 +11975,8 @@ tests/webtbs/tw20836.pp svneol=native#text/pascal
 tests/webtbs/tw20872a.pp svneol=native#text/pascal
 tests/webtbs/tw20872b.pp svneol=native#text/pascal
 tests/webtbs/tw20872c.pp svneol=native#text/pascal
-tests/webtbs/tw20874.pp svneol=native#text/pascal
+tests/webtbs/tw20874a.pp svneol=native#text/pascal
+tests/webtbs/tw20874b.pp svneol=native#text/pascal
 tests/webtbs/tw20889.pp svneol=native#text/pascal
 tests/webtbs/tw2109.pp svneol=native#text/plain
 tests/webtbs/tw2110.pp svneol=native#text/plain

+ 9 - 1
compiler/ncgld.pas

@@ -944,7 +944,15 @@ implementation
                     begin
                       case left.location.loc of
                         LOC_REGISTER,LOC_CREGISTER:
-                          cg.g_flags2reg(current_asmdata.CurrAsmList,left.location.size,right.location.resflags,left.location.register);
+{$ifdef cpu32bitalu}
+                          if left.location.size in [OS_S64,OS_64] then
+                            begin
+                              cg.g_flags2reg(current_asmdata.CurrAsmList,OS_32,right.location.resflags,left.location.register64.reglo);
+                              cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,0,left.location.register64.reghi);
+                            end
+                          else
+{$endif cpu32bitalu}
+                            cg.g_flags2reg(current_asmdata.CurrAsmList,left.location.size,right.location.resflags,left.location.register);
                         LOC_REFERENCE:
                           cg.g_flags2ref(current_asmdata.CurrAsmList,left.location.size,right.location.resflags,left.location.reference);
                         LOC_SUBSETREG,LOC_SUBSETREF:

+ 20 - 13
compiler/x86/cgx86.pas

@@ -1775,19 +1775,26 @@ unit cgx86;
       end;
 
 
-     procedure tcgx86.g_flags2ref(list: TAsmList; size: TCgSize; const f: tresflags; const ref: TReference);
-       var
-         ai : taicpu;
-         tmpref  : treference;
-       begin
-          tmpref:=ref;
-          make_simple_ref(list,tmpref);
-          if not(size in [OS_8,OS_S8]) then
-            a_load_const_ref(list,size,0,tmpref);
-          ai:=Taicpu.op_ref(A_SETcc,S_B,tmpref);
-          ai.setcondition(flags_to_cond(f));
-          list.concat(ai);
-       end;
+    procedure tcgx86.g_flags2ref(list: TAsmList; size: TCgSize; const f: tresflags; const ref: TReference);
+      var
+        ai : taicpu;
+        tmpref  : treference;
+      begin
+         tmpref:=ref;
+         make_simple_ref(list,tmpref);
+         if not(size in [OS_8,OS_S8]) then
+           a_load_const_ref(list,size,0,tmpref);
+         ai:=Taicpu.op_ref(A_SETcc,S_B,tmpref);
+         ai.setcondition(flags_to_cond(f));
+         list.concat(ai);
+{$ifndef cpu64bitalu}
+         if size in [OS_S64,OS_64] then
+           begin
+             inc(tmpref.offset,4);
+             a_load_const_ref(list,OS_32,0,tmpref);
+           end;
+{$endif cpu64bitalu}
+      end;
 
 
 { ************* concatcopy ************ }

+ 0 - 0
tests/webtbs/tw20874.pp → tests/webtbs/tw20874a.pp


+ 17 - 0
tests/webtbs/tw20874b.pp

@@ -0,0 +1,17 @@
+program qwordbooltest;
+
+{$mode objfpc}{$H+}
+
+var
+  A, B : Boolean64;
+begin
+  A := True;
+
+  // here it fails: qwordbooltest.pas(12,3) Fatal: Internal error 200109227
+  B := not A;
+
+  if B then
+    halt(1);
+
+  writeln('ok');
+end.