[PATCH] D39596: Allow separation of declarations and definitions in <Target>ISelDAGToDAG.inc

Krzysztof Parzyszek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 07:08:54 PDT 2017


kparzysz added a comment.

Here's an example of what an .inc file will look like:

  /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
  |*                                                                            *|
  |* DAG Instruction Selector for the Hexagon target                            *|
  |*                                                                            *|
  |* Automatically generated file, do not edit!                                 *|
  |*                                                                            *|
  \*===----------------------------------------------------------------------===*/
  
  // *** NOTE: This file is #included into the middle of the target
  // *** instruction selector class.  These functions are really methods.
  
  // If GET_DAGISEL_DECL is #defined with any value, only function
  // declarations will be included when this file is included.
  // If GET_DAGISEL_BODY is #defined, its value should be the name of
  // the instruction selector class. Function bodies will be emitted
  // and each function's name will be qualified with the name of the
  // class.
  //
  // When neither of the GET_DAGISEL* macros is defined, the functions
  // are emitted inline.
  
  #if defined(GET_DAGISEL_DECL) && defined(GET_DAGISEL_BODY)
  #error GET_DAGISEL_DECL and GET_DAGISEL_BODY cannot be both defined, undef both for inline definitions
  #endif
  
  #ifdef GET_DAGISEL_BODY
  #define LOCAL_DAGISEL_STRINGIZE(X) LOCAL_DAGISEL_STRINGIZE_(X)
  #define LOCAL_DAGISEL_STRINGIZE_(X) #X
  static_assert(sizeof(LOCAL_DAGISEL_STRINGIZE(GET_DAGISEL_BODY)) > 1,
     "GET_DAGISEL_BODY is empty: it should be defined with the class name");
  #undef LOCAL_DAGISEL_STRINGIZE_
  #undef LOCAL_DAGISEL_STRINGIZE
  #endif
  
  #if !defined(GET_DAGISEL_DECL) && !defined(GET_DAGISEL_BODY)
  #define DAGISEL_INLINE 1
  #else
  #define DAGISEL_INLINE 0
  #endif
  
  #if !DAGISEL_INLINE
  #define DAGISEL_CLASS_COLONCOLON GET_DAGISEL_BODY ::
  #else
  #define DAGISEL_CLASS_COLONCOLON
  #endif
  
  #ifdef GET_DAGISEL_DECL
  void SelectCode(SDNode *N);
  #endif
  #if defined(GET_DAGISEL_BODY) || DAGISEL_INLINE
  void DAGISEL_CLASS_COLONCOLON SelectCode(SDNode *N)
  {
    [...]
  }
  #endif // GET_DAGISEL_BODY
  #ifdef GET_DAGISEL_DECL
  bool CheckPatternPredicate(unsigned PredNo) const override;
  #endif
  #if defined(GET_DAGISEL_BODY) || DAGISEL_INLINE
  bool DAGISEL_CLASS_COLONCOLON CheckPatternPredicate(unsigned PredNo) const
  #if DAGISEL_INLINE
    override
  #endif
  {
    [...]
  }
  
  // etc.
  
  
  #ifdef DAGISEL_INLINE
  #undef DAGISEL_INLINE
  #endif
  #ifdef DAGISEL_CLASS_COLONCOLON
  #undef DAGISEL_CLASS_COLONCOLON
  #endif
  #ifdef GET_DAGISEL_DECL
  #undef GET_DAGISEL_DECL
  #endif
  #ifdef GET_DAGISEL_BODY
  #undef GET_DAGISEL_BODY
  #endif


Repository:
  rL LLVM

https://reviews.llvm.org/D39596





More information about the llvm-commits mailing list