Skip to content

Commit

Permalink
WIP - ARMv8A32 (#1108)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiphil committed Aug 7, 2023
1 parent 490b42d commit a1eaa31
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Source/Data/ARMv8A32-Instructions.json
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@
"OpcodeEncoding": [
{
"Condition": "[constant]",
"Encoding": "conditional|1011|rel24:label"
"Encoding": "conditional|1011|rel24:o1"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Compiler.Framework/CompilerEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static string ToText(this CompilerEvent stage)
CompilerEvent.SetupStageStart => "Setting Up Stage ",
CompilerEvent.SetupStageEnd => "Setting Up Stage [Completed]",
CompilerEvent.FinalizationStageStart => "Finalizing Stage",
CompilerEvent.FinalizationStageEnd => "Finalizing Stage Completed]",
CompilerEvent.FinalizationStageEnd => "Finalizing Stage [Completed]",
CompilerEvent.DebugInfo => "Debug Info",
CompilerEvent.Warning => "Warning",
CompilerEvent.Error => "Error",
Expand Down
6 changes: 6 additions & 0 deletions Source/Mosa.Compiler.Framework/OpcodeEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ public void EmitRelative32(int label)
Append32BitImmediate((uint)offset);
}

public void EmitRelative24(Operand operand)
{
Emitter.EmitRelative24(operand);
Append24Bits(0);
}

public void EmitRelative32(Operand operand)
{
Emitter.EmitRelative32(operand);
Expand Down
63 changes: 42 additions & 21 deletions Source/Mosa.Linux.sln
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mosa.Runtime.ARMv8A32", "Mo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mosa.Kernel.BareMetal.ARMv8A32", "Mosa.Kernel.BareMetal.ARMv8A32\Mosa.Kernel.BareMetal.ARMv8A32.csproj", "{6D7FEE6A-1623-49D2-817A-7307BE2BD8BC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mosa.BareMetal.HelloWorldARMv8A32", "Mosa.BareMetal.HelloWorld.ARMv8A32\Mosa.BareMetal.HelloWorldARMv8A32.csproj", "{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Instructions", "Instructions", "{225883A6-A279-4F4A-9A06-9FE4E32A1B6A}"
ProjectSection(SolutionItems) = preProject
Data\ARMv8A32-Instructions.json = Data\ARMv8A32-Instructions.json
Expand Down Expand Up @@ -172,6 +170,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mosa.Tool.Bootstrap", "Mosa
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mosa.UnitTests.BareMetal.x86", "Mosa.UnitTests.BareMetal.x86\Mosa.UnitTests.BareMetal.x86.csproj", "{BAB03C4A-D620-4E2B-A98A-BB8197CB8F57}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mosa.BareMetal.HelloWorld.x64", "Mosa.BareMetal.HelloWorld.x64\Mosa.BareMetal.HelloWorld.x64.csproj", "{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mosa.BareMetal.HelloWorld.ARMv8A32", "Mosa.BareMetal.HelloWorld.ARMv8A32\Mosa.BareMetal.HelloWorld.ARMv8A32.csproj", "{6B6FC829-9A26-465F-8056-7F986E40C7AB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -906,24 +908,6 @@ Global
{6D7FEE6A-1623-49D2-817A-7307BE2BD8BC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{6D7FEE6A-1623-49D2-817A-7307BE2BD8BC}.Release|x86.ActiveCfg = Release|Any CPU
{6D7FEE6A-1623-49D2-817A-7307BE2BD8BC}.Release|x86.Build.0 = Release|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Debug|x86.ActiveCfg = Debug|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Debug|x86.Build.0 = Debug|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Description|Any CPU.ActiveCfg = Debug|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Description|Any CPU.Build.0 = Debug|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Description|Mixed Platforms.ActiveCfg = Debug|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Description|Mixed Platforms.Build.0 = Debug|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Description|x86.ActiveCfg = Debug|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Description|x86.Build.0 = Debug|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Release|Any CPU.Build.0 = Release|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Release|x86.ActiveCfg = Release|Any CPU
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}.Release|x86.Build.0 = Release|Any CPU
{23C02A05-4F5A-467D-B48E-41BD4DD82714}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23C02A05-4F5A-467D-B48E-41BD4DD82714}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23C02A05-4F5A-467D-B48E-41BD4DD82714}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -1068,6 +1052,42 @@ Global
{BAB03C4A-D620-4E2B-A98A-BB8197CB8F57}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{BAB03C4A-D620-4E2B-A98A-BB8197CB8F57}.Release|x86.ActiveCfg = Release|Any CPU
{BAB03C4A-D620-4E2B-A98A-BB8197CB8F57}.Release|x86.Build.0 = Release|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Debug|x86.ActiveCfg = Debug|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Debug|x86.Build.0 = Debug|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Description|Any CPU.ActiveCfg = Debug|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Description|Any CPU.Build.0 = Debug|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Description|Mixed Platforms.ActiveCfg = Debug|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Description|Mixed Platforms.Build.0 = Debug|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Description|x86.ActiveCfg = Debug|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Description|x86.Build.0 = Debug|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Release|Any CPU.Build.0 = Release|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Release|x86.ActiveCfg = Release|Any CPU
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC}.Release|x86.Build.0 = Release|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Debug|x86.ActiveCfg = Debug|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Debug|x86.Build.0 = Debug|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Description|Any CPU.ActiveCfg = Debug|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Description|Any CPU.Build.0 = Debug|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Description|Mixed Platforms.ActiveCfg = Debug|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Description|Mixed Platforms.Build.0 = Debug|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Description|x86.ActiveCfg = Debug|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Description|x86.Build.0 = Debug|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Release|Any CPU.Build.0 = Release|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Release|x86.ActiveCfg = Release|Any CPU
{6B6FC829-9A26-465F-8056-7F986E40C7AB}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1115,7 +1135,6 @@ Global
{024D8FB8-37F2-4F22-A637-3AFF13CB3F56} = {079CE6E3-8038-44F5-B18A-2D586A827D95}
{599D1C00-7C78-4211-A958-1285C4CB76C1} = {3C5A2C4B-FD05-42B3-B6C6-C366DF978A62}
{6D7FEE6A-1623-49D2-817A-7307BE2BD8BC} = {75BB6B40-C122-422F-8B40-F50A70A08E0D}
{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69} = {BFA70B7C-ADB5-444D-AA88-D8B8E82B635D}
{225883A6-A279-4F4A-9A06-9FE4E32A1B6A} = {A406F567-5C89-45AB-88CE-E20616B28FFD}
{F84EFA2E-4B38-410F-A7DE-385DB71BB37F} = {A406F567-5C89-45AB-88CE-E20616B28FFD}
{23C02A05-4F5A-467D-B48E-41BD4DD82714} = {90065B0F-1BFE-40D8-AED5-11096B2535B0}
Expand All @@ -1126,6 +1145,8 @@ Global
{0894ACB7-DB95-4BAB-9BFD-759E7F27C940} = {DDBC7F79-A2A1-4D92-9AE7-ADDC838F1E5E}
{F4DB731D-8606-490F-893D-FB7341A413EA} = {D032B24A-CE3A-4881-BACE-CC4FE0AFD69D}
{BAB03C4A-D620-4E2B-A98A-BB8197CB8F57} = {88D3D1D0-85D2-4301-A9EA-3F964CB05415}
{BDBC1CE5-848F-4EBE-9731-B4AC33F1D0DC} = {BFA70B7C-ADB5-444D-AA88-D8B8E82B635D}
{6B6FC829-9A26-465F-8056-7F986E40C7AB} = {BFA70B7C-ADB5-444D-AA88-D8B8E82B635D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C22A5C94-6B05-4B1B-845A-A2EA7615E093}
Expand Down
46 changes: 42 additions & 4 deletions Source/Mosa.Platform.ARMv8A32/Architecture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ public override void ExtendMethodCompilerPipeline(Pipeline<BaseMethodCompilerSta
pipeline.InsertBefore<CodeGenerationStage>(
new JumpOptimizationStage()
);

//pipeline.InsertBefore<GreedyRegisterAllocatorStage>(
// new StopStage()
//);
}

/// <summary>
Expand All @@ -178,12 +182,34 @@ public override void ExtendMethodCompilerPipeline(Pipeline<BaseMethodCompilerSta
/// <exception cref="NotImplementCompilerException"></exception>
public override void InsertMoveInstruction(Context context, Operand destination, Operand source)
{
throw new NotImplementCompilerException();
var instruction = ARMv8A32.Mov;

if (destination.IsR4)
{
instruction = ARMv8A32.Mvf;
}
else if (destination.IsR8)
{
instruction = ARMv8A32.Mvf;
}

context.AppendInstruction(instruction, destination, source);
}

public override void InsertStoreInstruction(Context context, Operand destination, Operand offset, Operand value)
{
throw new NotImplementCompilerException();
var instruction = ARMv8A32.Str32;

if (destination.IsR4)
{
instruction = ARMv8A32.Stf;
}
else if (destination.IsR8)
{
instruction = ARMv8A32.Stf;
}

context.AppendInstruction(instruction, null, destination, offset, value);
}

/// <summary>
Expand All @@ -196,7 +222,18 @@ public override void InsertStoreInstruction(Context context, Operand destination
/// <exception cref="NotImplementCompilerException"></exception>
public override void InsertLoadInstruction(Context context, Operand destination, Operand source, Operand offset)
{
throw new NotImplementCompilerException();
var instruction = ARMv8A32.Ldr32;

if (destination.IsR4)
{
instruction = ARMv8A32.Ldf;
}
else if (destination.IsR8)
{
instruction = ARMv8A32.Ldf;
}

context.AppendInstruction(instruction, destination, source, offset);
}

/// <summary>
Expand All @@ -217,7 +254,8 @@ public override void InsertExchangeInstruction(Context context, Operand destinat
/// <param name="destination">The destination.</param>
public override void InsertJumpInstruction(Context context, BasicBlock destination)
{
// TODO
context.AppendInstruction(ARMv8A32.B, destination);
context.ConditionCode = ConditionCode.Always;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Platform.ARMv8A32/Instructions/Bl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override void Emit(InstructionNode node, OpcodeEncoder opcodeEncoder)
{
opcodeEncoder.Append4Bits(GetConditionCode(node.ConditionCode));
opcodeEncoder.Append4Bits(0b1011);
opcodeEncoder.EmitRelative24(node.BranchTargets[0].Label);
opcodeEncoder.EmitRelative24(node.Operand1);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Mosa.Platform.ARMv8A32/Transforms/IR/CallDirect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override void Transform(Context context, TransformContext transform)
}
else
{
context.SetInstruction(ARMv8A32.Bl, operand1);
context.ReplaceInstruction(ARMv8A32.Bl);
}
}
}
2 changes: 1 addition & 1 deletion Source/Mosa.Platform.ARMv8A32/Transforms/IR/StoreObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public StoreObject() : base(IRInstruction.StoreObject, TransformType.Manual | Tr

public override void Transform(Context context, TransformContext transform)
{
TransformLoad(transform, context, ARMv8A32.Ldr32, context.Result, transform.StackFrame, context.Operand1);
TransformStore(transform, context, ARMv8A32.Str32, context.Operand1, context.Operand2, context.Operand3);
}
}
13 changes: 7 additions & 6 deletions Source/Mosa.Tool.Compiler/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"profiles": {
"Mosa.Tool.Compiler": {
"commandName": "Project"
}
}
}
"profiles": {
"Mosa.Tool.Compiler": {
"commandName": "Project",
"commandLineArgs": "Mosa.BareMetal.HelloWorldARMv8A32.dll -check -arm32"
}
}
}
2 changes: 1 addition & 1 deletion Source/Mosa.sln
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mosa.Runtime.ARMv8A32", "Mo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mosa.Kernel.BareMetal.ARMv8A32", "Mosa.Kernel.BareMetal.ARMv8A32\Mosa.Kernel.BareMetal.ARMv8A32.csproj", "{6D7FEE6A-1623-49D2-817A-7307BE2BD8BC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mosa.BareMetal.HelloWorldARMv8A32", "Mosa.BareMetal.HelloWorld.ARMv8A32\Mosa.BareMetal.HelloWorldARMv8A32.csproj", "{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mosa.BareMetal.HelloWorld.ARMv8A32", "Mosa.BareMetal.HelloWorld.ARMv8A32\Mosa.BareMetal.HelloWorld.ARMv8A32.csproj", "{70D04EFA-8BEA-45D1-8FC2-F48F5C590C69}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Instructions", "Instructions", "{225883A6-A279-4F4A-9A06-9FE4E32A1B6A}"
ProjectSection(SolutionItems) = preProject
Expand Down

0 comments on commit a1eaa31

Please sign in to comment.