LLVM  12.0.0git
SystemZSubtarget.cpp
Go to the documentation of this file.
1 //===-- SystemZSubtarget.cpp - SystemZ subtarget information --------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "SystemZSubtarget.h"
11 #include "llvm/IR/GlobalValue.h"
13 
14 using namespace llvm;
15 
16 #define DEBUG_TYPE "systemz-subtarget"
17 
18 #define GET_SUBTARGETINFO_TARGET_DESC
19 #define GET_SUBTARGETINFO_CTOR
20 #include "SystemZGenSubtargetInfo.inc"
21 
23  "systemz-subreg-liveness",
24  cl::desc("Enable subregister liveness tracking for SystemZ (experimental)"),
25  cl::Hidden);
26 
27 // Pin the vtable to this file.
28 void SystemZSubtarget::anchor() {}
29 
31 SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
32  StringRef CPUName = CPU;
33  if (CPUName.empty())
34  CPUName = "generic";
35  // Parse features string.
36  ParseSubtargetFeatures(CPUName, FS);
37 
38  // -msoft-float implies -mno-vx.
39  if (HasSoftFloat)
40  HasVector = false;
41 
42  return *this;
43 }
44 
45 SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
46  const std::string &FS,
47  const TargetMachine &TM)
67  TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
68  TLInfo(TM, *this), TSInfo(), FrameLowering() {}
69 
70 
72  return UseSubRegLiveness;
73 }
74 
76  CodeModel::Model CM) const {
77  // PC32DBL accesses require the low bit to be clear.
78  //
79  // FIXME: Explicitly check for functions: the datalayout is currently
80  // missing information about function pointers.
81  const DataLayout &DL = GV->getParent()->getDataLayout();
82  if (GV->getPointerAlignment(DL) == 1 && !GV->getValueType()->isFunctionTy())
83  return false;
84 
85  // For the small model, all locally-binding symbols are in range.
86  if (CM == CodeModel::Small)
87  return TLInfo.getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV);
88 
89  // For Medium and above, assume that the symbol is not within the 4GB range.
90  // Taking the address of locally-defined text would be OK, but that
91  // case isn't easy to detect.
92  return false;
93 }
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
Definition: Value.cpp:753
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:397
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:156
bool isPC32DBLSymbol(const GlobalValue *GV, CodeModel::Model CM) const
bool enableSubRegLiveness() const override
bool shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const
const TargetMachine & getTargetMachine() const
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:216
Type * getValueType() const
Definition: GlobalValue.h:273
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:572
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:65
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
static cl::opt< bool > UseSubRegLiveness("systemz-subreg-liveness", cl::desc("Enable subregister liveness tracking for SystemZ (experimental)"), cl::Hidden)
SystemZSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const TargetMachine &TM)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL