blob: 5c0f7e629a69c5912c9700148b9d33e6f46cf8eb [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
Chris Lattner0c4aa142006-06-16 01:37:27 +000024/// PPCTargetMachine - Common code between 32-bit and 64-bit PowerPC targets.
25///
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;
Eric Christopher3faf2f12014-10-06 06:45:36 +000032 mutable StringMap<std::unique_ptr<PPCSubtarget>> SubtargetMap;
Bill Wendling40cb8112007-01-24 03:41:36 +000033
Chris Lattner2ed745a2005-10-14 23:44:05 +000034public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000035 PPCTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
36 StringRef FS, const TargetOptions &Options, Reloc::Model RM,
Eric Christopher8b770652015-01-26 19:03:15 +000037 CodeModel::Model CM, CodeGenOpt::Level OL);
Nate Begeman6cca84e2005-10-16 05:39:50 +000038
Reid Kleckner357600e2014-11-20 23:37:18 +000039 ~PPCTargetMachine() override;
40
Eric Christopher3faf2f12014-10-06 06:45:36 +000041 const PPCSubtarget *getSubtargetImpl(const Function &F) const override;
Anton Korobeynikov28dc9d02008-08-17 13:54:28 +000042
Chris Lattner12e97302006-09-04 04:14:57 +000043 // Pass Pipeline Configuration
Craig Topper0d3fa922014-04-29 07:57:37 +000044 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
Hal Finkel4e5ca9e2013-01-25 23:05:59 +000045
Chandler Carruth8b04c0d2015-02-01 13:20:00 +000046 TargetIRAnalysis getTargetIRAnalysis() override;
Chandler Carruth93dcdc42015-01-31 11:17:59 +000047
Aditya Nandakumara2719322014-11-13 09:26:31 +000048 TargetLoweringObjectFile *getObjFileLowering() const override {
49 return TLOF.get();
50 }
Eric Christopherfee6aaf2015-02-17 06:45:15 +000051 bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; }
52 bool isPPC64() const {
Daniel Sandersc81f4502015-06-16 15:44:21 +000053 const Triple &TT = getTargetTriple();
Eric Christopherfee6aaf2015-02-17 06:45:15 +000054 return (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le);
55 };
Misha Brukmand022a5a2004-08-11 00:09:42 +000056};
Chris Lattner0c4aa142006-06-16 01:37:27 +000057
58/// PPC32TargetMachine - PowerPC 32-bit target machine.
59///
60class PPC32TargetMachine : public PPCTargetMachine {
David Blaikiea379b1812011-12-20 02:50:00 +000061 virtual void anchor();
Chris Lattner0c4aa142006-06-16 01:37:27 +000062public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000063 PPC32TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
64 StringRef FS, const TargetOptions &Options,
Evan Chengecb29082011-11-16 08:38:26 +000065 Reloc::Model RM, CodeModel::Model CM,
66 CodeGenOpt::Level OL);
Chris Lattner0c4aa142006-06-16 01:37:27 +000067};
68
69/// PPC64TargetMachine - PowerPC 64-bit target machine.
70///
71class PPC64TargetMachine : public PPCTargetMachine {
David Blaikiea379b1812011-12-20 02:50:00 +000072 virtual void anchor();
Chris Lattner0c4aa142006-06-16 01:37:27 +000073public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000074 PPC64TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
75 StringRef FS, const TargetOptions &Options,
Evan Chengecb29082011-11-16 08:38:26 +000076 Reloc::Model RM, CodeModel::Model CM,
77 CodeGenOpt::Level OL);
Chris Lattner0c4aa142006-06-16 01:37:27 +000078};
79
Misha Brukmand022a5a2004-08-11 00:09:42 +000080} // end namespace llvm
81
82#endif