<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>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:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">On Fri, Aug 17, 2012 at 12:16 AM, Kaylor, Andrew <span dir="ltr"><<a href="mailto:andrew.kaylor@intel.com" target="_blank">andrew.kaylor@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">







<div lang="EN-US" link="blue" vlink="purple">
<div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi Paweł,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks for continuing this discussion.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><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.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><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.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><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.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><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.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">So here’s what I would suggest.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span>1.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Define the target triple as follows (adapted from Triple.h):<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">/// Target triples are strings in the canonical form:<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">/// or<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM-OBJECT_FORMAT
<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">/// or<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">/// or<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM-OBJECT_FORMAT-ENVIRONMENT<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span>2.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><u></u><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.<u></u><u></u></span></p><p><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span>3.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Remove “MachO” from the llvm::Triple::EnvironmentType enum.<u></u><u></u></span></p><p><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span>4.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Add the following methods to llvm::Triple:<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></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)<u></u><u></u></span></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)<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">bool hasExplicitObjectFormat() const<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">ObjectFormatType getObjectFormat() const<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">StringRef getObjectFormatName() const<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">bool isOutputObjectFormatELF() const<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">bool isOutputObjectFormatCOFF() const<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">bool isOutputObjectFormatMachO() const<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Courier New";color:#1f497d">static const char * getObjectFormatName(ObjectFormatType Kind)<u></u><u></u></span></p><p><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span>5.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><u></u><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<u></u><u></u></span></p><p><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span>6.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><u></u><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<u></u><u></u></span></p><p><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span>7.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><u></u><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<u></u><u></u></span></p><p><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span>8.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><u></u><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<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">How does that sound?<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">-Andy</span></p></div></div></blockquote><div><br></div><div>Hi Andy,</div><div><br></div><div>That sounds great. Do we need any approval for this change? I can do the coding I you don't mind.</div>

<div><br></div></div></blockquote><div><br></div><div>Changes to the Triple have pretty wide-reaching implications. Chris, what do you think?</div><div><br></div><div>-Jim</div><br><blockquote type="cite"><div class="gmail_quote"><div>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?</div>

<div><br></div><div>- Paweł</div></div>
_______________________________________________<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><br></blockquote></div><br></body></html>