|
@@ -270,7 +270,7 @@ uses
|
|
|
implementation
|
|
|
|
|
|
uses
|
|
|
- cutils,rgobj,itcpugas;
|
|
|
+ cutils,rgobj,itcpugas,aoptcpu;
|
|
|
|
|
|
|
|
|
procedure taicpu.loadshifterop(opidx:longint;const so:tshifterop);
|
|
@@ -1098,13 +1098,110 @@ implementation
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
- procedure finalizearmcode(list, listtoinsert: TAsmList);
|
|
|
+
|
|
|
+ function getMergedInstruction(FirstOp,LastOp:TAsmOp;InvertLast:boolean) : TAsmOp;
|
|
|
+ const
|
|
|
+ opTable: array[A_IT..A_ITTTT] of string =
|
|
|
+ ('T','TE','TT','TEE','TTE','TET','TTT',
|
|
|
+ 'TEEE','TTEE','TETE','TTTE',
|
|
|
+ 'TEET','TTET','TETT','TTTT');
|
|
|
+ invertedOpTable: array[A_IT..A_ITTTT] of string =
|
|
|
+ ('E','ET','EE','ETT','EET','ETE','EEE',
|
|
|
+ 'ETTT','EETT','ETET','EEET',
|
|
|
+ 'ETTE','EETE','ETEE','EEEE');
|
|
|
+ var
|
|
|
+ resStr : string;
|
|
|
+ i : TAsmOp;
|
|
|
begin
|
|
|
- insertpcrelativedata(list, listtoinsert);
|
|
|
+ if InvertLast then
|
|
|
+ resStr := opTable[FirstOp]+invertedOpTable[LastOp]
|
|
|
+ else
|
|
|
+ resStr := opTable[FirstOp]+opTable[LastOp];
|
|
|
+ if length(resStr) > 4 then
|
|
|
+ internalerror(2012100805);
|
|
|
+
|
|
|
+ for i := low(opTable) to high(opTable) do
|
|
|
+ if opTable[i] = resStr then
|
|
|
+ exit(i);
|
|
|
+
|
|
|
+ internalerror(2012100806);
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure foldITInstructions(list: TAsmList);
|
|
|
+ var
|
|
|
+ curtai,hp1 : tai;
|
|
|
+ levels,i : LongInt;
|
|
|
+ begin
|
|
|
+ curtai:=tai(list.First);
|
|
|
+ while assigned(curtai) do
|
|
|
+ begin
|
|
|
+ case curtai.typ of
|
|
|
+ ait_instruction:
|
|
|
+ if IsIT(taicpu(curtai).opcode) then
|
|
|
+ begin
|
|
|
+ levels := GetITLevels(taicpu(curtai).opcode);
|
|
|
+ if levels < 4 then
|
|
|
+ begin
|
|
|
+ i:=levels;
|
|
|
+ hp1:=tai(curtai.Next);
|
|
|
+ while assigned(hp1) and
|
|
|
+ (i > 0) do
|
|
|
+ begin
|
|
|
+ if hp1.typ=ait_instruction then
|
|
|
+ begin
|
|
|
+ dec(i);
|
|
|
+ if (i = 0) and
|
|
|
+ mustbelast(hp1) then
|
|
|
+ begin
|
|
|
+ hp1:=nil;
|
|
|
+ break;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ hp1:=tai(hp1.Next);
|
|
|
+ end;
|
|
|
+
|
|
|
+ if assigned(hp1) then
|
|
|
+ begin
|
|
|
+ // We are pointing at the first instruction after the IT block
|
|
|
+ while assigned(hp1) and
|
|
|
+ (hp1.typ<>ait_instruction) do
|
|
|
+ hp1:=tai(hp1.Next);
|
|
|
+
|
|
|
+ if assigned(hp1) and
|
|
|
+ (hp1.typ=ait_instruction) and
|
|
|
+ IsIT(taicpu(hp1).opcode) then
|
|
|
+ begin
|
|
|
+ if (levels+GetITLevels(taicpu(hp1).opcode) <= 4) and
|
|
|
+ ((taicpu(curtai).oper[0]^.cc=taicpu(hp1).oper[0]^.cc) or
|
|
|
+ (taicpu(curtai).oper[0]^.cc=inverse_cond(taicpu(hp1).oper[0]^.cc))) then
|
|
|
+ begin
|
|
|
+ taicpu(curtai).opcode:=getMergedInstruction(taicpu(curtai).opcode,
|
|
|
+ taicpu(hp1).opcode,
|
|
|
+ taicpu(curtai).oper[0]^.cc=inverse_cond(taicpu(hp1).oper[0]^.cc));
|
|
|
+
|
|
|
+ list.Remove(hp1);
|
|
|
+ hp1.Free;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+
|
|
|
+ curtai:=tai(curtai.Next);
|
|
|
+ end;
|
|
|
+ end;
|
|
|
|
|
|
+ procedure finalizearmcode(list, listtoinsert: TAsmList);
|
|
|
+ begin
|
|
|
{ Do Thumb-2 16bit -> 32bit transformations }
|
|
|
if current_settings.cputype in cpu_thumb2 then
|
|
|
- ensurethumb2encodings(list);
|
|
|
+ begin
|
|
|
+ ensurethumb2encodings(list);
|
|
|
+ foldITInstructions(list);
|
|
|
+ end;
|
|
|
+
|
|
|
+ insertpcrelativedata(list, listtoinsert);
|
|
|
end;
|
|
|
|
|
|
procedure InsertPData;
|