Skip to content

Commit

Permalink
Optimization + Fixes (#1059)
Browse files Browse the repository at this point in the history
* - Fixes

* - Fixes

* - Fixes

* - Fixes

* - Fixes
  • Loading branch information
tgiphil committed May 27, 2023
1 parent 050be28 commit ab6272e
Show file tree
Hide file tree
Showing 49 changed files with 328 additions and 342 deletions.
75 changes: 50 additions & 25 deletions Source/Data/IR-Instructions.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,84 +163,96 @@
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 2,
"ResultType": "Boolean"
"ResultType": "Boolean",
"Compare": "true"
},
{
"Name": "CompareR8",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 2,
"ResultType": "Boolean"
"ResultType": "Boolean",
"Compare": "true"
},
{
"Name": "CompareObject",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 2,
"ResultType": "Boolean"
"ResultType": "Boolean",
"Compare": "true"
},
{
"Name": "CompareManagedPointer",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 2,
"ResultType": "Boolean"
"ResultType": "Boolean",
"Compare": "true"
},
{
"Name": "Compare32x32",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 2,
"ResultType": "Boolean"
"ResultType": "Boolean",
"Compare": "true"
},
{
"Name": "Compare32x64",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 2,
"ResultType": "Boolean"
"ResultType": "Boolean",
"Compare": "true"
},
{
"Name": "Compare64x32",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 2,
"ResultType": "Boolean"
"ResultType": "Boolean",
"Compare": "true"
},
{
"Name": "Compare64x64",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 2,
"ResultType": "Boolean"
"ResultType": "Boolean",
"Compare": "true"
},
{
"Name": "Branch32",
"FamilyName": "IR",
"ResultCount": 2,
"OperandCount": 0,
"FlowControl": "ConditionalBranch"
"FlowControl": "ConditionalBranch",
"Branch": "true"
},
{
"Name": "Branch64",
"FamilyName": "IR",
"ResultCount": 2,
"OperandCount": 0,
"FlowControl": "ConditionalBranch"
"FlowControl": "ConditionalBranch",
"Branch": "true"
},
{
"Name": "BranchObject",
"FamilyName": "IR",
"ResultCount": 2,
"OperandCount": 0,
"FlowControl": "ConditionalBranch"
"FlowControl": "ConditionalBranch",
"Branch": "true"
},
{
"Name": "BranchManagedPointer",
"FamilyName": "IR",
"ResultCount": 2,
"OperandCount": 0,
"FlowControl": "ConditionalBranch"
"FlowControl": "ConditionalBranch",
"Branch": "true"
},
{
"Name": "ConvertR4ToR8",
Expand Down Expand Up @@ -820,19 +832,22 @@
"Name": "MoveCompound",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 1
"OperandCount": 1,
"Move": "true"
},
{
"Name": "MoveR4",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 1
"OperandCount": 1,
"Move": "true"
},
{
"Name": "MoveR8",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 1
"OperandCount": 1,
"Move": "true"
},
{
"Name": "SignExtend8x32",
Expand Down Expand Up @@ -898,25 +913,29 @@
"Name": "Move32",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 1
"OperandCount": 1,
"Move": "true"
},
{
"Name": "Move64",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 1
"OperandCount": 1,
"Move": "true"
},
{
"Name": "MoveObject",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 1
"OperandCount": 1,
"Move": "true"
},
{
"Name": "MoveManagedPointer",
"FamilyName": "IR",
"ResultCount": 1,
"OperandCount": 1
"OperandCount": 1,
"Move": "true"
},
{
"Name": "MulCarryOut32",
Expand Down Expand Up @@ -1020,42 +1039,48 @@
"FamilyName": "IR",
"ResultCount": 0,
"OperandCount": 0,
"VariableOperands": "true"
"VariableOperands": "true",
"Phi": "true"
},
{
"Name": "PhiManagedPointer",
"FamilyName": "IR",
"ResultCount": 0,
"OperandCount": 0,
"VariableOperands": "true"
"VariableOperands": "true",
"Phi": "true"
},
{
"Name": "Phi32",
"FamilyName": "IR",
"ResultCount": 0,
"OperandCount": 0,
"VariableOperands": "true"
"VariableOperands": "true",
"Phi": "true"
},
{
"Name": "Phi64",
"FamilyName": "IR",
"ResultCount": 0,
"OperandCount": 0,
"VariableOperands": "true"
"VariableOperands": "true",
"Phi": "true"
},
{
"Name": "PhiR4",
"FamilyName": "IR",
"ResultCount": 0,
"OperandCount": 0,
"VariableOperands": "true"
"VariableOperands": "true",
"Phi": "true"
},
{
"Name": "PhiR8",
"FamilyName": "IR",
"ResultCount": 0,
"OperandCount": 0,
"VariableOperands": "true"
"VariableOperands": "true",
"Phi": "true"
},
{
"Name": "Prologue",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ private bool ProcessInstruction(InstructionNode node)
{
CompareOperation(node);
}
else if (IsPhiInstruction(instruction))
else if (instruction.IsPhiInstruction)
{
Phi(node);
}
Expand Down
104 changes: 23 additions & 81 deletions Source/Mosa.Compiler.Framework/BaseInstruction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ public abstract class BaseInstruction
/// <value>The operand result count.</value>
public byte DefaultResultCount { get; protected set; }

/// <summary>
/// The type of the result type
/// </summary>
public virtual BuiltInType ResultType { get; protected set; } = BuiltInType.None;

/// <summary>
/// The type of the secondary result type
/// </summary>
public virtual BuiltInType ResultType2 { get; protected set; } = BuiltInType.None;

/// <summary>
/// Determines flow behavior of this instruction.
/// </summary>
Expand All @@ -51,103 +41,55 @@ public abstract class BaseInstruction
/// </remarks>
public virtual FlowControl FlowControl => FlowControl.Next;

/// <summary>
/// Gets a value indicating whether to [ignore during code generation].
/// </summary>
/// <value>
/// <c>true</c> if [ignore during code generation]; otherwise, <c>false</c>.
/// </value>
public virtual bool VariableOperands => false;

public virtual string Name { get; private set; }

public virtual string AlternativeName => null;

public virtual string FamilyName => null;

public virtual string Modifier => null;

public virtual string FullName { get; private set; }

public virtual string OpcodeName { get; private set; }

#endregion Properties

#region Is/Has Properties

public virtual bool IgnoreDuringCodeGeneration => false;

/// <summary>
/// Gets a value indicating whether to [ignore instruction's basic block].
/// </summary>
/// <value>
/// <c>true</c> if [ignore instruction basic block]; otherwise, <c>false</c>.
/// </value>
public virtual bool IgnoreInstructionBasicBlockTargets => false;

/// <summary>
/// Gets a value indicating whether this instance has an unspecified side effect.
/// </summary>
/// <value>
/// <c>true</c> if this instance has side effect; otherwise, <c>false</c>.
/// </value>
public virtual bool HasUnspecifiedSideEffect => false;

/// <summary>
/// Gets a value indicating whether this instance has memory write side effect.
/// </summary>
/// <value>
/// <c>true</c> if this instance has side effect; otherwise, <c>false</c>.
/// </value>
public virtual bool IsMemoryWrite => false;

/// <summary>
/// Gets a value indicating whether this instance has memory write side effect.
/// </summary>
/// <value>
/// <c>true</c> if this instance has side effect; otherwise, <c>false</c>.
/// </value>
public virtual bool IsMemoryRead => false;

/// <summary>
/// Gets a value indicating whether this instance has IO operation side effect.
/// </summary>
/// <value>
/// <c>true</c> if this instance has side effect; otherwise, <c>false</c>.
/// </value>
public virtual bool IsIOOperation => false;

/// <summary>
/// Gets a value indicating whether [variable operand count].
/// </summary>
/// <value>
/// <c>true</c> if [variable operand count]; otherwise, <c>false</c>.
/// </value>
public virtual bool VariableOperands => false;

/// <summary>
/// Gets a value indicating whether this <see cref="BaseInstruction"/> is commutative.
/// </summary>
/// <value>
/// <c>true</c> if commutative; otherwise, <c>false</c>.
/// </value>
public virtual bool IsCommutative => false;

/// <summary>
/// Gets a value indicating whether this instance is parameter load.
/// </summary>
/// <value>
/// <c>true</c> if this instance is parameter load; otherwise, <c>false</c>.
/// </value>
public virtual bool IsParameterLoad => false;

/// <summary>
/// Gets a value indicating whether this instance is parameter store.
/// </summary>
/// <value>
/// <c>true</c> if this instance is parameter store; otherwise, <c>false</c>.
/// </value>
public virtual bool IsParameterStore => false;

public virtual bool IsPlatformInstruction => false;

public virtual bool IsIRInstruction => false;

public virtual string Name { get; private set; }
public virtual bool IsPhiInstruction => false;

public virtual string AlternativeName => null;
public virtual bool IsIRBranchInstruction => false;

public virtual string FamilyName => null;
public virtual bool IsIRMoveInstruction => false;

public virtual string Modifier => null;
public virtual bool IsIRCompareInstruction => false;

public virtual string FullName { get; private set; }

public virtual string OpcodeName { get; private set; }

#endregion Properties
#endregion Is/Has Properties

#region Platform Properties

Expand Down

0 comments on commit ab6272e

Please sign in to comment.