[llvm] r226403 - [PowerPC] Don't hard-code R2 as register when processing TOC relocations

Hal Finkel hfinkel at anl.gov
Sun Jan 18 07:59:44 PST 2015


Author: hfinkel
Date: Sun Jan 18 09:59:44 2015
New Revision: 226403

URL: http://llvm.org/viewvc/llvm-project?rev=226403&view=rev
Log:
[PowerPC] Don't hard-code R2 as register when processing TOC relocations

Instructions that have high-order TOC relocations always carry R2 as their base
register, so it does not matter whether we take the register from the
instruction or just hard-code it in PPCAsmPrinter. In the future, however, we
might want to apply these relocations to instructions using a different
register, so taking the register from the instruction is a better thing to do.
No change in functionality here, however.

Modified:
    llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp

Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=226403&r1=226402&r2=226403&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Sun Jan 18 09:59:44 2015
@@ -699,7 +699,7 @@ void PPCAsmPrinter::EmitInstruction(cons
                               OutContext);
     EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS8)
                                 .addReg(MI->getOperand(0).getReg())
-                                .addReg(PPC::X2)
+                                .addReg(MI->getOperand(1).getReg())
                                 .addExpr(SymGotTprel));
     return;
   }
@@ -778,7 +778,7 @@ void PPCAsmPrinter::EmitInstruction(cons
                               OutContext);
     EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS8)
                                 .addReg(MI->getOperand(0).getReg())
-                                .addReg(PPC::X2)
+                                .addReg(MI->getOperand(1).getReg())
                                 .addExpr(SymGotTlsGD));
     return;
   }
@@ -815,7 +815,7 @@ void PPCAsmPrinter::EmitInstruction(cons
                               OutContext);
     EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS8)
                                 .addReg(MI->getOperand(0).getReg())
-                                .addReg(PPC::X2)
+                                .addReg(MI->getOperand(1).getReg())
                                 .addExpr(SymGotTlsLD));
     return;
   }





More information about the llvm-commits mailing list