-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a5a540
commit be11ee8
Showing
7 changed files
with
253 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace AsmGen | ||
{ | ||
public class IdrfTest : UarchTest | ||
{ | ||
public IdrfTest(int low, int high, int step) | ||
{ | ||
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step); | ||
this.Prefix = "idrf"; | ||
this.Description = "Immediate/Displacement Register File"; | ||
this.FunctionDefinitionParameters = "uint64_t iterations, int *arr, float *floatArr"; | ||
this.GetFunctionCallParameters = "structIterations, A, fpArr"; | ||
this.DivideTimeByCount = false; | ||
} | ||
|
||
public override bool SupportsIsa(IUarchTest.ISA isa) | ||
{ | ||
if (isa == IUarchTest.ISA.amd64) return true; | ||
return false; | ||
} | ||
|
||
public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa) | ||
{ | ||
const string dummyBranchTargetName = "idrftest_badtarget"; | ||
if (isa == IUarchTest.ISA.amd64) | ||
{ | ||
const int storeCount = 40; | ||
const int addCount = 130; | ||
List<string> testInstructions = new List<string>(); | ||
int storeIdx = 0, addIdx = 0; | ||
for (int i = 0; i < this.Counts[this.Counts.Length - 1]; i++) | ||
{ | ||
if (addIdx < addCount) | ||
{ | ||
string addInstr = " add $" + (i + 1) + ", %r1" + (12 + (i % 4)); | ||
testInstructions.Add(addInstr); | ||
addIdx++; | ||
} | ||
else if (storeIdx < storeCount) | ||
{ | ||
string storeInstr = " mov %r11d, " + +(((i + 1) & 0xFF) * 4) + "(%r8)"; | ||
testInstructions.Add(storeInstr); | ||
storeIdx++; | ||
} | ||
else | ||
{ | ||
string branchInstr = " test %r11, %r11\n je {dummyBranchTargetName}"; | ||
testInstructions.Add(branchInstr); | ||
} | ||
} | ||
|
||
string[] unrolledAdds = testInstructions.ToArray(); | ||
UarchTestHelpers.GenerateX86AsmStructureTestFuncs(sb, this.Counts, this.Prefix, unrolledAdds, unrolledAdds, includePtrChasingLoads: true); | ||
|
||
sb.AppendLine($"{dummyBranchTargetName}:\n int3"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Text; | ||
|
||
namespace AsmGen | ||
{ | ||
public class MixJumpStoreDataSched : UarchTest | ||
{ | ||
public MixJumpStoreDataSched(int low, int high, int step) | ||
{ | ||
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step); | ||
this.Prefix = "mixjumpstoredatasched"; | ||
this.Description = "Scheduler, Mixed Jumps and Store Data"; | ||
this.FunctionDefinitionParameters = "uint64_t iterations, int *arr, float *floatarr"; | ||
this.GetFunctionCallParameters = "structIterations, A, fpArr"; | ||
this.DivideTimeByCount = false; | ||
} | ||
|
||
public override bool SupportsIsa(IUarchTest.ISA isa) | ||
{ | ||
if (isa == IUarchTest.ISA.amd64) return true; | ||
//if (isa == IUarchTest.ISA.aarch64) return true; | ||
// if (isa == IUarchTest.ISA.mips64) return true; | ||
// if (isa == IUarchTest.ISA.riscv) return true; | ||
return false; | ||
} | ||
|
||
public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa) | ||
{ | ||
if (isa == IUarchTest.ISA.amd64) | ||
{ | ||
string[] unrolledJumps = new string[4]; | ||
unrolledJumps[0] = " cmp %rdi, %rsi\n je mixjumpstoredatasched_reallybadthing"; | ||
unrolledJumps[1] = " mov %rdi, (%r8)"; | ||
unrolledJumps[2] = " cmp %rdi, %rsi\n je mixjumpstoredatasched_reallybadthing"; | ||
unrolledJumps[3] = " mov %rdi, 64(%r8)"; | ||
UarchTestHelpers.GenerateX86AsmStructureTestFuncs(sb, this.Counts, this.Prefix, unrolledJumps, unrolledJumps, includePtrChasingLoads: true); | ||
|
||
sb.AppendLine("mixjumpstoredatasched_reallybadthing:\n int3"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Text; | ||
|
||
namespace AsmGen | ||
{ | ||
public class MixJumpStoreSchedTest : UarchTest | ||
{ | ||
public MixJumpStoreSchedTest(int low, int high, int step) | ||
{ | ||
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step); | ||
this.Prefix = "mixjumpstoresched"; | ||
this.Description = "Scheduler, Mixed Jumps and Stores (Address Dependency)"; | ||
this.FunctionDefinitionParameters = "uint64_t iterations, int *arr, float *floatarr"; | ||
this.GetFunctionCallParameters = "structIterations, A, fpArr"; | ||
this.DivideTimeByCount = false; | ||
} | ||
|
||
public override bool SupportsIsa(IUarchTest.ISA isa) | ||
{ | ||
if (isa == IUarchTest.ISA.amd64) return true; | ||
//if (isa == IUarchTest.ISA.aarch64) return true; | ||
// if (isa == IUarchTest.ISA.mips64) return true; | ||
// if (isa == IUarchTest.ISA.riscv) return true; | ||
return false; | ||
} | ||
|
||
public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa) | ||
{ | ||
if (isa == IUarchTest.ISA.amd64) | ||
{ | ||
string[] unrolledJumps = new string[4]; | ||
unrolledJumps[0] = " cmp %rdi, %rsi\n je mixstorejumpsched_reallybadthing"; | ||
unrolledJumps[1] = " mov %r14, (%r8, %rdi, 2)"; | ||
unrolledJumps[2] = " cmp %rdi, %rsi\n je mixstorejumpsched_reallybadthing"; | ||
unrolledJumps[3] = " mov %r14, 64(%r8, %rdi, 2)"; | ||
UarchTestHelpers.GenerateX86AsmStructureTestFuncs(sb, this.Counts, this.Prefix, unrolledJumps, unrolledJumps, includePtrChasingLoads: true); | ||
|
||
sb.AppendLine("mixstorejumpsched_reallybadthing:\n int3"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Text; | ||
|
||
namespace AsmGen | ||
{ | ||
public class RorSchedTest : UarchTest | ||
{ | ||
public RorSchedTest(int low, int high, int step) | ||
{ | ||
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step); | ||
this.Prefix = "rorsched"; | ||
this.Description = "Scheduler, Integer Rotate by Immediate (1)"; | ||
this.FunctionDefinitionParameters = "uint64_t iterations, int *arr"; | ||
this.GetFunctionCallParameters = "structIterations, A"; | ||
this.DivideTimeByCount = false; | ||
} | ||
|
||
public override bool SupportsIsa(IUarchTest.ISA isa) | ||
{ | ||
if (isa == IUarchTest.ISA.amd64) return true; | ||
return false; | ||
} | ||
|
||
public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa) | ||
{ | ||
if (isa == IUarchTest.ISA.amd64) | ||
{ | ||
string postLoadInstrs = " mov %rdi, %r15"; | ||
string postLoadInstrs2 = " mov %rsi, %r15"; | ||
string[] unrolledInstrs = new string[1]; | ||
unrolledInstrs[0] = " ror $1, %r15"; | ||
UarchTestHelpers.GenerateX86AsmStructureTestFuncs( | ||
sb, | ||
this.Counts, | ||
this.Prefix, | ||
unrolledInstrs, | ||
unrolledInstrs, | ||
postLoadInstrs1: postLoadInstrs, | ||
postLoadInstrs2: postLoadInstrs2, | ||
includePtrChasingLoads: false); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Text; | ||
|
||
namespace AsmGen | ||
{ | ||
public class ShlSchedTest : UarchTest | ||
{ | ||
public ShlSchedTest(int low, int high, int step) | ||
{ | ||
this.Counts = UarchTestHelpers.GenerateCountArray(low, high, step); | ||
this.Prefix = "shlsched"; | ||
this.Description = "Scheduler, Integer Shift by Immediate (1)"; | ||
this.FunctionDefinitionParameters = "uint64_t iterations, int *arr"; | ||
this.GetFunctionCallParameters = "structIterations, A"; | ||
this.DivideTimeByCount = false; | ||
} | ||
|
||
public override bool SupportsIsa(IUarchTest.ISA isa) | ||
{ | ||
if (isa == IUarchTest.ISA.amd64) return true; | ||
return false; | ||
} | ||
|
||
public override void GenerateAsm(StringBuilder sb, IUarchTest.ISA isa) | ||
{ | ||
if (isa == IUarchTest.ISA.amd64) | ||
{ | ||
string postLoadInstrs = " mov %rdi, %r15"; | ||
string postLoadInstrs2 = " mov %rsi, %r15"; | ||
string[] unrolledInstrs = new string[1]; | ||
unrolledInstrs[0] = " shl $1, %r15"; | ||
UarchTestHelpers.GenerateX86AsmStructureTestFuncs( | ||
sb, | ||
this.Counts, | ||
this.Prefix, | ||
unrolledInstrs, | ||
unrolledInstrs, | ||
postLoadInstrs1: postLoadInstrs, | ||
postLoadInstrs2: postLoadInstrs2, | ||
includePtrChasingLoads: false); | ||
} | ||
} | ||
} | ||
} |