blob: a7355f49fae5f945d66f4c0fd392e9a27ddcc986 [file] [log] [blame]
Chris Lattner7c90f732006-02-05 05:50:24 +00001//===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===//
Misha Brukmanb5f662f2005-04-21 23:30:14 +00002//
Brian Gaekee785e532004-02-25 19:28:19 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-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 Brukmanb5f662f2005-04-21 23:30:14 +00007//
Brian Gaekee785e532004-02-25 19:28:19 +00008//===----------------------------------------------------------------------===//
Misha Brukmanb5f662f2005-04-21 23:30:14 +00009//
Brian Gaekee785e532004-02-25 19:28:19 +000010//
11//===----------------------------------------------------------------------===//
12
Chris Lattner7c90f732006-02-05 05:50:24 +000013#include "SparcTargetMachine.h"
Craig Topper79aa3412012-03-17 18:46:09 +000014#include "Sparc.h"
Andrew Trick843ee2e2012-02-03 05:12:41 +000015#include "llvm/CodeGen/Passes.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000016#include "llvm/PassManager.h"
Evan Cheng3e74d6f2011-08-24 18:08:43 +000017#include "llvm/Support/TargetRegistry.h"
Chris Lattner8d8a6bc2004-02-28 19:52:49 +000018using namespace llvm;
Brian Gaekee785e532004-02-25 19:28:19 +000019
Daniel Dunbar0c795d62009-07-25 06:49:55 +000020extern "C" void LLVMInitializeSparcTarget() {
21 // Register the target.
Chris Lattner87c06d62010-02-04 06:34:01 +000022 RegisterTargetMachine<SparcV8TargetMachine> X(TheSparcTarget);
23 RegisterTargetMachine<SparcV9TargetMachine> Y(TheSparcV9Target);
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000024}
25
Chris Lattner7c90f732006-02-05 05:50:24 +000026/// SparcTargetMachine ctor - Create an ILP32 architecture model
Brian Gaekee785e532004-02-25 19:28:19 +000027///
Andrew Trick843ee2e2012-02-03 05:12:41 +000028SparcTargetMachine::SparcTargetMachine(const Target &T, StringRef TT,
Evan Cheng43966132011-07-19 06:37:02 +000029 StringRef CPU, StringRef FS,
Nick Lewycky8a8d4792011-12-02 22:16:29 +000030 const TargetOptions &Options,
Evan Cheng34ad6db2011-07-20 07:51:56 +000031 Reloc::Model RM, CodeModel::Model CM,
Evan Chengb95fc312011-11-16 08:38:26 +000032 CodeGenOpt::Level OL,
Evan Cheng34ad6db2011-07-20 07:51:56 +000033 bool is64bit)
Nick Lewycky8a8d4792011-12-02 22:16:29 +000034 : LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
Evan Cheng276365d2011-06-30 01:53:36 +000035 Subtarget(TT, CPU, FS, is64bit),
Micah Villmow3574eca2012-10-08 16:38:25 +000036 DL(Subtarget.getDataLayout()),
Jakob Stoklund Olesened277f32012-05-04 02:16:39 +000037 InstrInfo(Subtarget),
38 TLInfo(*this), TSInfo(*this),
Chandler Carruthaeef83c2013-01-07 01:37:14 +000039 FrameLowering(Subtarget) {
Rafael Espindola4a971702013-05-13 01:16:13 +000040 initAsmInfo();
Brian Gaeke0e2d4662004-10-09 05:57:01 +000041}
42
Andrew Trick843ee2e2012-02-03 05:12:41 +000043namespace {
44/// Sparc Code Generator Pass Configuration Options.
45class SparcPassConfig : public TargetPassConfig {
46public:
Andrew Trick061efcf2012-02-04 02:56:59 +000047 SparcPassConfig(SparcTargetMachine *TM, PassManagerBase &PM)
48 : TargetPassConfig(TM, PM) {}
Andrew Trick843ee2e2012-02-03 05:12:41 +000049
50 SparcTargetMachine &getSparcTargetMachine() const {
51 return getTM<SparcTargetMachine>();
52 }
53
54 virtual bool addInstSelector();
55 virtual bool addPreEmitPass();
56};
57} // namespace
58
Andrew Trick061efcf2012-02-04 02:56:59 +000059TargetPassConfig *SparcTargetMachine::createPassConfig(PassManagerBase &PM) {
60 return new SparcPassConfig(this, PM);
Andrew Trick843ee2e2012-02-03 05:12:41 +000061}
62
63bool SparcPassConfig::addInstSelector() {
Bob Wilson564fbf62012-07-02 19:48:31 +000064 addPass(createSparcISelDag(getSparcTargetMachine()));
Chris Lattner9ff6ba12004-02-28 20:21:45 +000065 return false;
Brian Gaekee785e532004-02-25 19:28:19 +000066}
67
Chris Lattner1911fd42006-09-04 04:14:57 +000068/// addPreEmitPass - This pass may be implemented by targets that want to run
69/// passes immediately before machine code is emitted. This should return
70/// true if -print-machineinstrs should print out the code after the passes.
Andrew Trick843ee2e2012-02-03 05:12:41 +000071bool SparcPassConfig::addPreEmitPass(){
Bob Wilson564fbf62012-07-02 19:48:31 +000072 addPass(createSparcDelaySlotFillerPass(getSparcTargetMachine()));
Chris Lattner1911fd42006-09-04 04:14:57 +000073 return true;
74}
Chris Lattner87c06d62010-02-04 06:34:01 +000075
David Blaikie2d24e2a2011-12-20 02:50:00 +000076void SparcV8TargetMachine::anchor() { }
77
Chris Lattner87c06d62010-02-04 06:34:01 +000078SparcV8TargetMachine::SparcV8TargetMachine(const Target &T,
Evan Cheng34ad6db2011-07-20 07:51:56 +000079 StringRef TT, StringRef CPU,
Nick Lewycky8a8d4792011-12-02 22:16:29 +000080 StringRef FS,
81 const TargetOptions &Options,
82 Reloc::Model RM,
Evan Chengb95fc312011-11-16 08:38:26 +000083 CodeModel::Model CM,
84 CodeGenOpt::Level OL)
Nick Lewycky8a8d4792011-12-02 22:16:29 +000085 : SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, false) {
Chris Lattner87c06d62010-02-04 06:34:01 +000086}
87
David Blaikie2d24e2a2011-12-20 02:50:00 +000088void SparcV9TargetMachine::anchor() { }
89
Andrew Trick843ee2e2012-02-03 05:12:41 +000090SparcV9TargetMachine::SparcV9TargetMachine(const Target &T,
Evan Cheng34ad6db2011-07-20 07:51:56 +000091 StringRef TT, StringRef CPU,
Nick Lewycky8a8d4792011-12-02 22:16:29 +000092 StringRef FS,
93 const TargetOptions &Options,
94 Reloc::Model RM,
Evan Chengb95fc312011-11-16 08:38:26 +000095 CodeModel::Model CM,
96 CodeGenOpt::Level OL)
Nick Lewycky8a8d4792011-12-02 22:16:29 +000097 : SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, true) {
Chris Lattner87c06d62010-02-04 06:34:01 +000098}