Skip to content

Commit ab6272e

Browse files
authored
Optimization + Fixes (#1059)
* - Fixes * - Fixes * - Fixes * - Fixes * - Fixes
1 parent 050be28 commit ab6272e

49 files changed

Lines changed: 328 additions & 342 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Source/Data/IR-Instructions.json

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -163,84 +163,96 @@
163163
"FamilyName": "IR",
164164
"ResultCount": 1,
165165
"OperandCount": 2,
166-
"ResultType": "Boolean"
166+
"ResultType": "Boolean",
167+
"Compare": "true"
167168
},
168169
{
169170
"Name": "CompareR8",
170171
"FamilyName": "IR",
171172
"ResultCount": 1,
172173
"OperandCount": 2,
173-
"ResultType": "Boolean"
174+
"ResultType": "Boolean",
175+
"Compare": "true"
174176
},
175177
{
176178
"Name": "CompareObject",
177179
"FamilyName": "IR",
178180
"ResultCount": 1,
179181
"OperandCount": 2,
180-
"ResultType": "Boolean"
182+
"ResultType": "Boolean",
183+
"Compare": "true"
181184
},
182185
{
183186
"Name": "CompareManagedPointer",
184187
"FamilyName": "IR",
185188
"ResultCount": 1,
186189
"OperandCount": 2,
187-
"ResultType": "Boolean"
190+
"ResultType": "Boolean",
191+
"Compare": "true"
188192
},
189193
{
190194
"Name": "Compare32x32",
191195
"FamilyName": "IR",
192196
"ResultCount": 1,
193197
"OperandCount": 2,
194-
"ResultType": "Boolean"
198+
"ResultType": "Boolean",
199+
"Compare": "true"
195200
},
196201
{
197202
"Name": "Compare32x64",
198203
"FamilyName": "IR",
199204
"ResultCount": 1,
200205
"OperandCount": 2,
201-
"ResultType": "Boolean"
206+
"ResultType": "Boolean",
207+
"Compare": "true"
202208
},
203209
{
204210
"Name": "Compare64x32",
205211
"FamilyName": "IR",
206212
"ResultCount": 1,
207213
"OperandCount": 2,
208-
"ResultType": "Boolean"
214+
"ResultType": "Boolean",
215+
"Compare": "true"
209216
},
210217
{
211218
"Name": "Compare64x64",
212219
"FamilyName": "IR",
213220
"ResultCount": 1,
214221
"OperandCount": 2,
215-
"ResultType": "Boolean"
222+
"ResultType": "Boolean",
223+
"Compare": "true"
216224
},
217225
{
218226
"Name": "Branch32",
219227
"FamilyName": "IR",
220228
"ResultCount": 2,
221229
"OperandCount": 0,
222-
"FlowControl": "ConditionalBranch"
230+
"FlowControl": "ConditionalBranch",
231+
"Branch": "true"
223232
},
224233
{
225234
"Name": "Branch64",
226235
"FamilyName": "IR",
227236
"ResultCount": 2,
228237
"OperandCount": 0,
229-
"FlowControl": "ConditionalBranch"
238+
"FlowControl": "ConditionalBranch",
239+
"Branch": "true"
230240
},
231241
{
232242
"Name": "BranchObject",
233243
"FamilyName": "IR",
234244
"ResultCount": 2,
235245
"OperandCount": 0,
236-
"FlowControl": "ConditionalBranch"
246+
"FlowControl": "ConditionalBranch",
247+
"Branch": "true"
237248
},
238249
{
239250
"Name": "BranchManagedPointer",
240251
"FamilyName": "IR",
241252
"ResultCount": 2,
242253
"OperandCount": 0,
243-
"FlowControl": "ConditionalBranch"
254+
"FlowControl": "ConditionalBranch",
255+
"Branch": "true"
244256
},
245257
{
246258
"Name": "ConvertR4ToR8",
@@ -820,19 +832,22 @@
820832
"Name": "MoveCompound",
821833
"FamilyName": "IR",
822834
"ResultCount": 1,
823-
"OperandCount": 1
835+
"OperandCount": 1,
836+
"Move": "true"
824837
},
825838
{
826839
"Name": "MoveR4",
827840
"FamilyName": "IR",
828841
"ResultCount": 1,
829-
"OperandCount": 1
842+
"OperandCount": 1,
843+
"Move": "true"
830844
},
831845
{
832846
"Name": "MoveR8",
833847
"FamilyName": "IR",
834848
"ResultCount": 1,
835-
"OperandCount": 1
849+
"OperandCount": 1,
850+
"Move": "true"
836851
},
837852
{
838853
"Name": "SignExtend8x32",
@@ -898,25 +913,29 @@
898913
"Name": "Move32",
899914
"FamilyName": "IR",
900915
"ResultCount": 1,
901-
"OperandCount": 1
916+
"OperandCount": 1,
917+
"Move": "true"
902918
},
903919
{
904920
"Name": "Move64",
905921
"FamilyName": "IR",
906922
"ResultCount": 1,
907-
"OperandCount": 1
923+
"OperandCount": 1,
924+
"Move": "true"
908925
},
909926
{
910927
"Name": "MoveObject",
911928
"FamilyName": "IR",
912929
"ResultCount": 1,
913-
"OperandCount": 1
930+
"OperandCount": 1,
931+
"Move": "true"
914932
},
915933
{
916934
"Name": "MoveManagedPointer",
917935
"FamilyName": "IR",
918936
"ResultCount": 1,
919-
"OperandCount": 1
937+
"OperandCount": 1,
938+
"Move": "true"
920939
},
921940
{
922941
"Name": "MulCarryOut32",
@@ -1020,42 +1039,48 @@
10201039
"FamilyName": "IR",
10211040
"ResultCount": 0,
10221041
"OperandCount": 0,
1023-
"VariableOperands": "true"
1042+
"VariableOperands": "true",
1043+
"Phi": "true"
10241044
},
10251045
{
10261046
"Name": "PhiManagedPointer",
10271047
"FamilyName": "IR",
10281048
"ResultCount": 0,
10291049
"OperandCount": 0,
1030-
"VariableOperands": "true"
1050+
"VariableOperands": "true",
1051+
"Phi": "true"
10311052
},
10321053
{
10331054
"Name": "Phi32",
10341055
"FamilyName": "IR",
10351056
"ResultCount": 0,
10361057
"OperandCount": 0,
1037-
"VariableOperands": "true"
1058+
"VariableOperands": "true",
1059+
"Phi": "true"
10381060
},
10391061
{
10401062
"Name": "Phi64",
10411063
"FamilyName": "IR",
10421064
"ResultCount": 0,
10431065
"OperandCount": 0,
1044-
"VariableOperands": "true"
1066+
"VariableOperands": "true",
1067+
"Phi": "true"
10451068
},
10461069
{
10471070
"Name": "PhiR4",
10481071
"FamilyName": "IR",
10491072
"ResultCount": 0,
10501073
"OperandCount": 0,
1051-
"VariableOperands": "true"
1074+
"VariableOperands": "true",
1075+
"Phi": "true"
10521076
},
10531077
{
10541078
"Name": "PhiR8",
10551079
"FamilyName": "IR",
10561080
"ResultCount": 0,
10571081
"OperandCount": 0,
1058-
"VariableOperands": "true"
1082+
"VariableOperands": "true",
1083+
"Phi": "true"
10591084
},
10601085
{
10611086
"Name": "Prologue",

Source/Mosa.Compiler.Framework/Analysis/SparseConditionalConstantPropagation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ private bool ProcessInstruction(InstructionNode node)
532532
{
533533
CompareOperation(node);
534534
}
535-
else if (IsPhiInstruction(instruction))
535+
else if (instruction.IsPhiInstruction)
536536
{
537537
Phi(node);
538538
}

Source/Mosa.Compiler.Framework/BaseInstruction.cs

Lines changed: 23 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ public abstract class BaseInstruction
3131
/// <value>The operand result count.</value>
3232
public byte DefaultResultCount { get; protected set; }
3333

34-
/// <summary>
35-
/// The type of the result type
36-
/// </summary>
37-
public virtual BuiltInType ResultType { get; protected set; } = BuiltInType.None;
38-
39-
/// <summary>
40-
/// The type of the secondary result type
41-
/// </summary>
42-
public virtual BuiltInType ResultType2 { get; protected set; } = BuiltInType.None;
43-
4434
/// <summary>
4535
/// Determines flow behavior of this instruction.
4636
/// </summary>
@@ -51,103 +41,55 @@ public abstract class BaseInstruction
5141
/// </remarks>
5242
public virtual FlowControl FlowControl => FlowControl.Next;
5343

54-
/// <summary>
55-
/// Gets a value indicating whether to [ignore during code generation].
56-
/// </summary>
57-
/// <value>
58-
/// <c>true</c> if [ignore during code generation]; otherwise, <c>false</c>.
59-
/// </value>
44+
public virtual bool VariableOperands => false;
45+
46+
public virtual string Name { get; private set; }
47+
48+
public virtual string AlternativeName => null;
49+
50+
public virtual string FamilyName => null;
51+
52+
public virtual string Modifier => null;
53+
54+
public virtual string FullName { get; private set; }
55+
56+
public virtual string OpcodeName { get; private set; }
57+
58+
#endregion Properties
59+
60+
#region Is/Has Properties
61+
6062
public virtual bool IgnoreDuringCodeGeneration => false;
6163

62-
/// <summary>
63-
/// Gets a value indicating whether to [ignore instruction's basic block].
64-
/// </summary>
65-
/// <value>
66-
/// <c>true</c> if [ignore instruction basic block]; otherwise, <c>false</c>.
67-
/// </value>
6864
public virtual bool IgnoreInstructionBasicBlockTargets => false;
6965

70-
/// <summary>
71-
/// Gets a value indicating whether this instance has an unspecified side effect.
72-
/// </summary>
73-
/// <value>
74-
/// <c>true</c> if this instance has side effect; otherwise, <c>false</c>.
75-
/// </value>
7666
public virtual bool HasUnspecifiedSideEffect => false;
7767

78-
/// <summary>
79-
/// Gets a value indicating whether this instance has memory write side effect.
80-
/// </summary>
81-
/// <value>
82-
/// <c>true</c> if this instance has side effect; otherwise, <c>false</c>.
83-
/// </value>
8468
public virtual bool IsMemoryWrite => false;
8569

86-
/// <summary>
87-
/// Gets a value indicating whether this instance has memory write side effect.
88-
/// </summary>
89-
/// <value>
90-
/// <c>true</c> if this instance has side effect; otherwise, <c>false</c>.
91-
/// </value>
9270
public virtual bool IsMemoryRead => false;
9371

94-
/// <summary>
95-
/// Gets a value indicating whether this instance has IO operation side effect.
96-
/// </summary>
97-
/// <value>
98-
/// <c>true</c> if this instance has side effect; otherwise, <c>false</c>.
99-
/// </value>
10072
public virtual bool IsIOOperation => false;
10173

102-
/// <summary>
103-
/// Gets a value indicating whether [variable operand count].
104-
/// </summary>
105-
/// <value>
106-
/// <c>true</c> if [variable operand count]; otherwise, <c>false</c>.
107-
/// </value>
108-
public virtual bool VariableOperands => false;
109-
110-
/// <summary>
111-
/// Gets a value indicating whether this <see cref="BaseInstruction"/> is commutative.
112-
/// </summary>
113-
/// <value>
114-
/// <c>true</c> if commutative; otherwise, <c>false</c>.
115-
/// </value>
11674
public virtual bool IsCommutative => false;
11775

118-
/// <summary>
119-
/// Gets a value indicating whether this instance is parameter load.
120-
/// </summary>
121-
/// <value>
122-
/// <c>true</c> if this instance is parameter load; otherwise, <c>false</c>.
123-
/// </value>
12476
public virtual bool IsParameterLoad => false;
12577

126-
/// <summary>
127-
/// Gets a value indicating whether this instance is parameter store.
128-
/// </summary>
129-
/// <value>
130-
/// <c>true</c> if this instance is parameter store; otherwise, <c>false</c>.
131-
/// </value>
13278
public virtual bool IsParameterStore => false;
13379

13480
public virtual bool IsPlatformInstruction => false;
13581

13682
public virtual bool IsIRInstruction => false;
13783

138-
public virtual string Name { get; private set; }
84+
public virtual bool IsPhiInstruction => false;
13985

140-
public virtual string AlternativeName => null;
86+
public virtual bool IsIRBranchInstruction => false;
14187

142-
public virtual string FamilyName => null;
88+
public virtual bool IsIRMoveInstruction => false;
14389

144-
public virtual string Modifier => null;
90+
public virtual bool IsIRCompareInstruction => false;
14591

146-
public virtual string FullName { get; private set; }
147-
148-
public virtual string OpcodeName { get; private set; }
149-
150-
#endregion Properties
92+
#endregion Is/Has Properties
15193

15294
#region Platform Properties
15395

0 commit comments

Comments
 (0)