aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2005-04-05 18:19:50 +0000
committerNate Begeman <natebegeman@mac.com>2005-04-05 18:19:50 +0000
commitad5f65c74bb2b06fdb5544d2dcdf586b26c44ca0 (patch)
tree05c027b77841862b53642f41aa60de5d23aa2d32
parenta3829d55806e5aa5e4dafd54e2e156444e7e8b1e (diff)
Behold, rlwinm with certain immediate arguments is printed as the much more
readable slwi or srwi (shift left/right word immediate). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21099 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/PowerPC/PPCAsmPrinter.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 025ce9824b..3006f62410 100644
--- a/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -397,6 +397,28 @@ void PowerPCAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) {
///
void PowerPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
++EmittedInsts;
+ // Check for slwi/srwi mnemonics.
+ if (MI->getOpcode() == PPC::RLWINM) {
+ bool FoundMnemonic = false;
+ unsigned char SH = MI->getOperand(2).getImmedValue();
+ unsigned char MB = MI->getOperand(3).getImmedValue();
+ unsigned char ME = MI->getOperand(4).getImmedValue();
+ if (SH <= 31 && MB == 0 && ME == (31-SH)) {
+ O << "slwi "; FoundMnemonic = true;
+ }
+ if (SH <= 31 && MB == (32-SH) && ME == 31) {
+ O << "srwi "; FoundMnemonic = true;
+ SH = 32-SH;
+ }
+ if (FoundMnemonic) {
+ printOperand(MI, 0, MVT::i64);
+ O << ", ";
+ printOperand(MI, 1, MVT::i64);
+ O << ", " << (unsigned int)SH << "\n";
+ return;
+ }
+ }
+
if (printInstruction(MI))
return; // Printer was automatically generated