<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">I've found a simpler way.<br>
I never overwrite a value, thus I can replace my usage of [] for
insertion by insert.<br>
Then I can replace my accesses with [] by find.<br>
<br>
It seems to work.<br>
<br>
Axel<br>
<br>
On 20/03/2017 00:09, Mekhanoshin, Stanislav wrote:<br>
</div>
<blockquote
cite="mid:BN6PR12MB1233E1147E2730F5BE0C1204ED3B0@BN6PR12MB1233.namprd12.prod.outlook.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<div style="color: black;">
<div style="color: #1f497d; font-family: Calibri, Myriad,
'Liberation Sans', sans-serif; font-size: 12pt;">
<p style="margin: 0 0 1em 0; color: #1f497d; font-family:
Calibri, Myriad, 'Liberation Sans', sans-serif; font-size:
12pt;">
Axel, I would subclass map instantiation and define own
operator[].</p>
<p style="margin: 0 0 1em 0; color: #1f497d; font-family:
Calibri, Myriad, 'Liberation Sans', sans-serif; font-size:
12pt;">
Stas<br>
</p>
</div>
<div style="color: black;">
<table style="color: black; font-size: 10pt; font-family:
Arial, sans-serif;" border="0" cellpadding="0"
cellspacing="0">
<tbody>
<tr>
<td colspan="2">--- Original message ---</td>
</tr>
<tr>
<td><b>From: </b></td>
<td>Axel Davy <a class="moz-txt-link-rfc2396E" href="mailto:axel.davy@ens.fr"><axel.davy@ens.fr></a></td>
</tr>
<tr>
<td><b>Sent: </b></td>
<td>March 19, 2017 4:00:49 PM</td>
</tr>
<tr>
<td><b>To: </b></td>
<td>Daniel Berlin <a class="moz-txt-link-rfc2396E" href="mailto:dberlin@dberlin.org"><dberlin@dberlin.org></a></td>
</tr>
<tr>
<td><b>CC: </b></td>
<td><a class="moz-txt-link-abbreviated" href="mailto:reviews+D31123+public+a88be35608dd4bb7@reviews.llvm.org">reviews+D31123+public+a88be35608dd4bb7@reviews.llvm.org</a>,
Matthias Braun <a class="moz-txt-link-rfc2396E" href="mailto:matze@braunis.de"><matze@braunis.de></a>, Mekhanoshin,
Stanislav <a class="moz-txt-link-rfc2396E" href="mailto:Stanislav.Mekhanoshin@amd.com"><Stanislav.Mekhanoshin@amd.com></a>,
Alexander Timofeev
<a class="moz-txt-link-rfc2396E" href="mailto:timofeev.alexander@gmail.com"><timofeev.alexander@gmail.com></a>, llvm-commits
<a class="moz-txt-link-rfc2396E" href="mailto:llvm-commits@lists.llvm.org"><llvm-commits@lists.llvm.org></a></td>
</tr>
<tr>
<td><b>Subject: </b></td>
<td>Re: [PATCH] D31123: RegisterPressure: Add operators
to RegisterMaskPair</td>
</tr>
</tbody>
</table>
<br>
<blockquote type="cite" class="gmail_quote" style="margin: 0 0
0 0.75ex; border-left: 1px solid #808080; padding-left:
0.75ex;">
<div class="moz-cite-prefix">Thanks.<br>
<br>
This looks like a lot of code just to replace two lines
though, should I really prefer this code over the previous
one ?<br>
<br>
Do you have suggestion to remove the errors when the the
constructor RegisterMaskPair() is not added ?<br>
<br>
Compilation gives<br>
<br>
In file included from
/home/axel/packages/llvm/llvm/include/llvm/PassRegistry.h:20:0,<br>
from
/home/axel/packages/llvm/llvm/include/llvm/PassSupport.h:27,<br>
from
/home/axel/packages/llvm/llvm/include/llvm/Pass.h:387,<br>
from
/home/axel/packages/llvm/llvm/include/llvm/IR/DataLayout.h:27,<br>
from
/home/axel/packages/llvm/llvm/include/llvm/Target/TargetMachine.h:19,<br>
from
/home/axel/packages/llvm/llvm/lib/Target/AMDGPU/AMDGPU.h:14,<br>
from
/home/axel/packages/llvm/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp:15:<br>
/home/axel/packages/llvm/llvm/include/llvm/ADT/DenseMap.h:
Dans l'instanciation de « BucketT*
llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT,
BucketT>::InsertIntoBucket(BucketT*, KeyArg&&,
ValueArgs&& ...) [with KeyArg = const unsigned
int&; ValueArgs = {}; DerivedT =
llvm::DenseMap<unsigned int,
llvm::RegisterMaskPair>; KeyT = unsigned int; ValueT =
llvm::RegisterMaskPair; KeyInfoT =
llvm::DenseMapInfo<unsigned int>; BucketT =
llvm::detail::DenseMapPair<unsigned int,
llvm::RegisterMaskPair>] » :<br>
/home/axel/packages/llvm/llvm/include/llvm/ADT/DenseMap.h:270:12:
requis par « llvm::DenseMapBase<DerivedT, KeyT, ValueT,
KeyInfoT, BucketT>::value_type&
llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT,
BucketT>::FindAndConstruct(const KeyT&) [with
DerivedT = llvm::DenseMap<unsigned int,
llvm::RegisterMaskPair>; KeyT = unsigned int; ValueT =
llvm::RegisterMaskPair; KeyInfoT =
llvm::DenseMapInfo<unsigned int>; BucketT =
llvm::detail::DenseMapPair<unsigned int,
llvm::RegisterMaskPair>;
llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT,
BucketT>::value_type =
llvm::detail::DenseMapPair<unsigned int,
llvm::RegisterMaskPair>] »<br>
/home/axel/packages/llvm/llvm/include/llvm/ADT/DenseMap.h:274:28:
requis par « ValueT& llvm::DenseMapBase<DerivedT,
KeyT, ValueT, KeyInfoT, BucketT>::operator[](const
KeyT&) [with DerivedT = llvm::DenseMap<unsigned
int, llvm::RegisterMaskPair>; KeyT = unsigned int;
ValueT = llvm::RegisterMaskPair; KeyInfoT =
llvm::DenseMapInfo<unsigned int>; BucketT =
llvm::detail::DenseMapPair<unsigned int,
llvm::RegisterMaskPair>] »<br>
/home/axel/packages/llvm/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp:2142:37:
requis depuis ici<br>
/home/axel/packages/llvm/llvm/include/llvm/ADT/DenseMap.h:458:5:
erreur : no matching function for call to
« llvm::RegisterMaskPair::RegisterMaskPair() »<br>
::new (&TheBucket->getSecond())
ValueT(std::forward<ValueArgs>(Values)...);<br>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
In file included from
/home/axel/packages/llvm/llvm/include/llvm/CodeGen/MachineScheduler.h:87:0,<br>
from
/home/axel/packages/llvm/llvm/lib/Target/AMDGPU/SIMachineScheduler.h:20,<br>
from
/home/axel/packages/llvm/llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp:17:<br>
/home/axel/packages/llvm/llvm/include/llvm/CodeGen/RegisterPressure.h:42:3:
note : candidate:
llvm::RegisterMaskPair::RegisterMaskPair(unsigned int,
llvm::LaneBitmask)<br>
RegisterMaskPair(unsigned RegUnit, LaneBitmask
LaneMask)<br>
^~~~~~~~~~~~~~~~<br>
/home/axel/packages/llvm/llvm/include/llvm/CodeGen/RegisterPressure.h:42:3:
note : candidate expects 2 arguments, 0 provided<br>
/home/axel/packages/llvm/llvm/include/llvm/CodeGen/RegisterPressure.h:38:8:
note : candidate: constexpr
llvm::RegisterMaskPair::RegisterMaskPair(const
llvm::RegisterMaskPair&)<br>
struct RegisterMaskPair {<br>
^~~~~~~~~~~~~~~~<br>
/home/axel/packages/llvm/llvm/include/llvm/CodeGen/RegisterPressure.h:38:8:
note : candidate expects 1 argument, 0 provided<br>
/home/axel/packages/llvm/llvm/include/llvm/CodeGen/RegisterPressure.h:38:8:
note : candidate: constexpr
llvm::RegisterMaskPair::RegisterMaskPair(llvm::RegisterMaskPair&&)<br>
/home/axel/packages/llvm/llvm/include/llvm/CodeGen/RegisterPressure.h:38:8:
note : candidate expects 1 argument, 0 provided<br>
<br>
On 19/03/2017 23:43, Daniel Berlin wrote:<br>
</div>
<blockquote
cite="mid:CAF4BwTXR96U6-O2RbtQKLqjNgnSiZ2ar+koJTvJqmdsySJLnjg@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Sun, Mar 19, 2017 at 3:28
PM, Axel Davy <span dir="ltr">
<<a moz-do-not-send="true"
href="mailto:axel.davy@ens.fr" target="_blank">axel.davy@ens.fr</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px
0px 0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<div
class="gmail-m_6555702049878739804moz-cite-prefix">I'm
not familiar with std::transform, but it looks
like one element in the source<br>
can only give one element in the destination,
whereas here you can have one element<br>
decomposing into several ones.</div>
</div>
</blockquote>
<div><br>
</div>
<div>std::transform does not require the input ==
the output type.</div>
<div><br>
</div>
<div>It only requires that assignment of the output
iterator takes the type</div>
<div><br>
</div>
<div>Thus, the following should work:<br>
<br>
</div>
<div>std::transform(Regs.begin(), Regs.end(),
vector_inserter(Result), [&] (const
RegisterMaskPair &RegPair)</div>
<div>{<br>
<blockquote class="gmail_quote" style="margin:0px
0px 0px 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
return getPairsForReg(RegPair.RegUnit,
RegPair.LaneMask)</blockquote>
</div>
<div>});</div>
<div><br>
</div>
<div>
<div>
<div><br>
</div>
</div>
</div>
<div>Where vector_inserter is defined as:<br>
<div>class vector__inserter</div>
<div> : public
std::iterator<std::output_iterator_tag, void,
void, void, void> {</div>
<div>private:</div>
<div> SmallVectorImpl<RegisterMaskPair>
&Result;<br>
<br>
</div>
<div>public:</div>
<div> explicit
op_inserter(SmallVectorImpl<RegisterMaskPair>
&Result) : Result(Result) {}<br>
</div>
<div><br>
</div>
<div> op_inserter &operator=(const
SmallVectorImpl<RegisterMaskPair>
&Val) {</div>
<div> Result.insert(Result.end(), Val.begin(),
Val.end())</div>
<div> return *this;</div>
<div> }</div>
<div> vector_inserter &operator*() { return
*this; }</div>
<div> vector_inserter &operator++() { return
*this; }</div>
<div> vector_inserter &operator++(int) {
return *this; }</div>
<div>};</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
</blockquote>
<p><br>
</p>
</blockquote>
</div>
</div>
</blockquote>
<p><br>
</p>
</body>
</html>