<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">>> Here's the line of thought that I'd like people to start with:<br>
>> * Triples don't describe the target. They look like they should, but they<br>
>>   don't. They're really just arbitrary strings. <br>
><br>
>Triples are used as a starting point, but no more.<br>
<br>
I disagree with this but for now let's assume it's true. The starting point is<br>
incorrect because triples are ambiguous and inconsistent (as demonstrated in<br>
this thread) and this should be fixed.<br>
<br>
>> * LLVM relies on Triple as a description of the target. It defines the<br>
>> backend to use, the binary format to use, OS and Vendor specific quirks to<br>
>> enable/disable, the default CPU, the default ABI, the endian, and countless<br>
>> other details about the target.<br>
><br>
>These two statements aren't necessarily true in whole.<br>
><br>
>a) We don't use the Triple to fully specify the target.<br>
<br>
The key word here is 'fully'. Triples do select an initial complete target<br>
which we then modify with command line options or programatically.<br>
<br>
>b) We don't use the Triple to fully specify the ABI.<br>
<br>
This statement makes the same mistake as in 'a)'.<br>
<br>
>c) We don't use the Triple to fully specify the CPU.<br>
<br>
This statement makes the same mistake as in 'a)'. Additionally, it's important<br>
to note that I said _default_ CPU. You are correct that -target-cpu and similar<br>
specify the CPU but the default CPU is often wrong because it doesn't account<br>
for triple-customization in the GCC toolchain on the same system. X86, ARM, and<br>
Mips examples have already been provided in this thread.<br>
<br>
>d) We do use the triple to handle endianness since most, if not all, triples<br>
>   actually bother to encode endianness.<br>
<br>
And it is occasionally incorrect, as demonstrated in this thread in the (perverse<br>
but sadly real) example where mips-linux-gnu was supposed to target little<br>
endian by default. It should also be noted that the -EL and -EB options currently<br>
operate by hacking the triple and replacing the first component.<br>
<br>
>e) The rest of the "countless details" may or may not be relevant, you haven't<br>
>   given an example of what you care about.<br>
<br>
"grep 'TT\.\|TheTargetTuple\.'" reveals most of the details that LLVM's various<br>
targets derive from the triple. I don't understand all the decisions being made<br>
by all targets but they are definitely using information from the triple to make<br>
behavioural decisions throughout the backends.<br>
<br>
> From here on your email relies on all of these assumptions being true. So I'm<br>
> > going to skip past that part and go to where you answer some of my questions.
<br>
> > At this point, in the MC layer we have a number of classes that need to know the ABI<br>
> > but lack this information. Our TargetMachine has an accurate TargetTuple object that<br>
> > describes the invariants of the desired target. The desired ABI is an invariant too so<br>
> > why not have it in the TargetTuple which is already plumbed in everywhere we need<br>
> > it? After all, it's a property of the target OS/Environment. If we have the ABI in the<br>
> > TargetTuple, then we don't need any other means to set the ABI, tools can set it up<br>
> > front in the TargetTuple and we don't need any command-line option handling for it in the backend.<br>
><br>
> This isn't sufficient anyways as I don't want to depend on a weird serialization format to deal with<br>
> something a simple command line can deal with (or you've said this in a way that's confused me). I see you saying you want:<br>
><br>
> -tuple mips-linux-gnu-abio32-el<br>
><br>
> to specify on a command line to, say, llvm-mc or a new assembler interface, or heck, to clang itself, that you want to compile for:<br>
><br>
> -triple mipsel-linux-gnu -mabi=o32<br>
><br>
> right? Basically? (Bikeshedding of how to actually serialize things aside?)<br>
<br>
I think you're still missing the central point so before I directly answer your<br>
question let met ask you this: What do you believe '-triple mipsel-linux-gnu'<br>
means? You're probably thinking something like "mips32r2 little endian, obviously"<br>
but this is not actually correct all the time. The true answer is 'whatever I<br>
(the person who built the toolchain) want it to mean'. It could be mips32r6, it<br>
could be mips4, it could even be big-endian mips64r5 with nan2008 and msa. It<br>
could even be octeon or p5600. In GCC toolchains, distributors routinely use<br>
configure-time options to define the triple they wish to use. Nothing is<br>
stopping anyone using the same string for completely different meanings and<br>
indeed conflicting definitions are very common. To be compatible with GCC<br>
toolchains we must be able to accommodate triple customization too.<br>
<br>
To answer your question: The reason I wanted that is because a consequence of<br>
supporting triple customization is that '-triple mipsel-linux-gnu' on your<br>
toolchain might mean something different to what it does on my toolchain.<br>
Being able to specify the tuple directly allows us to mitigate these toolchain differences<br>
and avoid the pain of having to figure out which meaning of the triple is in use.<br>
<br>
>> Meanwhile, in clang we have a number of command line options that change the<br>
>> desired target. Let's say we've constructed a Triple and resolved it to<br>
>> TargetTuple (more on that below). We're now processing the –EL option. At the<br>
>> moment, we substitute our mips-linux-gnu triple for a mipsel-linux-gnu triple,<br>
>> construct a Triple object from it and resolve the new Triple to a TargetTuple.<br>
>> But why do we need to bother with that kind of weird hackery when we can simply<br>
>> do Obj.setEndian(Little)? This is what Phase 7 of the plan is about. We end up<br>
>> with a cleaner way to process target changes that, until now, have required<br>
>> weird triple hacking to handle.<br>
><br>
> This is something else I don't understand. Here is the first time you start<br>
> talking about APIs which is what I'm particularly asking about in my earlier<br>
> mails. I'd like to see how you plan on changing the TargetMachine and MC level<br>
> APIs to deal with this. It seems like the Tuple is going to be a way to<br>
> side-load information around to the MC layer and while I agree that something<br>
> is necessary there, I don't think that this solution is the right one. (As I<br>
> said earlier in the thread)<br>
<br>
As far as this section is concerned, I don't intend to change the MC API or<br>
the TargetMachine API at all except in so far as replacing Triple objects with a<br>
TargetTuple. It's the Triple/TargetTuple API that changes to provide more<br>
convenient setters and getters like setEndian()/getEndian(). As you can see the<br>
API side is uninteresting. The important bit is that the values inside the<br>
TargetTuple reflect the desired target and not the arbitrary triple string.<br>
<br>
The ABI follow-on work is slightly different but not very much so. As above, I<br>
don't intend to change the MC/TargetMachine API. By adding the ABI blob-of-data<br>
to the TargetTuple we deliver it to the TargetMachine via the existing plumbing.<br>
After that, targets without per-function ABI selection (which aside from MIPS16<br>
includes MIPS for the foreseeable future) can just consult the TargetTuple since it's<br>
already reachable from everything. Targets that need per-function ABI selection can<br>
use the TargetTuple to initialize a TargetSubtargetInfo, override it as desired, and<br>
have the MC layer consult the TargetSubtargetInfo.<br>
<br>
>> I skipped the Triple -> TargetTuple resolution a moment ago and I should<br>
>> address that now. We already know that mapping Triple to TargetTuple is a<br>
>> many to many mapping. One Triple has many possible TargetTuple's depending<br>
>> on the environment. One TargetTuple can be formed from multiple possible<br>
>> Triples. In an ideal world, we'd like to bake in all of these mappings so<br>
>> that one clang binary supports everything. Unfortunately, being a many to<br>
>> many mapping, some of these mappings are mutually exclusive. Note that this<br>
>> isn't a new problem resulting from this project. The problem has always been<br>
>> there but has been ignored until now. To resolve this, we need to provide<br>
>> configure-time and possibly run-time controls for how this conversion is<br>
>> disambiguated. This resolution is performed as early as possible so that the<br>
>> middle/back-ends don't need to know anything about the ambiguity problem.<br>
><br>
> The minute you start talking about configure time controls we've already lost.<br>
> This, for me, is a non-starter. That said, I'd like to see the examples you<br>
> think show that things are impossible to deal with in the current architecture.<br>
<br>
I don't like it either but we can either deal with the world as it is or attempt<br>
to convince the entire computing industry that they're doing it wrong and need<br>
to replace the multiverse with something sensible. I don't fancy my chances<br>
with the latter so dealing with it is by far the most realistic option.<br>
<br>
I've already given several examples in this thread but to quickly re-iterate some<br>
of them:<br>
* mips-linux-gnu means different things on different Linux distributions.<br>
  * I've seen MIPS-II, MIPS32, MIPS32R2. They can't all be the one true meaning.<br>
  * I've also seen one instance of it meaning little endian.<br>
  * Modern toolchains will mean NAN2008, existing ones usually mean NAN1985.<br>
    (IEEE754-2008 made MIPS's QNaN/SNaN encodings wrong)<br>
  * Some use O32 FPXX instead of plain O32 FP32.<br>
* The sysroot layout for mips-mti-linux-gnu significantly changed in recent<br>
  toolchains. We can't hardcode both layouts since they're mutually exclusive and<br>
  very different.<br>
  * Likewise for mips-img-linux-gnu toolchains.<br>
* mips-linux-gnu -mips64 should produce O32 ABI code on a MIPS64 CPU but currently crashes.<br>
* mips64-linux-gnu -mips32 should produce O32 ABI code on a MIPS32 CPU but currently crashes.<br>
* i386-linux-gnu means i486 on Debian Etch and i586 on more recent Debians<br>
Renato had a number of similar ARM examples too.<br>
<br>
>> What can't be done to TargetMachine to avoid this serialization?<br>
>> TargetMachine already has the serialization (see TargetMachine::TargetTriple).<br>
>> We're not doing anything new here. We're simply replacing one object holding<br>
>> faulty information with a new object holding reliable information.<br>
> This is side stepping my question and making it about Triple. I've specifically<br>
> said that TargetMachine does not and is not completely dependent upon Triple.<br>
<br>
Again, you said 'completely'. If any portion is dependent on the faulty<br>
information in Triple then the behaviour is incorrect.<br>
<br>
>>> And a followup question: What can't be serialized at the function level in<br>
>>> the IR to make certain things clear that aren't global? We already do this<br>
>>> for a lot of command line options.<br>
>> The data I want to fix is global. I think the bit you may be getting hung up<br>
>> on here is that small portions of this global data can also be overridden at<br>
>> the function level. Those overrides aren't a problem and continue to operate<br>
>> in the same way as they do today.<br>
> Examples please.<br>
<br>
Examples of what? The point was that you're on the wrong track. The data I want<br>
to be correct is the data that is already in the triple but is incorrect.<br>
<br>
>> And one more: What global options do we need to consider here?<br>
>> I'm not certain I understand this question. If you're talking command line<br>
>> options, it's things like –EL, -EB, -mips32, -mips32r[2356], -mips64,<br>
>> -mips64r[2356], -mabi=…. If you're talking about Triple -> TargetTuple<br>
>> mappings, there's quite a wide variety but the main ones for Mips are endian,<br>
>> architecture, default CPU, and default ABI.<br>
> <br>
> All of these are representable right now in the TargetMachine as far as I can<br>
> tell. What examples are you having problems with?<br>
<br>
Architecture = Stored in 'TargetMachine::TargetTriple'. As previously explained, it's also<br>
         sometimes incorrect.<br>
Endian = Stored in 'TargetMachine::TargetTriple'. As previously explained, it's also<br>
         sometimes incorrect.<br>
CPU = You're correct on this one.<br>
Default CPU = Implied by the triple but often hardcoded to a single value<br>
              regardless of the correct behaviour of the triple on this target.<br>
Default ABI = Implied by the triple but often hardcoded to a single value<br>
              regardless of the correct behaviour of the triple on this target.<br>
<br>
Examples are earlier in this email.<br>
<br>
>>> The goal of the configuration level of the TargetMachine is that it controls things that don't change at the object level.<br>
>>> This is a fairly recently stated goal, but I think it makes sense for LLVM in general. TargetSubtargetInfo takes care of<br>
>>> everything that resides under this (as much as possible, some bits are still in transition, e.g. TargetOptions). This is part<br>
>>> of my suggestion to Daniel about the problems with MCSubtargetInfo and the assembler. Targets like Mips and ARM<br>
>>> were unfortunately designed to change things on the fly during assembly and need to collate or at least change defaults<br>
>>> as we're processing code. I definitely had to deal with a lot of the pain you're talking about when I was rewriting some<br>
>>> of the handling there during the TargetSubtargetInfo work.<br>
>><br>
>> I generally agree with this. The key bit I need to draw attention to is that<br>
>> the 'defaults' don't change, but are instead overridden. These constant<br>
>> defaults are stored in TargetMachine and particularly<br>
>> TargetMachine::TargetTriple. These defaults are wrong for some toolchains<br>
>> since the information stored in TargetMachine::TargetTriple are wrong. It's<br>
>> the defaults I'm trying to fix rather than the overrides.<br>
> <br>
> I don't understand what you mean here.<br>
<br>
I'm trying to clarify that the default CPU/ABI/etc. is defined by the triple.<br>
There is no single default which is correct for every toolchain.<br>
<br>
Triple implies the default subject to triple customization.<br>
TargetTuple carries the default to TargetMachine constructor.<br>
TargetMachine holds the value to use for the compilation unit (except where overridden).<br>
TargetSubtargetInfo holds the value to use for the function.<br>
<br>
>> I think I understand your proposed plan now and it's a few steps ahead of<br>
>> where we are and where we need to be. I agree that overridable state should<br>
>> be in TargetSubtargetInfo, however I can't initialize that state without the<br>
>> default values which come from the faulty information in<br>
>> TargetMachine::TargetTriple. This triple work is a pre-requisite to your plan<br>
>> and at first I don't need to override ABI's.<br>
> Can you provide an example of using a tool that you're having problems with?<br>
<br>
I'm using this particular example because I have the machine to hand. There are<br>
more examples above. On Debian Jessie (mips):<br>
$ touch empty.c<br>
$ gcc -c -o empty.gcc.o empty.c<br>
$ clang-3.5 -c -o empty.clang.o empty.c<br>
$ file empty.*.o<br>
empty.clang.o: ELF 32-bit MSB relocatable, MIPS, MIPS32 rel2 version 1 (SYSV), not stripped<br>
empty.gcc.o:   ELF 32-bit MSB relocatable, MIPS, MIPS-II version 1 (SYSV), not stripped<br>
<br>
Jessie only has clang-3.5 but you'd get the same result with clang-3.7 and clang-3.8.<br>
<br>
> Could you please provide some examples of things that are impossible right now<br>
> with command lines, how those interact with the TargetMachine, and how you see<br>
> it being impossible to deal with?<br>
<br>
There's some examples above but I'll give the detail in the morning. It's 11:30pm<br>
at the moment :-).<br>
<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF622173"><font color="#000000" face="Tahoma" size="2"><b>From:</b> Eric Christopher [echristo@gmail.com]<br>
<b>Sent:</b> 22 September 2015 20:40<br>
<b>To:</b> Daniel Sanders; Renato Golin; Jim Grosbach<br>
<b>Cc:</b> llvm-dev@lists.llvm.org<br>
<b>Subject:</b> Re: The Trouble with Triples<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr"><br>
<br>
<div class="gmail_quote">
<div dir="ltr">On Thu, Sep 17, 2015 at 6:21 AM Daniel Sanders <<a href="mailto:Daniel.Sanders@imgtec.com" target="_blank">Daniel.Sanders@imgtec.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">I think we need to take a step further back and re-enter from the right starting point. The thing that's bothering me about the push back so far is that it's trying to discuss
 and understand the consequences of resolving the core problem while seemingly ignoring the core problem itself. The reason I've been steering everything back to GNU Triple's being ambiguous and inconsistent is because it's the root of all the problems and
 the fixes to the various issues fall out naturally once this core point has been addressed.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u></span></p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>*sigh*</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">Here's the line of thought that I'd like people to start with:<u></u><u></u></span></p>
<p><u></u><span style="font-size:11.0pt; font-family:Symbol"><span>·<span style="font:7.0pt "Times New Roman"">        
</span></span></span><u></u><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">Triples don't describe the target. They look like they should, but they don't. They're really just arbitrary strings.</span> </p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>Triples are used as a starting point, but no more.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<div>
<p><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u><u></u></span></p>
<p><u></u><span style="font-size:11.0pt; font-family:Symbol"><span>·<span style="font:7.0pt "Times New Roman"">        
</span></span></span><u></u><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">LLVM relies on Triple as a description of the target. It defines the backend to use, the binary format to use, OS and Vendor specific quirks to enable/disable, the
 default CPU, the default ABI, the endian, and countless other details about the target.</span></p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>These two statements aren't necessarily true in whole.</div>
<div><br>
</div>
<div>a) We don't use the Triple to fully specify the target.</div>
<div>b) We don't use the Triple to fully specify the ABI.</div>
<div>c) We don't use the Triple to fully specify the CPU.</div>
<div>d) We do use the triple to handle endianness since most, if not all, triples actually bother to encode endianness.</div>
<div>e) The rest of the "countless details" may or may not be relevant, you haven't given an example of what you care about.</div>
<div><br>
</div>
<div>From here on your email relies on all of these assumptions being true. So I'm going to skip past that part and go to where you answer some of my questions.<span style="font-family:Calibri,sans-serif; font-size:11pt"> </span></div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">At this point, in the MC layer we have a number of classes that need to know the ABI but lack this information. Our TargetMachine has an accurate TargetTuple object that
 describes the invariants of the desired target. The desired ABI is an invariant too so why not have it in the TargetTuple which is already plumbed in everywhere we need it? After all, it's a property of the target OS/Environment. If we have the ABI in the
 TargetTuple, then we don't need any other means to set the ABI, tools can set it up front in the TargetTuple and we don't need any command-line option handling for it in the backend.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u></span></p>
</div>
</blockquote>
<div> </div>
<div>This isn't sufficient anyways as I don't want to depend on a weird serialization format to deal with something a simple command line can deal with (or you've said this in a way that's confused me). I see you saying you want:</div>
<div><br>
</div>
<div>-tuple mips-linux-gnu-abio32-el</div>
<div><br>
</div>
<div>to specify on a command line to, say, llvm-mc or a new assembler interface, or heck, to clang itself, that you want to compile for:</div>
<div><br>
</div>
<div>-triple mipsel-linux-gnu -mabi=o32</div>
<div><br>
</div>
<div>right? Basically? (Bikeshedding of how to actually serialize things aside?)</div>
<div> <br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">Meanwhile, in clang we have a number of command line options that change the desired target. Let's say we've constructed a Triple and resolved it to TargetTuple (more on
 that below). We're now processing the –EL option. At the moment, we substitute our mips-linux-gnu triple for a mipsel-linux-gnu triple, construct a Triple object from it and resolve the new Triple to a TargetTuple. But why do we need to bother with that kind
 of weird hackery when we can simply do Obj.setEndian(Little)? This is what Phase 7 of the plan is about. We end up with a cleaner way to process target changes that, until now, have required weird triple hacking to handle.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u> </span></p>
</div>
</blockquote>
<div><br>
</div>
<div>This is something else I don't understand. Here is the first time you start talking about APIs which is what I'm particularly asking about in my earlier mails. I'd like to see how you plan on changing the TargetMachine and MC level APIs to deal with this.
 It seems like the Tuple is going to be a way to side-load information around to the MC layer and while I agree that something is necessary there, I don't think that this solution is the right one. (As I said earlier in the thread)</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">I skipped the Triple -> TargetTuple resolution a moment ago and I should address that now. We already know that mapping Triple to TargetTuple is a many to many mapping.
 One Triple has many possible TargetTuple's depending on the environment. One TargetTuple can be formed from multiple possible Triples. In an ideal world, we'd like to bake in all of these mappings so that one clang binary supports everything. Unfortunately,
 being a many to many mapping, some of these mappings are mutually exclusive. Note that this isn't a new problem resulting from this project. The problem has always been there but has been ignored until now. To resolve this, we need to provide configure-time
 and possibly run-time controls for how this conversion is disambiguated. This resolution is performed as early as possible so that the middle/back-ends don't need to know anything about the ambiguity problem.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u> </span></p>
</div>
</blockquote>
<div>The minute you start talking about configure time controls we've already lost. This, for me, is a non-starter. That said, I'd like to see the examples you think show that things are impossible to deal with in the current architecture.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">---<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">To reply more directly to your email:</span></p>
</div>
</blockquote>
<div><br>
</div>
<div>Thanks :)</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u><u></u></span></p>
</div>
<div lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">>
</span>What can't be done to TargetMachine to avoid this serialization?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<div lang="EN-GB">
<div>
<p class="MsoNormal">TargetMachine already has the serialization (see TargetMachine::TargetTriple). We're not doing anything new here. We're simply replacing one object holding faulty information with a new object holding reliable information.<u></u><u></u></p>
</div>
</div>
<div lang="EN-GB">
<div>
<p class="MsoNormal"><u></u> </p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>This is side stepping my question and making it about Triple. I've specifically said that TargetMachine does not and is not completely dependent upon Triple.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<div>
<p class="MsoNormal"><u></u></p>
<p class="MsoNormal">> And a followup question: What can't be serialized at the function level in the IR to make certain things clear that aren't global? We already do this for a lot of command line options.<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
</div>
</div>
<div lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">The data I want to fix is global. I think the bit you may be getting hung up on here is that small portions of this global data can also be overridden at the function level.
 Those overrides aren't a problem and continue to operate in the same way as they do today.<u></u><u></u></span></p>
</div>
</div>
<div lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u> </span></p>
</div>
</div>
</blockquote>
<div>Examples please.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u></span></p>
<p class="MsoNormal">> And one more: What global options do we need to consider here?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<div lang="EN-GB">
<div>
<p class="MsoNormal">I'm not certain I understand this question. If you're talking command line options, it's things like –EL, -EB, -mips32, -mips32r[2356], -mips64, -mips64r[2356], -mabi=…. If you're talking about Triple -> TargetTuple mappings, there's quite
 a wide variety but the main ones for Mips are endian, architecture, default CPU, and default ABI.<u></u><u></u></p>
</div>
</div>
<div lang="EN-GB">
<div>
<p class="MsoNormal"><u></u></p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>All of these are representable right now in the TargetMachine as far as I can tell. What examples are you having problems with?</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<div>
<p class="MsoNormal"> <u></u></p>
<p class="MsoNormal">> The goal of the configuration level of the TargetMachine is that it controls things that don't change at the object level.<u></u><u></u></p>
<p class="MsoNormal">> This is a fairly recently stated goal, but I think it makes sense for LLVM in general. TargetSubtargetInfo takes care of<u></u><u></u></p>
<p class="MsoNormal">> everything that resides under this (as much as possible, some bits are still in transition, e.g. TargetOptions). This is part<u></u><u></u></p>
<p class="MsoNormal">> of my suggestion to Daniel about the problems with MCSubtargetInfo and the assembler. Targets like Mips and ARM<u></u><u></u></p>
<p class="MsoNormal">> were unfortunately designed to change things on the fly during assembly and need to collate or at least change defaults<u></u><u></u></p>
<p class="MsoNormal">> as we're processing code. I definitely had to deal with a lot of the pain you're talking about when I was rewriting some<u></u><u></u></p>
<p class="MsoNormal">> of the handling there during the TargetSubtargetInfo work.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<div lang="EN-GB">
<div>
<p class="MsoNormal">I generally agree with this. The key bit I need to draw attention to is that the 'defaults' don't change, but are instead overridden. These constant defaults are stored in TargetMachine and particularly TargetMachine::TargetTriple. These
 defaults are wrong for some toolchains since the information stored in TargetMachine::TargetTriple are wrong. It's the defaults I'm trying to fix rather than the overrides.<u></u><u></u></p>
<p class="MsoNormal"><u></u> </p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>I don't understand what you mean here.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<div>
<p class="MsoNormal"><u></u></p>
<p class="MsoNormal">I think I understand your proposed plan now and it's a few steps ahead of where we are and where we need to be. I agree that overridable state should be in TargetSubtargetInfo, however I can't initialize that state without the default values
 which come from the faulty information in TargetMachine::TargetTriple. This triple work is a pre-requisite to your plan and at first I don't need to override ABI's.<u></u><u></u></p>
</div>
</div>
<div lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u> </span></p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>Can you provide an example of using a tool that you're having problems with?</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">> Right now I see TargetTuple as trying to take over all of the various arguments to TargetMachine and encapsulate them into a single thing.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">> I also don't see this is bad, but I also don't see it taking all of them right now and I'm not sure how it solves some of the existing problems<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">> with data sharing that we've got which is where the push back you're both getting is coming from here. Ultimately library-wise I can agree<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">> with some of the directions you're headed - I just don't see the unification and interactions right now.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
</div>
</div>
<div lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"">I think we'll end up with TargetTuple taking over many arguments to TargetMachine but that's not my goal at this stage. My goal is simply to fix the faulty information currently
 held in Triple and use the now-accurate information in TargetTuple to fix various blocking issues that prevent a proper Mips toolchain product based on Clang/LLVM. At the end of Phase 7, it become possible to fix a number of issues that are impossible to fix
 right now because the available data we can consult at the moment is incorrect.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u> </span></p>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>Could you please provide some examples of things that are impossible right now with command lines, how those interact with the TargetMachine, and how you see it being impossible to deal with?</div>
<div><br>
</div>
<div>Thanks</div>
<div><br>
</div>
<div>-eric</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
<div style="border:none; border-left:solid blue 1.5pt; padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none; border-top:solid #b5c4df 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt; font-family:"Tahoma","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:10.0pt; font-family:"Tahoma","sans-serif"" lang="EN-US"> Eric Christopher [mailto:<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>]
<br>
<b>Sent:</b> 16 September 2015 23:52<br>
<b>To:</b> Renato Golin; Jim Grosbach<br>
<b>Cc:</b> Daniel Sanders; <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">
llvm-dev@lists.llvm.org</a></span></p>
</div>
</div>
</div>
</div>
</div>
<div lang="EN-GB">
<div>
<div style="border:none; border-left:solid blue 1.5pt; padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none; border-top:solid #b5c4df 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Tahoma","sans-serif"" lang="EN-US"><br>
<b>Subject:</b> Re: The Trouble with Triples<u></u><u></u></span></p>
</div>
</div>
</div>
</div>
</div>
<div lang="EN-GB">
<div>
<div style="border:none; border-left:solid blue 1.5pt; padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none; border-top:solid #b5c4df 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><span style="font-size:10.0pt; font-family:"Tahoma","sans-serif"" lang="EN-US"></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Let's take a step back here.<u></u><u></u></p>
</div>
</div>
</div>
</div>
<div lang="EN-GB">
<div>
<div style="border:none; border-left:solid blue 1.5pt; padding:0cm 0cm 0cm 4.0pt">
<div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">It appears that you and Daniel are trying to solve some problems. I think solving problems is good, I just want to make sure that we're solving them in a way that gets us a decent API at the end. I also want to make sure we're solving the
 right problems.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">TargetTuple appears to be related to the TargetParser as you bring up in this mail. They're two separate parts of similar problems - people trying to both serialize command line options and communication from the front end to the backend
 with respect to target information.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">This leads me to a question: What can't be done to TargetMachine to avoid this serialization?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">And a followup question: What can't be serialized at the function level in the IR to make certain things clear that aren't global? We already do this for a lot of command line options.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">And one more: What global options do we need to consider here?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">The goal of the configuration level of the TargetMachine is that it controls things that don't change at the object level. This is a fairly recently stated goal, but I think it makes sense for LLVM in general. TargetSubtargetInfo takes
 care of everything that resides under this (as much as possible, some bits are still in transition, e.g. TargetOptions). This is part of my suggestion to Daniel about the problems with MCSubtargetInfo and the assembler. Targets like Mips and ARM were unfortunately
 designed to change things on the fly during assembly and need to collate or at least change defaults as we're processing code. I definitely had to deal with a lot of the pain you're talking about when I was rewriting some of the handling there during the TargetSubtargetInfo
 work.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Now a bit more on TargetParser + TargetTuple:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">TargetParser appears to be trying to solve the parsing in Triple in a nice way for ARM and also some of the "what kind of subtarget feature canonicalization can we do in llvm that makes sense to communicate
 to the front end". I like this particular idea and have often wanted a library of feature handling, but it seems to have stabilized at an ARM specific set of code with no defined interface. I can't even figure out how I'd use it in lib/Basic right now for
 any target other than ARM. This isn't a condemnation of TargetParser, but I think it's something that needs to be thought through a bit more. It's been hooked up well before I'd expected it to and right now if we moved it to the ARM backend from Support it'd
 make just as much sense as it does where it is now other than making clang depend on the ARM backend as well as the X86 backend :)</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">Right now I see TargetTuple as trying to take over all of the various arguments to TargetMachine and encapsulate them into a single thing. I also don't see this is bad, but I also don't see it taking all of
 them right now and I'm not sure how it solves some of the existing problems with data sharing that we've got which is where the push back you're both getting is coming from here. Ultimately library-wise I can agree with some of the directions you're headed
 - I just don't see the unification and interactions right now.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">As a suggestion as a way forward here let's see if we can get my questions above answered and also show some of how the interactions between llvm's libraries are going to get fixed, moved to a better place,
 etc here.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">Thanks!</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt">-eric</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</div>
</div>
<div lang="EN-GB">
<div>
<div style="border:none; border-left:solid blue 1.5pt; padding:0cm 0cm 0cm 4.0pt">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Wed, Sep 16, 2015 at 3:02 PM Renato Golin <<a href="mailto:renato.golin@linaro.org" target="_blank">renato.golin@linaro.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none; border-left:solid #cccccc 1.0pt; padding:0cm 0cm 0cm 6.0pt; margin-left:4.8pt; margin-right:0cm">
<p class="MsoNormal">On 16 September 2015 at 21:56, Jim Grosbach <<a href="mailto:grosbach@apple.com" target="_blank">grosbach@apple.com</a>> wrote:<br>
> Why do we care about GAS? We have an assembler.<br>
<br>
It's not that simple.<br>
<br>
There are a lot of old code out there, including the Linux kernel<br>
which we do care a lot, that only compiles with GAS. We're slowly<br>
moving the legacy code up to modern standards, and specifically some<br>
kernel folks are happy to move up not only the asm syntax, but the C<br>
standard and move away from GNU-specific behaviour. But we're not<br>
quite there yet, and might not be for a few more years. so, yes, we<br>
still care about GAS.<br>
<br>
But this is not just about GAS.<br>
<br>
As I said on my previous email, this is about clearing the bloat in<br>
target descriptions by both: removing the need for adding numerous CPU<br>
names, target features, architecture names (xscale, strongarm, etc),<br>
AND making sure all parties (front/middle/back-ends) speak the same<br>
language, produced from the same source.<br>
<br>
The TargetTuple is that common language, and the TargetParser created<br>
from the TableGen files is the common source. The Triple becomes a<br>
legacy constructor value for the Tuple. All other target information<br>
classes are already (or should be) generated from the TableGen files,<br>
so the ultimate source becomes the TableGen description, which I think<br>
it what you were aiming to on your comment.<br>
<br>
For simple architectures, like x86, you don't even need a<br>
TargetParser. You can easily construct the Tuple from a triple and use<br>
the Tuple as you've always used the triple. No harm done. But for the<br>
complex ones like ARM and MIPS, having a common interface generated<br>
from the same place the other interfaces are is important to avoid<br>
more bridges between front and middle and back end interpretations of<br>
the same target. Whatever legacy ARM or MIPS carry can be isolated in<br>
their own implementation, leaving the rest of the targets with a clean<br>
and simple interface.<br>
<br>
cheers,<br>
--renato<u></u><u></u></p>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</body>
</html>