LLVM  16.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 
30 SystemZSubtarget &SystemZSubtarget::initializeSubtargetDependencies(
31  StringRef CPU, StringRef TuneCPU, StringRef FS) {
32  if (CPU.empty())
33  CPU = "generic";
34  if (TuneCPU.empty())
35  TuneCPU = CPU;
36  // Parse features string.
37  ParseSubtargetFeatures(CPU, TuneCPU, FS);
38 
39  // -msoft-float implies -mno-vx.
40  if (HasSoftFloat)
41  HasVector = false;
42 
43  // -mno-vx implicitly disables all vector-related features.
44  if (!HasVector) {
45  HasVectorEnhancements1 = false;
46  HasVectorEnhancements2 = false;
47  HasVectorPackedDecimal = false;
50  }
51 
52  return *this;
53 }
54 
56 SystemZSubtarget::initializeSpecialRegisters() {
57  if (isTargetXPLINK64())
58  return new SystemZXPLINK64Registers;
59  else if (isTargetELF())
60  return new SystemZELFRegisters;
61  else {
62  llvm_unreachable("Invalid Calling Convention. Cannot initialize Special "
63  "Call Registers!");
64  }
65 }
66 
67 SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
68  const std::string &TuneCPU,
69  const std::string &FS,
70  const TargetMachine &TM)
71  : SystemZGenSubtargetInfo(TT, CPU, TuneCPU, FS),
72  HasDistinctOps(false), HasLoadStoreOnCond(false), HasHighWord(false),
73  HasFPExtension(false), HasPopulationCount(false),
74  HasMessageSecurityAssist3(false), HasMessageSecurityAssist4(false),
75  HasResetReferenceBitsMultiple(false), HasFastSerialization(false),
76  HasInterlockedAccess1(false), HasMiscellaneousExtensions(false),
77  HasExecutionHint(false), HasLoadAndTrap(false),
78  HasTransactionalExecution(false), HasProcessorAssist(false),
79  HasDFPZonedConversion(false), HasEnhancedDAT2(false), HasVector(false),
80  HasLoadStoreOnCond2(false), HasLoadAndZeroRightmostByte(false),
81  HasMessageSecurityAssist5(false), HasDFPPackedConversion(false),
82  HasMiscellaneousExtensions2(false), HasGuardedStorage(false),
83  HasMessageSecurityAssist7(false), HasMessageSecurityAssist8(false),
84  HasVectorEnhancements1(false), HasVectorPackedDecimal(false),
85  HasInsertReferenceBitsMultiple(false), HasMiscellaneousExtensions3(false),
86  HasMessageSecurityAssist9(false), HasVectorEnhancements2(false),
87  HasVectorPackedDecimalEnhancement(false), HasEnhancedSort(false),
88  HasDeflateConversion(false), HasVectorPackedDecimalEnhancement2(false),
89  HasNNPAssist(false), HasBEAREnhancement(false),
90  HasResetDATProtection(false), HasProcessorActivityInstrumentation(false),
91  HasSoftFloat(false), TargetTriple(TT),
92  SpecialRegisters(initializeSpecialRegisters()),
93  InstrInfo(initializeSubtargetDependencies(CPU, TuneCPU, FS)),
94  TLInfo(TM, *this), FrameLowering(SystemZFrameLowering::create(*this)) {}
95 
97  return UseSubRegLiveness;
98 }
99 
101  CodeModel::Model CM) const {
102  // PC32DBL accesses require the low bit to be clear.
103  //
104  // FIXME: Explicitly check for functions: the datalayout is currently
105  // missing information about function pointers.
106  const DataLayout &DL = GV->getParent()->getDataLayout();
107  if (GV->getPointerAlignment(DL) == 1 && !GV->getValueType()->isFunctionTy())
108  return false;
109 
110  // For the small model, all locally-binding symbols are in range.
111  if (CM == CodeModel::Small)
112  return TLInfo.getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV);
113 
114  // For Medium and above, assume that the symbol is not within the 4GB range.
115  // Taking the address of locally-defined text would be OK, but that
116  // case isn't easy to detect.
117  return false;
118 }
llvm::SystemZSubtarget::isPC32DBLSymbol
bool isPC32DBLSymbol(const GlobalValue *GV, CodeModel::Model CM) const
Definition: SystemZSubtarget.cpp:100
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::Value::getPointerAlignment
Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
Definition: Value.cpp:918
llvm::SystemZSubtarget::ParseSubtargetFeatures
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
llvm::SystemZSubtarget::SystemZSubtarget
SystemZSubtarget(const Triple &TT, const std::string &CPU, const std::string &TuneCPU, const std::string &FS, const TargetMachine &TM)
Definition: SystemZSubtarget.cpp:67
llvm::SystemZSubtarget::HasVectorPackedDecimalEnhancement2
bool HasVectorPackedDecimalEnhancement2
Definition: SystemZSubtarget.h:71
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
llvm::SystemZSubtarget::HasVectorEnhancements1
bool HasVectorEnhancements1
Definition: SystemZSubtarget.h:62
SystemZMCTargetDesc.h
llvm::SystemZSubtarget::isTargetXPLINK64
bool isTargetXPLINK64() const
Definition: SystemZSubtarget.h:301
llvm::SystemZXPLINK64Registers
XPLINK64 calling convention specific use registers Particular to z/OS when in 64 bit mode.
Definition: SystemZRegisterInfo.h:82
GlobalValue.h
TargetMachine.h
false
Definition: StackSlotColoring.cpp:141
llvm::CodeModel::Small
@ Small
Definition: CodeGen.h:28
llvm::SystemZSubtarget::HasVectorEnhancements2
bool HasVectorEnhancements2
Definition: SystemZSubtarget.h:67
llvm::Type::isFunctionTy
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:214
llvm::SystemZSubtarget::isTargetELF
bool isTargetELF() const
Definition: SystemZSubtarget.h:295
llvm::CodeModel::Model
Model
Definition: CodeGen.h:28
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:126
llvm::cl::opt< bool >
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:636
llvm::SystemZSubtarget::HasVector
bool HasVector
Definition: SystemZSubtarget.h:53
SystemZGenSubtargetInfo
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
llvm::X86AS::FS
@ FS
Definition: X86.h:196
llvm::SystemZSubtarget
Definition: SystemZSubtarget.h:33
SystemZSubtarget.h
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::TargetMachine::shouldAssumeDSOLocal
bool shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const
Definition: TargetMachine.cpp:88
UseSubRegLiveness
static cl::opt< bool > UseSubRegLiveness("systemz-subreg-liveness", cl::desc("Enable subregister liveness tracking for SystemZ (experimental)"), cl::Hidden)
llvm::SystemZCallingConventionRegisters
A SystemZ-specific class detailing special use registers particular for calling conventions.
Definition: SystemZRegisterInfo.h:47
llvm::TargetLoweringBase::getTargetMachine
const TargetMachine & getTargetMachine() const
Definition: TargetLowering.h:347
llvm::SystemZSubtarget::enableSubRegLiveness
bool enableSubRegLiveness() const override
Definition: SystemZSubtarget.cpp:96
llvm::SystemZFrameLowering
Definition: SystemZFrameLowering.h:22
llvm::SystemZSubtarget::HasSoftFloat
bool HasSoftFloat
Definition: SystemZSubtarget.h:76
llvm::SystemZELFRegisters
ELF calling convention specific use registers Particular when on zLinux in 64 bit mode.
Definition: SystemZRegisterInfo.h:107
llvm::Module::getDataLayout
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:398
llvm::GlobalValue::getValueType
Type * getValueType() const
Definition: GlobalValue.h:278
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::SystemZSubtarget::HasVectorPackedDecimal
bool HasVectorPackedDecimal
Definition: SystemZSubtarget.h:63
llvm::cl::desc
Definition: CommandLine.h:412
llvm::SystemZSubtarget::HasVectorPackedDecimalEnhancement
bool HasVectorPackedDecimalEnhancement
Definition: SystemZSubtarget.h:68