[llvm] r335407 - [IR] Split Intrinsics.inc into enums and implementations

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 22 20:11:33 PDT 2018


Yikes, I thought check passed, but I forgot to fixup the AMDGPU includes.
Done in r335409.

On Fri, Jun 22, 2018 at 7:07 PM Reid Kleckner via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: rnk
> Date: Fri Jun 22 19:02:38 2018
> New Revision: 335407
>
> URL: http://llvm.org/viewvc/llvm-project?rev=335407&view=rev
> Log:
> [IR] Split Intrinsics.inc into enums and implementations
>
> Implements PR34259
>
> Intrinsics.h is a very popular header. Most LLVM TUs care about things
> like dbg_value, but they don't care how they are implemented. After I
> split these out, IntrinsicImpl.inc is 1.7 MB, so this saves each LLVM TU
> from scanning 1.7 MB of source that gets pre-processed away.
>
> It also means we can modify intrinsic properties without triggering a
> full rebuild, but that's probably less of a win.
>
> I think the next best thing to do would be to split out the target
> intrinsics into their own header. Very, very few TUs care about
> target-specific intrinsics. It's very hard to split up the target
> independent intrinsics like llvm.expect, assume, and dbg.value, though.
>
> Modified:
>     llvm/trunk/include/llvm/IR/CMakeLists.txt
>     llvm/trunk/include/llvm/IR/Intrinsics.h
>     llvm/trunk/lib/IR/Function.cpp
>     llvm/trunk/lib/Target/AMDGPU/CMakeLists.txt
>     llvm/trunk/test/TableGen/intrinsic-long-name.td
>     llvm/trunk/test/TableGen/intrinsic-struct.td
>     llvm/trunk/test/TableGen/intrinsic-varargs.td
>     llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
>     llvm/trunk/utils/TableGen/TableGen.cpp
>     llvm/trunk/utils/TableGen/TableGenBackends.h
>
> Modified: llvm/trunk/include/llvm/IR/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/CMakeLists.txt?rev=335407&r1=335406&r2=335407&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/CMakeLists.txt (original)
> +++ llvm/trunk/include/llvm/IR/CMakeLists.txt Fri Jun 22 19:02:38 2018
> @@ -2,5 +2,6 @@ set(LLVM_TARGET_DEFINITIONS Attributes.t
>  tablegen(LLVM Attributes.inc -gen-attrs)
>
>  set(LLVM_TARGET_DEFINITIONS Intrinsics.td)
> -tablegen(LLVM Intrinsics.inc -gen-intrinsic)
> +tablegen(LLVM IntrinsicEnums.inc -gen-intrinsic-enums)
> +tablegen(LLVM IntrinsicImpl.inc -gen-intrinsic-impl)
>  add_public_tablegen_target(intrinsics_gen)
>
> Modified: llvm/trunk/include/llvm/IR/Intrinsics.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Intrinsics.h?rev=335407&r1=335406&r2=335407&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/Intrinsics.h (original)
> +++ llvm/trunk/include/llvm/IR/Intrinsics.h Fri Jun 22 19:02:38 2018
> @@ -39,7 +39,7 @@ namespace Intrinsic {
>
>      // Get the intrinsic enums generated from Intrinsics.td
>  #define GET_INTRINSIC_ENUM_VALUES
> -#include "llvm/IR/Intrinsics.inc"
> +#include "llvm/IR/IntrinsicEnums.inc"
>  #undef GET_INTRINSIC_ENUM_VALUES
>      , num_intrinsics
>    };
>
> Modified: llvm/trunk/lib/IR/Function.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=335407&r1=335406&r2=335407&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/Function.cpp (original)
> +++ llvm/trunk/lib/IR/Function.cpp Fri Jun 22 19:02:38 2018
> @@ -487,13 +487,13 @@ void Function::copyAttributesFrom(const
>  static const char * const IntrinsicNameTable[] = {
>    "not_intrinsic",
>  #define GET_INTRINSIC_NAME_TABLE
> -#include "llvm/IR/Intrinsics.inc"
> +#include "llvm/IR/IntrinsicImpl.inc"
>  #undef GET_INTRINSIC_NAME_TABLE
>  };
>
>  /// Table of per-target intrinsic name tables.
>  #define GET_INTRINSIC_TARGET_DATA
> -#include "llvm/IR/Intrinsics.inc"
> +#include "llvm/IR/IntrinsicImpl.inc"
>  #undef GET_INTRINSIC_TARGET_DATA
>
>  /// Find the segment of \c IntrinsicNameTable for intrinsics with the same
> @@ -840,7 +840,7 @@ static void DecodeIITType(unsigned &Next
>  }
>
>  #define GET_INTRINSIC_GENERATOR_GLOBAL
> -#include "llvm/IR/Intrinsics.inc"
> +#include "llvm/IR/IntrinsicImpl.inc"
>  #undef GET_INTRINSIC_GENERATOR_GLOBAL
>
>  void Intrinsic::getIntrinsicInfoTableEntries(ID id,
> @@ -977,7 +977,7 @@ FunctionType *Intrinsic::getType(LLVMCon
>
>  bool Intrinsic::isOverloaded(ID id) {
>  #define GET_INTRINSIC_OVERLOAD_TABLE
> -#include "llvm/IR/Intrinsics.inc"
> +#include "llvm/IR/IntrinsicImpl.inc"
>  #undef GET_INTRINSIC_OVERLOAD_TABLE
>  }
>
> @@ -995,7 +995,7 @@ bool Intrinsic::isLeaf(ID id) {
>
>  /// This defines the "Intrinsic::getAttributes(ID id)" method.
>  #define GET_INTRINSIC_ATTRIBUTES
> -#include "llvm/IR/Intrinsics.inc"
> +#include "llvm/IR/IntrinsicImpl.inc"
>  #undef GET_INTRINSIC_ATTRIBUTES
>
>  Function *Intrinsic::getDeclaration(Module *M, ID id, ArrayRef<Type*>
> Tys) {
> @@ -1008,12 +1008,12 @@ Function *Intrinsic::getDeclaration(Modu
>
>  // This defines the "Intrinsic::getIntrinsicForGCCBuiltin()" method.
>  #define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
> -#include "llvm/IR/Intrinsics.inc"
> +#include "llvm/IR/IntrinsicImpl.inc"
>  #undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
>
>  // This defines the "Intrinsic::getIntrinsicForMSBuiltin()" method.
>  #define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
> -#include "llvm/IR/Intrinsics.inc"
> +#include "llvm/IR/IntrinsicImpl.inc"
>  #undef GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
>
>  bool Intrinsic::matchIntrinsicType(Type *Ty,
> ArrayRef<Intrinsic::IITDescriptor> &Infos,
>
> Modified: llvm/trunk/lib/Target/AMDGPU/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/CMakeLists.txt?rev=335407&r1=335406&r2=335407&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/AMDGPU/CMakeLists.txt (original)
> +++ llvm/trunk/lib/Target/AMDGPU/CMakeLists.txt Fri Jun 22 19:02:38 2018
> @@ -7,7 +7,8 @@ tablegen(LLVM AMDGPUGenDAGISel.inc -gen-
>  tablegen(LLVM AMDGPUGenDFAPacketizer.inc -gen-dfa-packetizer)
>  tablegen(LLVM AMDGPUGenDisassemblerTables.inc -gen-disassembler)
>  tablegen(LLVM AMDGPUGenInstrInfo.inc -gen-instr-info)
> -tablegen(LLVM AMDGPUGenIntrinsics.inc -gen-tgt-intrinsic)
> +tablegen(LLVM AMDGPUGenIntrinsicEnums.inc -gen-tgt-intrinsic-enums)
> +tablegen(LLVM AMDGPUGenIntrinsicImpl.inc -gen-tgt-intrinsic-impl)
>  tablegen(LLVM AMDGPUGenMCCodeEmitter.inc -gen-emitter)
>  tablegen(LLVM AMDGPUGenMCPseudoLowering.inc -gen-pseudo-lowering)
>  tablegen(LLVM AMDGPUGenRegisterBank.inc -gen-register-bank)
>
> Modified: llvm/trunk/test/TableGen/intrinsic-long-name.td
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/intrinsic-long-name.td?rev=335407&r1=335406&r2=335407&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/TableGen/intrinsic-long-name.td (original)
> +++ llvm/trunk/test/TableGen/intrinsic-long-name.td Fri Jun 22 19:02:38
> 2018
> @@ -1,4 +1,4 @@
> -// RUN: llvm-tblgen -gen-intrinsic %s | FileCheck %s
> +// RUN: llvm-tblgen -gen-intrinsic-enums %s | FileCheck %s
>  // XFAIL: vg_leak
>
>  class IntrinsicProperty;
>
> Modified: llvm/trunk/test/TableGen/intrinsic-struct.td
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/intrinsic-struct.td?rev=335407&r1=335406&r2=335407&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/TableGen/intrinsic-struct.td (original)
> +++ llvm/trunk/test/TableGen/intrinsic-struct.td Fri Jun 22 19:02:38 2018
> @@ -1,4 +1,4 @@
> -// RUN: llvm-tblgen -gen-intrinsic %s | FileCheck %s
> +// RUN: llvm-tblgen -gen-intrinsic-enums %s | FileCheck %s
>  // XFAIL: vg_leak
>
>  class IntrinsicProperty;
>
> Modified: llvm/trunk/test/TableGen/intrinsic-varargs.td
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/intrinsic-varargs.td?rev=335407&r1=335406&r2=335407&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/TableGen/intrinsic-varargs.td (original)
> +++ llvm/trunk/test/TableGen/intrinsic-varargs.td Fri Jun 22 19:02:38 2018
> @@ -1,4 +1,4 @@
> -// RUN: llvm-tblgen -gen-intrinsic %s | FileCheck %s
> +// RUN: llvm-tblgen -gen-intrinsic-impl %s | FileCheck %s
>  // XFAIL: vg_leak
>
>  class IntrinsicProperty;
>
> Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp?rev=335407&r1=335406&r2=335407&view=diff
>
> ==============================================================================
> --- llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp (original)
> +++ llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Fri Jun 22 19:02:38 2018
> @@ -34,7 +34,7 @@ public:
>    IntrinsicEmitter(RecordKeeper &R, bool T)
>      : Records(R), TargetOnly(T) {}
>
> -  void run(raw_ostream &OS);
> +  void run(raw_ostream &OS, bool Enums);
>
>    void EmitPrefix(raw_ostream &OS);
>
> @@ -56,7 +56,7 @@ public:
>  // IntrinsicEmitter Implementation
>
>  //===----------------------------------------------------------------------===//
>
> -void IntrinsicEmitter::run(raw_ostream &OS) {
> +void IntrinsicEmitter::run(raw_ostream &OS, bool Enums) {
>    emitSourceFileHeader("Intrinsic Function Source Fragment", OS);
>
>    CodeGenIntrinsicTable Ints(Records, TargetOnly);
> @@ -66,29 +66,31 @@ void IntrinsicEmitter::run(raw_ostream &
>
>    EmitPrefix(OS);
>
> -  // Emit the enum information.
> -  EmitEnumInfo(Ints, OS);
> -
> -  // Emit the target metadata.
> -  EmitTargetInfo(Ints, OS);
> +  if (Enums) {
> +    // Emit the enum information.
> +    EmitEnumInfo(Ints, OS);
> +  } else {
> +    // Emit the target metadata.
> +    EmitTargetInfo(Ints, OS);
>
> -  // Emit the intrinsic ID -> name table.
> -  EmitIntrinsicToNameTable(Ints, OS);
> +    // Emit the intrinsic ID -> name table.
> +    EmitIntrinsicToNameTable(Ints, OS);
>
> -  // Emit the intrinsic ID -> overload table.
> -  EmitIntrinsicToOverloadTable(Ints, OS);
> +    // Emit the intrinsic ID -> overload table.
> +    EmitIntrinsicToOverloadTable(Ints, OS);
>
> -  // Emit the intrinsic declaration generator.
> -  EmitGenerator(Ints, OS);
> +    // Emit the intrinsic declaration generator.
> +    EmitGenerator(Ints, OS);
>
> -  // Emit the intrinsic parameter attributes.
> -  EmitAttributes(Ints, OS);
> +    // Emit the intrinsic parameter attributes.
> +    EmitAttributes(Ints, OS);
>
> -  // Emit code to translate GCC builtins into LLVM intrinsics.
> -  EmitIntrinsicToBuiltinMap(Ints, true, OS);
> +    // Emit code to translate GCC builtins into LLVM intrinsics.
> +    EmitIntrinsicToBuiltinMap(Ints, true, OS);
>
> -  // Emit code to translate MS builtins into LLVM intrinsics.
> -  EmitIntrinsicToBuiltinMap(Ints, false, OS);
> +    // Emit code to translate MS builtins into LLVM intrinsics.
> +    EmitIntrinsicToBuiltinMap(Ints, false, OS);
> +  }
>
>    EmitSuffix(OS);
>  }
> @@ -839,6 +841,12 @@ void IntrinsicEmitter::EmitIntrinsicToBu
>    OS << "#endif\n\n";
>  }
>
> -void llvm::EmitIntrinsics(RecordKeeper &RK, raw_ostream &OS, bool
> TargetOnly) {
> -  IntrinsicEmitter(RK, TargetOnly).run(OS);
> +void llvm::EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS,
> +                              bool TargetOnly) {
> +  IntrinsicEmitter(RK, TargetOnly).run(OS, /*Enums=*/true);
> +}
> +
> +void llvm::EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS,
> +                             bool TargetOnly) {
> +  IntrinsicEmitter(RK, TargetOnly).run(OS, /*Enums=*/false);
>  }
>
> Modified: llvm/trunk/utils/TableGen/TableGen.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=335407&r1=335406&r2=335407&view=diff
>
> ==============================================================================
> --- llvm/trunk/utils/TableGen/TableGen.cpp (original)
> +++ llvm/trunk/utils/TableGen/TableGen.cpp Fri Jun 22 19:02:38 2018
> @@ -38,8 +38,10 @@ enum ActionType {
>    GenDFAPacketizer,
>    GenFastISel,
>    GenSubtarget,
> -  GenIntrinsic,
> -  GenTgtIntrinsic,
> +  GenIntrinsicEnums,
> +  GenIntrinsicImpl,
> +  GenTgtIntrinsicEnums,
> +  GenTgtIntrinsicImpl,
>    PrintEnums,
>    PrintSets,
>    GenOptParserDefs,
> @@ -85,9 +87,13 @@ namespace {
>                                 "Generate a \"fast\" instruction
> selector"),
>                      clEnumValN(GenSubtarget, "gen-subtarget",
>                                 "Generate subtarget enumerations"),
> -                    clEnumValN(GenIntrinsic, "gen-intrinsic",
> +                    clEnumValN(GenIntrinsicEnums, "gen-intrinsic-enums",
> +                               "Generate intrinsic enums"),
> +                    clEnumValN(GenIntrinsicImpl, "gen-intrinsic-impl",
>                                 "Generate intrinsic information"),
> -                    clEnumValN(GenTgtIntrinsic, "gen-tgt-intrinsic",
> +                    clEnumValN(GenTgtIntrinsicEnums,
> "gen-tgt-intrinsic-enums",
> +                               "Generate target intrinsic enums"),
> +                    clEnumValN(GenTgtIntrinsicImpl,
> "gen-tgt-intrinsic-impl",
>                                 "Generate target intrinsic information"),
>                      clEnumValN(PrintEnums, "print-enums",
>                                 "Print enum values for a class"),
> @@ -162,11 +168,17 @@ bool LLVMTableGenMain(raw_ostream &OS, R
>    case GenSubtarget:
>      EmitSubtarget(Records, OS);
>      break;
> -  case GenIntrinsic:
> -    EmitIntrinsics(Records, OS);
> +  case GenIntrinsicEnums:
> +    EmitIntrinsicEnums(Records, OS);
>      break;
> -  case GenTgtIntrinsic:
> -    EmitIntrinsics(Records, OS, true);
> +  case GenIntrinsicImpl:
> +    EmitIntrinsicImpl(Records, OS);
> +    break;
> +  case GenTgtIntrinsicEnums:
> +    EmitIntrinsicEnums(Records, OS, true);
> +    break;
> +  case GenTgtIntrinsicImpl:
> +    EmitIntrinsicImpl(Records, OS, true);
>      break;
>    case GenOptParserDefs:
>      EmitOptParser(Records, OS);
>
> Modified: llvm/trunk/utils/TableGen/TableGenBackends.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGenBackends.h?rev=335407&r1=335406&r2=335407&view=diff
>
> ==============================================================================
> --- llvm/trunk/utils/TableGen/TableGenBackends.h (original)
> +++ llvm/trunk/utils/TableGen/TableGenBackends.h Fri Jun 22 19:02:38 2018
> @@ -62,7 +62,10 @@ namespace llvm {
>  class raw_ostream;
>  class RecordKeeper;
>
> -void EmitIntrinsics(RecordKeeper &RK, raw_ostream &OS, bool TargetOnly =
> false);
> +void EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS,
> +                        bool TargetOnly = false);
> +void EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS,
> +                       bool TargetOnly = false);
>  void EmitAsmMatcher(RecordKeeper &RK, raw_ostream &OS);
>  void EmitAsmWriter(RecordKeeper &RK, raw_ostream &OS);
>  void EmitCallingConv(RecordKeeper &RK, raw_ostream &OS);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180622/330143ca/attachment.html>


More information about the llvm-commits mailing list