Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
clamchowder committed Oct 20, 2023
2 parents 7a2e922 + 6a608b4 commit fee0cee
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 30 deletions.
19 changes: 9 additions & 10 deletions AsmGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,25 @@ class Program
static void Main(string[] args)
{
List<IUarchTest> tests = new List<IUarchTest>();
tests.Add(new RobTest(64, 768, 1));
tests.Add(new RobTest(2, 64, 1));
tests.Add(new ZeroRobTest(128, 384, 1));
tests.Add(new IntRfTest(32, 256, 1));
tests.Add(new FpRfTest(32, 256, 1));
tests.Add(new IntRfTest(2, 64, 1));
tests.Add(new FpRfTest(2, 64, 1));
tests.Add(new MixIntVec128RfTest(100, 256, 1));
tests.Add(new Fadd256RfTest(4, 160, 1));
tests.Add(new MixFAdd256and32RfTest(4, 160, 1));
tests.Add(new FlagRfTest(4, 100, 1));
tests.Add(new LdqTest(4, 512, 1));
tests.Add(new FlagRfTest(2, 64, 1));
tests.Add(new LdqTest(2, 64, 1));
tests.Add(new StqTest(4, 512, 1));
tests.Add(new AddSchedTest(32, 128, 1));
tests.Add(new AddSchedTest(2, 64, 1));
tests.Add(new MulSchedTest(4, 64, 1));
tests.Add(new MaddSchedTest(4, 64, 1));
tests.Add(new JumpSchedTest(4, 64, 1));
tests.Add(new TakenJumpSchedTest(4, 64, 1));
tests.Add(new LoadSchedTest(4, 64, 1));
tests.Add(new StoreSchedTest(4, 64, 1));
tests.Add(new StoreDataSchedTest(4, 64, 1));
tests.Add(new MixLoadStoreSched(4, 96, 1));
tests.Add(new MixAddJumpSchedTest(4, 128, 1));
tests.Add(new MixAddJumpSchedTest(2, 64, 1));
tests.Add(new FaddSchedTest(20, 120, 1));
tests.Add(new FcmpSchedTest(8, 120, 1));
tests.Add(new JsCvtSched(8, 120, 1));
Expand All @@ -58,8 +57,8 @@ static void Main(string[] args)
tests.Add(new BtbTest(16, BtbTest.BranchType.Conditional));
tests.Add(new BtbTest(32, BtbTest.BranchType.Conditional));
tests.Add(new ReturnStackTest(1, 128, 1));
tests.Add(new BranchBufferTest(1, 192, 1));
tests.Add(new IndirectBranchTest());
tests.Add(new BranchBufferTest(1, 64, 1));
tests.Add(new IndirectBranchTest(false));
tests.Add(new BranchHistoryTest());
tests.Add(new NopLoopTest(512, 1));
tests.Add(new AddLoopTest(68, 256, 1));
Expand Down
49 changes: 29 additions & 20 deletions AsmGen/tests/IndirectBranchTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ public class IndirectBranchTest : IUarchTest
private int[] branchCounts;
private int[] targetCounts;
private int globalHistoryAssistBits;
public IndirectBranchTest()
private bool assists;

public IndirectBranchTest(bool assist)
{
Prefix = "indirectbranch";
Description = "Indirect branch prediction";
Expand All @@ -17,6 +19,7 @@ public IndirectBranchTest()
branchCounts = new int[] { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
targetCounts = new int[] { 2, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128 };
globalHistoryAssistBits = 4;
this.assists = assist;
}

public bool SupportsIsa(IUarchTest.ISA isa)
Expand Down Expand Up @@ -118,16 +121,19 @@ public void GenerateArmAsm(StringBuilder sb)

// global history assist branches
// rax = index into jump table. make that correlate with global history
sb.AppendLine(" mov x18, 1");
sb.AppendLine(" eor w12, w12, w12");
for (int eaxBits = 0; eaxBits < globalHistoryAssistBits; eaxBits++)
if (this.assists)
{
string targetName = functionLabel + "branch" + branchIdx + "ghist" + eaxBits;
sb.AppendLine(" and w12, w13, w18");
sb.AppendLine($" cbnz w12, {targetName}");
sb.AppendLine(" nop");
sb.AppendLine($"{targetName}:");
sb.AppendLine(" lsl w18, w18, 1");
sb.AppendLine(" mov x18, 1");
sb.AppendLine(" eor w12, w12, w12");
for (int eaxBits = 0; eaxBits < globalHistoryAssistBits; eaxBits++)
{
string targetName = functionLabel + "branch" + branchIdx + "ghist" + eaxBits;
sb.AppendLine(" and w12, w13, w18");
sb.AppendLine($" cbnz w12, {targetName}");
sb.AppendLine(" nop");
sb.AppendLine($"{targetName}:");
sb.AppendLine(" lsl w18, w18, 1");
}
}

// branch on value of x17
Expand Down Expand Up @@ -222,17 +228,20 @@ public void GenerateX86GccAsm(StringBuilder sb)
sb.AppendLine(" mov (%r10,%rbx,4), %eax"); // get the target for the current iteration into eax
sb.AppendLine(" mov (%r15,%rax,8), %r14"); // load address of jump target from jump table

sb.AppendLine(" mov %rsi, %r13");
sb.AppendLine(" mov $1, %rsi");
for (int eaxBits = 0; eaxBits < 7; eaxBits++)
if (assists)
{
string targetName = functionLabel + "branch" + branchIdx + "ghist" + eaxBits;
sb.AppendLine(" test %eax, %esi");
sb.AppendLine($" jnz {targetName}");
sb.AppendLine(" nop");
sb.AppendLine($"{targetName}:");

sb.AppendLine(" shl $1, %esi");
sb.AppendLine(" mov %rsi, %r13");
sb.AppendLine(" mov $1, %rsi");
for (int eaxBits = 0; eaxBits < 7; eaxBits++)
{
string targetName = functionLabel + "branch" + branchIdx + "ghist" + eaxBits;
sb.AppendLine(" test %eax, %esi");
sb.AppendLine($" jnz {targetName}");
sb.AppendLine(" nop");
sb.AppendLine($"{targetName}:");

sb.AppendLine(" shl $1, %esi");
}
}

sb.AppendLine(" mov %r13, %rsi");
Expand Down

0 comments on commit fee0cee

Please sign in to comment.