blob: 6496339519a1da089edfd58638ee221dc8c0bd1f [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;
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,
38 StringRef FS, const TargetOptions &Options, Reloc::Model RM,
Eric Christopher8b770652015-01-26 19:03:15 +000039 CodeModel::Model CM, CodeGenOpt::Level OL);
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;
Anton Korobeynikov28dc9d02008-08-17 13:54:28 +000044
Chris Lattner12e97302006-09-04 04:14:57 +000045 // Pass Pipeline Configuration
Craig Topper0d3fa922014-04-29 07:57:37 +000046 TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
Hal Finkel4e5ca9e2013-01-25 23:05:59 +000047
Chandler Carruth8b04c0d2015-02-01 13:20:00 +000048 TargetIRAnalysis getTargetIRAnalysis() override;
Chandler Carruth93dcdc42015-01-31 11:17:59 +000049
Aditya Nandakumara2719322014-11-13 09:26:31 +000050 TargetLoweringObjectFile *getObjFileLowering() const override {
51 return TLOF.get();
52 }
Eric Christopherfee6aaf2015-02-17 06:45:15 +000053 bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; }
54 bool isPPC64() const {
Daniel Sandersc81f4502015-06-16 15:44:21 +000055 const Triple &TT = getTargetTriple();
Eric Christopherfee6aaf2015-02-17 06:45:15 +000056 return (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le);
57 };
Misha Brukmand022a5a2004-08-11 00:09:42 +000058};
Chris Lattner0c4aa142006-06-16 01:37:27 +000059
60/// PPC32TargetMachine - PowerPC 32-bit target machine.
61///
62class PPC32TargetMachine : public PPCTargetMachine {
David Blaikiea379b1812011-12-20 02:50:00 +000063 virtual void anchor();
Chris Lattner0c4aa142006-06-16 01:37:27 +000064public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000065 PPC32TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
66 StringRef FS, const TargetOptions &Options,
Evan Chengecb29082011-11-16 08:38:26 +000067 Reloc::Model RM, CodeModel::Model CM,
68 CodeGenOpt::Level OL);
Chris Lattner0c4aa142006-06-16 01:37:27 +000069};
70
71/// PPC64TargetMachine - PowerPC 64-bit target machine.
72///
73class PPC64TargetMachine : public PPCTargetMachine {
David Blaikiea379b1812011-12-20 02:50:00 +000074 virtual void anchor();
Chris Lattner0c4aa142006-06-16 01:37:27 +000075public:
Daniel Sanders3e5de882015-06-11 19:41:26 +000076 PPC64TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
77 StringRef FS, const TargetOptions &Options,
Evan Chengecb29082011-11-16 08:38:26 +000078 Reloc::Model RM, CodeModel::Model CM,
79 CodeGenOpt::Level OL);
Chris Lattner0c4aa142006-06-16 01:37:27 +000080};
81
Misha Brukmand022a5a2004-08-11 00:09:42 +000082} // end namespace llvm
83
84#endif