PPCTargetMachine.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //===-- PPCTargetMachine.h - Define TargetMachine for PowerPC ---*- 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 PowerPC specific subclass of TargetMachine.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_POWERPC_PPCTARGETMACHINE_H
  13. #define LLVM_LIB_TARGET_POWERPC_PPCTARGETMACHINE_H
  14. #include "PPCInstrInfo.h"
  15. #include "PPCSubtarget.h"
  16. #include "llvm/IR/DataLayout.h"
  17. #include "llvm/Target/TargetMachine.h"
  18. namespace llvm {
  19. /// Common code between 32-bit and 64-bit PowerPC targets.
  20. ///
  21. class PPCTargetMachine final : public LLVMTargetMachine {
  22. public:
  23. enum PPCABI { PPC_ABI_UNKNOWN, PPC_ABI_ELFv1, PPC_ABI_ELFv2 };
  24. private:
  25. std::unique_ptr<TargetLoweringObjectFile> TLOF;
  26. PPCABI TargetABI;
  27. mutable StringMap<std::unique_ptr<PPCSubtarget>> SubtargetMap;
  28. public:
  29. PPCTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
  30. StringRef FS, const TargetOptions &Options,
  31. Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
  32. CodeGenOpt::Level OL, bool JIT);
  33. ~PPCTargetMachine() override;
  34. const PPCSubtarget *getSubtargetImpl(const Function &F) const override;
  35. // DO NOT IMPLEMENT: There is no such thing as a valid default subtarget,
  36. // subtargets are per-function entities based on the target-specific
  37. // attributes of each function.
  38. const PPCSubtarget *getSubtargetImpl() const = delete;
  39. // Pass Pipeline Configuration
  40. TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
  41. TargetTransformInfo getTargetTransformInfo(const Function &F) override;
  42. TargetLoweringObjectFile *getObjFileLowering() const override {
  43. return TLOF.get();
  44. }
  45. bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; }
  46. bool isPPC64() const {
  47. const Triple &TT = getTargetTriple();
  48. return (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le);
  49. };
  50. bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
  51. // Addrspacecasts are always noops.
  52. return true;
  53. }
  54. };
  55. } // end namespace llvm
  56. #endif