fpc/compiler/i8086/n8086cnv.pas
nickysn a55b728d34 * optimizations for ofs() on i8086 to load only the offset (in a temporary
register), without the segment

git-svn-id: trunk@32211 -
2015-10-30 21:27:35 +00:00

90 lines
2.7 KiB
ObjectPascal

{
Copyright (c) 1998-2002 by Florian Klaempfl
Generate code for i8086 assembler for type converting nodes
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************
}
unit n8086cnv;
{$i fpcdefs.inc}
interface
uses
node,ncgcnv,nx86cnv,defutil,defcmp;
type
{ t8086typeconvnode }
t8086typeconvnode = class(tx86typeconvnode)
protected
function typecheck_int_to_int: tnode;override;
function typecheck_proc_to_procvar: tnode;override;
procedure second_proc_to_procvar;override;
end;
implementation
uses
verbose,systems,globals,globtype,
aasmbase,aasmtai,aasmdata,aasmcpu,
symconst,symdef,symcpu,
cgbase,cga,procinfo,pass_1,pass_2,
ncon,ncal,ncnv,nmem,n8086mem,
cpubase,cpuinfo,
cgutils,cgobj,hlcgobj,cgx86,ncgutil,
tgobj;
function t8086typeconvnode.typecheck_int_to_int: tnode;
begin
Result:=inherited typecheck_int_to_int;
if (is_16bitint(totypedef) or is_8bitint(totypedef)) and (left.nodetype=addrn) then
begin
if left.nodetype=addrn then
ti8086addrnode(left).get_offset_only:=true;
end;
end;
function t8086typeconvnode.typecheck_proc_to_procvar: tnode;
begin
if (current_settings.x86memorymodel in x86_far_code_models) and
not is_proc_far(tabstractprocdef(left.resultdef)) then
CGMessage1(type_e_procedure_must_be_far,left.resultdef.GetTypeName);
Result:=inherited typecheck_proc_to_procvar;
end;
procedure t8086typeconvnode.second_proc_to_procvar;
begin
if is_proc_far(tabstractprocdef(resultdef))<>
(current_settings.x86memorymodel in x86_far_code_models) then
internalerror(2014041302);
if is_proc_far(tabstractprocdef(left.resultdef))<>
(current_settings.x86memorymodel in x86_far_code_models) then
internalerror(2014041303);
inherited;
end;
begin
ctypeconvnode:=t8086typeconvnode
end.