+ gathering of register reading data, nowhere used yet (necessary for instruction scheduling)

This commit is contained in:
Jonas Maebe 1998-11-18 17:58:22 +00:00
parent e413f19a4d
commit ae04ea5143

View File

@ -132,17 +132,13 @@ Type
content of this register. If Typ = con_const, then content of this register. If Typ = con_const, then
Longint(StartMod) = value of the constant)} Longint(StartMod) = value of the constant)}
StartMod: Pointer; StartMod: Pointer;
{starts at 0, gets increased everytime the register is modified} {starts at 0, gets increased everytime the register is written to}
WState: Byte; WState: Byte;
{starts at 0, gets increased everytime the register is read from} {starts at 0, gets increased everytime the register is read from}
RState: Byte; RState: Byte;
{how many instructions starting with StarMod does the block consist of} {how many instructions starting with StarMod does the block consist of}
NrOfMods: Byte; NrOfMods: Byte;
{if one register gets a block assigned from an other register, {the type of the content of the register: unknown, memory, constant}
this variable holds the name of that register (so it can be
substituted when checking the block afterwards)}
{ ModReg: TRegister; }
{the type of the content of the register: constant, ...}
Typ: Byte; Typ: Byte;
End; End;
@ -1202,7 +1198,7 @@ End;
Procedure DestroyReg(p1: PPaiProp; Reg: TRegister); Procedure DestroyReg(p1: PPaiProp; Reg: TRegister);
{Destroys the contents of the register Reg in the PPaiProp p1, as well as the {Destroys the contents of the register Reg in the PPaiProp p1, as well as the
contents of registers are loaded with a memory location based on Reg} contents of registers are loaded with a memory location based on Reg}
Var TmpState: Byte; Var TmpWState, TmpRState: Byte;
Counter: TRegister; Counter: TRegister;
Begin Begin
Reg := Reg32(Reg); Reg := Reg32(Reg);
@ -1213,9 +1209,11 @@ Begin
With p1^.Regs[Reg] Do With p1^.Regs[Reg] Do
Begin Begin
IncState(WState); IncState(WState);
TmpState := WState; TmpWState := WState;
TmpRState := RState;
FillChar(p1^.Regs[Reg], SizeOf(TContent), 0); FillChar(p1^.Regs[Reg], SizeOf(TContent), 0);
WState := TmpState; WState := TmpWState;
RState := TmpRState;
End; End;
For Counter := R_EAX to R_EDI Do For Counter := R_EAX to R_EDI Do
With p1^.Regs[Counter] Do With p1^.Regs[Counter] Do
@ -1224,9 +1222,11 @@ Begin
Then Then
Begin Begin
IncState(WState); IncState(WState);
TmpState := WState; TmpWState := WState;
TmpRState := RState;
FillChar(p1^.Regs[Counter], SizeOf(TContent), 0); FillChar(p1^.Regs[Counter], SizeOf(TContent), 0);
WState := TmpState; WState := TmpWState;
RState := TmpRState;
End; End;
End; End;
End; End;
@ -1510,15 +1510,37 @@ Begin {initializes/desrtoys all registers}
p^.DirFlag := F_Unknown; p^.DirFlag := F_Unknown;
End; End;
Procedure Destroy(PaiObj: Pai; opt: Longint; Op: Pointer); Procedure Destroy(PaiObj: Pai; Opt: Longint; Op: Pointer);
Begin Begin
Case opt Of Case Opt Of
top_reg: DestroyReg(PPaiProp(PaiObj^.fileinfo.line), TRegister(Op)); top_reg: DestroyReg(PPaiProp(PaiObj^.fileinfo.line), TRegister(Op));
top_ref: DestroyRefs(PaiObj, TReference(Op^), R_NO); top_ref: DestroyRefs(PaiObj, TReference(Op^), R_NO);
top_symbol:; top_symbol:;
End; End;
End; End;
Procedure ReadReg(p: PPaiProp; Reg: TRegister);
Begin
IncState(p^.Regs[Reg32(Reg)].RState)
End;
Procedure ReadRef(p: PPaiProp; Ref: PReference);
Begin
If Ref^.Base <> R_NO Then
ReadReg(p, Ref^.Base);
If Ref^.Index <> R_NO Then
ReadReg(p, Ref^.Index);
End;
Procedure ReadOp(P: PPaiProp; opt: Longint; Op: Pointer);
Begin
Case Opt Of
top_reg: ReadReg(P, TRegister(Op));
top_ref: ReadRef(P, PReference(Op));
top_symbol:
End;
End;
Procedure DFAPass1(AsmL: PAasmOutput); Procedure DFAPass1(AsmL: PAasmOutput);
{gathers the RegAlloc data... still need to think about where to store it} {gathers the RegAlloc data... still need to think about where to store it}
Begin Begin
@ -1783,16 +1805,24 @@ Begin
Top_Reg: Top_Reg:
Begin Begin
DestroyReg(CurProp, TRegister(Pai386(p)^.op2)); DestroyReg(CurProp, TRegister(Pai386(p)^.op2));
ReadReg(CurProp, TRegister(Pai386(p)^.op1));
{ CurProp^.Regs[TRegister(Pai386(p)^.op2)] := { CurProp^.Regs[TRegister(Pai386(p)^.op2)] :=
CurProp^.Regs[TRegister(Pai386(p)^.op1)]; CurProp^.Regs[TRegister(Pai386(p)^.op1)];
If (CurProp^.Regs[TRegister(Pai386(p)^.op2)].ModReg = R_NO) Then If (CurProp^.Regs[TRegister(Pai386(p)^.op2)].ModReg = R_NO) Then
CurProp^.Regs[TRegister(Pai386(p)^.op2)].ModReg := CurProp^.Regs[TRegister(Pai386(p)^.op2)].ModReg :=
Tregister(Pai386(p)^.op1);} Tregister(Pai386(p)^.op1);}
End; End;
Top_Ref: DestroyRefs(p, TReference(Pai386(p)^.op2^), TRegister(Pai386(p)^.op1)); Top_Ref:
Begin
ReadReg(CurProp, TRegister(Pai386(p)^.op1));
ReadRef(CurProp, PReference(Pai386(p)^.op2));
DestroyRefs(p, TReference(Pai386(p)^.op2^), TRegister(Pai386(p)^.op1));
End;
End; End;
Top_Ref: Top_Ref:
Begin {destination is always a register in this case} Begin {destination is always a register in this case}
ReadRef(CurProp, PReference(Pai386(p)^.op1));
ReadReg(CurProp, TRegister(Pai386(p)^.Op2));
TmpReg := Reg32(TRegister(Pai386(p)^.op2)); TmpReg := Reg32(TRegister(Pai386(p)^.op2));
If RegInRef(TmpReg, TReference(Pai386(p)^.op1^)) And If RegInRef(TmpReg, TReference(Pai386(p)^.op1^)) And
(CurProp^.Regs[TmpReg].Typ = Con_Ref) (CurProp^.Regs[TmpReg].Typ = Con_Ref)
@ -1839,13 +1869,22 @@ Begin
StartMod := Pai386(p)^.op1; StartMod := Pai386(p)^.op1;
End End
End; End;
Top_Ref: DestroyRefs(P, TReference(Pai386(p)^.op2^), R_NO); Top_Ref:
Begin
ReadRef(CurProp, PReference(Pai386(p)^.op2));
DestroyRefs(P, TReference(Pai386(p)^.op2^), R_NO);
End;
End; End;
End; End;
End; End;
End; End;
A_IMUL: A_IMUL:
Begin Begin
ReadOp(CurProp, Pai386(p)^.Op1t, Pai386(p)^.Op1);
If (Pai386(p)^.Op2t <> Top_Ref) Then
ReadOp(CurProp, Pai386(p)^.Op1t, Pai386(p)^.Op1)
Else ReadOp(CurProp, Pai386(p)^.Op2t, Pointer(Longint(TwoWords(Pai386(p)^.Op2).Word1)));
ReadOp(CurProp, Pai386(p)^.Op3t, Pointer(LongInt(TwoWords(Pai386(p)^.Op2).Word2)));
If (Pai386(p)^.Op3t = top_none) If (Pai386(p)^.Op3t = top_none)
Then Then
If (Pai386(p)^.Op2t = top_none) If (Pai386(p)^.Op2t = top_none)
@ -1856,6 +1895,8 @@ Begin
End End
Else Else
Begin Begin
ReadOp(CurProp, Pai386(p)^.Op1t, Pai386(p)^.Op1);
ReadOp(CurProp, Pai386(p)^.Op2t, Pai386(p)^.Op2);
If (Pai386(p)^.Op2t = top_reg) Then If (Pai386(p)^.Op2t = top_reg) Then
DestroyReg(CurProp, TRegister(Pai386(p)^.Op2)); DestroyReg(CurProp, TRegister(Pai386(p)^.Op2));
End End
@ -1864,6 +1905,8 @@ Begin
End; End;
A_XOR: A_XOR:
Begin Begin
ReadOp(CurProp, Pai386(p)^.Op1t, Pai386(p)^.Op1);
ReadOp(CurProp, Pai386(p)^.Op2t, Pai386(p)^.Op2);
If (Pai386(p)^.op1t = top_reg) And If (Pai386(p)^.op1t = top_reg) And
(Pai386(p)^.op2t = top_reg) And (Pai386(p)^.op2t = top_reg) And
(Pai386(p)^.op1 = Pai386(p)^.op2) (Pai386(p)^.op1 = Pai386(p)^.op2)
@ -1882,18 +1925,39 @@ Begin
(InstrProp.Ch[Cnt] <> C_None) Do (InstrProp.Ch[Cnt] <> C_None) Do
Begin Begin
Case InstrProp.Ch[Cnt] Of Case InstrProp.Ch[Cnt] Of
C_REAX..C_REDI: ; C_REAX..C_REDI: ReadReg(CurProp,TCh2Reg(InstrProp.Ch[Cnt]));
C_WEAX..C_RWEDI: DestroyReg(CurProp, TCh2Reg(InstrProp.Ch[Cnt])); C_WEAX..C_RWEDI:
Begin
If (InstrProp.Ch[Cnt] >= C_RWEAX) Then
ReadReg(CurProp, TCh2Reg(InstrProp.Ch[Cnt]));
DestroyReg(CurProp, TCh2Reg(InstrProp.Ch[Cnt]));
End;
C_CDirFlag: CurProp^.DirFlag := F_NotSet; C_CDirFlag: CurProp^.DirFlag := F_NotSet;
C_SDirFlag: CurProp^.DirFlag := F_Set; C_SDirFlag: CurProp^.DirFlag := F_Set;
C_ROp1:; C_ROp1: ReadOp(CurProp, Pai386(p)^.op1t, Pai386(p)^.op1);
C_ROp2:; C_ROp2: ReadOp(CurProp, Pai386(p)^.op2t, Pai386(p)^.op2);
C_ROp3:; C_ROp3: ReadOp(CurProp, Pai386(p)^.op3t, Pointer(Longint(TwoWords(Pai386(p)^.op2).word2)));
C_WOp1..C_RWOp1: Destroy(p, Pai386(p)^.op1t, Pai386(p)^.op1); C_WOp1..C_RWOp1:
C_WOp2..C_RWOp2: Destroy(p, Pai386(p)^.op2t, Pai386(p)^.op2); Begin
C_WOp3..C_RWOp3: Destroy(p, Pai386(p)^.op3t, Pointer(Longint(TwoWords(Pai386(p)^.op2).word2))); If (InstrProp.Ch[Cnt] = C_RWOp1) Then
ReadOp(CurProp, Pai386(p)^.op1t, Pai386(p)^.op1);
Destroy(p, Pai386(p)^.op1t, Pai386(p)^.op1);
End;
C_WOp2..C_RWOp2:
Begin
If (InstrProp.Ch[Cnt] = C_RWOp2) Then
ReadOp(CurProp, Pai386(p)^.op2t, Pai386(p)^.op2);
Destroy(p, Pai386(p)^.op2t, Pai386(p)^.op2);
End;
C_WOp3..C_RWOp3:
Begin
If (InstrProp.Ch[Cnt] = C_RWOp3) Then
ReadOp(CurProp, Pai386(p)^.op3t, Pointer(Longint(TwoWords(Pai386(p)^.op2).word2)));;
Destroy(p, Pai386(p)^.op3t, Pointer(Longint(TwoWords(Pai386(p)^.op2).word2)));
End;
C_MemEDI: C_MemEDI:
Begin Begin
ReadReg(CurProp, R_EDI);
FillChar(TmpRef, SizeOf(TmpRef), 0); FillChar(TmpRef, SizeOf(TmpRef), 0);
TmpRef.Base := R_EDI; TmpRef.Base := R_EDI;
DestroyRefs(p, TmpRef, R_NO) DestroyRefs(p, TmpRef, R_NO)
@ -2008,7 +2072,10 @@ End.
{ {
$Log$ $Log$
Revision 1.24 1998-11-13 10:13:44 peter Revision 1.25 1998-11-18 17:58:22 jonas
+ gathering of register reading data, nowhere used yet (necessary for instruction scheduling)
Revision 1.24 1998/11/13 10:13:44 peter
+ cpuid,emms support for asm readers + cpuid,emms support for asm readers
Revision 1.23 1998/11/09 19:40:46 jonas Revision 1.23 1998/11/09 19:40:46 jonas