<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;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 2, 2014, at 9:57 AM, Chandler Carruth <<a href="mailto:chandlerc@google.com" class="">chandlerc@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Aug 29, 2014 at 3:07 PM, Pete Cooper <span dir="ltr" class=""><<a href="mailto:peter_cooper@apple.com" target="_blank" class="">peter_cooper@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class="">Still not sure why its better to make all of this public…</div></div></div></div></blockquote>Ultimately it was because tablegen couldn’t set the values of the private fields when it used the ‘x = { … }’ syntax.</blockquote></div><br class=""></div><div class="gmail_extra">So, I'll ask a question in complete ignorance because I don't understand how tablegen works. Please don't hold anything up based on this question, just hoping you'll enlighten me.</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">If there is a static method to return a local variable constructed with the correct defaults, and/or a default constructor which provides them, why can't TableGen produce that? I'm imagining TableGen emitting the "return Blah(X, Y, Z, ...);" statement.</div></div></div></blockquote>Tablegen does actually construct a default model for targets which need it.  I think the only problem is getting that target specific model from say X86GenSubTargetInfo.inc to the target independent passes like Andy mentioned.  I’m happy to try figure out a way to do this.</div><div><br class=""></div><div>If you’re curious, this is what X86 currently generates for its NoSchedModel.  Other targets are almost certainly the same.</div><div><br class=""></div><div>static const llvm::MCSchedModel NoSchedModel = {<br class="">  MCSchedModel::DefaultIssueWidth,<br class="">  MCSchedModel::DefaultMicroOpBufferSize,<br class="">  MCSchedModel::DefaultLoopMicroOpBufferSize,<br class="">  MCSchedModel::DefaultLoadLatency,<br class="">  MCSchedModel::DefaultHighLatency,<br class="">  MCSchedModel::DefaultMispredictPenalty,<br class="">  0, // PostRAScheduler<br class="">  1, // CompleteModel<br class="">  0, // Processor ID<br class="">  0, 0, 0, 0, // No instruction-level machine model.<br class="">  nullptr}; // No Itinerary</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><br class=""></div><div class="gmail_extra">That seems better than having a global at all, even if it is {} initialized as an aggregate.... But there is probably a reason why this can't be done. =]</div></div>
</div></blockquote>Yeah, i’d like to avoid the { } constructor I have in the C++ code too.  Sounds tricky because of the target independent code, but maybe its possible.</div><div><br class=""></div><div>Naively, we could wrap all MCSchelModel’s in the target independent passes in Optional, but then we’d have to have them not run the pass (or part of the pass perhaps) in the case where the model doesn’t exist.  That would be a change of behavior, but then maybe thats worth investigating?</div><div><br class=""></div><div>Pete</div><br class=""></body></html>