blob: 59b4f1e30c0e5af5695c451166a2eb6d7ccf3c31 [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///
Chris Lattner12e97302006-09-04 04:14:57 +000026class PPCTargetMachine : 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 PPCSubtarget Subtarget;
33
Eric Christopher3faf2f12014-10-06 06:45:36 +000034 mutable StringMap<std::unique_ptr<PPCSubtarget>> SubtargetMap;
Bill Wendling40cb8112007-01-24 03:41:36 +000035
Chris Lattner2ed745a2005-10-14 23:44:05 +000036public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000037 PPCTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
Rafael Espindola8c34dd82016-05-18 22:04:49 +000038 StringRef FS, const TargetOptions &Options,
39 Optional<Reloc::Model> RM, CodeModel::Model CM,
40 CodeGenOpt::Level OL);
Nate Begeman6cca84e2005-10-16 05:39:50 +000041
Reid Kleckner357600e2014-11-20 23:37:18 +000042 ~PPCTargetMachine() override;
43
Eric Christopher3faf2f12014-10-06 06:45:36 +000044 const PPCSubtarget *getSubtargetImpl(const Function &F) const override;
Anton Korobeynikov28dc9d02008-08-17 13:54:28 +000045
Chris Lattner12e97302006-09-04 04:14:57 +000046 // Pass Pipeline Configuration
Craig Topper0d3fa922014-04-29 07:57:37 +000047 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
Hal Finkel4e5ca9e2013-01-25 23:05:59 +000048
Chandler Carruth8b04c0d2015-02-01 13:20:00 +000049 TargetIRAnalysis getTargetIRAnalysis() override;
Chandler Carruth93dcdc42015-01-31 11:17:59 +000050
Aditya Nandakumara2719322014-11-13 09:26:31 +000051 TargetLoweringObjectFile *getObjFileLowering() const override {
52 return TLOF.get();
53 }
Eric Christopherfee6aaf2015-02-17 06:45:15 +000054 bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; }
55 bool isPPC64() const {
Daniel Sandersc81f4502015-06-16 15:44:21 +000056 const Triple &TT = getTargetTriple();
Eric Christopherfee6aaf2015-02-17 06:45:15 +000057 return (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le);
58 };
Misha Brukmand022a5a2004-08-11 00:09:42 +000059};
Chris Lattner0c4aa142006-06-16 01:37:27 +000060
Rafael Espindola38af4d62016-05-18 16:00:24 +000061/// PowerPC 32-bit target machine.
Chris Lattner0c4aa142006-06-16 01:37:27 +000062///
63class PPC32TargetMachine : public PPCTargetMachine {
David Blaikiea379b1812011-12-20 02:50:00 +000064 virtual void anchor();
Chris Lattner0c4aa142006-06-16 01:37:27 +000065public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000066 PPC32TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
67 StringRef FS, const TargetOptions &Options,
Rafael Espindola8c34dd82016-05-18 22:04:49 +000068 Optional<Reloc::Model> RM, CodeModel::Model CM,
Evan Chengecb29082011-11-16 08:38:26 +000069 CodeGenOpt::Level OL);
Chris Lattner0c4aa142006-06-16 01:37:27 +000070};
71
Rafael Espindola38af4d62016-05-18 16:00:24 +000072/// PowerPC 64-bit target machine.
Chris Lattner0c4aa142006-06-16 01:37:27 +000073///
74class PPC64TargetMachine : public PPCTargetMachine {
David Blaikiea379b1812011-12-20 02:50:00 +000075 virtual void anchor();
Chris Lattner0c4aa142006-06-16 01:37:27 +000076public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000077 PPC64TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
78 StringRef FS, const TargetOptions &Options,
Rafael Espindola8c34dd82016-05-18 22:04:49 +000079 Optional<Reloc::Model> RM, CodeModel::Model CM,
Evan Chengecb29082011-11-16 08:38:26 +000080 CodeGenOpt::Level OL);
Chris Lattner0c4aa142006-06-16 01:37:27 +000081};
82
Misha Brukmand022a5a2004-08-11 00:09:42 +000083} // end namespace llvm
84
85#endif