Move DataLayout back to the TargetMachine from TargetSubtargetInfo
[oota-llvm.git] / lib / Target / X86 / X86TargetMachine.h
1 //===-- X86TargetMachine.h - Define TargetMachine for the X86 ---*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the X86 specific subclass of TargetMachine.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_LIB_TARGET_X86_X86TARGETMACHINE_H
15 #define LLVM_LIB_TARGET_X86_X86TARGETMACHINE_H
16 #include "X86InstrInfo.h"
17 #include "X86Subtarget.h"
18 #include "llvm/IR/DataLayout.h"
19 #include "llvm/Target/TargetMachine.h"
20
21 namespace llvm {
22
23 class StringRef;
24
25 class X86TargetMachine final : public LLVMTargetMachine {
26   std::unique_ptr<TargetLoweringObjectFile> TLOF;
27   // Calculates type size & alignment
28   const DataLayout DL;
29   X86Subtarget Subtarget;
30
31   mutable StringMap<std::unique_ptr<X86Subtarget>> SubtargetMap;
32
33 public:
34   X86TargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
35                    const TargetOptions &Options, Reloc::Model RM,
36                    CodeModel::Model CM, CodeGenOpt::Level OL);
37   ~X86TargetMachine() override;
38   const DataLayout *getDataLayout() const override { return &DL; }
39   const X86Subtarget *getSubtargetImpl() const override { return &Subtarget; }
40   const X86Subtarget *getSubtargetImpl(const Function &F) const override;
41
42   /// \brief Register X86 analysis passes with a pass manager.
43   void addAnalysisPasses(PassManagerBase &PM) override;
44
45   // Set up the pass pipeline.
46   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
47   TargetLoweringObjectFile *getObjFileLowering() const override {
48     return TLOF.get();
49   }
50 };
51
52 } // End llvm namespace
53
54 #endif