<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-void PPCTTI::getUnrollingPreferences(Loop *L, UnrollingPreferences &UP) const {<br>
-  if (ST->getDarwinDirective() == PPC::DIR_A2) {<br>
+void PPCTTI::getUnrollingPreferences(const Function *F, Loop *L,<br>
+                                     UnrollingPreferences &UP) const {<br></blockquote><div><br></div></div></div><div>And in places like this, if you passed the Subtarget, you could even call it "ST" and then the body of the function wouldn't need any changes at all. (granted, shadowing is subtle stuff... so I can understand if that's not ideal - but given the ultimate future will end up removing the member variable, it might be an acceptable intermediate state to reduce typing/churn)</div></div></div></div></blockquote><div><br></div></span><div>Right. And this would be why it might work. I.e. instead of Function, take Subtarget since that'll be what everything uses ultimately to get the various target data structures. I have no ultimate preference here other than I will likely have to cast that subtarget no matter what to be the type of the actual TargetSubtargetInfo that the target wants (I.e. PPCSubtargetInfo).</div><div><br></div><div>That said, it doesn't necessarily lose me anything.</div></div></div></div></blockquote><div><br></div></span><div>Having thought about this I think I'm going to go with it. I'll still have to do the specific casts but it will save some additional lookups and compile time. It might be premature optimization, but the API isn't any worse with it so let's do it.</div><span class="HOEnZb"><font color="#888888"><div><br></div></font></span></div></div></div></blockquote><div><br></div><div>Well, it turns out you can't get there from here. At least not by any map I've got.</div><div><br></div><div>The function doesn't have a pointer to the TargetMachine which means I can't do it via runOnFunction, so the only way I could construct this would be to use INITIALIZE_TM_PASS, but that will end up putting CodeGen into Analysis, which puts it into Scalar opts, which the comment above INITIALIZE_TM_PASS says would cause a cycle and don't do it.</div><div><br></div><div>I might be able to add a getAnalysis that takes a TM as an argument, but that starts to lead us down the same hole.</div><div><br></div><div>cc'ing Chandler to see if he has any ideas.</div><div><br></div><div>-eric</div></div></div></div>