I have been looking over AsmPrinter::EmitLinkage (around line 195 of lib\CodeGen\AsmPrinter\AsmPrinter.cpp) and it seems that its implementation will vary quite a bit depending on what object file format is in use (MachO, ELF, or COFF).<div>
<br></div><div>Would it make sense to delegate the implementation to a specialized object from current the object file format?</div><div><br></div><div>I am tempted to make it the MCAsmInfo implementation for the specific target. Currently MCAsmInfo looks just to hold useful information about the target, and not any target specific code.</div>
<div><br></div><div>TargetLoweringObjectFile looks to perform a similar function as MCAsmInfo, though this doesn't look to be responsible for directing the AsmPrinter, its only responsibility appears to be providing section assignment logic.</div>
<div><br></div><div>Another candidate I considered what TargetAsmBackend, but that appears to be meant to sit behind MCStreamer.</div><div><br></div><div>Another approach would be to further subdivide X86AsmPrinter to have object file format specific variants that could implement the required logic. The problems I am trying to solve are processor independent so I don't think this would be the right approach, but it could potentially be useful in other situations.</div>
<div><br></div><div>Finally, a new object could be created that is specialized by the different object file formats. There are already a number of specialized objects, and seems like at would make things confusing.</div>
<div><br></div>
<div>I think there are other places that could benefit from a similar transformation. On example would be the handling of the X86AsmPrinter::EmitEndOfAsmFile which has three separate blocks of code dedicated to the different object file formats. At least in the case of COFF, the operations being performed are not specific to X86.</div>
<div><br></div><div>-Nathan</div>