|
@@ -33,7 +33,7 @@ unit cgcpu;
|
|
cgbase,cgobj,
|
|
cgbase,cgobj,
|
|
aasmbase,aasmcpu,aasmtai,
|
|
aasmbase,aasmcpu,aasmtai,
|
|
cpubase,cpuinfo,node,cg64f32,cginfo;
|
|
cpubase,cpuinfo,node,cg64f32,cginfo;
|
|
- ;
|
|
|
|
|
|
+
|
|
|
|
|
|
type
|
|
type
|
|
tcgarm = class(tcg)
|
|
tcgarm = class(tcg)
|
|
@@ -124,7 +124,7 @@ unit cgcpu;
|
|
{ creates the correct branch instruction for a given combination }
|
|
{ creates the correct branch instruction for a given combination }
|
|
{ of asmcondflags and destination addressing mode }
|
|
{ of asmcondflags and destination addressing mode }
|
|
procedure a_jmp(list: taasmoutput; op: tasmop;
|
|
procedure a_jmp(list: taasmoutput; op: tasmop;
|
|
- c: tasmcondflag; crval: longint; l: tasmlabel);
|
|
|
|
|
|
+ c: tasmcond; l: tasmlabel);
|
|
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -150,12 +150,362 @@ unit cgcpu;
|
|
|
|
|
|
implementation
|
|
implementation
|
|
|
|
|
|
|
|
+
|
|
|
|
+ uses
|
|
|
|
+ globtype,globals,verbose,systems,cutils,symconst,symdef,symsym,rgobj,tgobj,cpupi;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_param_const(list : taasmoutput;size : tcgsize;a : aword;const locpara : tparalocation);
|
|
|
|
+ var
|
|
|
|
+ ref: treference;
|
|
|
|
+ begin
|
|
|
|
+ case locpara.loc of
|
|
|
|
+ LOC_REGISTER,LOC_CREGISTER:
|
|
|
|
+ a_load_const_reg(list,size,a,locpara.register);
|
|
|
|
+ LOC_REFERENCE:
|
|
|
|
+ begin
|
|
|
|
+ reference_reset(ref);
|
|
|
|
+ ref.base:=locpara.reference.index;
|
|
|
|
+ ref.offset:=locpara.reference.offset;
|
|
|
|
+ a_load_const_ref(list,size,a,ref);
|
|
|
|
+ end;
|
|
|
|
+ else
|
|
|
|
+ internalerror(2002081101);
|
|
|
|
+ end;
|
|
|
|
+ if locpara.sp_fixup<>0 then
|
|
|
|
+ internalerror(2002081102);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);
|
|
|
|
+ var
|
|
|
|
+ ref: treference;
|
|
|
|
+ tmpreg: tregister;
|
|
|
|
+ begin
|
|
|
|
+ case locpara.loc of
|
|
|
|
+ LOC_REGISTER,LOC_CREGISTER:
|
|
|
|
+ a_load_ref_reg(list,size,size,r,locpara.register);
|
|
|
|
+ LOC_REFERENCE:
|
|
|
|
+ begin
|
|
|
|
+ reference_reset(ref);
|
|
|
|
+ ref.base:=locpara.reference.index;
|
|
|
|
+ ref.offset:=locpara.reference.offset;
|
|
|
|
+ tmpreg := rg.getregisterint(list,size);
|
|
|
|
+ a_load_ref_reg(list,size,size,r,tmpreg);
|
|
|
|
+ a_load_reg_ref(list,size,size,tmpreg,ref);
|
|
|
|
+ rg.ungetregisterint(list,tmpreg);
|
|
|
|
+ end;
|
|
|
|
+ LOC_FPUREGISTER,LOC_CFPUREGISTER:
|
|
|
|
+ case size of
|
|
|
|
+ OS_F32, OS_F64:
|
|
|
|
+ a_loadfpu_ref_reg(list,size,r,locpara.register);
|
|
|
|
+ else
|
|
|
|
+ internalerror(2002072801);
|
|
|
|
+ end;
|
|
|
|
+ else
|
|
|
|
+ internalerror(2002081103);
|
|
|
|
+ end;
|
|
|
|
+ if locpara.sp_fixup<>0 then
|
|
|
|
+ internalerror(2002081104);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);
|
|
|
|
+ var
|
|
|
|
+ ref: treference;
|
|
|
|
+ tmpreg: tregister;
|
|
|
|
+ begin
|
|
|
|
+ case locpara.loc of
|
|
|
|
+ LOC_REGISTER,LOC_CREGISTER:
|
|
|
|
+ a_loadaddr_ref_reg(list,r,locpara.register);
|
|
|
|
+ LOC_REFERENCE:
|
|
|
|
+ begin
|
|
|
|
+ reference_reset(ref);
|
|
|
|
+ ref.base := locpara.reference.index;
|
|
|
|
+ ref.offset := locpara.reference.offset;
|
|
|
|
+ tmpreg := rg.getregisterint(list,OS_ADDR);
|
|
|
|
+ a_loadaddr_ref_reg(list,r,tmpreg);
|
|
|
|
+ a_load_reg_ref(list,OS_ADDR,OS_ADDR,tmpreg,ref);
|
|
|
|
+ rg.ungetregisterint(list,tmpreg);
|
|
|
|
+ end;
|
|
|
|
+ else
|
|
|
|
+ internalerror(2002080701);
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_call_name(list : taasmoutput;const s : string);
|
|
|
|
+ begin
|
|
|
|
+ list.concat(taicpu.op_sym(A_BL,objectlibrary.newasmsymbol(s)));
|
|
|
|
+ if not(pi_do_call in current_procinfo.flags) then
|
|
|
|
+ internalerror(2003060703);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_call_reg(list : taasmoutput;reg: tregister);
|
|
|
|
+ var
|
|
|
|
+ r : tregister;
|
|
|
|
+ begin
|
|
|
|
+ r.enum:=R_INTREGISTER;
|
|
|
|
+ r.number:=NR_PC;
|
|
|
|
+ list.concat(taicpu.op_reg_reg(A_MOV,r,reg));
|
|
|
|
+ if not(pi_do_call in current_procinfo.flags) then
|
|
|
|
+ internalerror(2003060704);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_call_ref(list : taasmoutput;const ref : treference);
|
|
|
|
+ var
|
|
|
|
+ r : tregister;
|
|
|
|
+ begin
|
|
|
|
+ r.enum:=R_INTREGISTER;
|
|
|
|
+ r.number:=NR_PC;
|
|
|
|
+ a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,r);
|
|
|
|
+ if not(pi_do_call in current_procinfo.flags) then
|
|
|
|
+ internalerror(2003060705);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; reg: TRegister);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
|
|
|
|
+ size: tcgsize; a: aword; src, dst: tregister);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
|
|
|
|
+ size: tcgsize; src1, src2, dst: tregister);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ function rotl(d : dword;b : byte) : dword;
|
|
|
|
+ begin
|
|
|
|
+ result=(d shr (32-b)) or (d shl b);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ function is_shifter_const(d : dword;var imm_shift : byte) : boolean;
|
|
|
|
+ var
|
|
|
|
+ i : longint;
|
|
|
|
+ begin
|
|
|
|
+ for i:=0 to 15 do
|
|
|
|
+ begin
|
|
|
|
+ if (d and not(rotl($ff,i)))=0 then
|
|
|
|
+ begin
|
|
|
|
+ imm_shift:=i;
|
|
|
|
+ result:=true;
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ result:=false;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure a_load_const_reg(list : taasmoutput; size: tcgsize; a : aword;reg : tregister);override;
|
|
|
|
+ var
|
|
|
|
+ imm_shift : byte;
|
|
|
|
+ l : tasmlabel;
|
|
|
|
+ hr : treference;
|
|
|
|
+ begin
|
|
|
|
+ if not(size in [OS_8,OS_S8,OS_16,OS_S16,OS_32,OS_S32]) then
|
|
|
|
+ internalerror(2002090902);
|
|
|
|
+ if is_shifter_const(a,imm_shift) then
|
|
|
|
+ list.concat(taicpu.op_reg_const(A_MOV,reg,a))
|
|
|
|
+ else if is_shifter_const(not(a),imm_shift) then
|
|
|
|
+ list.concat(taicpu.op_reg_const(A_MVN,reg,not(a)))
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ objectlibrary.getdatalabel(l);
|
|
|
|
+ aktlocaldata.concat(Tai_const_symbol.Create(l));
|
|
|
|
+ aktlocaldata.concat(Tai_const.Create_32bit(a));
|
|
|
|
+ reference_reset(hr);
|
|
|
|
+ hr.symbol:=l;
|
|
|
|
+ list.concat(taicpu.op_reg_ref(A_LDR,reg,hr));
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_load_reg_ref(list : taasmoutput; fromsize, tosize: tcgsize; reg : tregister;const ref : treference);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_load_ref_reg(list : taasmoutput; fromsize, tosize : tcgsize;const Ref : treference;reg : tregister);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_load_reg_reg(list : taasmoutput; fromsize, tosize : tcgsize;reg1,reg2 : tregister);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_loadfpu_reg_reg(list: taasmoutput; size: tcgsize; reg1, reg2: tregister);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ { comparison operations }
|
|
|
|
+ procedure tcgarm.a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
|
|
|
|
+ l : tasmlabel);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_jmp_always(list : taasmoutput;l: tasmlabel);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_flags2reg(list: taasmoutput; size: TCgSize; const f: TResFlags; reg: TRegister);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:integer);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_stackframe_entry(list : taasmoutput;localsize : longint);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_return_from_proc(list : taasmoutput;parasize : aword);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_restore_frame_pointer(list : taasmoutput);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword; delsource,loadref : boolean);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_overflowcheck(list: taasmoutput; const l: tlocation; def: tdef);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_save_standard_registers(list : taasmoutput; usedinproc : Tsupregset);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_restore_standard_registers(list : taasmoutput; usedinproc : Tsupregset);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_save_all_registers(list : taasmoutput);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_restore_all_registers(list : taasmoutput;accused,acchiused:boolean);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_stackframe_entry_sysv(list : taasmoutput;localsize : longint);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_return_from_proc_sysv(list : taasmoutput;parasize : aword);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_stackframe_entry_aix(list : taasmoutput;localsize : longint);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_return_from_proc_aix(list : taasmoutput;parasize : aword);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_stackframe_entry_mac(list : taasmoutput;localsize : longint);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ procedure tcgarm.g_return_from_proc_mac(list : taasmoutput;parasize : aword);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ { contains the common code of a_load_reg_ref and a_load_ref_reg }
|
|
|
|
+ procedure tcgarm.a_load_store(list:taasmoutput;op: tasmop;reg:tregister;
|
|
|
|
+ ref: treference);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ { creates the correct branch instruction for a given combination }
|
|
|
|
+ { of asmcondflags and destination addressing mode }
|
|
|
|
+ procedure tcgarm.a_jmp(list: taasmoutput; op: tasmop;
|
|
|
|
+ c: tasmcond; l: tasmlabel);
|
|
|
|
+ begin
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+
|
|
begin
|
|
begin
|
|
cg := tcgarm.create;
|
|
cg := tcgarm.create;
|
|
cg64 :=tcg64farm.create;
|
|
cg64 :=tcg64farm.create;
|
|
end.
|
|
end.
|
|
{
|
|
{
|
|
$Log$
|
|
$Log$
|
|
- Revision 1.1 2003-07-21 16:35:30 florian
|
|
|
|
|
|
+ Revision 1.2 2003-08-20 15:50:12 florian
|
|
|
|
+ * more arm stuff
|
|
|
|
+
|
|
|
|
+ Revision 1.1 2003/07/21 16:35:30 florian
|
|
* very basic stuff for the arm
|
|
* very basic stuff for the arm
|
|
}
|
|
}
|