-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Exegesis] Implemented strategy for load operation #113458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,60 @@ | ||
# RUN: llvm-exegesis -mode=latency --benchmark-phase=assemble-measured-code -mtriple=riscv64-unknown-linux-gnu --mcpu=generic -opcode-name=LD 2>&1 | FileCheck --check-prefix=TEST1 %s | ||
|
||
TEST1: --- | ||
TEST1-NEXT: mode: latency | ||
TEST1-NEXT: key: | ||
TEST1-NEXT: instructions: | ||
TEST1-NEXT: - 'LD X10 X10 i_0x0' | ||
|
||
# RUN: llvm-exegesis -mode=latency --benchmark-phase=assemble-measured-code -mtriple=riscv64-unknown-linux-gnu --mcpu=generic -opcode-name=LW 2>&1 | FileCheck --check-prefix=TEST2 %s | ||
|
||
TEST2: --- | ||
TEST2-NEXT: mode: latency | ||
TEST2-NEXT: key: | ||
TEST2-NEXT: instructions: | ||
TEST2-NEXT: - 'LW X10 X10 i_0x0' | ||
|
||
# RUN: llvm-exegesis -mode=latency --benchmark-phase=assemble-measured-code -mtriple=riscv64-unknown-linux-gnu --mcpu=generic -opcode-name=LH 2>&1 | FileCheck --check-prefix=TEST3 %s | ||
|
||
TEST3: --- | ||
TEST3-NEXT: mode: latency | ||
TEST3-NEXT: key: | ||
TEST3-NEXT: instructions: | ||
TEST3-NEXT: - 'LH X10 X10 i_0x0' | ||
|
||
# RUN: llvm-exegesis -mode=latency --benchmark-phase=assemble-measured-code -mtriple=riscv64-unknown-linux-gnu --mcpu=generic -opcode-name=LWU 2>&1 | FileCheck --check-prefix=TEST4 %s | ||
|
||
TEST4: --- | ||
TEST4-NEXT: mode: latency | ||
TEST4-NEXT: key: | ||
TEST4-NEXT: instructions: | ||
TEST4-NEXT: - 'LWU X10 X10 i_0x0' | ||
|
||
# RUN: llvm-exegesis -mode=latency --benchmark-phase=assemble-measured-code -mtriple=riscv64-unknown-linux-gnu --mcpu=generic -opcode-name=LBU 2>&1 | FileCheck --check-prefix=TEST5 %s | ||
|
||
TEST5: --- | ||
TEST5-NEXT: mode: latency | ||
TEST5-NEXT: key: | ||
TEST5-NEXT: instructions: | ||
TEST5-NEXT: - 'LBU X10 X10 i_0x0' | ||
|
||
# RUN: llvm-exegesis -mode=latency --benchmark-phase=assemble-measured-code -mtriple=riscv64-unknown-linux-gnu --mcpu=generic -opcode-name=LUI 2>&1 | FileCheck --check-prefix=TEST6 %s | ||
|
||
TEST6: LUI: No strategy found to make the execution serial | ||
|
||
|
||
# RUN: llvm-exegesis -mode=latency --benchmark-phase=assemble-measured-code -mtriple=riscv64-unknown-linux-gnu --mcpu=generic -opcode-name=LB 2>&1 | FileCheck --check-prefix=TEST7 %s | ||
|
||
TEST7: --- | ||
TEST7-NEXT: mode: latency | ||
TEST7-NEXT: key: | ||
TEST7-NEXT: instructions: | ||
TEST7-NEXT: - 'LB X10 X10 i_0x0' | ||
|
||
# RUN: llvm-exegesis -mode=latency --benchmark-phase=assemble-measured-code -mtriple=riscv64-unknown-linux-gnu --mcpu=generic -mattr=+a -opcode-name=LR_W_RL 2>&1 | FileCheck --check-prefix=TEST8 %s | ||
|
||
TEST8: --- | ||
TEST8-NEXT: mode: latency | ||
TEST8-NEXT: key: | ||
TEST8-NEXT: instructions: | ||
TEST8-NEXT: - 'LR_W_RL X10 X10' |
This file contains hidden or 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 |
---|---|---|
|
@@ -104,7 +104,48 @@ static void appendCodeTemplates(const LLVMState &State, | |
} | ||
case ExecutionMode::SERIAL_VIA_MEMORY_INSTR: { | ||
// Select back-to-back memory instruction. | ||
// TODO: Implement me. | ||
|
||
auto &I = Variant.getInstr(); | ||
if (I.Description.mayLoad()) { | ||
// If instruction is load, we can self-alias it in case when instruction | ||
// overrides whole address register. For that we use provided scratch | ||
// memory. | ||
|
||
// TODO: now it is not checked if load writes the whole register. | ||
|
||
auto DefOpIt = find_if(I.Operands, [](Operand const &Op) { | ||
return Op.isDef() && Op.isReg(); | ||
}); | ||
|
||
if (DefOpIt == I.Operands.end()) | ||
return; | ||
|
||
const Operand &DefOp = *DefOpIt; | ||
const ExegesisTarget &ET = State.getExegesisTarget(); | ||
unsigned ScratchMemoryRegister = ET.getScratchMemoryRegister( | ||
State.getTargetMachine().getTargetTriple()); | ||
const llvm::MCRegisterClass &RegClass = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: We can drop the |
||
State.getTargetMachine().getMCRegisterInfo()->getRegClass( | ||
DefOp.getExplicitOperandInfo().RegClass); | ||
|
||
// Register classes of def operand and memory operand must be the same | ||
// to perform aliasing. | ||
if (!RegClass.contains(ScratchMemoryRegister)) | ||
return; | ||
|
||
ET.fillMemoryOperands(Variant, ScratchMemoryRegister, 0); | ||
Variant.getValueFor(DefOp) = MCOperand::createReg(ScratchMemoryRegister); | ||
|
||
CodeTemplate CT; | ||
CT.Execution = ExecutionModeBit; | ||
CT.ScratchSpacePointerInReg = ScratchMemoryRegister; | ||
|
||
CT.Info = std::string(ExecutionClassDescription); | ||
CT.Instructions.push_back(std::move(Variant)); | ||
CodeTemplates.push_back(std::move(CT)); | ||
} | ||
|
||
// TODO: implement more cases | ||
return; | ||
} | ||
case ExecutionMode::SERIAL_VIA_EXPLICIT_REGS: { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.