+ internal inc/dec

This commit is contained in:
peter 1998-06-25 14:04:17 +00:00
parent 91130f7270
commit 4ac8e5d18f
7 changed files with 194 additions and 90 deletions

View File

@ -1353,25 +1353,33 @@ implementation
*****************************************************************************} *****************************************************************************}
procedure secondinline(var p : ptree); procedure secondinline(var p : ptree);
const in2size:array[in_inc_byte..in_dec_dword] of Topsize= const
{$ifdef OLDINC}
decisize:array[in_inc_byte..in_dec_dword] of Topsize=
(S_B,S_W,S_L,S_B,S_W,S_L); (S_B,S_W,S_L,S_B,S_W,S_L);
in2instr:array[in_inc_byte..in_dec_dword] of Tasmop= in2instr:array[in_inc_byte..in_dec_dword] of Tasmop=
(A_INC,A_INC,A_INC,A_DEC,A_DEC,A_DEC); (A_INC,A_INC,A_INC,A_DEC,A_DEC,A_DEC);
ad2instr:array[in_inc_byte..in_dec_dword] of Tasmop= ad2instr:array[in_inc_byte..in_dec_dword] of Tasmop=
(A_ADD,A_ADD,A_ADD,A_SUB,A_SUB,A_SUB); (A_ADD,A_ADD,A_ADD,A_SUB,A_SUB,A_SUB);
{$endif OLDINC}
{ tfloattype = (f32bit,s32real,s64real,s80real,s64bit); } { tfloattype = (f32bit,s32real,s64real,s80real,s64bit); }
float_name: array[tfloattype] of string[8]= float_name: array[tfloattype] of string[8]=
('FIXED','SINGLE','REAL','EXTENDED','COMP','FIXED16'); ('FIXED','SINGLE','REAL','EXTENDED','COMP','FIXED16');
incdecop:array[in_inc_x..in_dec_x] of tasmop=(A_INC,A_DEC);
addsubop:array[in_inc_x..in_dec_x] of tasmop=(A_ADD,A_SUB);
var var
aktfile : treference; aktfile : treference;
ft : tfiletype; ft : tfiletype;
opsize : topsize; opsize : topsize;
asmop : tasmop; asmop : tasmop;
pushed : tpushed; pushed : tpushed;
{inc/dec}
addconstant : boolean;
addvalue : longint;
{ produces code for READ(LN) and WRITE(LN) }
procedure handlereadwrite(doread,callwriteln : boolean); procedure handlereadwrite(doread,callwriteln : boolean);
{ produces code for READ(LN) and WRITE(LN) }
procedure loadstream; procedure loadstream;
const const
@ -1382,7 +1390,6 @@ implementation
new(r); new(r);
reset_reference(r^); reset_reference(r^);
r^.symbol:=stringdup('U_'+upper(target_info.system_unit)+io[byte(doread)]); r^.symbol:=stringdup('U_'+upper(target_info.system_unit)+io[byte(doread)]);
{ if not (cs_compilesystem in aktswitches) then }
concat_external(r^.symbol^,EXT_NEAR); concat_external(r^.symbol^,EXT_NEAR);
exprasmlist^.concat(new(pai386,op_ref_reg(A_LEA,S_L,r,R_EDI))) exprasmlist^.concat(new(pai386,op_ref_reg(A_LEA,S_L,r,R_EDI)))
end; end;
@ -1402,7 +1409,8 @@ implementation
getlabel(iolabel); getlabel(iolabel);
emitl(A_LABEL,iolabel); emitl(A_LABEL,iolabel);
end end
else iolabel:=nil; else
iolabel:=nil;
{ no automatic call from flush } { no automatic call from flush }
doflush:=false; doflush:=false;
{ for write of real with the length specified } { for write of real with the length specified }
@ -1956,6 +1964,77 @@ implementation
{ could this be usefull I don't think so (PM) { could this be usefull I don't think so (PM)
emitoverflowcheck;} emitoverflowcheck;}
end; end;
in_dec_x,
in_inc_x :
begin
{ set defaults }
addvalue:=1;
addconstant:=true;
{ load first parameter, must be a reference }
secondpass(p^.left^.left);
case p^.left^.left^.resulttype^.deftype of
orddef,
enumdef : begin
case p^.left^.left^.resulttype^.size of
1 : opsize:=S_B;
2 : opsize:=S_W;
4 : opsize:=S_L;
end;
end;
pointerdef : begin
opsize:=S_L;
addvalue:=ppointerdef(p^.left^.left^.resulttype)^.definition^.savesize;
end;
else
internalerror(10081);
end;
{ second argument specified?, must be a s32bit in register }
if assigned(p^.left^.right) then
begin
secondpass(p^.left^.right^.left);
{ when constant, just multiply the addvalue }
if is_constintnode(p^.left^.right^.left) then
addvalue:=addvalue*get_ordinal_value(p^.left^.right^.left)
else
begin
case p^.left^.right^.left^.location.loc of
LOC_REGISTER,
LOC_CREGISTER : hregister:=p^.left^.right^.left^.location.register;
LOC_MEM,
LOC_REFERENCE : begin
hregister:=getregister32;
exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
newreference(p^.left^.right^.left^.location.reference),hregister)));
end;
else
internalerror(10082);
end;
{ insert multiply with addvalue if its >1 }
if addvalue>1 then
exprasmlist^.concat(new(pai386,op_const_reg(A_IMUL,opsize,
addvalue,hregister)));
addconstant:=false;
end;
end;
{ write the add instruction }
if addconstant then
begin
if (addvalue=1) and not(cs_check_overflow in aktswitches) then
exprasmlist^.concat(new(pai386,op_ref(incdecop[p^.inlinenumber],opsize,
newreference(p^.left^.left^.location.reference))))
else
exprasmlist^.concat(new(pai386,op_const_ref(addsubop[p^.inlinenumber],opsize,
addvalue,newreference(p^.left^.left^.location.reference))));
end
else
begin
exprasmlist^.concat(new(pai386,op_reg_ref(addsubop[p^.inlinenumber],opsize,
hregister,newreference(p^.left^.left^.location.reference))));
ungetregister32(hregister);
end;
emitoverflowcheck(p^.left^.left);
end;
{$ifdef OLDINC}
in_inc_byte..in_dec_dword: in_inc_byte..in_dec_dword:
begin begin
secondpass(p^.left); secondpass(p^.left);
@ -1971,6 +2050,7 @@ implementation
exprasmlist^.concat(new(pai386,op_ref(in2instr[p^.inlinenumber], exprasmlist^.concat(new(pai386,op_ref(in2instr[p^.inlinenumber],
in2size[p^.inlinenumber],newreference(p^.left^.location.reference)))); in2size[p^.inlinenumber],newreference(p^.left^.location.reference))));
end; end;
{$endif OLDINC}
in_assigned_x : in_assigned_x :
begin begin
secondpass(p^.left^.left); secondpass(p^.left^.left);
@ -2193,7 +2273,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.4 1998-06-25 08:48:06 florian Revision 1.5 1998-06-25 14:04:17 peter
+ internal inc/dec
Revision 1.4 1998/06/25 08:48:06 florian
* first version of rtti support * first version of rtti support
Revision 1.3 1998/06/09 16:01:33 pierre Revision 1.3 1998/06/09 16:01:33 pierre

View File

@ -3719,23 +3719,20 @@ unit pass_1;
begin begin
firstcallparan(p^.left,nil); firstcallparan(p^.left,nil);
{ first param must be var } { first param must be var }
if p^.left^.left^.location.loc<>LOC_REFERENCE then if not (p^.left^.left^.location.loc in [LOC_MEM,LOC_REFERENCE]) then
Message(cg_e_illegal_expression); Message(cg_e_illegal_expression);
{ check type } { check type }
if (p^.left^.resulttype^.deftype=pointerdef) or if (p^.left^.resulttype^.deftype in [enumdef,pointerdef]) or
(p^.left^.resulttype^.deftype=enumdef) or
((p^.left^.resulttype^.deftype=orddef) and ((p^.left^.resulttype^.deftype=orddef) and
(porddef(p^.left^.resulttype)^.typ in [u8bit,s8bit,u16bit,s16bit,u32bit,s32bit]) (porddef(p^.left^.resulttype)^.typ in [bool8bit,u8bit,s8bit,
) then bool16bit,u16bit,s16bit,bool32bit,u32bit,s32bit])) then
begin begin
{ two paras ? } { two paras ? }
if assigned(p^.left^.right) then if assigned(p^.left^.right) then
begin begin
{ insert a type conversion } { insert a type conversion }
{ the second param is always longint } { the second param is always longint }
p^.left^.right^.left:=gentypeconvnode( p^.left^.right^.left:=gentypeconvnode(p^.left^.right^.left,s32bitdef);
p^.left^.right^.left,
s32bitdef);
{ check the type conversion } { check the type conversion }
firstpass(p^.left^.right^.left); firstpass(p^.left^.right^.left);
if assigned(p^.left^.right^.right) then if assigned(p^.left^.right^.right) then
@ -3811,8 +3808,8 @@ unit pass_1;
else if hp^.left^.resulttype^.deftype=orddef then else if hp^.left^.resulttype^.deftype=orddef then
case porddef(hp^.left^.resulttype)^.typ of case porddef(hp^.left^.resulttype)^.typ of
u8bit,s8bit, u8bit,s8bit,
u16bit,s16bit : u16bit,s16bit : hp^.left:=gentypeconvnode(hp^.left,s32bitdef);
hp^.left:=gentypeconvnode(hp^.left,s32bitdef); bool16bit,bool32bit : hp^.left:=gentypeconvnode(hp^.left,booldef);
end end
{ but we convert only if the first index<>0, because in this case } { but we convert only if the first index<>0, because in this case }
{ we have a ASCIIZ string } { we have a ASCIIZ string }
@ -4408,7 +4405,7 @@ unit pass_1;
if codegenerror then if codegenerror then
exit; exit;
if not((p^.left^.resulttype^.deftype=orddef) and if not((p^.left^.resulttype^.deftype=orddef) and
(porddef(p^.left^.resulttype)^.typ=bool8bit)) then (porddef(p^.left^.resulttype)^.typ in [bool8bit,bool16bit,bool32bit])) then
begin begin
Message(sym_e_type_mismatch); Message(sym_e_type_mismatch);
exit; exit;
@ -5047,7 +5044,10 @@ unit pass_1;
end. end.
{ {
$Log$ $Log$
Revision 1.34 1998-06-25 08:48:14 florian Revision 1.35 1998-06-25 14:04:19 peter
+ internal inc/dec
Revision 1.34 1998/06/25 08:48:14 florian
* first version of rtti support * first version of rtti support
Revision 1.33 1998/06/16 08:56:24 peter Revision 1.33 1998/06/16 08:56:24 peter

View File

@ -183,25 +183,26 @@ unit pdecl;
var var
sc : pstringcontainer; sc : pstringcontainer;
s : stringid; s : stringid;
old_block_type : tblock_type;
filepos : tfileposinfo;
symdone : boolean;
{ to handle absolute }
abssym : pabsolutesym;
{$ifdef i386}
l : longint; l : longint;
code : word; code : word;
hs : string; {$endif i386}
{ c var }
Csym : pvarsym;
is_cdecl,extern_Csym,export_Csym : boolean;
C_name : string;
{ case }
p,casedef : pdef; p,casedef : pdef;
{ maxsize contains the max. size of a variant } { maxsize contains the max. size of a variant }
{ startvarrec contains the start of the variant part of a record } { startvarrec contains the start of the variant part of a record }
maxsize,startvarrec : longint; maxsize,startvarrec : longint;
pt : ptree; pt : ptree;
old_block_type : tblock_type;
{ to handle absolute }
abssym : pabsolutesym;
filepos : tfileposinfo;
Csym : pvarsym;
is_cdecl,extern_Csym,export_Csym : boolean;
C_name : string;
symdone : boolean;
begin begin
hs:='';
old_block_type:=block_type; old_block_type:=block_type;
block_type:=bt_type; block_type:=bt_type;
{ Force an expected ID error message } { Force an expected ID error message }
@ -1859,7 +1860,10 @@ unit pdecl;
end. end.
{ {
$Log$ $Log$
Revision 1.28 1998-06-24 12:26:45 peter Revision 1.29 1998-06-25 14:04:21 peter
+ internal inc/dec
Revision 1.28 1998/06/24 12:26:45 peter
* stricter var parsing like tp7 and some optimizes with directive * stricter var parsing like tp7 and some optimizes with directive
parsing parsing

View File

@ -290,14 +290,15 @@ unit pexpr;
consume(LKLAMMER); consume(LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true); p1:=comp_expr(true);
p2:=gencallparanode(p1,nil);
Must_be_valid:=false; Must_be_valid:=false;
if token=COMMA then if token=COMMA then
begin begin
consume(COMMA); consume(COMMA);
p1:=comp_expr(true); p2:=gencallparanode(comp_expr(true),nil);
end
else
p2:=nil;
p2:=gencallparanode(p1,p2); p2:=gencallparanode(p1,p2);
end;
statement_syssym:=geninlinenode(l,p2); statement_syssym:=geninlinenode(l,p2);
consume(RKLAMMER); consume(RKLAMMER);
pd:=voiddef; pd:=voiddef;
@ -1786,7 +1787,10 @@ unit pexpr;
end. end.
{ {
$Log$ $Log$
Revision 1.26 1998-06-09 16:01:46 pierre Revision 1.27 1998-06-25 14:04:23 peter
+ internal inc/dec
Revision 1.26 1998/06/09 16:01:46 pierre
+ added procedure directive parsing for procvars + added procedure directive parsing for procvars
(accepted are popstack cdecl and pascal) (accepted are popstack cdecl and pascal)
+ added C vars with the following syntax + added C vars with the following syntax

View File

@ -58,9 +58,10 @@ begin
p^.insert(new(psyssym,init('INCLUDE',in_include_x_y))); p^.insert(new(psyssym,init('INCLUDE',in_include_x_y)));
p^.insert(new(psyssym,init('BREAK',in_break))); p^.insert(new(psyssym,init('BREAK',in_break)));
p^.insert(new(psyssym,init('CONTINUE',in_continue))); p^.insert(new(psyssym,init('CONTINUE',in_continue)));
{ for testing purpose } {$ifndef OLDINC}
p^.insert(new(psyssym,init('DECI',in_dec_x))); p^.insert(new(psyssym,init('DEC',in_dec_x)));
p^.insert(new(psyssym,init('INCI',in_inc_x))); p^.insert(new(psyssym,init('INC',in_inc_x)));
{$endif}
p^.insert(new(psyssym,init('STR',in_str_x_string))); p^.insert(new(psyssym,init('STR',in_str_x_string)));
end; end;
@ -231,7 +232,10 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.3 1998-06-04 23:51:55 peter Revision 1.4 1998-06-25 14:04:24 peter
+ internal inc/dec
Revision 1.3 1998/06/04 23:51:55 peter
* m68k compiles * m68k compiles
+ .def file creation moved to gendef.pas so it could also be used + .def file creation moved to gendef.pas so it could also be used
for win32 for win32

View File

@ -62,6 +62,7 @@ Function lo(l : Longint) : Word; [INTERNPROC: In_lo_long];
Function hi(i : Integer) : byte; [INTERNPROC: In_hi_Word]; Function hi(i : Integer) : byte; [INTERNPROC: In_hi_Word];
Function hi(w : Word) : byte; [INTERNPROC: In_hi_Word]; Function hi(w : Word) : byte; [INTERNPROC: In_hi_Word];
Function hi(l : Longint) : Word; [INTERNPROC: In_hi_long]; Function hi(l : Longint) : Word; [INTERNPROC: In_hi_long];
{$ifndef INTERN_INC}
Procedure Inc(var i : Cardinal); [INTERNPROC: In_Inc_DWord]; Procedure Inc(var i : Cardinal); [INTERNPROC: In_Inc_DWord];
Procedure Inc(var i : Longint); [INTERNPROC: In_Inc_DWord]; Procedure Inc(var i : Longint); [INTERNPROC: In_Inc_DWord];
Procedure Inc(var i : Integer); [INTERNPROC: In_Inc_Word]; Procedure Inc(var i : Integer); [INTERNPROC: In_Inc_Word];
@ -78,6 +79,7 @@ Procedure Dec(var i : shortint); [INTERNPROC: In_Dec_byte];
Procedure Dec(var i : byte); [INTERNPROC: In_Dec_byte]; Procedure Dec(var i : byte); [INTERNPROC: In_Dec_byte];
Procedure Dec(var c : Char); [INTERNPROC: In_Dec_byte]; Procedure Dec(var c : Char); [INTERNPROC: In_Dec_byte];
Procedure Dec(var p : PChar); [INTERNPROC: In_Dec_DWord]; Procedure Dec(var p : PChar); [INTERNPROC: In_Dec_DWord];
{$endif INTERN_INC}
Function chr(b : byte) : Char; [INTERNPROC: In_chr_byte]; Function chr(b : byte) : Char; [INTERNPROC: In_chr_byte];
Function Length(s : string) : byte; [INTERNPROC: In_Length_string]; Function Length(s : string) : byte; [INTERNPROC: In_Length_string];
@ -123,9 +125,9 @@ Procedure incr_ansi_ref (P : pointer);[Alias : 'INCR_ANSI_REF'];
Run-Time Type Information (RTTI) Run-Time Type Information (RTTI)
****************************************************************************} ****************************************************************************}
{$i rtti.inc} {$i rtti.inc}
{**************************************************************************** {****************************************************************************
Math Routines Math Routines
****************************************************************************} ****************************************************************************}
@ -142,6 +144,8 @@ begin
Lo := b and $0f Lo := b and $0f
end; end;
{$ifndef INTERN_INC}
Procedure Inc(var i : Cardinal;a: Longint); Procedure Inc(var i : Cardinal;a: Longint);
Begin Begin
I:=I+A; I:=I+A;
@ -222,6 +226,8 @@ Begin
longint(p):=longint(p)+a; longint(p):=longint(p)+a;
End; End;
{$endif INTERN_INC}
Function swap (X : Word) : Word; Function swap (X : Word) : Word;
Begin Begin
swap:=(X and $ff) shl 8 + (X shr 8) swap:=(X and $ff) shl 8 + (X shr 8)
@ -434,7 +440,10 @@ End;
{ {
$Log$ $Log$
Revision 1.11 1998-06-25 09:44:20 daniel Revision 1.12 1998-06-25 14:04:25 peter
+ internal inc/dec
Revision 1.11 1998/06/25 09:44:20 daniel
+ RTLLITE directive to compile minimal RTL. + RTLLITE directive to compile minimal RTL.
Revision 1.10 1998/06/15 15:16:26 daniel Revision 1.10 1998/06/15 15:16:26 daniel

View File

@ -116,9 +116,12 @@ Function hi(w:Word):byte;
Function hi(i:Integer):byte; Function hi(i:Integer):byte;
Function hi(l:Longint):Word; Function hi(l:Longint):Word;
Function Hi(B : Byte): byte; Function Hi(B : Byte): byte;
Function Swap (X:Word):Word;
Function Swap (X:Integer):Integer;
Function Swap (X:Cardinal):Cardinal;
Function Swap (X:Longint):Longint;
{$endif RTLLITE} {$ifndef INTERN_INC}
Procedure Inc(Var i:cardinal); Procedure Inc(Var i:cardinal);
Procedure Inc(Var i:Longint); Procedure Inc(Var i:Longint);
Procedure Inc(Var i:Integer); Procedure Inc(Var i:Integer);
@ -135,11 +138,6 @@ Procedure Dec(Var i:shortint);
Procedure Dec(Var i:byte); Procedure Dec(Var i:byte);
Procedure Dec(Var c:Char); Procedure Dec(Var c:Char);
Procedure Dec(Var p:PChar); Procedure Dec(Var p:PChar);
Function Chr(b:byte):Char;
Function Length(s:string):byte;
{$ifndef RTLLITE}
Procedure Dec(Var i:cardinal;a:Longint); Procedure Dec(Var i:cardinal;a:Longint);
Procedure Inc(Var i:cardinal;a:Longint); Procedure Inc(Var i:cardinal;a:Longint);
Procedure Dec(Var i:Longint;a:Longint); Procedure Dec(Var i:Longint;a:Longint);
@ -156,12 +154,11 @@ Procedure Dec(Var c:Char;a:Longint);
Procedure Inc(Var c:Char;a:Longint); Procedure Inc(Var c:Char;a:Longint);
Procedure Dec(Var p:PChar;a:Longint); Procedure Dec(Var p:PChar;a:Longint);
Procedure Inc(Var p:PChar;a:Longint); Procedure Inc(Var p:PChar;a:Longint);
Function Swap (X:Word):Word; {$endif INTERN_INC}
Function Swap (X:Integer):Integer;
Function Swap (X:Cardinal):Cardinal;
Function Swap (X:Longint):Longint;
{$endif RTLLITE} {$endif RTLLITE}
Function Chr(b:byte):Char;
Function Length(s:string):byte;
Function Random(l:Longint):Longint; Function Random(l:Longint):Longint;
Function Random:real; Function Random:real;
@ -389,7 +386,10 @@ Procedure halt;
{ {
$Log$ $Log$
Revision 1.13 1998-06-25 09:44:21 daniel Revision 1.14 1998-06-25 14:04:26 peter
+ internal inc/dec
Revision 1.13 1998/06/25 09:44:21 daniel
+ RTLLITE directive to compile minimal RTL. + RTLLITE directive to compile minimal RTL.
Revision 1.12 1998/06/15 15:16:27 daniel Revision 1.12 1998/06/15 15:16:27 daniel