diff --git a/Source/Data/IR-Instructions.json b/Source/Data/IR-Instructions.json
index ed548ca3ef..b2da705ba2 100644
--- a/Source/Data/IR-Instructions.json
+++ b/Source/Data/IR-Instructions.json
@@ -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",
@@ -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",
@@ -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",
@@ -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",
diff --git a/Source/Mosa.Compiler.Framework/Analysis/SparseConditionalConstantPropagation.cs b/Source/Mosa.Compiler.Framework/Analysis/SparseConditionalConstantPropagation.cs
index cbf1727816..27bd7ccae3 100644
--- a/Source/Mosa.Compiler.Framework/Analysis/SparseConditionalConstantPropagation.cs
+++ b/Source/Mosa.Compiler.Framework/Analysis/SparseConditionalConstantPropagation.cs
@@ -532,7 +532,7 @@ private bool ProcessInstruction(InstructionNode node)
{
CompareOperation(node);
}
- else if (IsPhiInstruction(instruction))
+ else if (instruction.IsPhiInstruction)
{
Phi(node);
}
diff --git a/Source/Mosa.Compiler.Framework/BaseInstruction.cs b/Source/Mosa.Compiler.Framework/BaseInstruction.cs
index 61852aa606..5b9b600a2c 100644
--- a/Source/Mosa.Compiler.Framework/BaseInstruction.cs
+++ b/Source/Mosa.Compiler.Framework/BaseInstruction.cs
@@ -31,16 +31,6 @@ public abstract class BaseInstruction
/// The operand result count.
public byte DefaultResultCount { get; protected set; }
- ///
- /// The type of the result type
- ///
- public virtual BuiltInType ResultType { get; protected set; } = BuiltInType.None;
-
- ///
- /// The type of the secondary result type
- ///
- public virtual BuiltInType ResultType2 { get; protected set; } = BuiltInType.None;
-
///
/// Determines flow behavior of this instruction.
///
@@ -51,103 +41,55 @@ public abstract class BaseInstruction
///
public virtual FlowControl FlowControl => FlowControl.Next;
- ///
- /// Gets a value indicating whether to [ignore during code generation].
- ///
- ///
- /// true if [ignore during code generation]; otherwise, false.
- ///
+ 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;
- ///
- /// Gets a value indicating whether to [ignore instruction's basic block].
- ///
- ///
- /// true if [ignore instruction basic block]; otherwise, false.
- ///
public virtual bool IgnoreInstructionBasicBlockTargets => false;
- ///
- /// Gets a value indicating whether this instance has an unspecified side effect.
- ///
- ///
- /// true if this instance has side effect; otherwise, false.
- ///
public virtual bool HasUnspecifiedSideEffect => false;
- ///
- /// Gets a value indicating whether this instance has memory write side effect.
- ///
- ///
- /// true if this instance has side effect; otherwise, false.
- ///
public virtual bool IsMemoryWrite => false;
- ///
- /// Gets a value indicating whether this instance has memory write side effect.
- ///
- ///
- /// true if this instance has side effect; otherwise, false.
- ///
public virtual bool IsMemoryRead => false;
- ///
- /// Gets a value indicating whether this instance has IO operation side effect.
- ///
- ///
- /// true if this instance has side effect; otherwise, false.
- ///
public virtual bool IsIOOperation => false;
- ///
- /// Gets a value indicating whether [variable operand count].
- ///
- ///
- /// true if [variable operand count]; otherwise, false.
- ///
- public virtual bool VariableOperands => false;
-
- ///
- /// Gets a value indicating whether this is commutative.
- ///
- ///
- /// true if commutative; otherwise, false.
- ///
public virtual bool IsCommutative => false;
- ///
- /// Gets a value indicating whether this instance is parameter load.
- ///
- ///
- /// true if this instance is parameter load; otherwise, false.
- ///
public virtual bool IsParameterLoad => false;
- ///
- /// Gets a value indicating whether this instance is parameter store.
- ///
- ///
- /// true if this instance is parameter store; otherwise, false.
- ///
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
diff --git a/Source/Mosa.Compiler.Framework/BaseMethodCompilerStage.cs b/Source/Mosa.Compiler.Framework/BaseMethodCompilerStage.cs
index ce59743762..e72bf29414 100644
--- a/Source/Mosa.Compiler.Framework/BaseMethodCompilerStage.cs
+++ b/Source/Mosa.Compiler.Framework/BaseMethodCompilerStage.cs
@@ -3,7 +3,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using Mosa.Compiler.Common.Exceptions;
-using Mosa.Compiler.Framework.IR;
using Mosa.Compiler.Framework.Linker;
using Mosa.Compiler.Framework.Trace;
using Mosa.Compiler.MosaTypeSystem;
@@ -482,7 +481,7 @@ public static void UpdatePhiBlock(BasicBlock phiBlock)
if (node.IsEmptyOrNop)
continue;
- if (!BaseMethodCompilerStage.IsPhiInstruction(node.Instruction))
+ if (!node.Instruction.IsPhiInstruction)
break;
UpdatePhi(node);
@@ -528,7 +527,7 @@ public static void RemoveBlockFromPhi(BasicBlock removedBlock, BasicBlock phiBlo
if (node.IsEmptyOrNop)
continue;
- if (!IsPhiInstruction(node.Instruction))
+ if (!node.Instruction.IsPhiInstruction)
break;
var sourceBlocks = node.PhiBlocks;
@@ -567,7 +566,7 @@ public static void UpdatePhiTarget(BasicBlock phiBlock, BasicBlock source, Basic
if (node.IsEmptyOrNop)
continue;
- if (!IsPhiInstruction(node.Instruction))
+ if (!node.Instruction.IsPhiInstruction)
break;
var index = node.PhiBlocks.IndexOf(source);
@@ -585,7 +584,7 @@ public static bool HasPhiInstruction(BasicBlock target)
if (node.IsEmptyOrNop)
continue;
- if (IsPhiInstruction(node.Instruction))
+ if (node.Instruction.IsPhiInstruction)
return true;
return false;
@@ -711,38 +710,6 @@ protected void PostEvent(CompilerEvent compileEvent, string message)
#region Helper Methods
- public static bool IsMoveInstruction(BaseInstruction instruction)
- {
- return instruction == IRInstruction.Move32
- || instruction == IRInstruction.Move64
- || instruction == IRInstruction.MoveObject
- || instruction == IRInstruction.MoveManagedPointer
- || instruction == IRInstruction.MoveR8
- || instruction == IRInstruction.MoveR4;
- }
-
- public static bool IsCompareInstruction(BaseInstruction instruction)
- {
- return instruction == IRInstruction.Compare32x32
- || instruction == IRInstruction.Compare32x64
- || instruction == IRInstruction.Compare64x32
- || instruction == IRInstruction.Compare64x64
- || instruction == IRInstruction.CompareObject
- || instruction == IRInstruction.CompareManagedPointer
- || instruction == IRInstruction.CompareR4
- || instruction == IRInstruction.CompareR8;
- }
-
- public static bool IsPhiInstruction(BaseInstruction instruction)
- {
- return instruction == IRInstruction.Phi32
- || instruction == IRInstruction.Phi64
- || instruction == IRInstruction.PhiObject
- || instruction == IRInstruction.PhiManagedPointer
- || instruction == IRInstruction.PhiR4
- || instruction == IRInstruction.PhiR8;
- }
-
public List AddMissingBlocksIfRequired(List blocks)
{
if (blocks.Count == BasicBlocks.Count)
@@ -840,14 +807,14 @@ protected bool CheckAllPhiInstructions()
if (node.IsEmptyOrNop)
continue;
- if (!IsPhiInstruction(node.Instruction))
+ if (!node.Instruction.IsPhiInstruction)
break;
foreach (var phiblock in node.PhiBlocks)
{
if (!block.PreviousBlocks.Contains(phiblock))
{
- throw new CompilerException("CheckAllPhiInstructions() failed in block: {block} at {node}!");
+ throw new CompilerException($"{FormattedStageName}:CheckAllPhiInstructions() failed in block: {block} at {node}!");
}
}
}
diff --git a/Source/Mosa.Compiler.Framework/BaseTransform.cs b/Source/Mosa.Compiler.Framework/BaseTransform.cs
index e9a669f207..59d4fd5006 100644
--- a/Source/Mosa.Compiler.Framework/BaseTransform.cs
+++ b/Source/Mosa.Compiler.Framework/BaseTransform.cs
@@ -7,7 +7,7 @@ namespace Mosa.Compiler.Framework;
[Flags]
public enum TransformType
-{ Transform, Auto, Manual, Optimization }
+{ Transform, Auto, Manual, Optimization, Window, Search }
public abstract class BaseTransform : IComparable
{
@@ -1012,11 +1012,6 @@ protected static bool IsNormal(ConditionCode conditionCode)
};
}
- public static bool IsPhiInstruction(BaseInstruction instruction)
- {
- return BaseCodeTransformationStage.IsPhiInstruction(instruction);
- }
-
#endregion Helpers
#region Block Helpers
diff --git a/Source/Mosa.Compiler.Framework/Compiler.cs b/Source/Mosa.Compiler.Framework/Compiler.cs
index bfc5a9ce2c..4945e05ee1 100644
--- a/Source/Mosa.Compiler.Framework/Compiler.cs
+++ b/Source/Mosa.Compiler.Framework/Compiler.cs
@@ -240,7 +240,7 @@ public Compiler(MosaCompiler mosaCompiler)
TraceLevel = CompilerSettings.TraceLevel;
Statistics = CompilerSettings.Statistics;
- PostEvent(CompilerEvent.CompileStart);
+ PostEvent(CompilerEvent.CompilerStart);
Linker = new MosaLinker(this);
@@ -402,7 +402,7 @@ internal void Setup()
public void ExecuteCompile()
{
- PostEvent(CompilerEvent.CompilingMethods);
+ PostEvent(CompilerEvent.CompilingMethodsStart);
while (true)
{
@@ -464,7 +464,7 @@ private MosaMethod CompileMethod(MosaMethod method, int threadID)
public void ExecuteCompile(int maxThreads)
{
- PostEvent(CompilerEvent.CompilingMethods);
+ PostEvent(CompilerEvent.CompilingMethodsStart);
if (maxThreads > 0)
{
@@ -547,7 +547,7 @@ internal void Finalization()
EmitCounters();
PostEvent(CompilerEvent.FinalizationEnd);
- PostEvent(CompilerEvent.CompileEnd);
+ PostEvent(CompilerEvent.CompilerEnd);
}
public void Stop()
diff --git a/Source/Mosa.Compiler.Framework/CompilerEvent.cs b/Source/Mosa.Compiler.Framework/CompilerEvent.cs
index cbb93f6477..ae21374402 100644
--- a/Source/Mosa.Compiler.Framework/CompilerEvent.cs
+++ b/Source/Mosa.Compiler.Framework/CompilerEvent.cs
@@ -4,10 +4,10 @@ namespace Mosa.Compiler.Framework.Trace;
public enum CompilerEvent
{
- CompileStart,
- CompileEnd,
+ CompilerStart,
+ CompilerEnd,
- CompilingMethods,
+ CompilingMethodsStart,
CompilingMethodsCompleted,
MethodCompileStart,
@@ -48,24 +48,24 @@ public static string ToText(this CompilerEvent stage)
{
return stage switch
{
- CompilerEvent.CompileStart => "Compile Started",
- CompilerEvent.CompileEnd => "Compile Completed",
- CompilerEvent.CompilingMethods => "Compiling Methods",
- CompilerEvent.CompilingMethodsCompleted => "Compiling Methods Completed",
- CompilerEvent.MethodCompileStart => "Method Compile Started",
- CompilerEvent.MethodCompileEnd => "Method Compile Completed",
+ CompilerEvent.CompilerStart => "Compiling",
+ CompilerEvent.CompilerEnd => "Compling [Completed]",
+ CompilerEvent.CompilingMethodsStart => "Compiling Methods",
+ CompilerEvent.CompilingMethodsCompleted => "Compiling Methods [Completed]",
+ CompilerEvent.MethodCompileStart => "Compiling Method",
+ CompilerEvent.MethodCompileEnd => "Compiling Method [Completed]",
CompilerEvent.MethodScheduled => "Method Scheduled",
CompilerEvent.InlineMethodsScheduled => "Inline Methods Scheduled",
- CompilerEvent.LinkingStart => "Linking Started",
- CompilerEvent.LinkingEnd => "Linking Completed",
- CompilerEvent.SetupStart => "Setup Started",
- CompilerEvent.SetupEnd => "Setup Completed",
- CompilerEvent.FinalizationStart => "Finalization Started",
- CompilerEvent.FinalizationEnd => "Finalization Completed",
- CompilerEvent.SetupStageStart => "Setup Stage Started",
- CompilerEvent.SetupStageEnd => "Setup Stage Completed",
- CompilerEvent.FinalizationStageStart => "Finalization Stage Started",
- CompilerEvent.FinalizationStageEnd => "Finalization Stage Completed",
+ CompilerEvent.LinkingStart => "Linking",
+ CompilerEvent.LinkingEnd => "Linking [Completed]",
+ CompilerEvent.SetupStart => "Setting Up",
+ CompilerEvent.SetupEnd => "Setting Up [Completed]",
+ CompilerEvent.FinalizationStart => "Finalizing",
+ CompilerEvent.FinalizationEnd => "Finalizing [Completed]",
+ CompilerEvent.SetupStageStart => "Setting Up Stage ",
+ CompilerEvent.SetupStageEnd => "Setting Up Stage [Completed]",
+ CompilerEvent.FinalizationStageStart => "Finalizing Stage",
+ CompilerEvent.FinalizationStageEnd => "Finalizing Stage Completed]",
CompilerEvent.DebugInfo => "Debug Info",
CompilerEvent.Warning => "Warning",
CompilerEvent.Error => "Error",
diff --git a/Source/Mosa.Compiler.Framework/IR/Branch32.cs b/Source/Mosa.Compiler.Framework/IR/Branch32.cs
index 6eec5ebaae..e77fd0170c 100644
--- a/Source/Mosa.Compiler.Framework/IR/Branch32.cs
+++ b/Source/Mosa.Compiler.Framework/IR/Branch32.cs
@@ -16,4 +16,6 @@ public Branch32()
}
public override FlowControl FlowControl => FlowControl.ConditionalBranch;
+
+ public override bool IsIRBranchInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/Branch64.cs b/Source/Mosa.Compiler.Framework/IR/Branch64.cs
index 9f9703b3bf..79bb79d480 100644
--- a/Source/Mosa.Compiler.Framework/IR/Branch64.cs
+++ b/Source/Mosa.Compiler.Framework/IR/Branch64.cs
@@ -16,4 +16,6 @@ public Branch64()
}
public override FlowControl FlowControl => FlowControl.ConditionalBranch;
+
+ public override bool IsIRBranchInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/BranchManagedPointer.cs b/Source/Mosa.Compiler.Framework/IR/BranchManagedPointer.cs
index f02e165bd8..c0a4123637 100644
--- a/Source/Mosa.Compiler.Framework/IR/BranchManagedPointer.cs
+++ b/Source/Mosa.Compiler.Framework/IR/BranchManagedPointer.cs
@@ -16,4 +16,6 @@ public BranchManagedPointer()
}
public override FlowControl FlowControl => FlowControl.ConditionalBranch;
+
+ public override bool IsIRBranchInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/BranchObject.cs b/Source/Mosa.Compiler.Framework/IR/BranchObject.cs
index c2b7dcba65..1647a9e977 100644
--- a/Source/Mosa.Compiler.Framework/IR/BranchObject.cs
+++ b/Source/Mosa.Compiler.Framework/IR/BranchObject.cs
@@ -16,4 +16,6 @@ public BranchObject()
}
public override FlowControl FlowControl => FlowControl.ConditionalBranch;
+
+ public override bool IsIRBranchInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/Compare32x32.cs b/Source/Mosa.Compiler.Framework/IR/Compare32x32.cs
index 997f96adf6..a9e58d4f3a 100644
--- a/Source/Mosa.Compiler.Framework/IR/Compare32x32.cs
+++ b/Source/Mosa.Compiler.Framework/IR/Compare32x32.cs
@@ -17,5 +17,5 @@ public Compare32x32()
{
}
- public override BuiltInType ResultType => BuiltInType.Boolean;
+ public override bool IsIRCompareInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/Compare32x64.cs b/Source/Mosa.Compiler.Framework/IR/Compare32x64.cs
index 40ef8525e7..8bf0545202 100644
--- a/Source/Mosa.Compiler.Framework/IR/Compare32x64.cs
+++ b/Source/Mosa.Compiler.Framework/IR/Compare32x64.cs
@@ -17,5 +17,5 @@ public Compare32x64()
{
}
- public override BuiltInType ResultType => BuiltInType.Boolean;
+ public override bool IsIRCompareInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/Compare64x32.cs b/Source/Mosa.Compiler.Framework/IR/Compare64x32.cs
index bb380a1089..51f9567d4d 100644
--- a/Source/Mosa.Compiler.Framework/IR/Compare64x32.cs
+++ b/Source/Mosa.Compiler.Framework/IR/Compare64x32.cs
@@ -17,5 +17,5 @@ public Compare64x32()
{
}
- public override BuiltInType ResultType => BuiltInType.Boolean;
+ public override bool IsIRCompareInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/Compare64x64.cs b/Source/Mosa.Compiler.Framework/IR/Compare64x64.cs
index 092eaa2340..8464ce028a 100644
--- a/Source/Mosa.Compiler.Framework/IR/Compare64x64.cs
+++ b/Source/Mosa.Compiler.Framework/IR/Compare64x64.cs
@@ -17,5 +17,5 @@ public Compare64x64()
{
}
- public override BuiltInType ResultType => BuiltInType.Boolean;
+ public override bool IsIRCompareInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/CompareManagedPointer.cs b/Source/Mosa.Compiler.Framework/IR/CompareManagedPointer.cs
index de4b3a1482..0842451e30 100644
--- a/Source/Mosa.Compiler.Framework/IR/CompareManagedPointer.cs
+++ b/Source/Mosa.Compiler.Framework/IR/CompareManagedPointer.cs
@@ -17,5 +17,5 @@ public CompareManagedPointer()
{
}
- public override BuiltInType ResultType => BuiltInType.Boolean;
+ public override bool IsIRCompareInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/CompareObject.cs b/Source/Mosa.Compiler.Framework/IR/CompareObject.cs
index b68b71364f..fcea6cdc21 100644
--- a/Source/Mosa.Compiler.Framework/IR/CompareObject.cs
+++ b/Source/Mosa.Compiler.Framework/IR/CompareObject.cs
@@ -17,5 +17,5 @@ public CompareObject()
{
}
- public override BuiltInType ResultType => BuiltInType.Boolean;
+ public override bool IsIRCompareInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/CompareR4.cs b/Source/Mosa.Compiler.Framework/IR/CompareR4.cs
index fc30f5a8ff..6a43fbbaa2 100644
--- a/Source/Mosa.Compiler.Framework/IR/CompareR4.cs
+++ b/Source/Mosa.Compiler.Framework/IR/CompareR4.cs
@@ -17,5 +17,5 @@ public CompareR4()
{
}
- public override BuiltInType ResultType => BuiltInType.Boolean;
+ public override bool IsIRCompareInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/CompareR8.cs b/Source/Mosa.Compiler.Framework/IR/CompareR8.cs
index e214e79ca8..2625db3f5e 100644
--- a/Source/Mosa.Compiler.Framework/IR/CompareR8.cs
+++ b/Source/Mosa.Compiler.Framework/IR/CompareR8.cs
@@ -17,5 +17,5 @@ public CompareR8()
{
}
- public override BuiltInType ResultType => BuiltInType.Boolean;
+ public override bool IsIRCompareInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/GetHigh32.cs b/Source/Mosa.Compiler.Framework/IR/GetHigh32.cs
index 83d021b576..8e2ad67f62 100644
--- a/Source/Mosa.Compiler.Framework/IR/GetHigh32.cs
+++ b/Source/Mosa.Compiler.Framework/IR/GetHigh32.cs
@@ -16,8 +16,4 @@ public GetHigh32()
: base(1, 1)
{
}
-
- public override BuiltInType ResultType => BuiltInType.UInt32;
-
- public override BuiltInType ResultType2 => BuiltInType.UInt32;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/GetLow32.cs b/Source/Mosa.Compiler.Framework/IR/GetLow32.cs
index 36505668bc..d1f189f15a 100644
--- a/Source/Mosa.Compiler.Framework/IR/GetLow32.cs
+++ b/Source/Mosa.Compiler.Framework/IR/GetLow32.cs
@@ -16,8 +16,4 @@ public GetLow32()
: base(1, 1)
{
}
-
- public override BuiltInType ResultType => BuiltInType.UInt32;
-
- public override BuiltInType ResultType2 => BuiltInType.UInt32;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/Move32.cs b/Source/Mosa.Compiler.Framework/IR/Move32.cs
index 7c7ab0717c..f1807e3b1d 100644
--- a/Source/Mosa.Compiler.Framework/IR/Move32.cs
+++ b/Source/Mosa.Compiler.Framework/IR/Move32.cs
@@ -14,4 +14,6 @@ public Move32()
: base(1, 1)
{
}
+
+ public override bool IsIRMoveInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/Move64.cs b/Source/Mosa.Compiler.Framework/IR/Move64.cs
index 3ba6706cd0..6d1f70a550 100644
--- a/Source/Mosa.Compiler.Framework/IR/Move64.cs
+++ b/Source/Mosa.Compiler.Framework/IR/Move64.cs
@@ -14,4 +14,6 @@ public Move64()
: base(1, 1)
{
}
+
+ public override bool IsIRMoveInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/MoveCompound.cs b/Source/Mosa.Compiler.Framework/IR/MoveCompound.cs
index a9b85a7c13..5d73b1ab9c 100644
--- a/Source/Mosa.Compiler.Framework/IR/MoveCompound.cs
+++ b/Source/Mosa.Compiler.Framework/IR/MoveCompound.cs
@@ -14,4 +14,6 @@ public MoveCompound()
: base(1, 1)
{
}
+
+ public override bool IsIRMoveInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/MoveManagedPointer.cs b/Source/Mosa.Compiler.Framework/IR/MoveManagedPointer.cs
index 1c9e08ea55..81a8ecc043 100644
--- a/Source/Mosa.Compiler.Framework/IR/MoveManagedPointer.cs
+++ b/Source/Mosa.Compiler.Framework/IR/MoveManagedPointer.cs
@@ -14,4 +14,6 @@ public MoveManagedPointer()
: base(1, 1)
{
}
+
+ public override bool IsIRMoveInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/MoveObject.cs b/Source/Mosa.Compiler.Framework/IR/MoveObject.cs
index 8c796ccf9c..22492d4c74 100644
--- a/Source/Mosa.Compiler.Framework/IR/MoveObject.cs
+++ b/Source/Mosa.Compiler.Framework/IR/MoveObject.cs
@@ -14,4 +14,6 @@ public MoveObject()
: base(1, 1)
{
}
+
+ public override bool IsIRMoveInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/MoveR4.cs b/Source/Mosa.Compiler.Framework/IR/MoveR4.cs
index 033aab5e48..d48d4dc4bd 100644
--- a/Source/Mosa.Compiler.Framework/IR/MoveR4.cs
+++ b/Source/Mosa.Compiler.Framework/IR/MoveR4.cs
@@ -14,4 +14,6 @@ public MoveR4()
: base(1, 1)
{
}
+
+ public override bool IsIRMoveInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/MoveR8.cs b/Source/Mosa.Compiler.Framework/IR/MoveR8.cs
index 1a1c2adb6c..99a42c86c6 100644
--- a/Source/Mosa.Compiler.Framework/IR/MoveR8.cs
+++ b/Source/Mosa.Compiler.Framework/IR/MoveR8.cs
@@ -14,4 +14,6 @@ public MoveR8()
: base(1, 1)
{
}
+
+ public override bool IsIRMoveInstruction => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/Phi32.cs b/Source/Mosa.Compiler.Framework/IR/Phi32.cs
index c07adec65c..c1cc59f390 100644
--- a/Source/Mosa.Compiler.Framework/IR/Phi32.cs
+++ b/Source/Mosa.Compiler.Framework/IR/Phi32.cs
@@ -15,5 +15,7 @@ public Phi32()
{
}
+ public override bool IsPhiInstruction => true;
+
public override bool VariableOperands => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/Phi64.cs b/Source/Mosa.Compiler.Framework/IR/Phi64.cs
index 7d3acdc7b9..b91237039f 100644
--- a/Source/Mosa.Compiler.Framework/IR/Phi64.cs
+++ b/Source/Mosa.Compiler.Framework/IR/Phi64.cs
@@ -15,5 +15,7 @@ public Phi64()
{
}
+ public override bool IsPhiInstruction => true;
+
public override bool VariableOperands => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/PhiManagedPointer.cs b/Source/Mosa.Compiler.Framework/IR/PhiManagedPointer.cs
index bccb06e486..97b0b33b83 100644
--- a/Source/Mosa.Compiler.Framework/IR/PhiManagedPointer.cs
+++ b/Source/Mosa.Compiler.Framework/IR/PhiManagedPointer.cs
@@ -15,5 +15,7 @@ public PhiManagedPointer()
{
}
+ public override bool IsPhiInstruction => true;
+
public override bool VariableOperands => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/PhiObject.cs b/Source/Mosa.Compiler.Framework/IR/PhiObject.cs
index c09598d53d..2a35be9024 100644
--- a/Source/Mosa.Compiler.Framework/IR/PhiObject.cs
+++ b/Source/Mosa.Compiler.Framework/IR/PhiObject.cs
@@ -15,5 +15,7 @@ public PhiObject()
{
}
+ public override bool IsPhiInstruction => true;
+
public override bool VariableOperands => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/PhiR4.cs b/Source/Mosa.Compiler.Framework/IR/PhiR4.cs
index aae6b5dcad..0372a21db0 100644
--- a/Source/Mosa.Compiler.Framework/IR/PhiR4.cs
+++ b/Source/Mosa.Compiler.Framework/IR/PhiR4.cs
@@ -15,5 +15,7 @@ public PhiR4()
{
}
+ public override bool IsPhiInstruction => true;
+
public override bool VariableOperands => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/PhiR8.cs b/Source/Mosa.Compiler.Framework/IR/PhiR8.cs
index e5401f5851..57def7fa82 100644
--- a/Source/Mosa.Compiler.Framework/IR/PhiR8.cs
+++ b/Source/Mosa.Compiler.Framework/IR/PhiR8.cs
@@ -15,5 +15,7 @@ public PhiR8()
{
}
+ public override bool IsPhiInstruction => true;
+
public override bool VariableOperands => true;
}
diff --git a/Source/Mosa.Compiler.Framework/IR/To64.cs b/Source/Mosa.Compiler.Framework/IR/To64.cs
index f66e31ee0c..4deca6f807 100644
--- a/Source/Mosa.Compiler.Framework/IR/To64.cs
+++ b/Source/Mosa.Compiler.Framework/IR/To64.cs
@@ -16,6 +16,4 @@ public To64()
: base(2, 1)
{
}
-
- public override BuiltInType ResultType => BuiltInType.UInt64;
}
diff --git a/Source/Mosa.Compiler.Framework/Stages/EnterSSAStage.cs b/Source/Mosa.Compiler.Framework/Stages/EnterSSAStage.cs
index 41af4a47b6..993ce80d75 100644
--- a/Source/Mosa.Compiler.Framework/Stages/EnterSSAStage.cs
+++ b/Source/Mosa.Compiler.Framework/Stages/EnterSSAStage.cs
@@ -179,7 +179,7 @@ private void UpdateOperands(BasicBlock block)
if (node.IsEmptyOrNop)
continue;
- if (!IsPhiInstruction(node.Instruction))
+ if (!node.Instruction.IsPhiInstruction)
{
for (var i = 0; i < node.OperandCount; ++i)
{
@@ -225,7 +225,7 @@ private void UpdatePHIs(BasicBlock block)
if (node.IsEmptyOrNop)
continue;
- if (!IsPhiInstruction(node.Instruction))
+ if (!node.Instruction.IsPhiInstruction)
break;
var op = node.GetOperand(index);
diff --git a/Source/Mosa.Compiler.Framework/Stages/ExitSSAStage.cs b/Source/Mosa.Compiler.Framework/Stages/ExitSSAStage.cs
index 975ebcb3da..00a8c7df27 100644
--- a/Source/Mosa.Compiler.Framework/Stages/ExitSSAStage.cs
+++ b/Source/Mosa.Compiler.Framework/Stages/ExitSSAStage.cs
@@ -35,7 +35,7 @@ protected override void Run()
InstructionCount.Increment();
- if (!IsPhiInstruction(node.Instruction))
+ if (!node.Instruction.IsPhiInstruction)
break;
if (node.OperandCount != node.Block.PreviousBlocks.Count)
diff --git a/Source/Mosa.Compiler.Framework/Stages/LoopInvariantCodeMotionStage.cs b/Source/Mosa.Compiler.Framework/Stages/LoopInvariantCodeMotionStage.cs
index 777a1bc566..18310286d8 100644
--- a/Source/Mosa.Compiler.Framework/Stages/LoopInvariantCodeMotionStage.cs
+++ b/Source/Mosa.Compiler.Framework/Stages/LoopInvariantCodeMotionStage.cs
@@ -300,7 +300,7 @@ private BasicBlock CreatePreHeader(Loop loop)
if (node.IsEmptyOrNop)
continue;
- if (!IsPhiInstruction(node.Instruction))
+ if (!node.Instruction.IsPhiInstruction)
break;
var landingpadSourceBlocks = new List(node.OperandCount);
diff --git a/Source/Mosa.Compiler.Framework/Stages/SparseConditionalConstantPropagationStage.cs b/Source/Mosa.Compiler.Framework/Stages/SparseConditionalConstantPropagationStage.cs
index f3d804eaa4..ff44423619 100644
--- a/Source/Mosa.Compiler.Framework/Stages/SparseConditionalConstantPropagationStage.cs
+++ b/Source/Mosa.Compiler.Framework/Stages/SparseConditionalConstantPropagationStage.cs
@@ -21,6 +21,8 @@ public class SparseConditionalConstantPropagationStage : BaseMethodCompilerStage
private readonly Counter DeadBlockCount = new Counter("SparseConditionalConstantPropagationStage.DeadBlocks");
private readonly Counter InstructionsRemovedCount = new Counter("SparseConditionalConstantPropagationStage.IRInstructionRemoved");
+ protected int Steps;
+
protected bool changed;
protected override void Initialize()
@@ -49,6 +51,9 @@ protected override void Run()
if (HasProtectedRegions)
return;
+ Steps = 0;
+ MethodCompiler.CreateTranformInstructionTrace(this, Steps++);
+
var analysis = new SparseConditionalConstantPropagation(BasicBlocks, CreateTraceLog, Is32BitPlatform);
var deadBlocks = analysis.GetDeadBlocked();
@@ -130,6 +135,8 @@ protected void ReplaceVirtualRegisterWithConstant(Operand target, ulong value)
trace?.Log($"REMOVED:\t{defNode}");
defNode.SetNop();
InstructionsRemovedCount.Increment();
+
+ MethodCompiler.CreateTranformInstructionTrace(this, Steps++);
}
protected void RemoveDeadBlocks(List deadBlocks)
@@ -137,6 +144,8 @@ protected void RemoveDeadBlocks(List deadBlocks)
foreach (var block in deadBlocks)
{
RemoveBranchesToDeadBlocks(block);
+
+ MethodCompiler.CreateTranformInstructionTrace(this, Steps++);
}
}
@@ -159,7 +168,7 @@ protected void RemoveBranchesToDeadBlocks(BasicBlock deadBlock)
if (node.BranchTargetsCount == 0)
continue;
- if (node.Instruction == IRInstruction.Branch32 || node.Instruction == IRInstruction.Branch64 || node.Instruction == IRInstruction.BranchObject)
+ if (node.Instruction.IsIRBranchInstruction)
{
trace?.Log("*** RemoveBranchesToDeadBlocks");
trace?.Log($"REMOVED:\t{node}");
@@ -195,7 +204,7 @@ private void CheckAndClearEmptyBlock(BasicBlock block)
EmptyBlockOfAllInstructions(block, true);
- //UpdatePhiBlocks(nextBlocks);
+ UpdatePhiBlocks(nextBlocks);
foreach (var next in nextBlocks)
{
diff --git a/Source/Mosa.Compiler.Framework/Stages/ValueNumberingStage.cs b/Source/Mosa.Compiler.Framework/Stages/ValueNumberingStage.cs
index 3e2176c61c..d11339a0e5 100644
--- a/Source/Mosa.Compiler.Framework/Stages/ValueNumberingStage.cs
+++ b/Source/Mosa.Compiler.Framework/Stages/ValueNumberingStage.cs
@@ -215,7 +215,7 @@ private void ValueNumber(BasicBlock block, out List nextblocks, out
if (node.IsEmptyOrNop)
continue;
- if (IsPhiInstruction(node.Instruction))
+ if (node.Instruction.IsPhiInstruction)
{
// Validate all successor are already processed
// and if not, just set the value number
@@ -281,7 +281,7 @@ private void ValueNumber(BasicBlock block, out List nextblocks, out
node.Operand2 = operand1;
}
- if (IsMoveInstruction(node.Instruction))
+ if (node.Instruction.IsIRMoveInstruction)
{
if (node.Result.IsCPURegister || node.Operand1.IsCPURegister)
{
@@ -372,7 +372,7 @@ private void ValueNumber(BasicBlock block, out List nextblocks, out
AddExpressionToHashTable(newExpression2);
newExpressions.Add(newExpression2);
}
- else if (IsCompareInstruction(node.Instruction) && node.Operand1 != node.Operand2 && node.ConditionCode != ConditionCode.Equal && node.ConditionCode != ConditionCode.NotEqual)
+ else if (node.Instruction.IsIRCompareInstruction && node.Operand1 != node.Operand2 && node.ConditionCode != ConditionCode.Equal && node.ConditionCode != ConditionCode.NotEqual)
{
var newExpression2 = new Expression
{
@@ -576,7 +576,7 @@ private void SetValueNumber(Operand operand, Operand valueVumber)
private bool IsPhiUseless(InstructionNode node)
{
- Debug.Assert(IsPhiInstruction(node.Instruction));
+ Debug.Assert(node.Instruction.IsPhiInstruction);
var operand = node.Operand1;
var operandVN = GetValueNumber(operand);
@@ -592,8 +592,8 @@ private bool IsPhiUseless(InstructionNode node)
private bool ArePhisRedundant(InstructionNode a, InstructionNode b)
{
- Debug.Assert(IsPhiInstruction(a.Instruction));
- Debug.Assert(IsPhiInstruction(b.Instruction));
+ Debug.Assert(a.Instruction.IsPhiInstruction);
+ Debug.Assert(b.Instruction.IsPhiInstruction);
if (a.OperandCount != b.OperandCount)
return false;
@@ -657,10 +657,10 @@ private void UpdateNodeWithValueNumbers(InstructionNode node)
else
{
// value has not been encountered yet --- skip it for now
- if (IsPhiInstruction(node.Instruction))
+ if (node.Instruction.IsPhiInstruction)
continue;
- //Debug.Assert(IsPhiInstruction(node.Instruction));
+ //Debug.Assert(node.Instruction.IsPhiInstruction);
//MethodCompiler.Compiler.Stop();
//return;
@@ -681,7 +681,7 @@ private void UpdatePhiSuccesors(BasicBlock block)
if (node.IsEmptyOrNop)
continue;
- if (!IsPhiInstruction(node.Instruction))
+ if (!node.Instruction.IsPhiInstruction)
break;
// update operands with their value number
@@ -699,7 +699,7 @@ private Operand CheckRedundant(InstructionNode node)
if (previousPhi.IsEmptyOrNop)
continue;
- Debug.Assert(IsPhiInstruction(previousPhi.Instruction));
+ Debug.Assert(previousPhi.Instruction.IsPhiInstruction);
if (ArePhisRedundant(node, previousPhi))
{
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/ManualTransforms.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/ManualTransforms.cs
index 0eb61f1413..9b22927565 100644
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/ManualTransforms.cs
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/ManualTransforms.cs
@@ -274,5 +274,8 @@ public static class ManualTransforms
new CodeMotion.LoadParamSignExtend8x32(),
new CodeMotion.LoadParamZeroExtend16x32(),
new CodeMotion.LoadParamZeroExtend8x32(),
+
+ new Overwrite.Move32Overwrite(),
+ new Overwrite.Move64Overwrite(),
};
}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/Overwrite/Move32Overwrite.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/Overwrite/Move32Overwrite.cs
new file mode 100644
index 0000000000..17fd3a87fa
--- /dev/null
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/Overwrite/Move32Overwrite.cs
@@ -0,0 +1,65 @@
+// Copyright (c) MOSA Project. Licensed under the New BSD License.
+
+namespace Mosa.Compiler.Framework.Transforms.Optimizations.Manual.Overwrite;
+
+///
+/// Move32Overwrite
+///
+[Transform("IR.Optimizations.Manual.Overwrite")]
+public sealed class Move32Overwrite : BaseTransform
+{
+ public Move32Overwrite() : base(IRInstruction.Move32, TransformType.Manual | TransformType.Optimization | TransformType.Search)
+ {
+ }
+
+ public override bool Match(Context context, TransformContext transform)
+ {
+ if (!context.Block.IsPrologue)
+ return false;
+
+ if (!context.Operand1.IsConstant)
+ return false;
+
+ if (context.Result.Uses.Count <= 1)
+ return false;
+
+ if (context.Result.Definitions.Count == 1)
+ return false;
+
+ var targets = context.Result.Definitions;
+
+ var uses = context.Result.Uses;
+ var at = context.Node;
+
+ while (true)
+ {
+ at = at.Next;
+
+ if (at.IsEmptyOrNop)
+ continue;
+
+ if (at.IsBlockEndInstruction)
+ {
+ at = at.Block.NextBlocks[0].First;
+
+ if (at.Block.NextBlocks.Count != 1)
+ return false;
+
+ continue;
+ }
+
+ if (uses.Contains(at))
+ return false;
+
+ if (targets.Contains(at))
+ break;
+ }
+
+ return true;
+ }
+
+ public override void Transform(Context context, TransformContext transform)
+ {
+ context.SetNop();
+ }
+}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/Overwrite/Move64Overwrite.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/Overwrite/Move64Overwrite.cs
new file mode 100644
index 0000000000..5b3bb1e55e
--- /dev/null
+++ b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/Overwrite/Move64Overwrite.cs
@@ -0,0 +1,65 @@
+// Copyright (c) MOSA Project. Licensed under the New BSD License.
+
+namespace Mosa.Compiler.Framework.Transforms.Optimizations.Manual.Overwrite;
+
+///
+/// Move64Overwrite
+///
+[Transform("IR.Optimizations.Manual.Overwrite")]
+public sealed class Move64Overwrite : BaseTransform
+{
+ public Move64Overwrite() : base(IRInstruction.Move64, TransformType.Manual | TransformType.Optimization | TransformType.Search)
+ {
+ }
+
+ public override bool Match(Context context, TransformContext transform)
+ {
+ if (!context.Block.IsPrologue)
+ return false;
+
+ if (!context.Operand1.IsConstant)
+ return false;
+
+ if (context.Result.Uses.Count <= 1)
+ return false;
+
+ if (context.Result.Definitions.Count == 1)
+ return false;
+
+ var targets = context.Result.Definitions;
+
+ var uses = context.Result.Uses;
+ var at = context.Node;
+
+ while (true)
+ {
+ at = at.Next;
+
+ if (at.IsEmptyOrNop)
+ continue;
+
+ if (at.IsBlockEndInstruction)
+ {
+ at = at.Block.NextBlocks[0].First;
+
+ if (at.Block.NextBlocks.Count != 1)
+ return false;
+
+ continue;
+ }
+
+ if (uses.Contains(at))
+ return false;
+
+ if (targets.Contains(at))
+ break;
+ }
+
+ return true;
+ }
+
+ public override void Transform(Context context, TransformContext transform)
+ {
+ context.SetNop();
+ }
+}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/Special/PromoteAddressOf32.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/Special/PromoteAddressOf32.cs
deleted file mode 100644
index a40c0be740..0000000000
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/Special/PromoteAddressOf32.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) MOSA Project. Licensed under the New BSD License.
-
-namespace Mosa.Compiler.Framework.Transforms.Optimizations.Manual.Special;
-
-public sealed class PromoteAddressOf32 : BaseTransform
-{
- public PromoteAddressOf32() : base(IRInstruction.AddressOf, TransformType.Manual | TransformType.Optimization)
- {
- }
-
- public override bool Match(Context context, TransformContext transform)
- {
- if (!context.Operand1.IsLocalStack)
- return false;
-
- if (context.Operand1.Uses.Count != 2)
- return false;
-
- if (context.Result.Uses.Count != 1)
- return false;
-
- if (!IsSSAForm(context.Result))
- return false;
-
- var store = context.Result.Uses[0];
-
- if (store.Instruction != IRInstruction.Store32)
- return false;
-
- if (store.Operand1 != context.Result)
- return false;
-
- if (!store.Operand2.IsConstantZero)
- return false;
-
- var load = context.Operand1.Uses[0] != context.Node
- ? context.Operand1.Uses[0]
- : context.Operand1.Uses[1];
-
- if (load.Instruction != IRInstruction.Load32)
- return false;
-
- if (load.Operand1 != transform.StackFrame)
- return false;
-
- return true;
- }
-
- public override void Transform(Context context, TransformContext transform)
- {
- var store = context.Result.Uses[0];
-
- var load = context.Operand1.Uses[0] != context.Node
- ? context.Operand1.Uses[0]
- : context.Operand1.Uses[1];
-
- load.SetInstruction(IRInstruction.MoveManagedPointer, load.Result, store.Operand3);
- context.SetNop();
- store.SetNop();
- }
-}
diff --git a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/Special/PromoteAddressOf64.cs b/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/Special/PromoteAddressOf64.cs
deleted file mode 100644
index bdb2d84292..0000000000
--- a/Source/Mosa.Compiler.Framework/Transforms/Optimizations/Manual/Special/PromoteAddressOf64.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) MOSA Project. Licensed under the New BSD License.
-
-namespace Mosa.Compiler.Framework.Transforms.Optimizations.Manual.Special;
-
-public sealed class PromoteAddressOf64 : BaseTransform
-{
- public PromoteAddressOf64() : base(IRInstruction.AddressOf, TransformType.Manual | TransformType.Optimization)
- {
- }
-
- public override bool Match(Context context, TransformContext transform)
- {
- if (!context.Operand1.IsLocalStack)
- return false;
-
- if (context.Operand1.Uses.Count != 2)
- return false;
-
- if (context.Result.Uses.Count != 1)
- return false;
-
- if (!IsSSAForm(context.Result))
- return false;
-
- var store = context.Result.Uses[0];
-
- if (store.Instruction != IRInstruction.Store64)
- return false;
-
- if (store.Operand1 != context.Result)
- return false;
-
- if (!store.Operand2.IsConstantZero)
- return false;
-
- var load = context.Operand1.Uses[0] != context.Node
- ? context.Operand1.Uses[0]
- : context.Operand1.Uses[1];
-
- if (load.Instruction != IRInstruction.Load64)
- return false;
-
- if (load.Operand1 != transform.StackFrame)
- return false;
-
- return true;
- }
-
- public override void Transform(Context context, TransformContext transform)
- {
- var store = context.Result.Uses[0];
-
- var load = context.Operand1.Uses[0] != context.Node
- ? context.Operand1.Uses[0]
- : context.Operand1.Uses[1];
-
- load.SetInstruction(IRInstruction.MoveManagedPointer, load.Result, store.Operand3);
- context.SetNop();
- store.SetNop();
- }
-}
diff --git a/Source/Mosa.Utility.Configuration/CommandLineArguments.cs b/Source/Mosa.Utility.Configuration/CommandLineArguments.cs
index 6da7769feb..49d829afaf 100644
--- a/Source/Mosa.Utility.Configuration/CommandLineArguments.cs
+++ b/Source/Mosa.Utility.Configuration/CommandLineArguments.cs
@@ -64,6 +64,8 @@ private static List GetMap()
new Argument { Name = "-output-hash", Setting = "CompilerDebug.PreLinkHashFile", Value = "%DEFAULT%"},
new Argument { Name = "-output-hash", Setting = "CompilerDebug.PostLinkHashFile", Value = "%DEFAULT%"},
+ new Argument { Name = "-output-debug-file", Setting = "CompilerDebug.DebugFile"},
+
new Argument { Name = "-check", Setting = "CompilerDebug.FullCheckMode", Value = "true"},
new Argument { Name = "-platform", Setting = "Compiler.Platform"},
diff --git a/Source/Mosa.Utility.Launcher/Builder.cs b/Source/Mosa.Utility.Launcher/Builder.cs
index 8d40b7b60e..ecd3be2f6f 100644
--- a/Source/Mosa.Utility.Launcher/Builder.cs
+++ b/Source/Mosa.Utility.Launcher/Builder.cs
@@ -316,7 +316,7 @@ private void GenerateASMFile()
private void NotifyEvent(CompilerEvent compilerEvent, string message, int threadID)
{
- if (compilerEvent is CompilerEvent.CompileStart or CompilerEvent.CompileEnd or CompilerEvent.CompilingMethods or CompilerEvent.CompilingMethodsCompleted or CompilerEvent.InlineMethodsScheduled or CompilerEvent.LinkingStart or CompilerEvent.LinkingEnd or CompilerEvent.Warning or CompilerEvent.Error or CompilerEvent.Exception)
+ if (compilerEvent is CompilerEvent.CompilerStart or CompilerEvent.CompilerEnd or CompilerEvent.CompilingMethodsStart or CompilerEvent.CompilingMethodsCompleted or CompilerEvent.InlineMethodsScheduled or CompilerEvent.LinkingStart or CompilerEvent.LinkingEnd or CompilerEvent.Warning or CompilerEvent.Error or CompilerEvent.Exception)
{
var status = $"Compiling: {$"{(DateTime.Now - CompileStartTime).TotalSeconds:0.00}"} secs: {compilerEvent.ToText()}";
diff --git a/Source/Mosa.Utility.Launcher/Starter.cs b/Source/Mosa.Utility.Launcher/Starter.cs
index 668d5b3f2c..4152735a72 100644
--- a/Source/Mosa.Utility.Launcher/Starter.cs
+++ b/Source/Mosa.Utility.Launcher/Starter.cs
@@ -409,10 +409,10 @@ private void LaunchDebugger()
// FIXME!!!
var argMap = CommandLineArguments.Map;
- var arg = $" {argMap.Find((x) => x.Setting == "CompilerDebug.DebugFile").Name} {Path.Combine(LauncherSettings.TemporaryFolder, Path.GetFileNameWithoutExtension(LauncherSettings.ImageFile) + ".debug")}";
- arg += $" {argMap.Find((x) => x.Setting == "GDB.Host").Name} {LauncherSettings.GDBHost}";
- arg += $" {argMap.Find((x) => x.Setting == "GDB.Port").Name} {LauncherSettings.GDBPort}";
- arg += $" {argMap.Find((x) => x.Setting == "Image.ImageFile").Name} {Quote(LauncherSettings.ImageFile)}";
+ var arg = $" -output-debug-file {Path.Combine(LauncherSettings.TemporaryFolder, Path.GetFileNameWithoutExtension(LauncherSettings.ImageFile) + ".debug")}";
+ arg += $" -gdb-host {LauncherSettings.GDBHost}";
+ arg += $" -gdb-port {LauncherSettings.GDBPort}";
+ arg += $" -image {Quote(LauncherSettings.ImageFile)}";
LaunchApplication("Mosa.Tool.Debugger.exe", arg);
}
@@ -425,8 +425,7 @@ private void LaunchGDB()
arg = $"{arg} -s {Quote(Path.Combine(LauncherSettings.TemporaryFolder, Path.GetFileNameWithoutExtension(LauncherSettings.ImageFile) + ".bin"))}";
arg = $"{arg} -x {Quote(gdbscript)}";
- // FIXME!
- var symbol = Linker.GetSymbol("Default::MultibootInit():System.Void");
+ var symbol = Linker.EntryPoint;
var breakAddress = symbol.VirtualAddress;
var sb = new StringBuilder();
diff --git a/Source/Mosa.Utility.SourceCodeGenerator/BuildIRInstructionFiles.cs b/Source/Mosa.Utility.SourceCodeGenerator/BuildIRInstructionFiles.cs
index 46f94d159f..4ef12b8c0b 100644
--- a/Source/Mosa.Utility.SourceCodeGenerator/BuildIRInstructionFiles.cs
+++ b/Source/Mosa.Utility.SourceCodeGenerator/BuildIRInstructionFiles.cs
@@ -56,16 +56,28 @@ protected override void Body(dynamic node = null)
Lines.AppendLine("\tpublic override FlowControl FlowControl => FlowControl." + node.FlowControl + ";");
}
- if (node.ResultType != null && node.ResultType != "")
+ if (node.Branch != null && node.Branch == "true")
{
Lines.AppendLine();
- Lines.AppendLine("\tpublic override BuiltInType ResultType => BuiltInType." + node.ResultType + ";");
+ Lines.AppendLine("\tpublic override bool IsIRBranchInstruction => true;");
}
- if (node.ResultType2 != null && node.ResultType2 != "")
+ if (node.Phi != null && node.Phi == "true")
{
Lines.AppendLine();
- Lines.AppendLine("\tpublic override BuiltInType ResultType2 => BuiltInType." + node.ResultType2 + ";");
+ Lines.AppendLine("\tpublic override bool IsPhiInstruction => true;");
+ }
+
+ if (node.Move != null && node.Move == "true")
+ {
+ Lines.AppendLine();
+ Lines.AppendLine("\tpublic override bool IsIRMoveInstruction => true;");
+ }
+
+ if (node.Compare != null && node.Compare == "true")
+ {
+ Lines.AppendLine();
+ Lines.AppendLine("\tpublic override bool IsIRCompareInstruction => true;");
}
if (node.IgnoreDuringCodeGeneration != null && node.IgnoreDuringCodeGeneration == "true")