blob: f6707f9a20ddfc88e2a869b6efc97628e775b9d2 [file] [log] [blame]
Anton Korobeynikov4403b932009-07-16 13:27:25 +00001//===- SystemZSubtarget.cpp - SystemZ Subtarget Information -------*- C++ -*-=//
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//
Evan Cheng5b1b44892011-07-01 21:01:15 +000010// This file implements the SystemZ specific subclass of TargetSubtargetInfo.
Anton Korobeynikov4403b932009-07-16 13:27:25 +000011//
12//===----------------------------------------------------------------------===//
13
14#include "SystemZSubtarget.h"
15#include "SystemZ.h"
Anton Korobeynikov6fe326c2009-07-16 14:16:05 +000016#include "llvm/GlobalValue.h"
Anton Korobeynikov4403b932009-07-16 13:27:25 +000017#include "llvm/Target/TargetMachine.h"
Evan Chengffc0e732011-07-09 05:47:46 +000018#include "llvm/Target/TargetRegistry.h"
Anton Korobeynikov4403b932009-07-16 13:27:25 +000019
Evan Chengebdeeab2011-07-08 01:53:10 +000020#define GET_SUBTARGETINFO_ENUM
Evan Cheng94214702011-07-01 20:45:01 +000021#define GET_SUBTARGETINFO_MC_DESC
22#define GET_SUBTARGETINFO_TARGET_DESC
Evan Chengebdeeab2011-07-08 01:53:10 +000023#define GET_SUBTARGETINFO_CTOR
Evan Cheng385e9302011-07-01 22:36:09 +000024#include "SystemZGenSubtargetInfo.inc"
Evan Cheng94214702011-07-01 20:45:01 +000025
Anton Korobeynikov4403b932009-07-16 13:27:25 +000026using namespace llvm;
27
Daniel Dunbar3be03402009-08-02 22:11:08 +000028SystemZSubtarget::SystemZSubtarget(const std::string &TT,
Evan Cheng276365d2011-06-30 01:53:36 +000029 const std::string &CPU,
Anton Korobeynikov747052c2009-07-16 14:05:00 +000030 const std::string &FS):
Evan Cheng0ddff1b2011-07-07 07:07:08 +000031 SystemZGenSubtargetInfo(TT, CPU, FS), HasZ10Insts(false) {
Evan Cheng276365d2011-06-30 01:53:36 +000032 std::string CPUName = CPU;
33 if (CPUName.empty())
34 CPUName = "z9";
Anton Korobeynikov4403b932009-07-16 13:27:25 +000035
36 // Parse features string.
Evan Cheng0ddff1b2011-07-07 07:07:08 +000037 ParseSubtargetFeatures(CPUName, FS);
Anton Korobeynikov4403b932009-07-16 13:27:25 +000038}
Anton Korobeynikov6fe326c2009-07-16 14:16:05 +000039
40/// True if accessing the GV requires an extra load.
41bool SystemZSubtarget::GVRequiresExtraLoad(const GlobalValue* GV,
42 const TargetMachine& TM,
43 bool isDirectCall) const {
44 if (TM.getRelocationModel() == Reloc::PIC_) {
45 // Extra load is needed for all externally visible.
46 if (isDirectCall)
47 return false;
48
49 if (GV->hasLocalLinkage() || GV->hasHiddenVisibility())
50 return false;
51
52 return true;
53 }
54
55 return false;
56}
Evan Chengffc0e732011-07-09 05:47:46 +000057
58MCSubtargetInfo *createSystemZMCSubtargetInfo(StringRef TT, StringRef CPU,
59 StringRef FS) {
60 MCSubtargetInfo *X = new MCSubtargetInfo();
61 InitSystemZMCSubtargetInfo(X, CPU, FS);
62 return X;
63}
64
65extern "C" void LLVMInitializeSystemZMCSubtargetInfo() {
66 TargetRegistry::RegisterMCSubtargetInfo(TheSystemZTarget,
67 createSystemZMCSubtargetInfo);
68}