blob: 4be8ea9936499f4613975e99d3e69bf9cc766e55 [file] [log] [blame]
Anton Korobeynikov4403b932009-07-16 13:27:25 +00001//===-- 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"
19using 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.
26extern "C" int SystemZTargetMachineModule;
27int SystemZTargetMachineModule = 0;
28
29// Register the target.
30static RegisterTarget<SystemZTargetMachine>
31X("systemz", "SystemZ [experimental]");
32
33const 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///
40SystemZTargetMachine::SystemZTargetMachine(const Module &M, const std::string &FS)
41 : Subtarget(*this, M, FS),
Anton Korobeynikov70f717f2009-07-16 14:04:22 +000042 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 Korobeynikov4403b932009-07-16 13:27:25 +000043 InstrInfo(*this), TLInfo(*this),
Anton Korobeynikov51f613f2009-07-16 13:49:25 +000044 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -160) {
Anton Korobeynikov6fe326c2009-07-16 14:16:05 +000045
46 if (getRelocationModel() == Reloc::Default)
47 setRelocationModel(Reloc::Static);
Anton Korobeynikov4403b932009-07-16 13:27:25 +000048}
49
50bool SystemZTargetMachine::addInstSelector(PassManagerBase &PM,
51 CodeGenOpt::Level OptLevel) {
52 // Install an instruction selector.
53 PM.add(createSystemZISelDag(*this, OptLevel));
54 return false;
55}
56
57bool 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
66unsigned 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}