| 1 | //===-- X86TargetMachine.h - Define TargetMachine for the X86 ---*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file declares the X86 specific subclass of TargetMachine. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #ifndef LLVM_LIB_TARGET_X86_X86TARGETMACHINE_H |
| 14 | #define LLVM_LIB_TARGET_X86_X86TARGETMACHINE_H |
| 15 | |
| 16 | #include "X86Subtarget.h" |
| 17 | #include "llvm/ADT/StringMap.h" |
| 18 | #include "llvm/CodeGen/CodeGenTargetMachineImpl.h" |
| 19 | #include "llvm/Support/CodeGen.h" |
| 20 | #include <memory> |
| 21 | #include <optional> |
| 22 | |
| 23 | namespace llvm { |
| 24 | |
| 25 | class StringRef; |
| 26 | class TargetTransformInfo; |
| 27 | |
| 28 | class X86TargetMachine final : public CodeGenTargetMachineImpl { |
| 29 | std::unique_ptr<TargetLoweringObjectFile> TLOF; |
| 30 | mutable StringMap<std::unique_ptr<X86Subtarget>> SubtargetMap; |
| 31 | // True if this is used in JIT. |
| 32 | bool IsJIT; |
| 33 | |
| 34 | /// Reset internal state. |
| 35 | void reset() override; |
| 36 | |
| 37 | public: |
| 38 | X86TargetMachine(const Target &T, const Triple &TT, StringRef CPU, |
| 39 | StringRef FS, const TargetOptions &Options, |
| 40 | std::optional<Reloc::Model> RM, |
| 41 | std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, |
| 42 | bool JIT); |
| 43 | ~X86TargetMachine() override; |
| 44 | |
| 45 | const X86Subtarget *getSubtargetImpl(const Function &F) const override; |
| 46 | // DO NOT IMPLEMENT: There is no such thing as a valid default subtarget, |
| 47 | // subtargets are per-function entities based on the target-specific |
| 48 | // attributes of each function. |
| 49 | const X86Subtarget *getSubtargetImpl() const = delete; |
| 50 | |
| 51 | TargetTransformInfo getTargetTransformInfo(const Function &F) const override; |
| 52 | |
| 53 | // Set up the pass pipeline. |
| 54 | TargetPassConfig *createPassConfig(PassManagerBase &PM) override; |
| 55 | |
| 56 | TargetLoweringObjectFile *getObjFileLowering() const override { |
| 57 | return TLOF.get(); |
| 58 | } |
| 59 | |
| 60 | MachineFunctionInfo * |
| 61 | createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, |
| 62 | const TargetSubtargetInfo *STI) const override; |
| 63 | |
| 64 | yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const override; |
| 65 | yaml::MachineFunctionInfo * |
| 66 | convertFuncInfoToYAML(const MachineFunction &MF) const override; |
| 67 | bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, |
| 68 | PerFunctionMIParsingState &PFS, |
| 69 | SMDiagnostic &Error, |
| 70 | SMRange &SourceRange) const override; |
| 71 | |
| 72 | void registerPassBuilderCallbacks(PassBuilder &PB) override; |
| 73 | |
| 74 | Error buildCodeGenPipeline(ModulePassManager &, raw_pwrite_stream &, |
| 75 | raw_pwrite_stream *, CodeGenFileType, |
| 76 | const CGPassBuilderOption &, |
| 77 | PassInstrumentationCallbacks *) override; |
| 78 | |
| 79 | bool isJIT() const { return IsJIT; } |
| 80 | |
| 81 | bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override; |
| 82 | ScheduleDAGInstrs * |
| 83 | createMachineScheduler(MachineSchedContext *C) const override; |
| 84 | ScheduleDAGInstrs * |
| 85 | createPostMachineScheduler(MachineSchedContext *C) const override; |
| 86 | }; |
| 87 | |
| 88 | } // end namespace llvm |
| 89 | |
| 90 | #endif // LLVM_LIB_TARGET_X86_X86TARGETMACHINE_H |
| 91 | |