blob: 75b98a815ab42cbc5d1e64bca4b95b40859ebed4 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- PPCTargetMachine.h - Define TargetMachine for PowerPC ---*- C++ -*-===//
Misha Brukmanb4402432005-04-21 23:30:14 +00002//
Misha Brukmand022a5a2004-08-11 00:09:42 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukmanb4402432005-04-21 23:30:14 +00007//
Misha Brukmand022a5a2004-08-11 00:09:42 +00008//===----------------------------------------------------------------------===//
Misha Brukmanb4402432005-04-21 23:30:14 +00009//
Misha Brukman116f9272004-08-17 04:55:41 +000010// This file declares the PowerPC specific subclass of TargetMachine.
Misha Brukmand022a5a2004-08-11 00:09:42 +000011//
12//===----------------------------------------------------------------------===//
13
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_POWERPC_PPCTARGETMACHINE_H
15#define LLVM_LIB_TARGET_POWERPC_PPCTARGETMACHINE_H
Misha Brukmand022a5a2004-08-11 00:09:42 +000016
Chandler Carruth802d7552012-12-04 07:12:27 +000017#include "PPCInstrInfo.h"
Chandler Carruth802d7552012-12-04 07:12:27 +000018#include "PPCSubtarget.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000019#include "llvm/IR/DataLayout.h"
Chris Lattner2ed745a2005-10-14 23:44:05 +000020#include "llvm/Target/TargetMachine.h"
Misha Brukmand022a5a2004-08-11 00:09:42 +000021
22namespace llvm {
Misha Brukmand022a5a2004-08-11 00:09:42 +000023
Rafael Espindola38af4d62016-05-18 16:00:24 +000024/// Common code between 32-bit and 64-bit PowerPC targets.
Chris Lattner0c4aa142006-06-16 01:37:27 +000025///
Matthias Braunbb8507e2017-10-12 22:57:28 +000026class PPCTargetMachine final : public LLVMTargetMachine {
Eric Christopherfee6aaf2015-02-17 06:45:15 +000027public:
28 enum PPCABI { PPC_ABI_UNKNOWN, PPC_ABI_ELFv1, PPC_ABI_ELFv2 };
29private:
Aditya Nandakumara2719322014-11-13 09:26:31 +000030 std::unique_ptr<TargetLoweringObjectFile> TLOF;
Eric Christopherfee6aaf2015-02-17 06:45:15 +000031 PPCABI TargetABI;
Hal Finkelcbf08922015-07-12 02:33:57 +000032
Eric Christopher3faf2f12014-10-06 06:45:36 +000033 mutable StringMap<std::unique_ptr<PPCSubtarget>> SubtargetMap;
Bill Wendling40cb8112007-01-24 03:41:36 +000034
Chris Lattner2ed745a2005-10-14 23:44:05 +000035public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000036 PPCTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
Rafael Espindola8c34dd82016-05-18 22:04:49 +000037 StringRef FS, const TargetOptions &Options,
Rafael Espindola79e238a2017-08-03 02:16:21 +000038 Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
39 CodeGenOpt::Level OL, bool JIT);
Nate Begeman6cca84e2005-10-16 05:39:50 +000040
Reid Kleckner357600e2014-11-20 23:37:18 +000041 ~PPCTargetMachine() override;
42
Eric Christopher3faf2f12014-10-06 06:45:36 +000043 const PPCSubtarget *getSubtargetImpl(const Function &F) const override;
Eric Christopher97ae58682017-07-25 22:21:08 +000044 // DO NOT IMPLEMENT: There is no such thing as a valid default subtarget,
45 // subtargets are per-function entities based on the target-specific
46 // attributes of each function.
Eric Christopherb4fb2562017-06-30 19:49:05 +000047 const PPCSubtarget *getSubtargetImpl() const = delete;
Anton Korobeynikov28dc9d02008-08-17 13:54:28 +000048
Chris Lattner12e97302006-09-04 04:14:57 +000049 // Pass Pipeline Configuration
Craig Topper0d3fa922014-04-29 07:57:37 +000050 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
Hal Finkel4e5ca9e2013-01-25 23:05:59 +000051
Sanjoy Das26d11ca2017-12-22 18:21:59 +000052 TargetTransformInfo getTargetTransformInfo(const Function &F) override;
Chandler Carruth93dcdc42015-01-31 11:17:59 +000053
Aditya Nandakumara2719322014-11-13 09:26:31 +000054 TargetLoweringObjectFile *getObjFileLowering() const override {
55 return TLOF.get();
56 }
Eric Christopherfee6aaf2015-02-17 06:45:15 +000057 bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; }
58 bool isPPC64() const {
Daniel Sandersc81f4502015-06-16 15:44:21 +000059 const Triple &TT = getTargetTriple();
Eric Christopherfee6aaf2015-02-17 06:45:15 +000060 return (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le);
61 };
Matthias Braund6a36ae2017-05-31 18:41:23 +000062
63 bool isMachineVerifierClean() const override {
64 return false;
65 }
Misha Brukmand022a5a2004-08-11 00:09:42 +000066};
Misha Brukmand022a5a2004-08-11 00:09:42 +000067} // end namespace llvm
68
69#endif