<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=utf-8">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","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;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@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"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Personally, I’d be happy to handle the explicit ELF request the same way the explicit MachO request is currently handled (i.e. in the environment string, which
 is what the non-committed patch does), but when this came up before the consensus was that that wasn’t general enough.  My proposal below is just an attempt to flesh out what general support for explicit object format requests might look like.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">-Andy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Jim Grosbach [mailto:grosbach@apple.com]
<br>
<b>Sent:</b> Friday, August 17, 2012 7:51 AM<br>
<b>To:</b> Paweł Bylica; Chris Lattner<br>
<b>Cc:</b> llvmdev@cs.uiuc.edu (LLVMdev@cs.uiuc.edu); Kaylor, Andrew<br>
<b>Subject:</b> Re: [LLVMdev] RFC: MCJIT enhancements<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Aug 17, 2012, at 2:50 AM, Paweł Bylica <<a href="mailto:pawel.bylica@ibs.org.pl">pawel.bylica@ibs.org.pl</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<div>
<p class="MsoNormal">On Fri, Aug 17, 2012 at 12:16 AM, Kaylor, Andrew <<a href="mailto:andrew.kaylor@intel.com" target="_blank">andrew.kaylor@intel.com</a>> wrote:<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi Paweł,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks for continuing this discussion.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I like the simplicity of your suggestion.  My only concern involves the ambiguity of what is meant
 by “environment”.  Presently there are functions in the llvm::Triple class to access the environment as an enumeration of a fixed set of values.  It seems that some non-enumerated values are already in use, but introducing possible combinations of ABI and
 object format would seem to strain the API.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I couldn’t find an explanation anywhere of what is meant by environment in the context of the triple,
 and it isn’t clear from looking at the possible values whether object format properly belongs to the environment concept or whether it should be a new triple component.  Looking at the uses in the LLVM code base, it seems that the environment element has been
 used specifically to enable generation of MachO objects on non-Darwin OSes.  I see that clang  recognizes “iphoneos” as a value (though it’s not in the Triple::EnvironmentType enum), and it’s not clear to me what it uses it for.  Beyond that, the environment
 seems to be used to influence ABI selection, which would seem to have some degree of overlap with object format selection while being essentially different.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">In other words, environment seems to be a bit of a catch-all dumping ground at the moment.  That’s
 not entirely bad, I suppose, but it does make the task of cleanly extending the target triple more complicated.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">It would seem that at some point the target triple has evolved into a target quadruple with the addition
 of environment.  The question now, I think, is whether it makes sense to extend it further into a target quintuple, adding object format as a well-defined, but optional, component with full API support.  The difficulty, of course, is that with two optional
 extensions the expected canonical form becomes ambiguous, but I don’t think that’s much of a problem.  Given that object format is a relatively small enumeration, the triple parser should be able to handle it presence or absence while parsing or normalizing.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">So here’s what I would suggest.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">1.</span><span style="font-size:7.0pt;color:#1F497D">      
</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Define the target triple as follows (adapted from Triple.h):</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">/// Target triples are strings in the canonical form:</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">/// or</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM-OBJECT_FORMAT
</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">/// or</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">/// or</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM-OBJECT_FORMAT-ENVIRONMENT</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">2.</span><span style="font-size:7.0pt;color:#1F497D">      
</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Add an llvm::Triple::ObjectFormatType enum with all llvm-supported object formats.</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">3.</span><span style="font-size:7.0pt;color:#1F497D">      
</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Remove “MachO” from the llvm::Triple::EnvironmentType enum.</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">4.</span><span style="font-size:7.0pt;color:#1F497D">      
</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Add the following methods to llvm::Triple:</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr, const Twine &ObjFmtStr)</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr, const Twine &ObjFmtStr, const Twine &EnvStr)</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">bool hasExplicitObjectFormat() const</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">ObjectFormatType getObjectFormat() const</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">StringRef getObjectFormatName() const</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">bool isOutputObjectFormatELF() const</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">bool isOutputObjectFormatCOFF() const</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">bool isOutputObjectFormatMachO() const</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Courier New";color:#1F497D">static const char * getObjectFormatName(ObjectFormatType Kind)</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">5.</span><span style="font-size:7.0pt;color:#1F497D">      
</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">When an object format is specified, it will be used by MC and MCJIT if supported for the specified architecture</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">6.</span><span style="font-size:7.0pt;color:#1F497D">      
</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">When an unsupport object format is specified, a fatal error will be thrown</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">7.</span><span style="font-size:7.0pt;color:#1F497D">      
</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">When an object format and environment are both specified but are incompatible, a fatal error will be thrown</span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">8.</span><span style="font-size:7.0pt;color:#1F497D">      
</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">When an object format is not specified everything will behave as it currently does</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">How does that sound?</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">-Andy</span><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Hi Andy,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">That sounds great. Do we need any approval for this change? I can do the coding I you don't mind.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Changes to the Triple have pretty wide-reaching implications. Chris, what do you think?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">-Jim<o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">I have one more question. Triples are specified in both modules and TargetMachine. In 3.1 triple from module was used by default. In trunk it has been changed, and LLVM_HOSTTRIPLE is used by default. Do we have any rules in case module
 triple conflicts with TargetMachine triple?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">- Paweł<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>