Fix m68k errors with -CriotR option

git-svn-id: trunk@43165 -
This commit is contained in:
pierre 2019-10-10 21:57:07 +00:00
parent 450dd50e7b
commit 1bed61195e
2 changed files with 24 additions and 16 deletions

View File

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

View File

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