1 //===-- PPCTargetMachine.h - Define TargetMachine for PowerPC ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the PowerPC specific subclass of TargetMachine.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_POWERPC_PPCTARGETMACHINE_H
15 #define LLVM_LIB_TARGET_POWERPC_PPCTARGETMACHINE_H
17 #include "PPCInstrInfo.h"
18 #include "PPCSubtarget.h"
19 #include "llvm/IR/DataLayout.h"
20 #include "llvm/Target/TargetMachine.h"
24 /// Common code between 32-bit and 64-bit PowerPC targets.
26 class PPCTargetMachine : public LLVMTargetMachine {
28 enum PPCABI { PPC_ABI_UNKNOWN, PPC_ABI_ELFv1, PPC_ABI_ELFv2 };
30 std::unique_ptr<TargetLoweringObjectFile> TLOF;
33 mutable StringMap<std::unique_ptr<PPCSubtarget>> SubtargetMap;
36 PPCTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
37 StringRef FS, const TargetOptions &Options,
38 Optional<Reloc::Model> RM, CodeModel::Model CM,
39 CodeGenOpt::Level OL);
41 ~PPCTargetMachine() override;
43 const PPCSubtarget *getSubtargetImpl(const Function &F) const override;
45 // Pass Pipeline Configuration
46 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
48 TargetIRAnalysis getTargetIRAnalysis() override;
50 TargetLoweringObjectFile *getObjFileLowering() const override {
53 bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; }
54 bool isPPC64() const {
55 const Triple &TT = getTargetTriple();
56 return (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le);
59 bool isMachineVerifierClean() const override {
64 /// PowerPC 32-bit target machine.
66 class PPC32TargetMachine : public PPCTargetMachine {
67 virtual void anchor();
69 PPC32TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
70 StringRef FS, const TargetOptions &Options,
71 Optional<Reloc::Model> RM, CodeModel::Model CM,
72 CodeGenOpt::Level OL);
75 /// PowerPC 64-bit target machine.
77 class PPC64TargetMachine : public PPCTargetMachine {
78 virtual void anchor();
80 PPC64TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
81 StringRef FS, const TargetOptions &Options,
82 Optional<Reloc::Model> RM, CodeModel::Model CM,
83 CodeGenOpt::Level OL);
86 } // end namespace llvm