106c3fb27SDimitry Andric //===-- RISCVTargetMachine.h - Define TargetMachine for RISC-V --*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 906c3fb27SDimitry Andric // This file declares the RISC-V specific subclass of TargetMachine. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_RISCV_RISCVTARGETMACHINE_H 140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_RISCV_RISCVTARGETMACHINE_H 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #include "MCTargetDesc/RISCVMCTargetDesc.h" 170b57cec5SDimitry Andric #include "RISCVSubtarget.h" 180b57cec5SDimitry Andric #include "llvm/CodeGen/SelectionDAGTargetInfo.h" 190b57cec5SDimitry Andric #include "llvm/IR/DataLayout.h" 200b57cec5SDimitry Andric #include "llvm/Target/TargetMachine.h" 21bdd1243dSDimitry Andric #include <optional> 220b57cec5SDimitry Andric 230b57cec5SDimitry Andric namespace llvm { 240b57cec5SDimitry Andric class RISCVTargetMachine : public LLVMTargetMachine { 250b57cec5SDimitry Andric std::unique_ptr<TargetLoweringObjectFile> TLOF; 26480093f4SDimitry Andric mutable StringMap<std::unique_ptr<RISCVSubtarget>> SubtargetMap; 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric public: 290b57cec5SDimitry Andric RISCVTargetMachine(const Target &T, const Triple &TT, StringRef CPU, 300b57cec5SDimitry Andric StringRef FS, const TargetOptions &Options, 31bdd1243dSDimitry Andric std::optional<Reloc::Model> RM, 325f757f3fSDimitry Andric std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, 33bdd1243dSDimitry Andric bool JIT); 340b57cec5SDimitry Andric 35480093f4SDimitry Andric const RISCVSubtarget *getSubtargetImpl(const Function &F) const override; 36480093f4SDimitry Andric // DO NOT IMPLEMENT: There is no such thing as a valid default subtarget, 37480093f4SDimitry Andric // subtargets are per-function entities based on the target-specific 38480093f4SDimitry Andric // attributes of each function. 39480093f4SDimitry Andric const RISCVSubtarget *getSubtargetImpl() const = delete; 400b57cec5SDimitry Andric 410b57cec5SDimitry Andric TargetPassConfig *createPassConfig(PassManagerBase &PM) override; 420b57cec5SDimitry Andric getObjFileLowering()430b57cec5SDimitry Andric TargetLoweringObjectFile *getObjFileLowering() const override { 440b57cec5SDimitry Andric return TLOF.get(); 450b57cec5SDimitry Andric } 460b57cec5SDimitry Andric 47bdd1243dSDimitry Andric MachineFunctionInfo * 48bdd1243dSDimitry Andric createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, 49bdd1243dSDimitry Andric const TargetSubtargetInfo *STI) const override; 50bdd1243dSDimitry Andric 5181ad6265SDimitry Andric TargetTransformInfo getTargetTransformInfo(const Function &F) const override; 52e8d8bef9SDimitry Andric 53972a253aSDimitry Andric bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DstAS) const override; 543a9a9c0cSDimitry Andric 553a9a9c0cSDimitry Andric yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const override; 563a9a9c0cSDimitry Andric yaml::MachineFunctionInfo * 573a9a9c0cSDimitry Andric convertFuncInfoToYAML(const MachineFunction &MF) const override; 583a9a9c0cSDimitry Andric bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, 593a9a9c0cSDimitry Andric PerFunctionMIParsingState &PFS, 603a9a9c0cSDimitry Andric SMDiagnostic &Error, 613a9a9c0cSDimitry Andric SMRange &SourceRange) const override; 62*0fca6ea1SDimitry Andric void registerPassBuilderCallbacks(PassBuilder &PB) override; 630b57cec5SDimitry Andric }; 64e8d8bef9SDimitry Andric } // namespace llvm 650b57cec5SDimitry Andric 660b57cec5SDimitry Andric #endif 67