1e8d8bef9SDimitry Andric //===--- CSKYTargetMachine.h - Define TargetMachine for CSKY ----*- C++ -*-===//
2e8d8bef9SDimitry Andric //
3e8d8bef9SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4e8d8bef9SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5e8d8bef9SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e8d8bef9SDimitry Andric //
7e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===//
8e8d8bef9SDimitry Andric //
9e8d8bef9SDimitry Andric // This file declares the CSKY specific subclass of TargetMachine.
10e8d8bef9SDimitry Andric //
11e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===//
12e8d8bef9SDimitry Andric 
13e8d8bef9SDimitry Andric #ifndef LLVM_LIB_TARGET_CSKY_CSKYTARGETMACHINE_H
14e8d8bef9SDimitry Andric #define LLVM_LIB_TARGET_CSKY_CSKYTARGETMACHINE_H
15e8d8bef9SDimitry Andric 
16349cc55cSDimitry Andric #include "CSKYSubtarget.h"
17e8d8bef9SDimitry Andric #include "llvm/IR/DataLayout.h"
18e8d8bef9SDimitry Andric #include "llvm/Target/TargetMachine.h"
19bdd1243dSDimitry Andric #include <optional>
20e8d8bef9SDimitry Andric 
21e8d8bef9SDimitry Andric namespace llvm {
22e8d8bef9SDimitry Andric 
23e8d8bef9SDimitry Andric class CSKYTargetMachine : public LLVMTargetMachine {
24e8d8bef9SDimitry Andric   std::unique_ptr<TargetLoweringObjectFile> TLOF;
25349cc55cSDimitry Andric   mutable StringMap<std::unique_ptr<CSKYSubtarget>> SubtargetMap;
26e8d8bef9SDimitry Andric 
27e8d8bef9SDimitry Andric public:
28e8d8bef9SDimitry Andric   CSKYTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
29e8d8bef9SDimitry Andric                     StringRef FS, const TargetOptions &Options,
30bdd1243dSDimitry Andric                     std::optional<Reloc::Model> RM,
31*5f757f3fSDimitry Andric                     std::optional<CodeModel::Model> CM, CodeGenOptLevel OL,
32bdd1243dSDimitry Andric                     bool JIT);
33e8d8bef9SDimitry Andric 
34e8d8bef9SDimitry Andric   TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
35e8d8bef9SDimitry Andric 
36349cc55cSDimitry Andric   const CSKYSubtarget *getSubtargetImpl(const Function &F) const override;
37349cc55cSDimitry Andric   // DO NOT IMPLEMENT: There is no such thing as a valid default subtarget,
38349cc55cSDimitry Andric   // subtargets are per-function entities based on the target-specific
39349cc55cSDimitry Andric   // attributes of each function.
40349cc55cSDimitry Andric   const CSKYSubtarget *getSubtargetImpl() const = delete;
41349cc55cSDimitry Andric 
getObjFileLowering()42e8d8bef9SDimitry Andric   TargetLoweringObjectFile *getObjFileLowering() const override {
43e8d8bef9SDimitry Andric     return TLOF.get();
44e8d8bef9SDimitry Andric   }
45bdd1243dSDimitry Andric 
46bdd1243dSDimitry Andric   MachineFunctionInfo *
47bdd1243dSDimitry Andric   createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
48bdd1243dSDimitry Andric                             const TargetSubtargetInfo *STI) const override;
49e8d8bef9SDimitry Andric };
50e8d8bef9SDimitry Andric } // namespace llvm
51e8d8bef9SDimitry Andric 
52e8d8bef9SDimitry Andric #endif
53