<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Hi Craig,<br>
<br>
Whenever I write helper functions, I'm never sure whether to make them<br>
static or private member functions.  What criteria did you use when<br>
choosing to make these functions static?<br>
<br>
Thanks,<br>
Tom<br>
<br></blockquote><div><br></div><div>Part of this answer is going to be very specific to the set of routines that I was dealing with.</div><div><br></div><div>Some of these didn't access anything from the class they were in. That case should be static at least in the class. If not outside the class in the implementation file itself. I think <span style="font-family:arial,sans-serif;font-size:13px">LowerSDIV in this particular commit fell into that class.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Another class of things I changed was ones that only needed the X86Subtarget from the class they were in. This file is full of methods that are were already static that fell into this type of function. So I was just following along and passing them the one extra parameter they needed.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">There were a few that needed some virtual methods from TargetLowering (which is the parent class of X86TargetLowering). So they maybe should have been in the class. But it turns out its easy to get a pointer to the TargetLowering base from the DAG argument passed to all these functions. Obviously this doesn't work if they are calling methods that only exist in X86TargetLowering itself. And again there were already examples of functions that were querying the TargetLowering from the DAG parameter.</span></div>
<div><br></div><div>So it comes down to a tradeoff of how much extra stuff you would need to pass to make it a static function I guess. If you end up passing 'this' it definitely should just be in the class.<br></div>
<div> </div></div>~Craig
</div></div>