[llvm-commits] [PATCH] review request: [MC] [llvm-mc] Getting target specific information to <target>ELFObjectWriter

Carter, Jack jcarter at mips.com
Fri Jan 4 18:20:08 PST 2013


Jim,

Happy new year.

I still need to pass ELF e_header information somehow to MipsELFObjectWriter. This includes the relocation model the chip level and any processor extensions along with xgot use.

I don't see any target, including ARM, doing what I need here. How do I get this information accessible to MipsELFObjectWriter? My patch does this, but I will take another path if it works.

As an experiment I exported MCObjectWriter and created an accessor method to hand over a pointer to MCELFObjectTargetWriter which can be cast to MipsELFObjectWriter. This works fine and doesn't require MCSubtargetInfo at all, but I fear that exposing the declarations in lib/MC/ELFObjectWriter is a non-starter. I'll attach a sample patch for reference.

In the case of my MCSubtargetInfo patch, I don't see where there is a place for all of the information I need. We don't store the relocation model (PIC/CPIC/STATIC) there nor in the features list. Thus the new data member.

This has to work for both llc and llvm-mc.

Regards,

Jack

________________________________
From: Jim Grosbach [grosbach at apple.com]
Sent: Friday, December 21, 2012 4:01 PM
To: Carter, Jack
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: [PATCH] review request: [MC] [llvm-mc] Getting target specific information to <target>ELFObjectWriter

Hi Jack,

There is no such class as "SubtargetInfo". There is MCSubtargetInfo and TargetSubtargetInfo. Please be very, very careful to indicate which you're talking about. The distinction is not arbitrary.

As to the additional data member, I'm unconvinced it's necessary. Targets already do target-specific things with regards to the object file writers (ARM, for example).

Likewise, why does the ELFObjectWriter need the MCSubtargetInfo? Any sub target information is, by definition, target specific and should already be available to the backend (assembler or compiler) whenever the object writer needs such information. For a rough example on the compiler side, ARMAsmPrinter::emitAttributes().

-Jim



On Dec 21, 2012, at 3:07 PM, "Carter, Jack" <jcarter at mips.com<mailto:jcarter at mips.com>> wrote:


SUMMARY:
This patch adds the SubtargetInfo class
object to the creation of the <target>MCAsmBackend
class object.

PROBLEM:
The problem I have been having for some time is how
to get access to target specific information during
the direct object output phase. The current issue was
how to fill the ELF header's target specific E_FLAGS
bit field.

SOLUTION:
The information has already been collected and isolated
by the SubtargetInfo class object. This patch
passes the const reference to this class object to the
<target>MCAsmBackend class object which in turn passes
it to the <target>ELFObjectWriter class object which
updates the E_FLAGS.

This is the current creation routine for the backend:

MCAsmBackend *llvm::createMipsAsmBackendEB64(const Target &T, StringRef TT,
                                             StringRef CPU,
                                             const SubtargetInfo *STI) {
  return new MipsAsmBackend(T, Triple(TT).getOS(),
                            /*IsLittle*/false, /*Is64Bit*/true, STI);
}

I believe we could reduce this to the one parameter STI
and derive the rest of the information from it. I also
believe that STI could be used with the other MC classes
to reduce the need for future parameters there as well.

Since llc and llvm-mc use SubtargetInfo differently I have
added a new data member to SubtargetInfo that is a set of
integers for passing information. This data member may be
extended to allow a set of unions so wome other object,
but until there is a need for it, I want to keep it simple.

The tags for the sets are target specific so what ARM would
use it for would be different than for Mips if they want.

CONCLUSION:
* This patch does not affect the current behavior of other
  targets.
* Future E_FLAGS additions will be easy to implement at the
  individual target level.
* This change has changes in both the llvm and clang trees.


Contributer: Jack Carter

<elf_header.patch><elf_header_clang.patch>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130105/b67ecd25/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: new_eheader.patch
Type: text/x-patch
Size: 37748 bytes
Desc: new_eheader.patch
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130105/b67ecd25/attachment.bin>


More information about the llvm-commits mailing list