mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-25 16:38:18 +02:00

longer aligns the temp offset in case it's odd (not required for jvm) * ignore the "def" argument in alloctemp() for the jvm since all stack slots can be reused for anything there, and reformatted its alloctemp() git-svn-id: branches/jvmbackend@18297 -
79 lines
2.2 KiB
ObjectPascal
79 lines
2.2 KiB
ObjectPascal
{
|
|
Copyright (C) 2010 by Jonas Maebe
|
|
|
|
This unit handles the temporary variables for the JVM
|
|
|
|
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.
|
|
|
|
****************************************************************************
|
|
}
|
|
{
|
|
This unit handles the temporary variables for the JVM.
|
|
}
|
|
unit tgcpu;
|
|
|
|
{$i fpcdefs.inc}
|
|
|
|
interface
|
|
|
|
uses
|
|
globtype,
|
|
aasmdata,
|
|
symtype,tgobj;
|
|
|
|
type
|
|
|
|
{ ttgjvm }
|
|
|
|
ttgjvm = class(ttgobj)
|
|
protected
|
|
function alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint; override;
|
|
public
|
|
procedure setfirsttemp(l : longint); override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
verbose;
|
|
|
|
|
|
{ ttgjvm }
|
|
|
|
function ttgjvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint;
|
|
begin
|
|
{ the JVM only supports 1 slot (= 4 bytes in FPC) and 2 slot (= 8 bytes in
|
|
FPC) temps on the stack. double and int64 are 2 slots, the rest is one slot.
|
|
There are no problems with reusing the same slot for a value of a different
|
|
type. There are no alignment requirements either. }
|
|
if size<4 then
|
|
size:=4;
|
|
if not(size in [4,8]) then
|
|
internalerror(2010121401);
|
|
{ don't pass on "def", since we don't care if a slot is used again for a
|
|
different type }
|
|
result:=inherited alloctemp(list, size shr 2, 1, temptype, nil);
|
|
end;
|
|
|
|
procedure ttgjvm.setfirsttemp(l: longint);
|
|
begin
|
|
firsttemp:=l;
|
|
lasttemp:=l;
|
|
end;
|
|
|
|
begin
|
|
tgobjclass:=ttgjvm;
|
|
end.
|