|
@@ -71,6 +71,7 @@ interface
|
|
procedure WriteInstruction(hp : tai);
|
|
procedure WriteInstruction(hp : tai);
|
|
protected
|
|
protected
|
|
owner: TLLVMAssember;
|
|
owner: TLLVMAssember;
|
|
|
|
+ fstr: TSymStr;
|
|
|
|
|
|
function InstructionToString(hp : tai): TSymStr;
|
|
function InstructionToString(hp : tai): TSymStr;
|
|
function getopstr(const o:toper; refwithalign: boolean) : TSymStr;
|
|
function getopstr(const o:toper; refwithalign: boolean) : TSymStr;
|
|
@@ -265,6 +266,8 @@ implementation
|
|
function TLLVMInstrWriter.getopstr(const o:toper; refwithalign: boolean) : TSymStr;
|
|
function TLLVMInstrWriter.getopstr(const o:toper; refwithalign: boolean) : TSymStr;
|
|
var
|
|
var
|
|
hs : ansistring;
|
|
hs : ansistring;
|
|
|
|
+ hp: tai;
|
|
|
|
+ tmpinline: cardinal;
|
|
begin
|
|
begin
|
|
case o.typ of
|
|
case o.typ of
|
|
top_reg:
|
|
top_reg:
|
|
@@ -316,7 +319,12 @@ implementation
|
|
end;
|
|
end;
|
|
top_tai:
|
|
top_tai:
|
|
begin
|
|
begin
|
|
- result:=InstructionToString(o.ai);
|
|
|
|
|
|
+ tmpinline:=1;
|
|
|
|
+ hp:=o.ai;
|
|
|
|
+ owner.AsmWrite(fstr);
|
|
|
|
+ fstr:='';
|
|
|
|
+ owner.WriteTai(false,false,tmpinline,hp);
|
|
|
|
+ result:='';
|
|
end;
|
|
end;
|
|
{$if defined(cpuextended) and defined(FPC_HAS_TYPE_EXTENDED)}
|
|
{$if defined(cpuextended) and defined(FPC_HAS_TYPE_EXTENDED)}
|
|
top_extended80:
|
|
top_extended80:
|
|
@@ -339,15 +347,17 @@ implementation
|
|
function TLLVMInstrWriter.InstructionToString(hp: tai): TSymStr;
|
|
function TLLVMInstrWriter.InstructionToString(hp: tai): TSymStr;
|
|
var
|
|
var
|
|
op: tllvmop;
|
|
op: tllvmop;
|
|
- s, sep: TSymStr;
|
|
|
|
|
|
+ sep: TSymStr;
|
|
i, opstart: byte;
|
|
i, opstart: byte;
|
|
|
|
+ nested: boolean;
|
|
done: boolean;
|
|
done: boolean;
|
|
begin
|
|
begin
|
|
op:=taillvm(hp).llvmopcode;
|
|
op:=taillvm(hp).llvmopcode;
|
|
- s:=#9;
|
|
|
|
|
|
+ fstr:=#9;
|
|
sep:=' ';
|
|
sep:=' ';
|
|
done:=false;
|
|
done:=false;
|
|
opstart:=0;
|
|
opstart:=0;
|
|
|
|
+ nested:=false;
|
|
case op of
|
|
case op of
|
|
la_ret, la_br, la_switch, la_indirectbr,
|
|
la_ret, la_br, la_switch, la_indirectbr,
|
|
la_invoke, la_resume,
|
|
la_invoke, la_resume,
|
|
@@ -362,13 +372,13 @@ implementation
|
|
la_call:
|
|
la_call:
|
|
begin
|
|
begin
|
|
if taillvm(hp).oper[0]^.reg<>NR_NO then
|
|
if taillvm(hp).oper[0]^.reg<>NR_NO then
|
|
- s:=s+getregisterstring(taillvm(hp).oper[0]^.reg)+' = ';
|
|
|
|
|
|
+ fstr:=fstr+getregisterstring(taillvm(hp).oper[0]^.reg)+' = ';
|
|
sep:=' ';
|
|
sep:=' ';
|
|
opstart:=1;
|
|
opstart:=1;
|
|
end;
|
|
end;
|
|
la_alloca:
|
|
la_alloca:
|
|
begin
|
|
begin
|
|
- s:=s+getreferencestring(taillvm(hp).oper[0]^.ref^,false)+' = ';
|
|
|
|
|
|
+ fstr:=fstr+getreferencestring(taillvm(hp).oper[0]^.ref^,false)+' = ';
|
|
sep:=' ';
|
|
sep:=' ';
|
|
opstart:=1;
|
|
opstart:=1;
|
|
end;
|
|
end;
|
|
@@ -381,8 +391,10 @@ implementation
|
|
data initialisers }
|
|
data initialisers }
|
|
if (taillvm(hp).oper[0]^.typ<>top_reg) or
|
|
if (taillvm(hp).oper[0]^.typ<>top_reg) or
|
|
(taillvm(hp).oper[0]^.reg<>NR_NO) then
|
|
(taillvm(hp).oper[0]^.reg<>NR_NO) then
|
|
- s:=s+getopstr(taillvm(hp).oper[0]^,false)+' = ';
|
|
|
|
- s:=s+llvm_op2str[op]+' '+
|
|
|
|
|
|
+ fstr:=fstr+getopstr(taillvm(hp).oper[0]^,false)+' = '
|
|
|
|
+ else
|
|
|
|
+ nested:=true;
|
|
|
|
+ fstr:=fstr+llvm_op2str[op]+' '+
|
|
getopstr(taillvm(hp).oper[1]^,false)+' '+
|
|
getopstr(taillvm(hp).oper[1]^,false)+' '+
|
|
getopstr(taillvm(hp).oper[2]^,false)+' to '+
|
|
getopstr(taillvm(hp).oper[2]^,false)+' to '+
|
|
getopstr(taillvm(hp).oper[3]^,false);
|
|
getopstr(taillvm(hp).oper[3]^,false);
|
|
@@ -390,7 +402,11 @@ implementation
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
- s:=s+getopstr(taillvm(hp).oper[0]^,true)+' = ';
|
|
|
|
|
|
+ if (taillvm(hp).oper[0]^.typ<>top_reg) or
|
|
|
|
+ (taillvm(hp).oper[0]^.reg<>NR_NO) then
|
|
|
|
+ fstr:=fstr+getopstr(taillvm(hp).oper[0]^,true)+' = '
|
|
|
|
+ else
|
|
|
|
+ nested:=true;
|
|
sep:=' ';
|
|
sep:=' ';
|
|
opstart:=1
|
|
opstart:=1
|
|
end;
|
|
end;
|
|
@@ -398,12 +414,14 @@ implementation
|
|
{ process operands }
|
|
{ process operands }
|
|
if not done then
|
|
if not done then
|
|
begin
|
|
begin
|
|
- s:=s+llvm_op2str[op];
|
|
|
|
|
|
+ fstr:=fstr+llvm_op2str[op];
|
|
|
|
+ if nested then
|
|
|
|
+ fstr:=fstr+' (';
|
|
if taillvm(hp).ops<>0 then
|
|
if taillvm(hp).ops<>0 then
|
|
begin
|
|
begin
|
|
for i:=opstart to taillvm(hp).ops-1 do
|
|
for i:=opstart to taillvm(hp).ops-1 do
|
|
begin
|
|
begin
|
|
- s:=s+sep+getopstr(taillvm(hp).oper[i]^,op in [la_load,la_store]);
|
|
|
|
|
|
+ fstr:=fstr+sep+getopstr(taillvm(hp).oper[i]^,op in [la_load,la_store]);
|
|
if (taillvm(hp).oper[i]^.typ in [top_def,top_cond,top_fpcond]) or
|
|
if (taillvm(hp).oper[i]^.typ in [top_def,top_cond,top_fpcond]) or
|
|
(op=la_call) then
|
|
(op=la_call) then
|
|
sep :=' '
|
|
sep :=' '
|
|
@@ -414,9 +432,11 @@ implementation
|
|
end;
|
|
end;
|
|
if op=la_alloca then
|
|
if op=la_alloca then
|
|
begin
|
|
begin
|
|
- s:=s+getreferencealignstring(taillvm(hp).oper[0]^.ref^)
|
|
|
|
|
|
+ fstr:=fstr+getreferencealignstring(taillvm(hp).oper[0]^.ref^)
|
|
end;
|
|
end;
|
|
- result:=s;
|
|
|
|
|
|
+ if nested then
|
|
|
|
+ fstr:=fstr+')';
|
|
|
|
+ result:=fstr;
|
|
end;
|
|
end;
|
|
|
|
|
|
{****************************************************************************}
|
|
{****************************************************************************}
|