* made setfirsttemp() virtual and override it in jvm/tgcpu so it no

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 -
This commit is contained in:
Jonas Maebe 2011-08-20 07:36:14 +00:00
parent dc8df7fe79
commit c84ec623dd
2 changed files with 33 additions and 17 deletions

View File

@ -29,7 +29,9 @@ unit tgcpu;
interface
uses
tgobj;
globtype,
aasmdata,
symtype,tgobj;
type
@ -38,25 +40,39 @@ unit tgcpu;
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
implementation
{ ttgjvm }
uses
verbose;
function ttgjvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint;
begin
{ the JVM only support s1 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 vakue 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);
Result:=inherited alloctemp(list, size div 4, 1, temptype, def);
end;
{ 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
tgclass:=ttgjvm;
tgobjclass:=ttgjvm;
end.

View File

@ -78,7 +78,7 @@ unit tgobj;
@param(l start offset where temps will start in stack)
}
procedure setfirsttemp(l : longint);
procedure setfirsttemp(l : longint); virtual;
procedure gettemp(list: TAsmList; size, alignment : longint;temptype:ttemptype;out ref : treference);
procedure gettemptyped(list: TAsmList; def:tdef;temptype:ttemptype;out ref : treference);