[llvm-commits] [RFC] PPC64 TOC and MCJIT support

Roman Divacky rdivacky at freebsd.org
Mon Aug 6 11:49:33 PDT 2012


Wow, this looks awesome, some parts of this (adding of enums and handling them)
can be committed as is. Maybe you can split them into logical chunks? Ie.
"Handle ELF::PPC{64} in ELF" etc. The TOC handling changes look fine to me.
The LDtoc* stuff too. I cant comment on the JIT part.

Also, please send the patches as attachments, not inline.

One more additional comments at the end.

Anyway, really nice work!

Roman Divacky

On Mon, Aug 06, 2012 at 03:11:57PM -0300, Adhemerval Zanella wrote:
> Although the patch is still WIP and requires a lot of work, I'd appreciate some
> advices and feedback for my modifications. As I stated em previous emails, although
> llvm generates working code for PPC32, it lacks some functionality for PPC64,
> mainly the TOC usage for PIC and PIE generation.
> 
> This patch is based on previous email and feedback I got to add support for TOC
> and the PPC64 relocation needed for both JIT and assembly. Currently the assembly
> generated creates the @toc relocation correctly instead of @ha/@lo, that works
> on mostly cases, but are not full PIC and PIE.
> 
> The testcase result remains the same, so next step I add PPC64 toc testcase 
> to fully test the TOC code generation.
> 
> ---
> 
> -  if (isPPC64 && !TOC.empty()) {
> +  if (isPPC64 && !TOC.empty() && OutStreamer.hasRawTextSupport()) {
>      const MCSectionELF *Section = OutStreamer.getContext().getELFSection(".toc",
>          ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC,
>          SectionKind::getReadOnly());

the OutStreamer.hasRawTextSupport() is needed because we emit ".tc"

would this be a right thing to do?

-      OutStreamer.EmitRawText("\t.tc " + Twine(I->first->getName()) +
-                              "[TC]," + I->first->getName());
+      MCSymbol *S = OutContext.GetOrCreateSymbol(I->first->getName());
+      OutStreamer.EmitValue(MCSymbolRefExpr::Create(S, OutContext),
+                            Subtarget.isPPC64() ? 8 : 4/*size*/, 0/*addrspace*/);




More information about the llvm-commits mailing list