llvm.org GIT mirror llvm / af7c445
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335407 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 1 year, 3 months ago
10 changed file(s) with 76 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
11 tablegen(LLVM Attributes.inc -gen-attrs)
22
33 set(LLVM_TARGET_DEFINITIONS Intrinsics.td)
4 tablegen(LLVM Intrinsics.inc -gen-intrinsic)
4 tablegen(LLVM IntrinsicEnums.inc -gen-intrinsic-enums)
5 tablegen(LLVM IntrinsicImpl.inc -gen-intrinsic-impl)
56 add_public_tablegen_target(intrinsics_gen)
3838
3939 // Get the intrinsic enums generated from Intrinsics.td
4040 #define GET_INTRINSIC_ENUM_VALUES
41 #include "llvm/IR/Intrinsics.inc"
41 #include "llvm/IR/IntrinsicEnums.inc"
4242 #undef GET_INTRINSIC_ENUM_VALUES
4343 , num_intrinsics
4444 };
486486 static const char * const IntrinsicNameTable[] = {
487487 "not_intrinsic",
488488 #define GET_INTRINSIC_NAME_TABLE
489 #include "llvm/IR/Intrinsics.inc"
489 #include "llvm/IR/IntrinsicImpl.inc"
490490 #undef GET_INTRINSIC_NAME_TABLE
491491 };
492492
493493 /// Table of per-target intrinsic name tables.
494494 #define GET_INTRINSIC_TARGET_DATA
495 #include "llvm/IR/Intrinsics.inc"
495 #include "llvm/IR/IntrinsicImpl.inc"
496496 #undef GET_INTRINSIC_TARGET_DATA
497497
498498 /// Find the segment of \c IntrinsicNameTable for intrinsics with the same
839839 }
840840
841841 #define GET_INTRINSIC_GENERATOR_GLOBAL
842 #include "llvm/IR/Intrinsics.inc"
842 #include "llvm/IR/IntrinsicImpl.inc"
843843 #undef GET_INTRINSIC_GENERATOR_GLOBAL
844844
845845 void Intrinsic::getIntrinsicInfoTableEntries(ID id,
976976
977977 bool Intrinsic::isOverloaded(ID id) {
978978 #define GET_INTRINSIC_OVERLOAD_TABLE
979 #include "llvm/IR/Intrinsics.inc"
979 #include "llvm/IR/IntrinsicImpl.inc"
980980 #undef GET_INTRINSIC_OVERLOAD_TABLE
981981 }
982982
994994
995995 /// This defines the "Intrinsic::getAttributes(ID id)" method.
996996 #define GET_INTRINSIC_ATTRIBUTES
997 #include "llvm/IR/Intrinsics.inc"
997 #include "llvm/IR/IntrinsicImpl.inc"
998998 #undef GET_INTRINSIC_ATTRIBUTES
999999
10001000 Function *Intrinsic::getDeclaration(Module *M, ID id, ArrayRef Tys) {
10071007
10081008 // This defines the "Intrinsic::getIntrinsicForGCCBuiltin()" method.
10091009 #define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
1010 #include "llvm/IR/Intrinsics.inc"
1010 #include "llvm/IR/IntrinsicImpl.inc"
10111011 #undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN
10121012
10131013 // This defines the "Intrinsic::getIntrinsicForMSBuiltin()" method.
10141014 #define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
1015 #include "llvm/IR/Intrinsics.inc"
1015 #include "llvm/IR/IntrinsicImpl.inc"
10161016 #undef GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
10171017
10181018 bool Intrinsic::matchIntrinsicType(Type *Ty, ArrayRef &Infos,
66 tablegen(LLVM AMDGPUGenDFAPacketizer.inc -gen-dfa-packetizer)
77 tablegen(LLVM AMDGPUGenDisassemblerTables.inc -gen-disassembler)
88 tablegen(LLVM AMDGPUGenInstrInfo.inc -gen-instr-info)
9 tablegen(LLVM AMDGPUGenIntrinsics.inc -gen-tgt-intrinsic)
9 tablegen(LLVM AMDGPUGenIntrinsicEnums.inc -gen-tgt-intrinsic-enums)
10 tablegen(LLVM AMDGPUGenIntrinsicImpl.inc -gen-tgt-intrinsic-impl)
1011 tablegen(LLVM AMDGPUGenMCCodeEmitter.inc -gen-emitter)
1112 tablegen(LLVM AMDGPUGenMCPseudoLowering.inc -gen-pseudo-lowering)
1213 tablegen(LLVM AMDGPUGenRegisterBank.inc -gen-register-bank)
None // RUN: llvm-tblgen -gen-intrinsic %s | FileCheck %s
0 // RUN: llvm-tblgen -gen-intrinsic-enums %s | FileCheck %s
11 // XFAIL: vg_leak
22
33 class IntrinsicProperty;
None // RUN: llvm-tblgen -gen-intrinsic %s | FileCheck %s
0 // RUN: llvm-tblgen -gen-intrinsic-enums %s | FileCheck %s
11 // XFAIL: vg_leak
22
33 class IntrinsicProperty;
None // RUN: llvm-tblgen -gen-intrinsic %s | FileCheck %s
0 // RUN: llvm-tblgen -gen-intrinsic-impl %s | FileCheck %s
11 // XFAIL: vg_leak
22
33 class IntrinsicProperty;
3333 IntrinsicEmitter(RecordKeeper &R, bool T)
3434 : Records(R), TargetOnly(T) {}
3535
36 void run(raw_ostream &OS);
36 void run(raw_ostream &OS, bool Enums);
3737
3838 void EmitPrefix(raw_ostream &OS);
3939
5555 // IntrinsicEmitter Implementation
5656 //===----------------------------------------------------------------------===//
5757
58 void IntrinsicEmitter::run(raw_ostream &OS) {
58 void IntrinsicEmitter::run(raw_ostream &OS, bool Enums) {
5959 emitSourceFileHeader("Intrinsic Function Source Fragment", OS);
6060
6161 CodeGenIntrinsicTable Ints(Records, TargetOnly);
6565
6666 EmitPrefix(OS);
6767
68 // Emit the enum information.
69 EmitEnumInfo(Ints, OS);
70
71 // Emit the target metadata.
72 EmitTargetInfo(Ints, OS);
73
74 // Emit the intrinsic ID -> name table.
75 EmitIntrinsicToNameTable(Ints, OS);
76
77 // Emit the intrinsic ID -> overload table.
78 EmitIntrinsicToOverloadTable(Ints, OS);
79
80 // Emit the intrinsic declaration generator.
81 EmitGenerator(Ints, OS);
82
83 // Emit the intrinsic parameter attributes.
84 EmitAttributes(Ints, OS);
85
86 // Emit code to translate GCC builtins into LLVM intrinsics.
87 EmitIntrinsicToBuiltinMap(Ints, true, OS);
88
89 // Emit code to translate MS builtins into LLVM intrinsics.
90 EmitIntrinsicToBuiltinMap(Ints, false, OS);
68 if (Enums) {
69 // Emit the enum information.
70 EmitEnumInfo(Ints, OS);
71 } else {
72 // Emit the target metadata.
73 EmitTargetInfo(Ints, OS);
74
75 // Emit the intrinsic ID -> name table.
76 EmitIntrinsicToNameTable(Ints, OS);
77
78 // Emit the intrinsic ID -> overload table.
79 EmitIntrinsicToOverloadTable(Ints, OS);
80
81 // Emit the intrinsic declaration generator.
82 EmitGenerator(Ints, OS);
83
84 // Emit the intrinsic parameter attributes.
85 EmitAttributes(Ints, OS);
86
87 // Emit code to translate GCC builtins into LLVM intrinsics.
88 EmitIntrinsicToBuiltinMap(Ints, true, OS);
89
90 // Emit code to translate MS builtins into LLVM intrinsics.
91 EmitIntrinsicToBuiltinMap(Ints, false, OS);
92 }
9193
9294 EmitSuffix(OS);
9395 }
838840 OS << "#endif\n\n";
839841 }
840842
841 void llvm::EmitIntrinsics(RecordKeeper &RK, raw_ostream &OS, bool TargetOnly) {
842 IntrinsicEmitter(RK, TargetOnly).run(OS);
843 }
843 void llvm::EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS,
844 bool TargetOnly) {
845 IntrinsicEmitter(RK, TargetOnly).run(OS, /*Enums=*/true);
846 }
847
848 void llvm::EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS,
849 bool TargetOnly) {
850 IntrinsicEmitter(RK, TargetOnly).run(OS, /*Enums=*/false);
851 }
3737 GenDFAPacketizer,
3838 GenFastISel,
3939 GenSubtarget,
40 GenIntrinsic,
41 GenTgtIntrinsic,
40 GenIntrinsicEnums,
41 GenIntrinsicImpl,
42 GenTgtIntrinsicEnums,
43 GenTgtIntrinsicImpl,
4244 PrintEnums,
4345 PrintSets,
4446 GenOptParserDefs,
8486 "Generate a \"fast\" instruction selector"),
8587 clEnumValN(GenSubtarget, "gen-subtarget",
8688 "Generate subtarget enumerations"),
87 clEnumValN(GenIntrinsic, "gen-intrinsic",
89 clEnumValN(GenIntrinsicEnums, "gen-intrinsic-enums",
90 "Generate intrinsic enums"),
91 clEnumValN(GenIntrinsicImpl, "gen-intrinsic-impl",
8892 "Generate intrinsic information"),
89 clEnumValN(GenTgtIntrinsic, "gen-tgt-intrinsic",
93 clEnumValN(GenTgtIntrinsicEnums, "gen-tgt-intrinsic-enums",
94 "Generate target intrinsic enums"),
95 clEnumValN(GenTgtIntrinsicImpl, "gen-tgt-intrinsic-impl",
9096 "Generate target intrinsic information"),
9197 clEnumValN(PrintEnums, "print-enums",
9298 "Print enum values for a class"),
161167 case GenSubtarget:
162168 EmitSubtarget(Records, OS);
163169 break;
164 case GenIntrinsic:
165 EmitIntrinsics(Records, OS);
166 break;
167 case GenTgtIntrinsic:
168 EmitIntrinsics(Records, OS, true);
170 case GenIntrinsicEnums:
171 EmitIntrinsicEnums(Records, OS);
172 break;
173 case GenIntrinsicImpl:
174 EmitIntrinsicImpl(Records, OS);
175 break;
176 case GenTgtIntrinsicEnums:
177 EmitIntrinsicEnums(Records, OS, true);
178 break;
179 case GenTgtIntrinsicImpl:
180 EmitIntrinsicImpl(Records, OS, true);
169181 break;
170182 case GenOptParserDefs:
171183 EmitOptParser(Records, OS);
6161 class raw_ostream;
6262 class RecordKeeper;
6363
64 void EmitIntrinsics(RecordKeeper &RK, raw_ostream &OS, bool TargetOnly = false);
64 void EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS,
65 bool TargetOnly = false);
66 void EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS,
67 bool TargetOnly = false);
6568 void EmitAsmMatcher(RecordKeeper &RK, raw_ostream &OS);
6669 void EmitAsmWriter(RecordKeeper &RK, raw_ostream &OS);
6770 void EmitCallingConv(RecordKeeper &RK, raw_ostream &OS);