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/TargetRegistry.h"
19 using namespace llvm;
20 
21 extern "C" void LLVMInitializeSystemZTarget() {
22   // Register the target.
23   RegisterTargetMachine<SystemZTargetMachine> X(TheSystemZTarget);
24 }
25 
26 const TargetAsmInfo *SystemZTargetMachine::createTargetAsmInfo() const {
27   // FIXME: Handle Solaris subtarget someday :)
28   return new SystemZTargetAsmInfo(*this);
29 }
30 
31 /// SystemZTargetMachine ctor - Create an ILP64 architecture model
32 ///
33 SystemZTargetMachine::SystemZTargetMachine(const Target &T,
34                                            const Module &M,
35                                            const std::string &FS)
36   : LLVMTargetMachine(T),
37     Subtarget(*this, M, FS),
38     DataLayout("E-p:64:64:64-i8:8:16-i16:16:16-i32:32:32-i64:64:64-f32:32:32"
39                "-f64:64:64-f128:128:128-a0:16:16"),
40     InstrInfo(*this), TLInfo(*this),
41     FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -160) {
42 
43   if (getRelocationModel() == Reloc::Default)
44     setRelocationModel(Reloc::Static);
45 }
46 
47 bool SystemZTargetMachine::addInstSelector(PassManagerBase &PM,
48                                           CodeGenOpt::Level OptLevel) {
49   // Install an instruction selector.
50   PM.add(createSystemZISelDag(*this, OptLevel));
51   return false;
52 }
53 
54 unsigned SystemZTargetMachine::getModuleMatchQuality(const Module &M) {
55   std::string TT = M.getTargetTriple();
56 
57   // We strongly match s390x
58   if (TT.size() >= 5 && TT[0] == 's' && TT[1] == '3' && TT[2] == '9' &&
59       TT[3] == '0' &&  TT[4] == 'x')
60     return 20;
61 
62   return 0;
63 }
64