-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[PowerPC] Add DMR and WACC COPY support #149129
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
Open
maryammo
wants to merge
1
commit into
llvm:main
Choose a base branch
from
maryammo:dmf/dmr_copy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
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
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//===-------------- PPCVSXCopy.cpp - VSX Copy Legalization ----------------===// | ||
//===-------------- PPCVSXWACCCopy.cpp - VSX and WACC Copy Legalization ----------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
|
@@ -8,7 +8,7 @@ | |
// | ||
// A pass which deals with the complexity of generating legal VSX register | ||
// copies to/from register classes which partially overlap with the VSX | ||
// register file. | ||
// register file and combines the wacc/wacc_hi copies when needed. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
|
@@ -29,12 +29,12 @@ using namespace llvm; | |
#define DEBUG_TYPE "ppc-vsx-copy" | ||
|
||
namespace { | ||
// PPCVSXCopy pass - For copies between VSX registers and non-VSX registers | ||
// PPCVSXWACCCopy pass - For copies between VSX registers and non-VSX registers | ||
// (Altivec and scalar floating-point registers), we need to transform the | ||
// copies into subregister copies with other restrictions. | ||
struct PPCVSXCopy : public MachineFunctionPass { | ||
struct PPCVSXWACCCopy : public MachineFunctionPass { | ||
static char ID; | ||
PPCVSXCopy() : MachineFunctionPass(ID) {} | ||
PPCVSXWACCCopy() : MachineFunctionPass(ID) {} | ||
|
||
const TargetInstrInfo *TII; | ||
|
||
|
@@ -122,6 +122,33 @@ namespace { | |
// Transform the original copy into a subregister extraction copy. | ||
SrcMO.setReg(NewVReg); | ||
SrcMO.setSubReg(PPC::sub_64); | ||
} else if (IsRegInClass(DstMO.getReg(), &PPC::WACC_HIRCRegClass, MRI) && | ||
IsRegInClass(SrcMO.getReg(), &PPC::WACCRCRegClass, MRI)) { | ||
// Matches the pattern: | ||
// %a:waccrc = COPY %b.sub_wacc_hi:dmrrc | ||
// %c:wacc_hirc = COPY %a:waccrc | ||
// And replaces it with: | ||
// %c:wacc_hirc = COPY %b.sub_wacc_hi:dmrrc | ||
MachineInstr *DefMI = MRI.getUniqueVRegDef(SrcMO.getReg()); | ||
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: indent off 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. I will run this through clang-format. Since it modifies this file significantly, I kept it for after the review is done. |
||
if (!DefMI || !DefMI->isCopy()) | ||
continue; | ||
|
||
MachineOperand &OrigSrc = DefMI->getOperand(1); | ||
|
||
if (!IsRegInClass(OrigSrc.getReg(), &PPC::DMRRCRegClass, MRI)) | ||
continue; | ||
|
||
if (OrigSrc.getSubReg() != PPC::sub_wacc_hi) | ||
continue; | ||
|
||
// Rewrite the second copy to use the original register's subreg | ||
SrcMO.setReg(OrigSrc.getReg()); | ||
SrcMO.setSubReg(PPC::sub_wacc_hi); | ||
Changed = true; | ||
|
||
// Remove the intermediate copy if safe | ||
if (MRI.use_nodbg_empty(DefMI->getOperand(0).getReg())) | ||
DefMI->eraseFromParent(); | ||
} | ||
} | ||
|
||
|
@@ -151,9 +178,9 @@ namespace { | |
}; | ||
} // end anonymous namespace | ||
|
||
INITIALIZE_PASS(PPCVSXCopy, DEBUG_TYPE, | ||
INITIALIZE_PASS(PPCVSXWACCCopy, DEBUG_TYPE, | ||
"PowerPC VSX Copy Legalization", false, false) | ||
|
||
char PPCVSXCopy::ID = 0; | ||
char PPCVSXWACCCopy::ID = 0; | ||
FunctionPass* | ||
llvm::createPPCVSXCopyPass() { return new PPCVSXCopy(); } | ||
llvm::createPPCVSXWACCCopyPass() { return new PPCVSXWACCCopy(); } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to add a comment about the type of copy this is meant to do similar to the blocks above.