<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">I’m trying to retarget LLVM to a TI processor. We plan to use our existing assembler, which is not gas-based. I’m finding a lot of inconsistency in the retargeting hooks available under the AsmPrinter interface. I’ll cite four examples:<o:p></o:p></p>
<p class="MsoNormal">1. The TI assembler’s global directive is called ‘.global’ rather than ‘.globl’. This one’s easy: there is a getGlobalDriective() interface in MCAsmInfo.<o:p></o:p></p>
<p class="MsoNormal">2. The TI assembler’s common directive is called ‘.common’ rather than .comm’. Oops, that’s hardwired into MCAsmStreamer.<o:p></o:p></p>
<p class="MsoNormal">3. The TI assembler’s common directive does not imply global linkage; a separate .global is required. I was able to hack that by overriding AsmPrinter::EmitGlobalVariable().<o:p></o:p></p>
<p class="MsoNormal">4. The TI assembler’s align directive is called ‘.align’ rather than ‘.p2align’ and its argument is absolute bytes, not a power of two. Oops, that’s also hardwired in.<o:p></o:p></p>
<p class="MsoNormal">Those are a few of the things I’ve encountered so far; I’m sure there are dozens more. I’m wondering how to handle these types of things in general. I could:<o:p></o:p></p>
<p class="MsoNormal">A) Keep extending MCAsmInfo for anything I need. This seems like it agrees with the intent of that interface, but I’m concerned it could be quite a few additions . I’m curious why it’s implemented as a bunch of scalar properties with getters
 rather than a general API. <o:p></o:p></p>
<p class="MsoNormal">B) Override much of the default ASMPrinter in the target version. It seems like this could end up duplicating much of what is in the base class. Also much of the implementation is (currently) private, so the target version cannot access
 it. Of course, there is ‘protected’.<o:p></o:p></p>
<p class="MsoNormal">C) Create a new implementation of the MCStreamer interface, similar to MCAsmStreamer, that would support the TI assembler. This seems overkill, as the formats are not that different. It also seems like it defeats the purpose of the MCAsmInfo
 interface.<o:p></o:p></p>
<p class="MsoNormal">There are no plans to upstream any of this in the near future, but it could happen someday, so I’m looking for the most agreeable way forward. Thoughts?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">-Alan<o:p></o:p></p>
</div>
</body>
</html>