[llvm-dev] RFC: Splitting <Target>DAGISel.inc into declarations and definitions

Krzysztof Parzyszek via llvm-dev llvm-dev at lists.llvm.org
Thu Nov 2 13:12:26 PDT 2017


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:

--- FooDAGISel.inc ---
void SelectCode(Node *N) {
   // 1E6 lines of pattern matching code

--- FooISelDAGToDAG.cpp ---
class FooDAGToDAGISel : public SelectionDAGISel {
#include "FooDAGISel.inc"

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).

What I propose is to have TableGen emit information that would allow 
something like this:

class FooDAGToDAGISel : public SelectionDAGISel {
#include "FooDAGISel.inc"

#include "FooDAGISel.inc"

This would allow only putting member declarations in the class 
definition, and then include the member bodies in a single place.

What does everybody think?


Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation

More information about the llvm-dev mailing list