Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 1 | //===-- MBlazeTargetMachine.cpp - Define TargetMachine for MBlaze ---------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // Implements the info about MBlaze target spec. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "MBlaze.h" |
Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 15 | #include "MBlazeTargetMachine.h" |
| 16 | #include "llvm/PassManager.h" |
Wesley Peck | 4e9141f | 2010-10-21 03:57:26 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/Passes.h" |
| 18 | #include "llvm/Support/FormattedStream.h" |
Evan Cheng | 3e74d6f | 2011-08-24 18:08:43 +0000 | [diff] [blame] | 19 | #include "llvm/Support/TargetRegistry.h" |
Wesley Peck | 4e9141f | 2010-10-21 03:57:26 +0000 | [diff] [blame] | 20 | #include "llvm/Target/TargetOptions.h" |
Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 21 | using namespace llvm; |
| 22 | |
| 23 | extern "C" void LLVMInitializeMBlazeTarget() { |
| 24 | // Register the target. |
| 25 | RegisterTargetMachine<MBlazeTargetMachine> X(TheMBlazeTarget); |
Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | // DataLayout --> Big-endian, 32-bit pointer/ABI/alignment |
| 29 | // The stack is always 8 byte aligned |
| 30 | // On function prologue, the stack is created by decrementing |
| 31 | // its pointer. Once decremented, all references are done with positive |
| 32 | // offset from the stack/frame pointer, using StackGrowsUp enables |
| 33 | // an easier handling. |
| 34 | MBlazeTargetMachine:: |
Evan Cheng | 4396613 | 2011-07-19 06:37:02 +0000 | [diff] [blame] | 35 | MBlazeTargetMachine(const Target &T, StringRef TT, |
Evan Cheng | 34ad6db | 2011-07-20 07:51:56 +0000 | [diff] [blame] | 36 | StringRef CPU, StringRef FS, |
Evan Cheng | b95fc31 | 2011-11-16 08:38:26 +0000 | [diff] [blame^] | 37 | Reloc::Model RM, CodeModel::Model CM, |
| 38 | CodeGenOpt::Level OL): |
| 39 | LLVMTargetMachine(T, TT, CPU, FS, RM, CM, OL), |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 40 | Subtarget(TT, CPU, FS), |
Wesley Peck | 4da992a | 2010-10-21 19:48:38 +0000 | [diff] [blame] | 41 | DataLayout("E-p:32:32:32-i8:8:8-i16:16:16"), |
Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 42 | InstrInfo(*this), |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 43 | FrameLowering(Subtarget), |
Wesley Peck | 3d820ba | 2011-04-11 22:31:52 +0000 | [diff] [blame] | 44 | TLInfo(*this), TSInfo(*this), ELFWriterInfo(*this), |
| 45 | InstrItins(Subtarget.getInstrItineraryData()) { |
Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | // Install an instruction selector pass using |
| 49 | // the ISelDag to gen MBlaze code. |
Evan Cheng | b95fc31 | 2011-11-16 08:38:26 +0000 | [diff] [blame^] | 50 | bool MBlazeTargetMachine::addInstSelector(PassManagerBase &PM) { |
Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 51 | PM.add(createMBlazeISelDag(*this)); |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | // Implemented by targets that want to run passes immediately before |
| 56 | // machine code is emitted. return true if -print-machineinstrs should |
| 57 | // print out the code after the passes. |
Evan Cheng | b95fc31 | 2011-11-16 08:38:26 +0000 | [diff] [blame^] | 58 | bool MBlazeTargetMachine::addPreEmitPass(PassManagerBase &PM) { |
Wesley Peck | a70f28c | 2010-02-23 19:15:24 +0000 | [diff] [blame] | 59 | PM.add(createMBlazeDelaySlotFillerPass(*this)); |
| 60 | return true; |
| 61 | } |