aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/CodeGen/X86/CodeGenerator.cs
diff options
context:
space:
mode:
authorFICTURE7 <FICTURE7@gmail.com>2020-09-12 19:32:53 +0400
committerGitHub <noreply@github.com>2020-09-12 12:32:53 -0300
commit36ec1bc6c023811235d9f5fb664feff09bc7b4f7 (patch)
tree98d74ad92cdce8294bb5116bf7cd06acb55ff9da /ARMeilleure/CodeGen/X86/CodeGenerator.cs
parent3d055da5fc77f462e9c7099e08570213c0220cd4 (diff)
Relax block ordering constraints (#1535)
* Relax block ordering constraints Before `block.Next` had to follow `block.ListNext`, now it does not. Instead `CodeGenerator` will now emit the necessary jump instructions to ensure control flow. This makes control flow and block order modifications easier. It also eliminates some simple cases of redundant branches. * Set PPTC version
Diffstat (limited to 'ARMeilleure/CodeGen/X86/CodeGenerator.cs')
-rw-r--r--ARMeilleure/CodeGen/X86/CodeGenerator.cs25
1 files changed, 18 insertions, 7 deletions
diff --git a/ARMeilleure/CodeGen/X86/CodeGenerator.cs b/ARMeilleure/CodeGen/X86/CodeGenerator.cs
index f2d4c462..a51f4a13 100644
--- a/ARMeilleure/CodeGen/X86/CodeGenerator.cs
+++ b/ARMeilleure/CodeGen/X86/CodeGenerator.cs
@@ -32,7 +32,6 @@ namespace ARMeilleure.CodeGen.X86
Add(Instruction.BitwiseExclusiveOr, GenerateBitwiseExclusiveOr);
Add(Instruction.BitwiseNot, GenerateBitwiseNot);
Add(Instruction.BitwiseOr, GenerateBitwiseOr);
- Add(Instruction.Branch, GenerateBranch);
Add(Instruction.BranchIf, GenerateBranchIf);
Add(Instruction.ByteSwap, GenerateByteSwap);
Add(Instruction.Call, GenerateCall);
@@ -168,6 +167,23 @@ namespace ARMeilleure.CodeGen.X86
GenerateOperation(context, operation);
}
}
+
+ if (block.SuccessorCount == 0)
+ {
+ // The only blocks which can have 0 successors are exit blocks.
+ Debug.Assert(block.Operations.Last is Operation operation &&
+ (operation.Instruction == Instruction.Tailcall ||
+ operation.Instruction == Instruction.Return));
+ }
+ else
+ {
+ BasicBlock succ = block.GetSuccessor(0);
+
+ if (succ != block.ListNext)
+ {
+ context.JumpTo(succ);
+ }
+ }
}
Logger.EndPass(PassName.CodeGeneration);
@@ -512,11 +528,6 @@ namespace ARMeilleure.CodeGen.X86
context.Assembler.Or(dest, src2, dest.Type);
}
- private static void GenerateBranch(CodeGenContext context, Operation operation)
- {
- context.JumpTo(context.CurrBlock.Branch);
- }
-
private static void GenerateBranchIf(CodeGenContext context, Operation operation)
{
Operand comp = operation.GetSource(2);
@@ -527,7 +538,7 @@ namespace ARMeilleure.CodeGen.X86
GenerateCompareCommon(context, operation);
- context.JumpTo(cond, context.CurrBlock.Branch);
+ context.JumpTo(cond, context.CurrBlock.GetSuccessor(1));
}
private static void GenerateByteSwap(CodeGenContext context, Operation operation)