* string type st_ fixed

This commit is contained in:
peter 1998-08-10 14:43:14 +00:00
parent 6396267185
commit 9050cab930
3 changed files with 123 additions and 71 deletions

View File

@ -38,7 +38,7 @@ unit cg68k;
interface
{***************************************************************************}
uses objects,verbose,cobjects,systems,globals,tree,
uses objects,verbose,cobjects,comphook,systems,globals,tree,
symtable,types,strings,pass_1,hcodegen,temp_gen,
aasm,m68k,tgen68k,files,cga68k,cg68k2,link
{$ifdef GDB}
@ -752,7 +752,7 @@ implementation
{ move to FPU }
floatload(pfloatdef(p^.left^.resulttype)^.typ,
p^.left^.location.reference,p^.location);
if (cs_fp_emulation) in aktswitches then
if (cs_fp_emulation) in aktmoduleswitches then
{ if in emulation mode change sign manually }
exprasmlist^.concat(new(pai68k,op_const_reg(A_BCHG,S_L,31,
p^.location.fpureg)))
@ -772,7 +772,7 @@ implementation
LOC_FPU : begin
p^.location.loc:=LOC_FPU;
p^.location.fpureg := p^.left^.location.fpureg;
if (cs_fp_emulation) in aktswitches then
if (cs_fp_emulation) in aktmoduleswitches then
exprasmlist^.concat(new(pai68k,op_const_reg(A_BCHG,S_L,31,p^.location.fpureg)))
else
exprasmlist^.concat(new(pai68k,op_reg(A_FNEG,S_FX,p^.location.fpureg)));
@ -1259,7 +1259,7 @@ implementation
else
begin
{ quick hack, to overcome Delphi 2 }
if (cs_maxoptimieren in aktswitches) and
if (cs_maxoptimize in aktglobalswitches) and
(p^.left^.resulttype^.deftype=arraydef) then
begin
extraoffset:=0;
@ -1359,7 +1359,7 @@ implementation
end;
{ produce possible range check code: }
if cs_rangechecking in aktswitches then
if cs_check_range in aktlocalswitches then
begin
if p^.left^.resulttype^.deftype=arraydef then
begin
@ -1469,9 +1469,9 @@ implementation
exit;
{ range checking is different for u32bit }
{ lets try to generate it allways }
if (cs_rangechecking in aktswitches) and
if (cs_check_range in aktlocalswitches) and
{ with $R+ explicit type conversations in TP aren't range checked! }
(not(p^.explizit) or not(cs_tp_compatible in aktswitches)) and
(not(p^.explizit) or not(cs_tp_compatible in aktmoduleswitches)) and
((porddef(p1)^.low>porddef(p2)^.low) or
(porddef(p1)^.high<porddef(p2)^.high) or
(porddef(p1)^.typ=u32bit) or
@ -1978,7 +1978,7 @@ implementation
+ else}
p^.location.loc := LOC_FPU;
{ get floating point register. }
if (cs_fp_emulation in aktswitches) then
if (cs_fp_emulation in aktmoduleswitches) then
begin
p^.location.fpureg := getregister32;
exprasmlist^.concat(new(pai68k, op_ref_reg(A_MOVE, S_L, r, R_D0)));
@ -2011,7 +2011,7 @@ implementation
{ instead of allocating reserved registers. }
if (p^.left^.location.loc<>LOC_FPU) then
begin
if (cs_fp_emulation in aktswitches) then
if (cs_fp_emulation in aktmoduleswitches) then
begin
exprasmlist^.concat(new(pai68k,op_ref_reg(A_MOVE,S_L,newreference(p^.left^.location.reference),R_D0)));
exprasmlist^.concat(new(pai68k,op_const_reg(A_MOVE,S_L,65536,R_D1)));
@ -2027,7 +2027,7 @@ implementation
end
else
begin
if (cs_fp_emulation in aktswitches) then
if (cs_fp_emulation in aktmoduleswitches) then
begin
exprasmlist^.concat(new(pai68k,op_reg_reg(A_MOVE,S_L,p^.left^.location.fpureg,R_D0)));
exprasmlist^.concat(new(pai68k,op_const_reg(A_MOVE,S_L,65536,R_D1)));
@ -2182,7 +2182,7 @@ implementation
reset_reference(r);
r.base:=R_SP;
if (cs_fp_emulation in aktswitches) then
if (cs_fp_emulation in aktmoduleswitches) then
begin
p^.location.loc:=LOC_FPU;
p^.location.fpureg := getregister32;
@ -2275,8 +2275,8 @@ implementation
((porddef(p^.resulttype)^.low>porddef(hp^.resulttype)^.low) or
(porddef(p^.resulttype)^.high<porddef(hp^.resulttype)^.high)) then
begin
if (cs_rangechecking in aktswitches) and
(not(p^.explizit) or not(cs_tp_compatible in aktswitches)) then
if (cs_check_range in aktlocalswitches) and
(not(p^.explizit) or not(cs_tp_compatible in aktmoduleswitches)) then
porddef(p^.resulttype)^.genrangecheck;
if porddef(hp^.resulttype)^.typ=s32bit then
begin
@ -2316,8 +2316,8 @@ implementation
end
else internalerror(6);
if (cs_rangechecking in aktswitches) and
(not(p^.explizit) or not(cs_tp_compatible in aktswitches)) then
if (cs_check_range in aktlocalswitches) and
(not(p^.explizit) or not(cs_tp_compatible in aktmoduleswitches)) then
Begin
new(hpp);
reset_reference(hpp^);
@ -2702,7 +2702,7 @@ implementation
reset_reference(r^);
r^.base:=R_SP;
s:=getfloatsize(pfloatdef(p^.left^.resulttype)^.typ);
if (cs_fp_emulation in aktswitches) or (s=S_FS) then
if (cs_fp_emulation in aktmoduleswitches) or (s=S_FS) then
begin
{ when in emulation mode... }
{ only single supported!!! }
@ -2930,7 +2930,7 @@ implementation
((p^.procdefinition^.options and povirtualmethod)=0) then
begin
if ((p^.procdefinition^.options and poiocheck)<>0)
and (cs_iocheck in aktswitches) then
and (cs_check_io in aktlocalswitches) then
begin
getlabel(iolabel);
emitl(A_LABEL,iolabel);
@ -3302,7 +3302,7 @@ implementation
if p^.procdefinition^.extnumber=-1 then
internalerror($Da);
r^.offset:=p^.procdefinition^.extnumber*4+12;
if (cs_rangechecking in aktswitches) then
if (cs_check_range in aktlocalswitches) then
begin
{ If the base is already A0, the no instruction will }
{ be emitted! }
@ -3462,7 +3462,7 @@ implementation
p^.location.fpureg:=hregister;
end;
s64bit,s64real,s80real: begin
if cs_fp_emulation in aktswitches then
if cs_fp_emulation in aktmoduleswitches then
begin
p^.location.loc:=LOC_FPU;
hregister:=getregister32;
@ -3593,7 +3593,7 @@ implementation
new(r);
reset_reference(r^);
r^.symbol:=stringdup('U_'+upper(target_info.system_unit)+io[byte(doread)]);
if not (cs_compilesystem in aktswitches) then
if not (cs_compilesystem in aktmoduleswitches) then
concat_external(r^.symbol^,EXT_NEAR);
exprasmlist^.concat(new(pai68k,op_ref_reg(A_LEA,S_L,r,R_A0)))
@ -3609,7 +3609,7 @@ implementation
begin
{ I/O check }
if cs_iocheck in aktswitches then
if cs_check_io in aktlocalswitches then
begin
getlabel(iolabel);
emitl(A_LABEL,iolabel);
@ -3782,18 +3782,18 @@ implementation
{ push maximum string length }
push_int(pstringdef(pararesult)^.len);
case pstringdef(pararesult)^.string_typ of
shortstring: emitcall ('READ_TEXT_STRING',true);
ansistring : emitcall ('READ_TEXT_ANSISTRING',true);
longstring : emitcall ('READ_TEXT_LONGSTRING',true);
widestring : emitcall ('READ_TEXT_ANSISTRING',true);
st_shortstring: emitcall ('READ_TEXT_STRING',true);
st_ansistring : emitcall ('READ_TEXT_ANSISTRING',true);
st_longstring : emitcall ('READ_TEXT_LONGSTRING',true);
st_widestring : emitcall ('READ_TEXT_ANSISTRING',true);
end
end
else
Case pstringdef(Pararesult)^.string_typ of
shortstring: emitcall ('WRITE_TEXT_STRING',true);
ansistring : emitcall ('WRITE_TEXT_ANSISTRING',true);
longstring : emitcall ('WRITE_TEXT_LONGSTRING',true);
widestring : emitcall ('WRITE_TEXT_ANSISTRING',true);
st_shortstring: emitcall ('WRITE_TEXT_STRING',true);
st_ansistring : emitcall ('WRITE_TEXT_ANSISTRING',true);
st_longstring : emitcall ('WRITE_TEXT_LONGSTRING',true);
st_widestring : emitcall ('WRITE_TEXT_ANSISTRING',true);
end;
end;
pointerdef : begin
@ -4620,7 +4620,7 @@ implementation
else
begin
{ single values are in the floating point registers }
if cs_fp_emulation in aktswitches then
if cs_fp_emulation in aktmoduleswitches then
emit_reg_reg(A_MOVE,S_L,p^.left^.location.fpureg,R_D0)
else
exprasmlist^.concat(new(pai68k,op_reg_reg(A_FMOVE,S_FS,
@ -4878,14 +4878,14 @@ do_jmp:
hr^.base:=getaddressreg;
emit_reg_reg(A_MOVE,S_L,hregister,hr^.base);
exprasmlist^.concat(new(pai68k,op_ref(A_JMP,S_NO,hr)));
{ if not(cs_littlesize in aktswitches^ ) then
{ if not(cs_littlesize in aktglobalswitches^ ) then
datasegment^.concat(new(pai68k,op_const(A_ALIGN,S_NO,4))); }
datasegment^.concat(new(pai_label,init(table)));
last:=min_;
genitem(hp);
if hr^.base <> R_NO then ungetregister(hr^.base);
{ !!!!!!!
if not(cs_littlesize in aktswitches^ ) then
if not(cs_littlesize in aktglobalswitches^ ) then
exprasmlist^.concat(new(pai68k,op_const(A_ALIGN,S_NO,4)));
}
end;
@ -4929,7 +4929,7 @@ do_jmp:
else internalerror(2002);
end;
{ now generate the jumps }
if cs_optimize in aktswitches then
if cs_optimize in aktglobalswitches then
begin
{ procedures are empirically passed on }
{ consumption can also be calculated }
@ -4946,7 +4946,7 @@ do_jmp:
jumptable_no_range:=(lv=min_label) and (hv=max_label);
{ optimize for size ? }
if cs_littlesize in aktswitches then
if cs_littlesize in aktglobalswitches then
begin
if (labels<=2) or ((max_label-min_label)>3*labels) then
{ a linear list is always smaller than a jump tree }
@ -5035,6 +5035,47 @@ do_jmp:
exprasmlist^.concat(new(pai_labeled,init(A_JMP,quickexitlabel)));
end;
procedure secondon(var p : ptree);
var
nextonlabel,myendexceptlabel : plabel;
ref : treference;
begin
{ !!!!!!!!!!!!!!! }
(* getlabel(nextonlabel);
{ push the vmt }
exprasmlist^.concat(new(pai386,op_csymbol(A_PUSH,S_L,
newcsymbol(p^.excepttype^.vmt_mangledname,0))));
maybe_concat_external(p^.excepttype^.owner,
p^.excepttype^.vmt_mangledname);
emitcall('FPC_CATCHES',true);
exprasmlist^.concat(new(pai386,
op_reg_reg(A_TEST,S_L,R_EAX,R_EAX)));
emitl(A_JE,nextonlabel);
ref.symbol:=nil;
gettempofsizereference(4,ref);
{ what a hack ! }
if assigned(p^.exceptsymtable) then
pvarsym(p^.exceptsymtable^.root)^.address:=ref.offset;
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,
R_EAX,newreference(ref))));
if assigned(p^.right) then
secondpass(p^.right);
{ clear some stuff }
ungetiftemp(ref);
emitl(A_JMP,endexceptlabel);
emitl(A_LABEL,nextonlabel);
{ next on node }
if assigned(p^.left) then
secondpass(p^.left); *)
end;
procedure secondas(var p : ptree);
var
@ -5163,22 +5204,23 @@ end;
secondstatement,secondnothing,secondifn,secondbreakn,
secondcontinuen,second_while_repeatn,second_while_repeatn,secondfor,
secondexitn,secondwith,secondcase,secondlabel,
secondgoto,secondsimplenewdispose,secondtryexcept,secondraise,
secondnothing,secondtryfinally,secondis,secondas,seconderror,
secondgoto,secondsimplenewdispose,secondtryexcept,
secondraise,
secondnothing,secondtryfinally,secondon,secondis,
secondas,seconderror,
secondfail,secondadd,secondprocinline,
secondnothing,secondloadvmt);
var
oldcodegenerror : boolean;
oldswitches : Tcswitches;
oldpos : tfileposinfo;
oldcodegenerror : boolean;
oldlocalswitches : tlocalswitches;
oldpos : tfileposinfo;
begin
oldcodegenerror:=codegenerror;
oldswitches:=aktswitches;
oldlocalswitches:=aktlocalswitches;
oldpos:=aktfilepos;
aktfilepos:=p^.fileinfo;
aktswitches:=p^.pragmas;
aktlocalswitches:=p^.localswitches;
if not(p^.error) then
begin
codegenerror:=false;
@ -5188,13 +5230,13 @@ end;
end
else
codegenerror:=true;
aktswitches:=oldswitches;
aktlocalswitches:=oldlocalswitches;
aktfilepos:=oldpos;
end;
function do_secondpass(var p : ptree) : boolean;
begin
codegenerror:=false;
if not(p^.error) then
@ -5202,6 +5244,7 @@ end;
do_secondpass:=codegenerror;
end;
var
regvars : array[1..maxvarregs] of pvarsym;
regvars_para : array[1..maxvarregs] of boolean;
@ -5231,7 +5274,7 @@ end;
{ parameter get a less value }
if parasym then
begin
if cs_littlesize in aktswitches then
if cs_littlesize in aktglobalswitches then
dec(j,1)
else
dec(j,100);
@ -5266,7 +5309,7 @@ end;
begin
cleartempgen;
{ when size optimization only count occurrence }
if cs_littlesize in aktswitches then
if cs_littlesize in aktglobalswitches then
t_times:=1
else
{ reference for repetition is 100 }
@ -5284,7 +5327,7 @@ end;
begin
{ max. optimizations }
{ only if no asm is used }
if (cs_maxoptimieren in aktswitches) and
if (cs_maxoptimize in aktglobalswitches) and
((procinfo.flags and pi_uses_asm)=0) then
begin
{ can we omit the stack frame ? }
@ -5404,7 +5447,7 @@ end;
{ dummy }
regsize:=S_W;
end;
if (verbosity and v_debug)=v_debug then
if (status.verbosity and v_debug)=v_debug then
begin
for i:=1 to maxvarregs do
begin
@ -5432,7 +5475,10 @@ end.
{
$Log$
Revision 1.12 1998-07-15 16:41:01 jonas
Revision 1.13 1998-08-10 14:43:14 peter
* string type st_ fixed
Revision 1.12 1998/07/15 16:41:01 jonas
* fixed bug that caused the stackframe never to be omitted
Revision 1.11 1998/07/14 14:46:43 peter

View File

@ -746,7 +746,7 @@ Implementation
{ fpu_reg = right(FP1) / fpu_reg }
{ fpu_reg = right(FP1) - fpu_reg }
begin
if (cs_fp_emulation in aktswitches) then
if (cs_fp_emulation in aktmoduleswitches) then
begin
{ fpu_reg = right / D1 }
{ fpu_reg = right - D1 }
@ -814,7 +814,7 @@ Implementation
{ fpu_reg = fpu_reg / right }
{ fpu_reg = fpu_reg - right }
{ + commutative ops }
if cs_fp_emulation in aktswitches then
if cs_fp_emulation in aktmoduleswitches then
begin
{ load value into D7 }
@ -1478,7 +1478,7 @@ Implementation
too much comparisions. 8 comparisions are, however, still
smalller than emitting the set.}
maxcompares:=5;
if cs_littlesize in aktswitches then
if cs_littlesize in aktglobalswitches then
maxcompares:=8;
for i:=0 to 255 do
if i in byteset(Aset^) then
@ -1960,7 +1960,10 @@ Implementation
end.
{
$Log$
Revision 1.6 1998-07-10 10:51:00 peter
Revision 1.7 1998-08-10 14:43:17 peter
* string type st_ fixed
Revision 1.6 1998/07/10 10:51:00 peter
* m68k updates
Revision 1.5 1998/06/08 13:13:37 pierre

View File

@ -312,7 +312,7 @@ unit cga68k;
begin
exprasmlist^.concat(new(pai68k,op_csymbol(A_JSR,S_NO,newcsymbol(routine,0))));
if add_to_externals and
not (cs_compilesystem in aktswitches) then
not (cs_compilesystem in aktmoduleswitches) then
concat_external(routine,EXT_NEAR);
end;
@ -364,7 +364,7 @@ unit cga68k;
hl : plabel;
begin
if cs_check_overflow in aktswitches then
if cs_check_overflow in aktlocalswitches then
begin
getlabel(hl);
if not ((p^.resulttype^.deftype=pointerdef) or
@ -389,7 +389,7 @@ unit cga68k;
R_D6, R_SPPUSH)));
end
else
if not(cs_littlesize in aktswitches) and (l >= -128) and (l <= 127) then
if not(cs_littlesize in aktglobalswitches) and (l >= -128) and (l <= 127) then
begin
exprasmlist^.concat(new(pai68k,op_const_reg(A_MOVEQ,S_L,l,R_D6)));
exprasmlist^.concat(new(pai68k,op_reg_reg(A_MOVE,S_L,R_D6,R_SPPUSH)));
@ -465,7 +465,7 @@ begin
if (aktprocsym^.definition^.options and poproginit<>0) then
begin
{Init the stack checking.}
if (cs_check_stack in aktswitches) and
if (cs_check_stack in aktlocalswitches) and
(target_info.target=target_linux) then
begin
procinfo.aktentrycode^.insert(new(pai68k,
@ -529,10 +529,10 @@ begin
nostackframe:=false;
if stackframe<>0 then
begin
if cs_littlesize in aktswitches then
if cs_littlesize in aktglobalswitches then
begin
if (cs_check_stack in aktswitches) and
(target_info.target<>target_linux) then
if (cs_check_stack in aktlocalswitches) and
(target_info.target<>target_linux) then
begin
procinfo.aktentrycode^.insert(new(pai68k,
op_csymbol(A_JSR,S_NO,newcsymbol('STACKCHECK',0))));
@ -554,7 +554,7 @@ begin
if (stackframe > -32767) and (stackframe < 32769) then
begin
procinfo.aktentrycode^.insert(new(pai68k,op_const_reg(A_SUB,S_L,stackframe,R_SP)));
if (cs_check_stack in aktswitches) then
if (cs_check_stack in aktlocalswitches) then
begin
procinfo.aktentrycode^.insert(new(pai68k,
op_csymbol(A_JSR,S_NO,newcsymbol('STACKCHECK',0))));
@ -588,7 +588,7 @@ begin
hs:=proc_names.get;
{$IfDef GDB}
if (cs_debuginfo in aktswitches) and target_os.use_function_relative_addresses then
if (cs_debuginfo in aktmoduleswitches) and target_os.use_function_relative_addresses then
stab_function_name := new(pai_stab_function_name,init(strpnew(hs)));
oldaktprocname:=aktprocsym^.name;
{$EndIf GDB}
@ -601,7 +601,7 @@ begin
else
procinfo.aktentrycode^.insert(new(pai_symbol,init(hs)));
{$ifdef GDB}
if (cs_debuginfo in aktswitches) and
if (cs_debuginfo in aktmoduleswitches) and
target_os.use_function_relative_addresses then
begin
procinfo.aktentrycode^.insert(new(pai_stab_function_name,init(strpnew(hs))));
@ -615,7 +615,7 @@ begin
{$ifdef GDB}
aktprocsym^.setname(oldaktprocname);
if (cs_debuginfo in aktswitches) then
if (cs_debuginfo in aktmoduleswitches) then
begin
if target_os.use_function_relative_addresses then
procinfo.aktentrycode^.insert(stab_function_name);
@ -712,14 +712,14 @@ begin
{ how the return value is handled }
{ if in FPU mode, return in FP0 }
if (pfloatdef(procinfo.retdef)^.typ = s32real)
and (cs_fp_emulation in aktswitches) then
and (cs_fp_emulation in aktmoduleswitches) then
begin
procinfo.aktexitcode^.concat(new(pai68k,op_ref_reg(A_MOVE,
S_L,hr,R_D0)))
end
else
begin
if cs_fp_emulation in aktswitches then
if cs_fp_emulation in aktmoduleswitches then
procinfo.aktexitcode^.concat(new(pai68k,op_ref_reg(A_MOVE,
S_L,hr,R_D0)))
else
@ -787,7 +787,7 @@ begin
A_RTS,S_NO)))
end;
{$ifdef GDB}
if cs_debuginfo in aktswitches then
if cs_debuginfo in aktmoduleswitches then
begin
aktprocsym^.concatstabto(procinfo.aktexitcode);
if assigned(procinfo._class) then
@ -831,7 +831,7 @@ end;
del_reference(source);
{ from 12 bytes movs is being used }
if (size<=8) or (not(cs_littlesize in aktswitches) and (size<=12)) then
if (size<=8) or (not(cs_littlesize in aktglobalswitches) and (size<=12)) then
begin
helpsize:=size div 4;
{ move a dword x times }
@ -1086,7 +1086,7 @@ end;
end;
end; { end case }
location.loc := LOC_FPU;
if not ((cs_fp_emulation) in aktswitches) then
if not ((cs_fp_emulation) in aktmoduleswitches) then
begin
location.fpureg := getfloatreg;
exprasmlist^.concat(new(pai68k,op_ref_reg(A_FMOVE,s,newreference(ref),location.fpureg)))
@ -1152,7 +1152,7 @@ end;
Message(cg_f_unknown_float_type);
end;
end; { end case }
if not ((cs_fp_emulation) in aktswitches) then
if not ((cs_fp_emulation) in aktmoduleswitches) then
begin
exprasmlist^.concat(new(pai68k,op_reg_ref(A_FMOVE,s,location.fpureg,newreference(ref))));
ungetregister(location.fpureg);
@ -1220,7 +1220,10 @@ end;
end.
{
$Log$
Revision 1.7 1998-07-10 10:51:01 peter
Revision 1.8 1998-08-10 14:43:16 peter
* string type st_ fixed
Revision 1.7 1998/07/10 10:51:01 peter
* m68k updates
Revision 1.6 1998/06/08 13:13:39 pierre