blob: 01be4edf7d70f36cd20cf72a042ba25521059145 [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
Anton Korobeynikov7df84622009-07-16 14:36:52 +000021extern Target TheSystemZTarget;
22namespace {
23 // Register the target.
24 RegisterTarget<SystemZTargetMachine> X(TheSystemZTarget,
25 "systemz",
26 "SystemZ [experimental]");
27}
Anton Korobeynikov4403b932009-07-16 13:27:25 +000028
Anton Korobeynikov7df84622009-07-16 14:36:52 +000029// Force static initialization.
30extern "C" void LLVMInitializeSystemZTarget() {
31
32}
Anton Korobeynikov4403b932009-07-16 13:27:25 +000033
34const TargetAsmInfo *SystemZTargetMachine::createTargetAsmInfo() const {
35 // FIXME: Handle Solaris subtarget someday :)
36 return new SystemZTargetAsmInfo(*this);
37}
38
39/// SystemZTargetMachine ctor - Create an ILP64 architecture model
40///
Anton Korobeynikov7df84622009-07-16 14:36:52 +000041SystemZTargetMachine::SystemZTargetMachine(const Target &T,
42 const Module &M,
43 const std::string &FS)
44 : LLVMTargetMachine(T),
45 Subtarget(*this, M, FS),
46 DataLayout("E-p:64:64:64-i8:8:16-i16:16:16-i32:32:32-i64:64:64-f32:32:32"
47 "-f64:64:64-f128:128:128-a0:16:16"),
Anton Korobeynikov4403b932009-07-16 13:27:25 +000048 InstrInfo(*this), TLInfo(*this),
Anton Korobeynikov51f613f2009-07-16 13:49:25 +000049 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -160) {
Anton Korobeynikov6fe326c2009-07-16 14:16:05 +000050
51 if (getRelocationModel() == Reloc::Default)
52 setRelocationModel(Reloc::Static);
Anton Korobeynikov4403b932009-07-16 13:27:25 +000053}
54
55bool SystemZTargetMachine::addInstSelector(PassManagerBase &PM,
56 CodeGenOpt::Level OptLevel) {
57 // Install an instruction selector.
58 PM.add(createSystemZISelDag(*this, OptLevel));
59 return false;
60}
61
Anton Korobeynikov4403b932009-07-16 13:27:25 +000062unsigned SystemZTargetMachine::getModuleMatchQuality(const Module &M) {
63 std::string TT = M.getTargetTriple();
64
65 // We strongly match s390x
66 if (TT.size() >= 5 && TT[0] == 's' && TT[1] == '3' && TT[2] == '9' &&
67 TT[3] == '0' && TT[4] == 'x')
68 return 20;
69
70 return 0;
71}