[PATCH] 32-bit PowerPC ELF Position Independent Code

Hal Finkel hfinkel at anl.gov
Wed Jul 16 20:20:59 PDT 2014


Hi Justin,

Thanks for working on this!

As Bill said, we need test cases. In addition, a few comments:

+  const MCExpr *tocExpr = MCBinaryExpr::CreateAdd(MCSymbolRefExpr::Create(CurrentPos, OutContext),

+                                                  MCConstantExpr::Create(0x8000, OutContext),

+                                                  OutContext);

what is 0x8000? Please provide a comment.

       BuildMI(FirstMBB, MBBI, dl, TII.get(PPC::MFLR), GlobalBaseReg);

+      if (PPCSubTarget->isTargetELF()) {

+        unsigned TempReg = RegInfo->createVirtualRegister(&PPC::GPRCRegClass);

+        BuildMI(FirstMBB, MBBI, dl, TII.get(PPC::GetGBRO), TempReg).addReg(GlobalBaseReg);

+        BuildMI(FirstMBB, MBBI, dl, TII.get(PPC::UpdateGBR)).addReg(GlobalBaseReg).addReg(TempReg);

+        MF->getInfo<PPCFunctionInfo>()->setUsesPICBase(true);

It is okay here for TempReg to be R0?

         // automatically synthesizes these stubs.

-        OpFlags = PPCII::MO_DARWIN_STUB;

+        OpFlags = PPCII::MO_PLT_STUB;

is this going to break Darwin?

       // unless we're building with the leopard linker or later, which

       // automatically synthesizes these stubs.

-      OpFlags = PPCII::MO_DARWIN_STUB;

+      OpFlags = PPCII::MO_PLT_STUB;

this too? Darwin breaking?

-  explicit PPCFunctionInfo(MachineFunction &MF) 
+  explicit PPCFunctionInfo(MachineFunction &MFC) 
...
+      MF(MFC),

This is unnecessary; because of the way that C++ name lookup works, MF(MF) will be fine here.

Thanks again,
Hal

----- Original Message -----
> From: "Justin Hibbits" <chmeeedalf at gmail.com>
> To: llvm-commits at cs.uiuc.edu
> Sent: Friday, July 11, 2014 7:54:08 PM
> Subject: [PATCH] 32-bit PowerPC ELF Position Independent Code
> 
> Hi,
> 
> For the last few weeks I've been working off and on with ppc32 PIC
> for
> ELF/SysVR4, and now have something to show for it.  The patch is
> attached.  It passes all existing tests, and I haven't yet added new
> tests for this.  I also tested by compiling zlib on FreeBSD/PowerPC,
> and running some commands linked against it.
> 
> Differences from GCC:
> 
> * GCC sets aside r30 as the PIC register, this will use any available
>   register.
> * GNU AS writes a real difference to the function pre-word, whereas
> the
>   LLVM assembler writes 0, with a relocation.  This appears to be
>   irrelevant, as it works correctly in my test case.
> 
> - Justin
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-commits mailing list