SystemZTargetMachine.cpp revision 51f613fb2b177a19fcc92c38cc58c99de4c330b0
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" 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), 42 DataLayout("E-p:64:64:64-i1:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128"), 43 InstrInfo(*this), TLInfo(*this), 44 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -160) { 45} 46 47bool SystemZTargetMachine::addInstSelector(PassManagerBase &PM, 48 CodeGenOpt::Level OptLevel) { 49 // Install an instruction selector. 50 PM.add(createSystemZISelDag(*this, OptLevel)); 51 return false; 52} 53 54bool SystemZTargetMachine::addAssemblyEmitter(PassManagerBase &PM, 55 CodeGenOpt::Level OptLevel, 56 bool Verbose, 57 raw_ostream &Out) { 58 // Output assembly language. 59 PM.add(createSystemZCodePrinterPass(Out, *this, OptLevel, Verbose)); 60 return false; 61} 62 63unsigned SystemZTargetMachine::getModuleMatchQuality(const Module &M) { 64 std::string TT = M.getTargetTriple(); 65 66 // We strongly match s390x 67 if (TT.size() >= 5 && TT[0] == 's' && TT[1] == '3' && TT[2] == '9' && 68 TT[3] == '0' && TT[4] == 'x') 69 return 20; 70 71 return 0; 72} 73