RISCVTargetMachine.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //===-- RISCVTargetMachine.h - Define TargetMachine for RISCV ---*- 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 RISCV specific subclass of TargetMachine.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_RISCV_RISCVTARGETMACHINE_H
  13. #define LLVM_LIB_TARGET_RISCV_RISCVTARGETMACHINE_H
  14. #include "MCTargetDesc/RISCVMCTargetDesc.h"
  15. #include "RISCVSubtarget.h"
  16. #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
  17. #include "llvm/IR/DataLayout.h"
  18. #include "llvm/Target/TargetMachine.h"
  19. #include <optional>
  20. namespace llvm {
  21. class RISCVTargetMachine : public LLVMTargetMachine {
  22. std::unique_ptr<TargetLoweringObjectFile> TLOF;
  23. mutable StringMap<std::unique_ptr<RISCVSubtarget>> SubtargetMap;
  24. public:
  25. RISCVTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
  26. StringRef FS, const TargetOptions &Options,
  27. std::optional<Reloc::Model> RM,
  28. std::optional<CodeModel::Model> CM, CodeGenOpt::Level OL,
  29. bool JIT);
  30. const RISCVSubtarget *getSubtargetImpl(const Function &F) const override;
  31. // DO NOT IMPLEMENT: There is no such thing as a valid default subtarget,
  32. // subtargets are per-function entities based on the target-specific
  33. // attributes of each function.
  34. const RISCVSubtarget *getSubtargetImpl() const = delete;
  35. TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
  36. TargetLoweringObjectFile *getObjFileLowering() const override {
  37. return TLOF.get();
  38. }
  39. MachineFunctionInfo *
  40. createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
  41. const TargetSubtargetInfo *STI) const override;
  42. TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
  43. bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DstAS) const override;
  44. yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const override;
  45. yaml::MachineFunctionInfo *
  46. convertFuncInfoToYAML(const MachineFunction &MF) const override;
  47. bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &,
  48. PerFunctionMIParsingState &PFS,
  49. SMDiagnostic &Error,
  50. SMRange &SourceRange) const override;
  51. };
  52. } // namespace llvm
  53. #endif