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
23namespace llvm {
24
25class StringRef;
26class TargetTransformInfo;
27
28class 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
37public:
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 &MPM, raw_pwrite_stream &Out,
75 raw_pwrite_stream *DwoOut,
76 CodeGenFileType FileType,
77 const CGPassBuilderOption &Opt, MCContext &Ctx,
78 PassInstrumentationCallbacks *PIC) override;
79
80 bool isJIT() const { return IsJIT; }
81
82 bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override;
83 ScheduleDAGInstrs *
84 createMachineScheduler(MachineSchedContext *C) const override;
85 ScheduleDAGInstrs *
86 createPostMachineScheduler(MachineSchedContext *C) const override;
87
88 bool canLowerCondLoop() const override { return true; }
89};
90
91} // end namespace llvm
92
93#endif // LLVM_LIB_TARGET_X86_X86TARGETMACHINE_H
94