Browse Source

Fix m68k errors with -CriotR option

git-svn-id: trunk@43165 -
pierre 5 năm trước cách đây
mục cha
commit
1bed61195e
2 tập tin đã thay đổi với 24 bổ sung16 xóa
  1. 11 4
      compiler/m68k/cgcpu.pas
  2. 13 12
      compiler/m68k/ra68kmot.pas

+ 11 - 4
compiler/m68k/cgcpu.pas

@@ -1155,6 +1155,13 @@ unit cgcpu;
       begin
         optimize_op_const(size, op, a);
         opcode := topcg2tasmop[op];
+        if (a >0) and (a<=high(dword)) then
+          a:=longint(dword(a))
+        else if (a>=low(longint)) then
+          a:=longint(a)
+        else
+	  internalerror(201810201);
+          
         case op of
           OP_NONE :
             begin
@@ -2549,16 +2556,16 @@ unit cgcpu;
             begin
               hreg:=cg.getintregister(list,OS_INT);
               { cg.a_load_const_reg provides optimized loading to register for special cases }
-              cg.a_load_const_reg(list,OS_S32,longint(highvalue),hreg);
+              cg.a_load_const_reg(list,OS_S32,tcgint(highvalue),hreg);
               { don't use cg.a_op_const_reg() here, because a possible optimized
                 ADDQ/SUBQ wouldn't set the eXtend bit }
-              list.concat(taicpu.op_const_reg(opcode,S_L,longint(lowvalue),regdst.reglo));
+              list.concat(taicpu.op_const_reg(opcode,S_L,tcgint(lowvalue),regdst.reglo));
               list.concat(taicpu.op_reg_reg(xopcode,S_L,hreg,regdst.reghi));
             end;
           OP_AND,OP_OR,OP_XOR:
             begin
-              cg.a_op_const_reg(list,op,OS_S32,longint(lowvalue),regdst.reglo);
-              cg.a_op_const_reg(list,op,OS_S32,longint(highvalue),regdst.reghi);
+              cg.a_op_const_reg(list,op,OS_S32,tcgint(lowvalue),regdst.reglo);
+              cg.a_op_const_reg(list,op,OS_S32,tcgint(highvalue),regdst.reghi);
             end;
           { this is handled in 1st pass for 32-bit cpus (helper call) }
           OP_IDIV,OP_DIV,

+ 13 - 12
compiler/m68k/ra68kmot.pas

@@ -82,11 +82,11 @@ unit ra68kmot;
          function try_to_consume(t : tasmtoken):boolean;
          procedure consume_all_until(tokens : tasmtokenset);
          function findopcode(const s: string; var opsize: topsize): tasmop;
-         Function BuildExpression(allow_symbol : boolean; asmsym : pshortstring) : longint;
-         Procedure BuildConstant(maxvalue: longint);
+         Function BuildExpression(allow_symbol : boolean; asmsym : pshortstring) : tcgint;
+         Procedure BuildConstant(maxvalue: tcgint);
          Procedure BuildRealConstant(typ : tfloattype);
          Procedure BuildScaling(const oper:tm68koperand);
-         Function BuildRefExpression: longint;
+         Function BuildRefExpression: tcgint;
          procedure BuildReference(const oper:tm68koperand);
          procedure BuildRegList(const oper:tm68koperand);
          procedure BuildRegPair(const oper:tm68koperand);
@@ -621,9 +621,9 @@ const
 
 
 
-    Function tm68kmotreader.BuildExpression(allow_symbol : boolean; asmsym : pshortstring) : longint;
+    Function tm68kmotreader.BuildExpression(allow_symbol : boolean; asmsym : pshortstring) : tcgint;
   {*********************************************************************}
-  { FUNCTION BuildExpression: longint                                   }
+  { FUNCTION BuildExpression: tcgint                                    }
   {  Description: This routine calculates a constant expression to      }
   {  a given value. The return value is the value calculated from       }
   {  the expression.                                                    }
@@ -934,7 +934,7 @@ const
   end;
 
 
-  Procedure tm68kmotreader.BuildConstant(maxvalue: longint);
+  Procedure tm68kmotreader.BuildConstant(maxvalue: tcgint);
   {*********************************************************************}
   { PROCEDURE BuildConstant                                             }
   {  Description: This routine takes care of parsing a DB,DD,or DW      }
@@ -948,7 +948,7 @@ const
   {*********************************************************************}
   var
    expr: string;
-   value : longint;
+   value : tcgint;
   begin
       Repeat
         Case actasmtoken of
@@ -1059,9 +1059,9 @@ const
   end;
 
 
-  Function TM68kMotreader.BuildRefExpression: longint;
+  Function TM68kMotreader.BuildRefExpression: tcgint;
   {*********************************************************************}
-  { FUNCTION BuildRefExpression: longint                                   }
+  { FUNCTION BuildRefExpression: tcgint                                 }
   {  Description: This routine calculates a constant expression to      }
   {  a given value. The return value is the value calculated from       }
   {  the expression.                                                    }
@@ -1177,7 +1177,7 @@ const
   {*********************************************************************}
   procedure TM68kMotreader.BuildReference(const oper:tm68koperand);
     var
-      l:longint;
+      l:tcgint;
       code: integer;
       str: string;
     begin
@@ -1423,7 +1423,8 @@ const
                          Message(asmr_e_invalid_operand_type);
                       { identifiers are handled by BuildExpression }
                       oper.opr.typ := OPR_CONSTANT;
-                      oper.opr.val :=BuildExpression(true,@tempstr);
+		      l:=BuildExpression(true,@tempstr);
+                      oper.opr.val :=aint(l);
                       if tempstr<>'' then
                         begin
                           l:=oper.opr.val;
@@ -1712,7 +1713,7 @@ const
               AS_DD:
                 begin
                   Consume(AS_DD);
-                  BuildConstant(longint($ffffffff));
+                  BuildConstant(tcgint($ffffffff));
                 end;
               AS_XDEF:
                 begin