|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 using System; |
|
18 using System.Collections.Generic; |
|
19 using System.Text; |
|
20 using System.IO; |
|
21 using SymbianUtils.BasicTypes; |
|
22 using SymbianStructuresLib.Arm; |
|
23 using SymbianStructuresLib.Arm.Instructions; |
|
24 using SymbianStructuresLib.Arm.Registers; |
|
25 using SymbianInstructionLib.Arm.Instructions.Common; |
|
26 using SymbianInstructionLib.Arm.Instructions.Arm; |
|
27 using SymbianInstructionLib.Arm.Instructions.Arm.DataProcessing; |
|
28 using SymbianInstructionLib.Arm.Instructions.Thumb; |
|
29 using SymbianInstructionLib.Arm.Instructions.Thumb.DataProcessing; |
|
30 using SymbianStackAlgorithmAccurate.CPU; |
|
31 using SymbianStackAlgorithmAccurate.Prologue; |
|
32 |
|
33 namespace SymbianStackAlgorithmAccurate.Instructions.Types |
|
34 { |
|
35 internal class AccInstBranch : AccInstruction |
|
36 { |
|
37 #region Constructors |
|
38 public AccInstBranch( IArmInstruction aInstruction ) |
|
39 : base( aInstruction ) |
|
40 { |
|
41 System.Diagnostics.Debug.Assert( base.Instruction.AIGroup == TArmInstructionGroup.EGroupBranch ); |
|
42 } |
|
43 #endregion |
|
44 |
|
45 #region API |
|
46 internal override void Process( ArmPrologueHelper aProlog ) |
|
47 { |
|
48 } |
|
49 |
|
50 internal override void Prefilter( AccInstructionList aInstructions, int aMyIndex, int aInstructionCountOffsetToPC ) |
|
51 { |
|
52 if ( this.Ignored == false ) |
|
53 { |
|
54 int count = aInstructions.Count; |
|
55 // |
|
56 if ( base.Instruction.AIConditionCode == TArmInstructionCondition.AL ) |
|
57 { |
|
58 // As soon as we see any unconditional branch statement we can be sure that we are past the Prologue. |
|
59 for ( int i = aMyIndex + 1; i < count; i++ ) |
|
60 { |
|
61 aInstructions[ i ].Ignored = true; |
|
62 } |
|
63 } |
|
64 else |
|
65 { |
|
66 // Count the number of interesting instructions before the conditional branch |
|
67 int interestingInstructionCount = 0; |
|
68 for ( int i = 0; i < aMyIndex; i++ ) |
|
69 { |
|
70 AccInstruction accInstruction = aInstructions[ i ]; |
|
71 IArmInstruction inst = accInstruction.Instruction; |
|
72 // |
|
73 bool involvesSP = inst.QueryInvolvement( TArmRegisterType.EArmReg_SP ); |
|
74 if ( involvesSP ) |
|
75 { |
|
76 ++interestingInstructionCount; |
|
77 } |
|
78 } |
|
79 |
|
80 // If we have seen at least one interesting instruction then assume prologue is complete. |
|
81 if ( interestingInstructionCount >= 1 ) |
|
82 { |
|
83 for ( int i = aMyIndex; i < count; i++ ) |
|
84 { |
|
85 aInstructions[ i ].Ignored = true; |
|
86 } |
|
87 } |
|
88 } |
|
89 } |
|
90 } |
|
91 #endregion |
|
92 |
|
93 #region Properties |
|
94 #endregion |
|
95 |
|
96 #region Internal methods |
|
97 #endregion |
|
98 |
|
99 #region Data members |
|
100 #endregion |
|
101 } |
|
102 } |
|
103 |