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

Jim Grosbach grosbach at apple.com
Fri Dec 21 16:01:45 PST 2012


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> 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/20121221/0a8d0012/attachment.html>


More information about the llvm-commits mailing list