<div dir="ltr">This seems reasonable to me.<div><br></div><div>Though I think we usually make these things self cleaning so the "#undef DAGISEL_DECL" should be in the .inc file after its #ifdef.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote">On Thu, Nov 2, 2017 at 1:12 PM, Krzysztof Parzyszek via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Currently, TableGen generates all the instruction selection functions (in the .inc file) as if they were top-most functions. To make them members of their corresponding SelectionDAGISel derivative, each target has to include the .inc file directly into the body of the class:<br>
<br>
--- FooDAGISel.inc ---<br>
void SelectCode(Node *N) {<br>
// 1E6 lines of pattern matching code<br>
}<br>
...<br>
----------------------<br>
<br>
--- FooISelDAGToDAG.cpp ---<br>
class FooDAGToDAGISel : public SelectionDAGISel {<br>
#include "FooDAGISel.inc"<br>
};<br>
---------------------------<br>
<br>
If someone wanted to put the class definition in a separate header file, the large .inc file would need to be included in that header. If that someone then wanted to split their .cpp file into smaller pieces, each such .cpp would contain these function bodies (which would then be needlessly compiled multiple times).<br>
<br>
<br>
What I propose is to have TableGen emit information that would allow something like this:<br>
<br>
class FooDAGToDAGISel : public SelectionDAGISel {<br>
#define DAGISEL_DECL<br>
#include "FooDAGISel.inc"<br>
#undef DAGISEL_DECL<br>
};<br>
<br>
#define DAGISEL_BODY(FooDAGToDAGISel)<br>
#include "FooDAGISel.inc"<br>
#undef DAGISEL_BODY<br>
<br>
This would allow only putting member declarations in the class definition, and then include the member bodies in a single place.<br>
<br>
What does everybody think?<span class="HOEnZb"><font color="#888888"><br>
<br>
-Krzysztof<br>
<br>
<br>
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</font></span></blockquote></div><br></div>