* powerpc target fixed, very simple units can be compiled

This commit is contained in:
florian 2002-07-07 09:44:31 +00:00
parent 1da4738cf5
commit be574d1cf2
11 changed files with 507 additions and 339 deletions

View File

@ -20,15 +20,15 @@
****************************************************************************
}
unit cpuasm;
unit aasmcpu;
{$i fpcdefs.inc}
interface
uses
cclasses,tainst,
aasm,globals,verbose,
cclasses,aasmtai,
aasmbase,globals,verbose,
cpubase;
type
@ -337,7 +337,10 @@ implementation
end.
{
$Log$
Revision 1.8 2002-05-18 13:34:26 peter
Revision 1.1 2002-07-07 09:44:31 florian
* powerpc target fixed, very simple units can be compiled
Revision 1.8 2002/05/18 13:34:26 peter
* readded missing revisions
Revision 1.7 2002/05/16 19:46:53 carl

View File

@ -1,291 +0,0 @@
{
$Id$
Copyright (c) 1998-2002 by Florian Klaempfl
This unit implements an asm for the PowerPC
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 agas;
interface
uses
cpubase,dos,globals,systems,{errors,}cobjects,aasm,strings,files,
agatt
{$ifdef GDB}
,gdb
{$endif GDB}
;
type
paicpuattasmlist=^taicpuattasmlist;
taicpuattasmlist=object(tattasmlist)
function getreferencestring(var ref : treference) : string; Virtual;
function getopstr_jmp(const o:toper) : string; Virtual;
procedure WriteInstruction (HP : Pai); virtual;
function cond2str(op: tasmop; c: tasmcond): string;
{ to construct the output for conditional branches }
function branchmode(o: tasmop): string[4];
end;
implementation
uses cpuasm;
const
gas_op2str : array[tasmop] of string[14] = ('<none>',
'add','add.','addo','addo.','addc','addc.','addco','addco.',
'adde','adde.','addeo','addeo.','addi','addic','addic.','addis',
'addme','addme.','addmeo','addmeo.','addze','addze.','addzeo',
'addzeo.','and','and.','andc','andc.','andi.','andis.','b',
'ba','bl','bla','bc','bca','bcl','bcla','bcctr','bcctrl','bclr',
'bclrl','cmp','cmpi','cmpl','cmpli','cntlzw','cntlzw.','crand',
'crandc','creqv','crnand','crnor','cror','crorc','crxor','dcba',
'dcbf','dcbi','dcbst','dcbt','divw','divw.','divwo','divwo.',
'divwu','divwu.','divwuo','divwuo.','eciwx','ecowx','eieio','eqv',
'eqv.','extsb','extsb.','extsh','extsh.','fabs','fabs.','fadd',
'fadd.','fadds','fadds.','fcompo','fcmpu','fctiw','fctw.','fctwz',
'fctwz.','fdiv','fdiv.','fdivs','fdivs.','fmadd','fmadd.','fmadds',
'fmadds.','fmr','fmsub','fmsub.','fmsubs','fmsubs.','fmul','fmul.',
'fmuls','fmuls.','fnabs','fnabs.','fneg','fneg.','fnmadd',
'fnmadd.','fnmadds','fnmadds.','fnmsub','fnmsub.','fnmsubs',
'fnmsubs.','fres','fres.','frsp','frsp.','frsqrte','frsqrte.',
'fsel','fsel.','fsqrt','fsqrt.','fsqrts','fsqrts.','fsub','fsub.',
'fsubs','fsubs.','icbi','isync','lbz','lbzu','lbzux','lbzx',
'lfd','lfdu','lfdux','lfdx','lfs','lfsu','lfsux','lfsx','lha',
'lhau','lhaux','lhax','hbrx','lhz','lhzu','lhzux','lhzx','lmw',
'lswi','lswx','lwarx','lwbrx','lwz','lwzu','lwzux','lwzx','mcrf',
'mcrfs','mcrxr','lcrxe','mfcr','mffs','maffs.','mfmsr','mfspr','mfsr',
'mfsrin','mftb','mtfcrf','mtfd0','mtfsb1','mtfsf','mtfsf.',
'mtfsfi','mtfsfi.','mtmsr','mtspr','mtsr','mtsrin','mulhw',
'mulhw.','mulhwu','mulhwu.','mulli','mullh','mullw.','mullwo',
'mullwo.','nand','nand.','neg','neg.','nego','nego.','nor','nor.',
'or','or.','orc','orc.','ori','oris', 'rfi', 'rlwimi', 'rlwimi.',
'rlwinm', 'tlwinm.','rlwnm','sc','slw', 'slw.', 'sraw', 'sraw.',
'srawi', 'srawi.','srw', 'srw.', 'stb', 'stbu', 'stbux','stbx','stfd',
'stfdu', 'stfdux', 'stfdx', 'stfiwx', 'stfs', 'stfsu', 'stfsux', 'stfsx',
'sth', 'sthbrx', 'sthu', 'sthux', 'sthx', 'stmw', 'stswi', 'stswx', 'stw',
'stwbrx', 'stwx.', 'stwu', 'stwux', 'stwx', 'subf', 'subf.', 'subfo',
'subfo.', 'subfc', 'subc.', 'subfco', 'subfco.', 'subfe', 'subfe.',
'subfeo', 'subfeo.', 'subfic', 'subfme', 'subfme.', 'subfmeo', 'subfmeo.',
'subfze', 'subfze.', 'subfzeo', 'subfzeo.', 'sync', 'tlbia', 'tlbie',
'tlbsync', 'tw', 'twi', 'xor', 'xor.', 'xori', 'xoris',
{ some simplified mnemonics }
'subi', 'subis', 'subic', 'subic.', 'sub', 'sub.', 'subo', 'subo.',
'subc', 'subc.', 'subco', '.subco.', 'cmpwi', 'cmpw', 'cmplwi', 'cmplw',
'extlwi', 'extlwi.', 'extrwi', 'extrwi.', 'inslwi', 'inslwi.', 'insrwi',
'insrwi.', 'rotlwi', 'rotlwi.', 'rotlw', 'rotlw.', 'slwi', 'slwi.',
'srwi', 'srwi.', 'clrlwi', 'clrlwi.', 'clrrwi', 'clrrwi.', 'clrslwi',
'clrslwi.', 'blr', 'bctr', 'blrl', 'bctrl', 'crset', 'crclr', 'crmove',
'crnot', 'mt', 'mf','nop', 'li', 'lis', 'la', 'mr','not', 'mtcr');
function taicpuattasmlist.getreferencestring(var ref : treference) : string;
var
s : string;
begin
if ref.is_immediate then
begin
{$ifndef testing}
internalerror(1000101);
exit;
{$else testing}
writeln('internalerror 1000101');
halt(1);
{$endif testing}
end
else
begin
with ref do
begin
inc(offset,offsetfixup);
if (offset < -32768) or (offset > 32767) then
{$ifndef testing}
internalerror(19991);
{$else testing}
begin
writeln('internalerror 19991');
halt(1);
end;
{$endif testing}
s:='';
if assigned(symbol) then
s:=s+symbol^.name + symaddr2str[symaddr];
if offset<0 then
s:=s+tostr(offset)
else
if (offset>0) then
begin
if assigned(symbol) then
s:=s+'+'+tostr(offset)
else
s:=s+tostr(offset);
end;
if (index=R_NO) and (base<>R_NO) then
s:=s+'('+att_reg2str[base]+')'
else if (index<>R_NO) and (base<>R_NO) and (offset = 0) then
s:=s+att_reg2str[base]+','+att_reg2str[index]
else if ((index<>R_NO) or (base<>R_NO)) then
{$ifndef testing}
internalerror(19992);
{$else testing}
begin
writeln('internalerror 19992');
halt(1);
end;
{$endif testing}
end;
end;
getreferencestring:=s;
end;
function taicpuattasmlist.getopstr_jmp(const o:toper) : string;
var
hs : string;
begin
case o.typ of
top_reg :
getopstr_jmp:=att_reg2str[o.reg];
{ no top_ref jumping for powerpc }
top_const :
getopstr_jmp:=tostr(o.val);
top_symbol :
begin
hs:=o.sym^.name;
if o.symofs>0 then
hs:=hs+'+'+tostr(o.symofs)
else
if o.symofs<0 then
hs:=hs+tostr(o.symofs);
getopstr_jmp:=hs;
end;
else
{$ifndef testing}
internalerror(10001);
{$else testing}
begin
writeln('internalerror 10001');
halt(1);
end;
{$endif testing}
end;
end;
Procedure taicpuattasmlist.WriteInstruction (HP : Pai);
var op: TAsmOp;
s: string;
i: byte;
sep: string[3];
begin
op:=paicpu(hp)^.opcode;
if is_calljmp(op) then
{ direct BO/BI in op[0] and op[1] not supported, put them in condition! }
s:=s+cond2str(op,paicpu(hp)^.condition)+
getopstr_jmp(paicpu(hp)^.oper[0])
else
{ process operands }
begin
s:=#9+gas_op2str[op];
if paicpu(hp)^.ops<>0 then
begin
if not is_calljmp(op) then
sep := ','
else sep := '#9';
for i:=0 to paicpu(hp)^.ops-1 do
begin
s:=s+sep+getopstr(paicpu(hp)^.oper[i])
sep:=',';
end;
end;
end;
AsmWriteLn(s);
end;
function taicpuattasmlist.cond2str(op: tasmop; c: tasmcond): string;
{ note: no checking is performed whether the given combination of }
{ conditions is valid }
var tempstr: sintrg;
begin
tempstr := '#9';
case c.simple of
false: cond2str := tempstr+gas_op2str[op]+'#9'+tostr(c.bo)+','+
tostr(c.bi);
true:
if (op >= A_B) and (op <= A_BCLRL) then
case c.cond of
{ unconditional branch }
CF_NONE: condstr := tempstr+op2str(op);
{ bdnzt etc }
else
begin
tempstr := tempstr+'b'+asmcondflag2str[c.cond]+
branchmode(op)+'#9';
case op of
CF_LT..CF_NU:
cond2str := tempstr+att_reg2str[c.cr];
CF_T..CF_DZF:
cond2str := tempstr+tostr(c.crbit);
end;
end;
end
{ we have a trap instruction }
{ not yet implementer !!!!!!!!!!!!!!!!!!!!! }
{ else
begin
case tempstr := 'tw';}
end;
end;
function taicpuattasmlist.branchmode(o: tasmop): string[4];
var tempstr: string[4];
begin
tempstr := '';
case o of
A_BCCTR,A_BCCTRL: tempstr := 'ctr'
A_BCLR,A_BCLRL: tempstr := 'lr'
case o of
A_BL,A_BLA,A_BCL,A_BCLA,A_BCCTRL,A_BCLRL: tempstr := tempstr+'l';
end;
case o of
A_BA,A_BLA,A_BCA,A_BCLA: tempstr:=tempstr+'a';
end;
branchmode := tempstr;
end;
end.
{
$Log$
Revision 1.6 2002-05-18 13:34:26 peter
* readded missing revisions
Revision 1.5 2002/05/16 19:46:52 carl
+ defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
+ try to fix temp allocation (still in ifdef)
+ generic constructor calls
+ start of tassembler / tmodulebase class cleanup
Revision 1.3 2002/04/20 21:41:51 carl
* renamed some constants
Revision 1.2 2002/04/06 18:13:01 jonas
* several powerpc-related additions and fixes
}

View File

@ -0,0 +1,350 @@
{
$Id$
Copyright (c) 1998-2002 by Florian Klaempfl
This unit implements an asm for the PowerPC
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 implements the GNU Assembler writer for the PowerPC
}
unit agppcgas;
interface
uses
aasmtai,
aggas;
type
PPPCGNUAssembler=^TPPCGNUAssembler;
TPPCGNUAssembler=class(TGNUassembler)
procedure WriteInstruction(hp : tai);override;
end;
implementation
uses
cutils,globals,verbose,
systems,
assemble,
aasmcpu,cpubase;
const
as_ppc_gas_info : tasminfo =
(
id : as_powerpc_as;
idtxt : 'AS';
asmbin : 'as';
asmcmd : '-o $OBJ $ASM';
supported_target : target_any;
outputbinary: false;
allowdirect : true;
externals : false;
needar : true;
labelprefix_only_inside_procedure : false;
labelprefix : '.L';
comment : '# ';
secnames : ('',
'.text','.data','.text',
'','','','','','',
'.stab','.stabstr','COMMON')
);
op2str : array[tasmop] of string[14] = ('<none>',
'add','add.','addo','addo.','addc','addc.','addco','addco.',
'adde','adde.','addeo','addeo.','addi','addic','addic.','addis',
'addme','addme.','addmeo','addmeo.','addze','addze.','addzeo',
'addzeo.','and','and.','andc','andc.','andi.','andis.','b',
'ba','bl','bla','bc','bca','bcl','bcla','bcctr','bcctrl','bclr',
'bclrl','cmp','cmpi','cmpl','cmpli','cntlzw','cntlzw.','crand',
'crandc','creqv','crnand','crnor','cror','crorc','crxor','dcba',
'dcbf','dcbi','dcbst','dcbt','divw','divw.','divwo','divwo.',
'divwu','divwu.','divwuo','divwuo.','eciwx','ecowx','eieio','eqv',
'eqv.','extsb','extsb.','extsh','extsh.','fabs','fabs.','fadd',
'fadd.','fadds','fadds.','fcompo','fcmpu','fctiw','fctw.','fctwz',
'fctwz.','fdiv','fdiv.','fdivs','fdivs.','fmadd','fmadd.','fmadds',
'fmadds.','fmr','fmsub','fmsub.','fmsubs','fmsubs.','fmul','fmul.',
'fmuls','fmuls.','fnabs','fnabs.','fneg','fneg.','fnmadd',
'fnmadd.','fnmadds','fnmadds.','fnmsub','fnmsub.','fnmsubs',
'fnmsubs.','fres','fres.','frsp','frsp.','frsqrte','frsqrte.',
'fsel','fsel.','fsqrt','fsqrt.','fsqrts','fsqrts.','fsub','fsub.',
'fsubs','fsubs.','icbi','isync','lbz','lbzu','lbzux','lbzx',
'lfd','lfdu','lfdux','lfdx','lfs','lfsu','lfsux','lfsx','lha',
'lhau','lhaux','lhax','hbrx','lhz','lhzu','lhzux','lhzx','lmw',
'lswi','lswx','lwarx','lwbrx','lwz','lwzu','lwzux','lwzx','mcrf',
'mcrfs','mcrxr','lcrxe','mfcr','mffs','maffs.','mfmsr','mfspr','mfsr',
'mfsrin','mftb','mtfcrf','mtfd0','mtfsb1','mtfsf','mtfsf.',
'mtfsfi','mtfsfi.','mtmsr','mtspr','mtsr','mtsrin','mulhw',
'mulhw.','mulhwu','mulhwu.','mulli','mullh','mullw.','mullwo',
'mullwo.','nand','nand.','neg','neg.','nego','nego.','nor','nor.',
'or','or.','orc','orc.','ori','oris', 'rfi', 'rlwimi', 'rlwimi.',
'rlwinm', 'tlwinm.','rlwnm','sc','slw', 'slw.', 'sraw', 'sraw.',
'srawi', 'srawi.','srw', 'srw.', 'stb', 'stbu', 'stbux','stbx','stfd',
'stfdu', 'stfdux', 'stfdx', 'stfiwx', 'stfs', 'stfsu', 'stfsux', 'stfsx',
'sth', 'sthbrx', 'sthu', 'sthux', 'sthx', 'stmw', 'stswi', 'stswx', 'stw',
'stwbrx', 'stwx.', 'stwu', 'stwux', 'stwx', 'subf', 'subf.', 'subfo',
'subfo.', 'subfc', 'subc.', 'subfco', 'subfco.', 'subfe', 'subfe.',
'subfeo', 'subfeo.', 'subfic', 'subfme', 'subfme.', 'subfmeo', 'subfmeo.',
'subfze', 'subfze.', 'subfzeo', 'subfzeo.', 'sync', 'tlbia', 'tlbie',
'tlbsync', 'tw', 'twi', 'xor', 'xor.', 'xori', 'xoris',
{ some simplified mnemonics }
'subi', 'subis', 'subic', 'subic.', 'sub', 'sub.', 'subo', 'subo.',
'subc', 'subc.', 'subco', '.subco.', 'cmpwi', 'cmpw', 'cmplwi', 'cmplw',
'extlwi', 'extlwi.', 'extrwi', 'extrwi.', 'inslwi', 'inslwi.', 'insrwi',
'insrwi.', 'rotlwi', 'rotlwi.', 'rotlw', 'rotlw.', 'slwi', 'slwi.',
'srwi', 'srwi.', 'clrlwi', 'clrlwi.', 'clrrwi', 'clrrwi.', 'clrslwi',
'clrslwi.', 'blr', 'bctr', 'blrl', 'bctrl', 'crset', 'crclr', 'crmove',
'crnot', 'mt', 'mf','nop', 'li', 'lis', 'la', 'mr','mr.','not', 'mtcr');
reg2str : reg2strtable = ('',
'0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16',
'17','18','19','20','21','22','23','24','25','26','27','28','29','30','31',
'F0','F1','F2','F3','F4','F5','F6','F7', 'F8','F9','F10','F11','F12',
'F13','F14','F15','F16','F17', 'F18','F19','F20','F21','F22', 'F23','F24',
'F25','F26','F27','F28','F29','F30','F31',
'M0','M1','M2','M3','M4','M5','M6','M7','M8','M9','M10','M11','M12',
'M13','M14','M15','M16','M17','M18','M19','M20','M21','M22', 'M23','M24',
'M25','M26','M27','M28','M29','M30','M31',
'CR','CR0','CR1','CR2','CR3','CR4','CR5','CR6','CR7',
'XER','LR','CTR','FPSCR'
);
function getreferencestring(var ref : treference) : string;
var
s : string;
begin
with ref do
begin
inc(offset,offsetfixup);
if (offset < -32768) or (offset > 32767) then
{$ifndef testing}
internalerror(19991);
{$else testing}
begin
writeln('internalerror 19991');
halt(1);
end;
{$endif testing}
s:='';
if assigned(symbol) then
s:=s+symbol.name + symaddr2str[symaddr];
if offset<0 then
s:=s+tostr(offset)
else
if (offset>0) then
begin
if assigned(symbol) then
s:=s+'+'+tostr(offset)
else
s:=s+tostr(offset);
end;
if (index=R_NO) and (base<>R_NO) then
s:=s+'('+reg2str[base]+')'
else if (index<>R_NO) and (base<>R_NO) and (offset = 0) then
s:=s+reg2str[base]+','+reg2str[index]
else if ((index<>R_NO) or (base<>R_NO)) then
{$ifndef testing}
internalerror(19992);
{$else testing}
begin
writeln('internalerror 19992');
halt(1);
end;
{$endif testing}
end;
getreferencestring:=s;
end;
function getopstr_jmp(const o:toper) : string;
var
hs : string;
begin
case o.typ of
top_reg :
getopstr_jmp:=reg2str[o.reg];
{ no top_ref jumping for powerpc }
top_const :
getopstr_jmp:=tostr(o.val);
top_symbol :
begin
hs:=o.sym.name;
if o.symofs>0 then
hs:=hs+'+'+tostr(o.symofs)
else
if o.symofs<0 then
hs:=hs+tostr(o.symofs);
getopstr_jmp:=hs;
end;
else
{$ifndef testing}
internalerror(2002070603);
{$else testing}
begin
writeln('internalerror 10001');
halt(1);
end;
{$endif testing}
end;
end;
function getopstr(const o:toper) : string;
var
hs : string;
begin
case o.typ of
top_reg:
getopstr:=reg2str[o.reg];
{ no top_ref jumping for powerpc }
top_const:
getopstr:=tostr(o.val);
top_ref:
getopstr:=getreferencestring(o.ref^);
top_symbol:
begin
hs:=o.sym.name;
if o.symofs>0 then
hs:=hs+'+'+tostr(o.symofs)
else
if o.symofs<0 then
hs:=hs+tostr(o.symofs);
getopstr:=hs;
end;
else
{$ifndef testing}
internalerror(2002070604);
{$else testing}
begin
writeln('internalerror 10001');
halt(1);
end;
{$endif testing}
end;
end;
function branchmode(o: tasmop): string[4];
var tempstr: string[4];
begin
tempstr := '';
case o of
A_BCCTR,A_BCCTRL: tempstr := 'ctr';
A_BCLR,A_BCLRL: tempstr := 'lr';
end;
case o of
A_BL,A_BLA,A_BCL,A_BCLA,A_BCCTRL,A_BCLRL: tempstr := tempstr+'l';
end;
case o of
A_BA,A_BLA,A_BCA,A_BCLA: tempstr:=tempstr+'a';
end;
branchmode := tempstr;
end;
function cond2str(op: tasmop; c: tasmcond): string;
{ note: no checking is performed whether the given combination of }
{ conditions is valid }
var tempstr: string;
begin
tempstr:=#9;
case c.simple of
false: cond2str := tempstr+op2str[op]+#9+tostr(c.bo)+','+
tostr(c.bi);
true:
if (op >= A_B) and (op <= A_BCLRL) then
case c.cond of
{ unconditional branch }
C_NONE:
cond2str := tempstr+op2str[op];
{ bdnzt etc }
else
begin
tempstr := tempstr+'b'+asmcondflag2str[c.cond]+
branchmode(op)+#9;
case c.cond of
C_LT..C_NU:
cond2str := tempstr+reg2str[c.cr];
C_T..C_DZF:
cond2str := tempstr+tostr(c.crbit);
end;
end;
end
{ we have a trap instruction }
else
begin
internalerror(2002070601);
{ not yet implementer !!!!!!!!!!!!!!!!!!!!! }
{ case tempstr := 'tw';}
end;
end;
end;
Procedure TPPCGNUAssembler.WriteInstruction(hp : tai);
var op: TAsmOp;
s: string;
i: byte;
sep: string[3];
begin
op:=taicpu(hp).opcode;
if is_calljmp(op) then
{ direct BO/BI in op[0] and op[1] not supported, put them in condition! }
s:=cond2str(op,taicpu(hp).condition)+
getopstr_jmp(taicpu(hp).oper[0])
else
{ process operands }
begin
s:=#9+op2str[op];
if taicpu(hp).ops<>0 then
begin
{
if not is_calljmp(op) then
sep:=','
else
}
sep:=#9;
for i:=0 to taicpu(hp).ops-1 do
begin
s:=s+sep+getopstr(taicpu(hp).oper[i]);
sep:=',';
end;
end;
end;
AsmWriteLn(s);
end;
begin
RegisterAssembler(as_ppc_gas_info,TPPCGNUAssembler);
end.
{
$Log$
Revision 1.1 2002-07-07 09:44:31 florian
* powerpc target fixed, very simple units can be compiled
Revision 1.6 2002/05/18 13:34:26 peter
* readded missing revisions
Revision 1.5 2002/05/16 19:46:52 carl
+ defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
+ try to fix temp allocation (still in ifdef)
+ generic constructor calls
+ start of tassembler / tmodulebase class cleanup
Revision 1.3 2002/04/20 21:41:51 carl
* renamed some constants
Revision 1.2 2002/04/06 18:13:01 jonas
* several powerpc-related additions and fixes
}

View File

@ -41,7 +41,7 @@ Unit aoptcpub; { Assembler OPTimizer CPU specific Base }
Interface
Uses
CPUAsm,AOptBase;
aasmcpu,AOptBase;
Type
@ -117,7 +117,10 @@ End.
{
$Log$
Revision 1.4 2002-05-18 13:34:26 peter
Revision 1.5 2002-07-07 09:44:31 florian
* powerpc target fixed, very simple units can be compiled
Revision 1.4 2002/05/18 13:34:26 peter
* readded missing revisions
Revision 1.3 2002/05/16 19:46:52 carl

View File

@ -28,15 +28,19 @@ unit cga;
interface
uses
cpubase,cpuasm,
symconst,symtype,symdef,aasm;
aasmbase,aasmcpu,
cpubase,
symconst,symtype,symdef;
implementation
end.
{
$Log$
Revision 1.4 2002-05-18 13:34:26 peter
Revision 1.5 2002-07-07 09:44:31 florian
* powerpc target fixed, very simple units can be compiled
Revision 1.4 2002/05/18 13:34:26 peter
* readded missing revisions
Revision 1.3 2002/05/16 19:46:53 carl

View File

@ -27,19 +27,21 @@ unit cgcpu;
interface
uses
cgbase,cgobj,aasm,cpuasm,cpubase,cpuinfo,node,cg64f32,cginfo;
cgbase,cgobj,
aasmbase,aasmcpu,aasmtai,
cpubase,cpuinfo,node,cg64f32,cginfo;
type
tcgppc = class(tcg64f32)
tcgppc = class(tcg)
{ passing parameters, per default the parameter is pushed }
{ nr gives the number of the parameter (enumerated from }
{ left to right), this allows to move the parameter to }
{ register, if the cpu supports register calling }
{ conventions }
procedure a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;nr : longint);override;
procedure a_param_const(list : taasmoutput;size : tcgsize;a : aword;nr : longint);override;
procedure a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;nr : longint);override;
procedure a_paramaddr_ref(list : taasmoutput;const r : treference;nr : longint);override;
procedure a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;const locpara : tparalocation);override;
procedure a_param_const(list : taasmoutput;size : tcgsize;a : aword;const locpara : tparalocation);override;
procedure a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);override;
procedure a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);override;
procedure a_call_name(list : taasmoutput;const s : string);override;
@ -137,7 +139,7 @@ const
{ parameter passing... Still needs extra support from the processor }
{ independent code generator }
procedure tcgppc.a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;nr : longint);
procedure tcgppc.a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;const locpara : tparalocation);
var
ref: treference;
@ -157,7 +159,7 @@ const
end;
procedure tcgppc.a_param_const(list : taasmoutput;size : tcgsize;a : aword;nr : longint);
procedure tcgppc.a_param_const(list : taasmoutput;size : tcgsize;a : aword;const locpara : tparalocation);
var
ref: treference;
@ -177,7 +179,7 @@ const
end;
procedure tcgppc.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;nr : longint);
procedure tcgppc.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);
var
ref: treference;
@ -201,7 +203,7 @@ const
end;
procedure tcgppc.a_paramaddr_ref(list : taasmoutput;const r : treference;nr : longint);
procedure tcgppc.a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);
var
ref: treference;
@ -279,7 +281,7 @@ const
{ 64 bit stuff should be handled separately }
if size in [OS_64,OS_S64] then
internalerror(200109236);
op := storeinstr[size,ref2.index<>R_NO,false];
op := storeinstr[tcgsize2unsigned[size],ref2.index<>R_NO,false];
a_load_store(list,op,reg,ref2);
End;
@ -1173,7 +1175,10 @@ begin
end.
{
$Log$
Revision 1.19 2002-05-20 13:30:41 carl
Revision 1.20 2002-07-07 09:44:31 florian
* powerpc target fixed, very simple units can be compiled
Revision 1.19 2002/05/20 13:30:41 carl
* bugfix of hdisponen (base must be set, not index)
* more portability fixes

View File

@ -20,6 +20,8 @@
****************************************************************************
}
{ This Unit contains the base types for the PowerPC
}
unit cpubase;
{$i fpcdefs.inc}
@ -27,7 +29,7 @@ unit cpubase;
interface
uses
strings,cutils,cclasses,aasm,cpuinfo,cginfo;
strings,cutils,cclasses,aasmbase,cpuinfo,cginfo;
{*****************************************************************************
@ -113,6 +115,14 @@ uses
{# Set type definition for registers }
tregisterset = set of tregister;
{ A type to store register locations for 64 Bit values. }
tregister64 = packed record
reglo,reghi : tregister;
end;
{ alias for compact code }
treg64 = tregister64;
{# Type definition for the array of string of register nnames }
reg2strtable = array[tregister] of string[5];
@ -143,19 +153,6 @@ uses
VX = 6;
OX = 7;}
att_reg2str : reg2strtable = ('',
'0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16',
'17','18','19','20','21','22','23','24','25','26','27','28','29','30','31',
'F0','F1','F2','F3','F4','F5','F6','F7', 'F8','F9','F10','F11','F12',
'F13','F14','F15','F16','F17', 'F18','F19','F20','F21','F22', 'F23','F24',
'F25','F26','F27','F28','F29','F30','F31',
'M0','M1','M2','M3','M4','M5','M6','M7','M8','M9','M10','M11','M12',
'M13','M14','M15','M16','M17','M18','M19','M20','M21','M22', 'M23','M24',
'M25','M26','M27','M28','M29','M30','M31',
'CR','CR0','CR1','CR2','CR3','CR4','CR5','CR6','CR7',
'XER','LR','CTR','FPSCR'
);
mot_reg2str : reg2strtable = ('',
'r0','r1','r2','r3','r4','r5','r6','r7','r8','r9','r10','r11','r12','r13',
'r14','r15','r16','r17','r18','r19','r20','r21','r22','r23','r24','r25',
@ -282,6 +279,13 @@ uses
alignment : byte;
end;
{ reference record }
pparareference = ^tparareference;
tparareference = packed record
index : tregister;
offset : longint;
end;
const
symaddr2str: array[trefsymaddr] of string[3] = ('','@ha','@l');
@ -327,25 +331,50 @@ uses
LOC_FLAGS { boolean results only, flags are set }
);
{ tparamlocation describes where a parameter for a procedure is stored.
References are given from the caller's point of view. The usual
TLocation isn't used, because contains a lot of unnessary fields.
}
tparalocation = packed record
loc : TLoc;
sp_fixup : longint;
case TLoc of
LOC_REFERENCE : (reference : tparareference);
{ segment in reference at the same place as in loc_register }
LOC_FPUREGISTER, LOC_CFPUREGISTER, LOC_MMREGISTER, LOC_CMMREGISTER,
LOC_REGISTER,LOC_CREGISTER : (
case longint of
1 : (register,registerhigh : tregister);
{ overlay a registerlow }
2 : (registerlow : tregister);
{ overlay a 64 Bit register type }
3 : (reg64 : tregister64);
4 : (register64 : tregister64);
);
end;
tlocation = packed record
size : TCGSize;
case loc : tloc of
loc : tloc;
case tloc of
LOC_CREFERENCE,LOC_REFERENCE : (reference : treference);
LOC_CONSTANT : (
case longint of
1 : (value : AWord);
2 : (valuelow, valuehigh:AWord);
{ overlay a complete 64 Bit value }
3 : (valueqword : qword);
);
LOC_FPUREGISTER, LOC_CFPUREGISTER, LOC_MMREGISTER, LOC_CMMREGISTER,
LOC_REGISTER,LOC_CREGISTER : (
case longint of
1 : (registerlow,registerhigh : tregister);
2 : (register : tregister);
{ overlay a 64 Bit register type }
3 : (reg64 : tregister64);
4 : (register64 : tregister64);
);
LOC_JUMP : ();
LOC_FLAGS : (resflags : tresflags);
LOC_INVALID : ();
end;
{*****************************************************************************
@ -588,7 +617,10 @@ implementation
end.
{
$Log$
Revision 1.14 2002-05-18 13:34:26 peter
Revision 1.15 2002-07-07 09:44:31 florian
* powerpc target fixed, very simple units can be compiled
Revision 1.14 2002/05/18 13:34:26 peter
* readded missing revisions
Revision 1.12 2002/05/14 19:35:01 peter

View File

@ -0,0 +1,49 @@
{
$Id$
Copyright (c) 2002 by Florian Klaempfl
PowerPC specific calling conventions
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.
****************************************************************************
}
{ PowerPC specific calling conventions are handled by this unit
}
unit cpupara;
interface
uses
cpubase;
var
paralocdummy : tparalocation;
function getintparaloc(nr : longint) : tparalocation;
implementation
function getintparaloc(nr : longint) : tparalocation;
begin
end;
end.
{
$Log$
Revision 1.1 2002-07-07 09:44:32 florian
* powerpc target fixed, very simple units can be compiled
}

View File

@ -44,12 +44,18 @@ implementation
Assemblers
**************************************}
{$ifndef NOAGPPCGAS}
,agppcgas
{$endif}
;
end.
{
$Log$
Revision 1.3 2002-05-18 13:34:26 peter
Revision 1.4 2002-07-07 09:44:32 florian
* powerpc target fixed, very simple units can be compiled
Revision 1.3 2002/05/18 13:34:26 peter
* readded missing revisions
Revision 1.2 2002/05/16 19:46:53 carl
@ -60,5 +66,4 @@ end.
Revision 1.1 2002/05/13 19:52:46 peter
* a ppcppc can be build again
}

View File

@ -51,10 +51,12 @@ implementation
uses
globtype,systems,
cutils,verbose,globals,
symconst,symdef,aasm,types,
symconst,symdef,
aasmbase,aasmcpu,aasmtai,
types,
cgbase,cgobj,pass_1,pass_2,
ncon,
cpubase,cpuinfo,cpuasm,cginfo,
cpubase,cpuinfo,cginfo,
ncgutil,cga,cgcpu,cg64f32,rgobj;
{*****************************************************************************
@ -205,7 +207,7 @@ implementation
hregisterlow := rg.getregisterint(exprasmlist);
location.registerlow := hregisterlow;
tcg64f32(cg).a_load64_ref_reg(exprasmlist,
left.location.reference,hregisterlow,hregisterhigh);
left.location.reference,joinreg64(hregisterlow,hregisterhigh));
end;
end;
if (right.nodetype = ordconstn) then
@ -547,7 +549,10 @@ begin
end.
{
$Log$
Revision 1.10 2002-05-20 13:30:42 carl
Revision 1.11 2002-07-07 09:44:32 florian
* powerpc target fixed, very simple units can be compiled
Revision 1.10 2002/05/20 13:30:42 carl
* bugfix of hdisponen (base must be set, not index)
* more portability fixes

View File

@ -29,7 +29,7 @@ unit rgcpu;
interface
uses
aasm,
aasmbase,aasmtai,
cpubase,
rgobj;
@ -71,7 +71,10 @@ end.
{
$Log$
Revision 1.2 2002-05-16 19:46:53 carl
Revision 1.3 2002-07-07 09:44:32 florian
* powerpc target fixed, very simple units can be compiled
Revision 1.2 2002/05/16 19:46:53 carl
+ defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
+ try to fix temp allocation (still in ifdef)
+ generic constructor calls