Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 1 | //===-- SystemZTargetMachine.cpp - Define TargetMachine for SystemZ -----------===// |
| 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 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "SystemZTargetAsmInfo.h" |
| 14 | #include "SystemZTargetMachine.h" |
| 15 | #include "SystemZ.h" |
| 16 | #include "llvm/Module.h" |
| 17 | #include "llvm/PassManager.h" |
| 18 | #include "llvm/Target/TargetMachineRegistry.h" |
| 19 | using namespace llvm; |
| 20 | |
| 21 | /// SystemZTargetMachineModule - Note that this is used on hosts that |
| 22 | /// cannot link in a library unless there are references into the |
| 23 | /// library. In particular, it seems that it is not possible to get |
| 24 | /// things to work on Win32 without this. Though it is unused, do not |
| 25 | /// remove it. |
| 26 | extern "C" int SystemZTargetMachineModule; |
| 27 | int SystemZTargetMachineModule = 0; |
| 28 | |
| 29 | // Register the target. |
| 30 | static RegisterTarget<SystemZTargetMachine> |
| 31 | X("systemz", "SystemZ [experimental]"); |
| 32 | |
| 33 | const TargetAsmInfo *SystemZTargetMachine::createTargetAsmInfo() const { |
| 34 | // FIXME: Handle Solaris subtarget someday :) |
| 35 | return new SystemZTargetAsmInfo(*this); |
| 36 | } |
| 37 | |
| 38 | /// SystemZTargetMachine ctor - Create an ILP64 architecture model |
| 39 | /// |
| 40 | SystemZTargetMachine::SystemZTargetMachine(const Module &M, const std::string &FS) |
| 41 | : Subtarget(*this, M, FS), |
Anton Korobeynikov | 70f717f | 2009-07-16 14:04:22 +0000 | [diff] [blame] | 42 | DataLayout("E-p:64:64:64-i8:8:16-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-a0:16:16"), |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 43 | InstrInfo(*this), TLInfo(*this), |
Anton Korobeynikov | 51f613f | 2009-07-16 13:49:25 +0000 | [diff] [blame] | 44 | FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -160) { |
Anton Korobeynikov | 6fe326c | 2009-07-16 14:16:05 +0000 | [diff] [blame^] | 45 | |
| 46 | if (getRelocationModel() == Reloc::Default) |
| 47 | setRelocationModel(Reloc::Static); |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | bool SystemZTargetMachine::addInstSelector(PassManagerBase &PM, |
| 51 | CodeGenOpt::Level OptLevel) { |
| 52 | // Install an instruction selector. |
| 53 | PM.add(createSystemZISelDag(*this, OptLevel)); |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | bool SystemZTargetMachine::addAssemblyEmitter(PassManagerBase &PM, |
| 58 | CodeGenOpt::Level OptLevel, |
| 59 | bool Verbose, |
| 60 | raw_ostream &Out) { |
| 61 | // Output assembly language. |
| 62 | PM.add(createSystemZCodePrinterPass(Out, *this, OptLevel, Verbose)); |
| 63 | return false; |
| 64 | } |
| 65 | |
| 66 | unsigned SystemZTargetMachine::getModuleMatchQuality(const Module &M) { |
| 67 | std::string TT = M.getTargetTriple(); |
| 68 | |
| 69 | // We strongly match s390x |
| 70 | if (TT.size() >= 5 && TT[0] == 's' && TT[1] == '3' && TT[2] == '9' && |
| 71 | TT[3] == '0' && TT[4] == 'x') |
| 72 | return 20; |
| 73 | |
| 74 | return 0; |
| 75 | } |