[PATCH] 32-bit PowerPC ELF Position Independent Code
Justin Hibbits
chmeeedalf at gmail.com
Wed Jul 16 21:08:29 PDT 2014
Hi Hal,
On Jul 16, 2014 8:21 PM, "Hal Finkel" <hfinkel at anl.gov> wrote:
>
> Hi Justin,
>
> Thanks for working on this!
>
> As Bill said, we need test cases. In addition, a few comments:
I have only one more test case to provide for this and I think it should be
ready.
>
> + const MCExpr *tocExpr =
MCBinaryExpr::CreateAdd(MCSymbolRefExpr::Create(CurrentPos, OutContext),
>
> +
MCConstantExpr::Create(0x8000, OutContext),
>
> + OutContext);
>
> what is 0x8000? Please provide a comment.
I will provide a comment on this. The GOT pointer points to the middle of
the GOT which is 64k in total size.
>
> 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?
Since it is active for only two instructions r0 should be fine.
>
> // automatically synthesizes these stubs.
>
> - OpFlags = PPCII::MO_DARWIN_STUB;
>
> + OpFlags = PPCII::MO_PLT_STUB;
>
> is this going to break Darwin?
No. I overrode this constant to serve the same purpose in ELF as it serves
in 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?
Again nope.
>
> - 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.
Gotcha. My c++fu is weak, didn't know this.
Thanks for the review. I will have another patch for you layer tonight or
tomorrow.
- Justin
>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140716/53464369/attachment.html>
More information about the llvm-commits
mailing list