llvm.org GIT mirror llvm / 7801136
Some refactoring so TargetRegistry.h no longer has to include any files from MC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138367 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 9 years ago
19 changed file(s) with 105 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
1414 #ifndef LLVM_MC_MCCODEGENINFO_H
1515 #define LLVM_MC_MCCODEGENINFO_H
1616
17 #include "llvm/Support/CodeGen.h"
18
1719 namespace llvm {
18
19 // Relocation model types.
20 namespace Reloc {
21 enum Model { Default, Static, PIC_, DynamicNoPIC };
22 }
23
24 // Code model types.
25 namespace CodeModel {
26 enum Model { Default, JITDefault, Small, Kernel, Medium, Large };
27 }
2820
2921 class MCCodeGenInfo {
3022 /// RelocationModel - Relocation model: statcic, pic, etc.
2222 friend class Target;
2323 const MCInstrInfo *Info;
2424
25 public:
2526 MCInstrAnalysis(const MCInstrInfo *Info) : Info(Info) {}
26 public:
27
2728 virtual ~MCInstrAnalysis() {}
2829
2930 virtual bool isBranch(const MCInst &Inst) const {
0 //===-- llvm/Support/CodeGen.h - CodeGen Concepts ---------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file define some types which define code generation concepts. For
10 // example, relocation model.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_SUPPORT_CODEGEN_H
15 #define LLVM_SUPPORT_CODEGEN_H
16
17 namespace llvm {
18
19 // Relocation model types.
20 namespace Reloc {
21 enum Model { Default, Static, PIC_, DynamicNoPIC };
22 }
23
24 // Code model types.
25 namespace CodeModel {
26 enum Model { Default, JITDefault, Small, Kernel, Medium, Large };
27 }
28
29 } // end llvm namespace
30
31 #endif
1818 #ifndef LLVM_TARGET_TARGETREGISTRY_H
1919 #define LLVM_TARGET_TARGETREGISTRY_H
2020
21 #include "llvm/MC/MCCodeGenInfo.h"
22 #include "llvm/MC/MCInstrAnalysis.h"
21 #include "llvm/Support/CodeGen.h"
2322 #include "llvm/ADT/Triple.h"
2423 #include
2524 #include
3534 class MCCodeGenInfo;
3635 class MCContext;
3736 class MCDisassembler;
37 class MCInstrAnalysis;
3838 class MCInstPrinter;
3939 class MCInstrInfo;
4040 class MCRegisterInfo;
290290 ///
291291 MCInstrAnalysis *createMCInstrAnalysis(const MCInstrInfo *Info) const {
292292 if (!MCInstrAnalysisCtorFn)
293 return new MCInstrAnalysis(Info);
293 return 0;
294294 return MCInstrAnalysisCtorFn(Info);
295295 }
296296
889889 }
890890 };
891891
892 /// RegisterMCInstrAnalysis - Helper template for registering a target
893 /// instruction analyzer implementation. This invokes the static "Create"
894 /// method on the class to actually do the construction. Usage:
895 ///
896 /// extern "C" void LLVMInitializeFooTarget() {
897 /// extern Target TheFooTarget;
898 /// RegisterMCInstrAnalysis X(TheFooTarget);
899 /// }
900 template
901 struct RegisterMCInstrAnalysis {
902 RegisterMCInstrAnalysis(Target &T) {
903 TargetRegistry::RegisterMCInstrAnalysis(T, &Allocator);
904 }
905 private:
906 static MCInstrAnalysis *Allocator(const MCInstrInfo *Info) {
907 return new MCInstrAnalysisImpl(Info);
908 }
909 };
910
911 /// RegisterMCInstrAnalysisFn - Helper template for registering a target
912 /// instruction analyzer implementation. This invokes the specified function
913 /// to do the construction. Usage:
914 ///
915 /// extern "C" void LLVMInitializeFooTarget() {
916 /// extern Target TheFooTarget;
917 /// RegisterMCInstrAnalysisFn X(TheFooTarget, TheFunction);
918 /// }
919 struct RegisterMCInstrAnalysisFn {
920 RegisterMCInstrAnalysisFn(Target &T, Target::MCInstrAnalysisCtorFnTy Fn) {
921 TargetRegistry::RegisterMCInstrAnalysis(T, Fn);
922 }
923 };
924
892925 /// RegisterMCRegInfo - Helper template for registering a target register info
893926 /// implementation. This invokes the static "Create" method on the class to
894927 /// actually do the construction. Usage:
1717 #include "llvm/MC/MCStreamer.h"
1818 #include "llvm/MC/MCExpr.h"
1919 #include "llvm/MC/MCInst.h"
20 #include "llvm/MC/MCInstrDesc.h"
2021 #include "llvm/MC/MCRegisterInfo.h"
2122 #include "llvm/MC/MCSubtargetInfo.h"
2223 #include "llvm/MC/MCTargetAsmParser.h"
1414 #include "ARMMCAsmInfo.h"
1515 #include "ARMBaseInfo.h"
1616 #include "InstPrinter/ARMInstPrinter.h"
17 #include "llvm/MC/MCCodeGenInfo.h"
18 #include "llvm/MC/MCInstrAnalysis.h"
1719 #include "llvm/MC/MCInstrInfo.h"
1820 #include "llvm/MC/MCRegisterInfo.h"
1921 #include "llvm/MC/MCStreamer.h"
215217 TargetRegistry::RegisterMCRegInfo(TheARMTarget, createARMMCRegisterInfo);
216218 TargetRegistry::RegisterMCRegInfo(TheThumbTarget, createARMMCRegisterInfo);
217219
218 TargetRegistry::RegisterMCInstrAnalysis(TheARMTarget,
219 createARMMCInstrAnalysis);
220 TargetRegistry::RegisterMCInstrAnalysis(TheThumbTarget,
221 createARMMCInstrAnalysis);
222
223220 // Register the MC subtarget info.
224221 TargetRegistry::RegisterMCSubtargetInfo(TheARMTarget,
225222 ARM_MC::createARMMCSubtargetInfo);
226223 TargetRegistry::RegisterMCSubtargetInfo(TheThumbTarget,
227224 ARM_MC::createARMMCSubtargetInfo);
228225
226 // Register the MC instruction analyzer.
227 TargetRegistry::RegisterMCInstrAnalysis(TheARMTarget,
228 createARMMCInstrAnalysis);
229 TargetRegistry::RegisterMCInstrAnalysis(TheThumbTarget,
230 createARMMCInstrAnalysis);
231
229232 // Register the MC Code Emitter
230233 TargetRegistry::RegisterMCCodeEmitter(TheARMTarget, createARMMCCodeEmitter);
231234 TargetRegistry::RegisterMCCodeEmitter(TheThumbTarget, createARMMCCodeEmitter);
1212
1313 #include "AlphaMCTargetDesc.h"
1414 #include "AlphaMCAsmInfo.h"
15 #include "llvm/MC/MCCodeGenInfo.h"
1516 #include "llvm/MC/MCInstrInfo.h"
1617 #include "llvm/MC/MCRegisterInfo.h"
1718 #include "llvm/MC/MCSubtargetInfo.h"
1212
1313 #include "BlackfinMCTargetDesc.h"
1414 #include "BlackfinMCAsmInfo.h"
15 #include "llvm/MC/MCCodeGenInfo.h"
1516 #include "llvm/MC/MCInstrInfo.h"
1617 #include "llvm/MC/MCRegisterInfo.h"
1718 #include "llvm/MC/MCSubtargetInfo.h"
1313 #include "SPUMCTargetDesc.h"
1414 #include "SPUMCAsmInfo.h"
1515 #include "llvm/MC/MachineLocation.h"
16 #include "llvm/MC/MCCodeGenInfo.h"
1617 #include "llvm/MC/MCInstrInfo.h"
1718 #include "llvm/MC/MCRegisterInfo.h"
1819 #include "llvm/MC/MCSubtargetInfo.h"
1313 #include "MBlazeMCTargetDesc.h"
1414 #include "MBlazeMCAsmInfo.h"
1515 #include "InstPrinter/MBlazeInstPrinter.h"
16 #include "llvm/MC/MCCodeGenInfo.h"
1617 #include "llvm/MC/MCInstrInfo.h"
1718 #include "llvm/MC/MCRegisterInfo.h"
1819 #include "llvm/MC/MCStreamer.h"
1313 #include "MSP430MCTargetDesc.h"
1414 #include "MSP430MCAsmInfo.h"
1515 #include "InstPrinter/MSP430InstPrinter.h"
16 #include "llvm/MC/MCCodeGenInfo.h"
1617 #include "llvm/MC/MCInstrInfo.h"
1718 #include "llvm/MC/MCRegisterInfo.h"
1819 #include "llvm/MC/MCSubtargetInfo.h"
1414 #include "MipsMCAsmInfo.h"
1515 #include "InstPrinter/MipsInstPrinter.h"
1616 #include "llvm/MC/MachineLocation.h"
17 #include "llvm/MC/MCCodeGenInfo.h"
1718 #include "llvm/MC/MCInstrInfo.h"
1819 #include "llvm/MC/MCRegisterInfo.h"
1920 #include "llvm/MC/MCSubtargetInfo.h"
1212
1313 #include "PTXMCTargetDesc.h"
1414 #include "PTXMCAsmInfo.h"
15 #include "llvm/MC/MCCodeGenInfo.h"
1516 #include "llvm/MC/MCInstrInfo.h"
1617 #include "llvm/MC/MCRegisterInfo.h"
1718 #include "llvm/MC/MCSubtargetInfo.h"
1414 #include "PPCMCAsmInfo.h"
1515 #include "InstPrinter/PPCInstPrinter.h"
1616 #include "llvm/MC/MachineLocation.h"
17 #include "llvm/MC/MCCodeGenInfo.h"
1718 #include "llvm/MC/MCInstrInfo.h"
1819 #include "llvm/MC/MCRegisterInfo.h"
1920 #include "llvm/MC/MCStreamer.h"
1212
1313 #include "SparcMCTargetDesc.h"
1414 #include "SparcMCAsmInfo.h"
15 #include "llvm/MC/MCCodeGenInfo.h"
1516 #include "llvm/MC/MCInstrInfo.h"
1617 #include "llvm/MC/MCRegisterInfo.h"
1718 #include "llvm/MC/MCSubtargetInfo.h"
1212
1313 #include "SystemZMCTargetDesc.h"
1414 #include "SystemZMCAsmInfo.h"
15 #include "llvm/MC/MCCodeGenInfo.h"
1516 #include "llvm/MC/MCInstrInfo.h"
1617 #include "llvm/MC/MCRegisterInfo.h"
1718 #include "llvm/MC/MCSubtargetInfo.h"
1515 #include "InstPrinter/X86ATTInstPrinter.h"
1616 #include "InstPrinter/X86IntelInstPrinter.h"
1717 #include "llvm/MC/MachineLocation.h"
18 #include "llvm/MC/MCCodeGenInfo.h"
19 #include "llvm/MC/MCInstrAnalysis.h"
1820 #include "llvm/MC/MCInstrInfo.h"
1921 #include "llvm/MC/MCRegisterInfo.h"
2022 #include "llvm/MC/MCStreamer.h"
392394 return 0;
393395 }
394396
397 static MCInstrAnalysis *createX86MCInstrAnalysis(const MCInstrInfo *Info) {
398 return new MCInstrAnalysis(Info);
399 }
400
395401 // Force static initialization.
396402 extern "C" void LLVMInitializeX86TargetMC() {
397403 // Register the MC asm info.
416422 TargetRegistry::RegisterMCSubtargetInfo(TheX86_64Target,
417423 X86_MC::createX86MCSubtargetInfo);
418424
425 // Register the MC instruction analyzer.
426 TargetRegistry::RegisterMCInstrAnalysis(TheX86_32Target,
427 createX86MCInstrAnalysis);
428 TargetRegistry::RegisterMCInstrAnalysis(TheX86_64Target,
429 createX86MCInstrAnalysis);
430
419431 // Register the code emitter.
420432 TargetRegistry::RegisterMCCodeEmitter(TheX86_32Target,
421433 createX86MCCodeEmitter);
1212
1313 #include "XCoreMCTargetDesc.h"
1414 #include "XCoreMCAsmInfo.h"
15 #include "llvm/MC/MCCodeGenInfo.h"
1516 #include "llvm/MC/MCInstrInfo.h"
1617 #include "llvm/MC/MCRegisterInfo.h"
1718 #include "llvm/MC/MCSubtargetInfo.h"
2121 #include "llvm/MC/MCDisassembler.h"
2222 #include "llvm/MC/MCInst.h"
2323 #include "llvm/MC/MCInstPrinter.h"
24 #include "llvm/MC/MCInstrAnalysis.h"
2425 #include "llvm/MC/MCInstrDesc.h"
2526 #include "llvm/MC/MCInstrInfo.h"
2627 #include "llvm/Support/CommandLine.h"