PPCTargetMachine.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. enum Endian { NOT_DETECTED, LITTLE, BIG };
  25. private:
  26. std::unique_ptr<TargetLoweringObjectFile> TLOF;
  27. PPCABI TargetABI;
  28. Endian Endianness = Endian::NOT_DETECTED;
  29. mutable StringMap<std::unique_ptr<PPCSubtarget>> SubtargetMap;
  30. public:
  31. PPCTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
  32. StringRef FS, const TargetOptions &Options,
  33. Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
  34. CodeGenOpt::Level OL, bool JIT);
  35. ~PPCTargetMachine() override;
  36. const PPCSubtarget *getSubtargetImpl(const Function &F) const override;
  37. // DO NOT IMPLEMENT: There is no such thing as a valid default subtarget,
  38. // subtargets are per-function entities based on the target-specific
  39. // attributes of each function.
  40. const PPCSubtarget *getSubtargetImpl() const = delete;
  41. // Pass Pipeline Configuration
  42. TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
  43. TargetTransformInfo getTargetTransformInfo(const Function &F) override;
  44. TargetLoweringObjectFile *getObjFileLowering() const override {
  45. return TLOF.get();
  46. }
  47. bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; }
  48. bool isPPC64() const {
  49. const Triple &TT = getTargetTriple();
  50. return (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le);
  51. };
  52. bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
  53. // Addrspacecasts are always noops.
  54. return true;
  55. }
  56. bool isLittleEndian() const;
  57. int unqualifiedInlineAsmVariant() const override { return 1; }
  58. };
  59. } // end namespace llvm
  60. #endif