<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I have been working on getting ELF object file writing working for the MBlaze backend. Currently, each supported backend calls ELFObjectWriter::createELFObjectWriter from within the backend's TargetAsmBackend::createObjectWriter method. The createELFObjectWriter method then creates a new backend specific ELFObjectWriter class (either X86ELFObjectWriter or ARMELFObjectWriter) by decoding a given machine type.<div><br></div><div>The attached patch does some code refactoring so that a backend can create it's own ELFObjectWriter class and instantiate this class directly in TargetAsmBackend::createObjectWriter. This allows backend specific stuff in lib/MC/ELFObjectWriter.cpp to be moved to the backend's directory.</div><div><br></div><div>There are obviously several things that could be done differently:</div><div>1. The backend specific ELFObjectWriter classes are declared and implemented in X86AsmBackend.cpp and ARMAsmBackend.cpp; it may be better to put these classes in their own files.</div><div><div><br></div><div>2. The ELFObjectWriter base class is declared in llvm/MC/MCObjectWriter.h; it may be better to put this declaration in its own header file.</div><div><br></div><div>3. Some of the flags, such as Is64Bit and EMachine, could be virtual methods instead of values passed to the base ELFObjectWriter class.</div><div><br></div><div>4. Refactoring of MachObjectWriter and WinCOFFObjectWriter could be done as well.</div><div><br></div><div>5. I could just add the MBlaze backend specific stuff into ELFObjectWriter like all of the other backends.</div><div><br></div><div>Are their any other opinions on this? I personally prefer all of the MBlaze backend stuff to be contained inside of lib/Target/MBlaze so that I don't have to hunt around the LLVM source tree when I'm implementing/fixing the MBlaze backend. If #5 is preferred instead, then I can re-implement the MBlaze ELF stuff that way instead.<br><div><br class="webkit-block-placeholder"></div><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Menlo; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div><span class="Apple-style-span" style="font-family: Helvetica; ">--</span></div><div><div style="font-family: Helvetica; ">Wesley Peck</div><div style="font-family: Helvetica; ">University of Kansas</div><div style="font-family: Helvetica; ">SLDG Laboratory</div></div></span>
</div><div><br class="webkit-block-placeholder"></div><div></div></div></div></body></html>