[InstCombine] Signed saturation patterns
[llvm-core.git] / lib / Target / SystemZ / SystemZSubtarget.cpp
blob5e8af81842c430381c71569f7086a9212a717a40
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 //===----------------------------------------------------------------------===//
9 #include "SystemZSubtarget.h"
10 #include "MCTargetDesc/SystemZMCTargetDesc.h"
11 #include "llvm/IR/GlobalValue.h"
13 using namespace llvm;
15 #define DEBUG_TYPE "systemz-subtarget"
17 #define GET_SUBTARGETINFO_TARGET_DESC
18 #define GET_SUBTARGETINFO_CTOR
19 #include "SystemZGenSubtargetInfo.inc"
21 static cl::opt<bool> UseSubRegLiveness(
22 "systemz-subreg-liveness",
23 cl::desc("Enable subregister liveness tracking for SystemZ (experimental)"),
24 cl::Hidden);
26 // Pin the vtable to this file.
27 void SystemZSubtarget::anchor() {}
29 SystemZSubtarget &
30 SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
31 std::string CPUName = CPU;
32 if (CPUName.empty())
33 CPUName = "generic";
34 // Parse features string.
35 ParseSubtargetFeatures(CPUName, FS);
36 return *this;
39 SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
40 const std::string &FS,
41 const TargetMachine &TM)
42 : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false),
43 HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false),
44 HasPopulationCount(false), HasMessageSecurityAssist3(false),
45 HasMessageSecurityAssist4(false), HasResetReferenceBitsMultiple(false),
46 HasFastSerialization(false), HasInterlockedAccess1(false),
47 HasMiscellaneousExtensions(false),
48 HasExecutionHint(false), HasLoadAndTrap(false),
49 HasTransactionalExecution(false), HasProcessorAssist(false),
50 HasDFPZonedConversion(false), HasEnhancedDAT2(false),
51 HasVector(false), HasLoadStoreOnCond2(false),
52 HasLoadAndZeroRightmostByte(false), HasMessageSecurityAssist5(false),
53 HasDFPPackedConversion(false),
54 HasMiscellaneousExtensions2(false), HasGuardedStorage(false),
55 HasMessageSecurityAssist7(false), HasMessageSecurityAssist8(false),
56 HasVectorEnhancements1(false), HasVectorPackedDecimal(false),
57 HasInsertReferenceBitsMultiple(false),
58 HasMiscellaneousExtensions3(false), HasMessageSecurityAssist9(false),
59 HasVectorEnhancements2(false), HasVectorPackedDecimalEnhancement(false),
60 HasEnhancedSort(false), HasDeflateConversion(false),
61 TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
62 TLInfo(TM, *this), TSInfo(), FrameLowering() {}
65 bool SystemZSubtarget::enableSubRegLiveness() const {
66 return UseSubRegLiveness;
69 bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
70 CodeModel::Model CM) const {
71 // PC32DBL accesses require the low bit to be clear. Note that a zero
72 // value selects the default alignment and is therefore OK.
73 if (GV->getAlignment() == 1)
74 return false;
76 // For the small model, all locally-binding symbols are in range.
77 if (CM == CodeModel::Small)
78 return TLInfo.getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV);
80 // For Medium and above, assume that the symbol is not within the 4GB range.
81 // Taking the address of locally-defined text would be OK, but that
82 // case isn't easy to detect.
83 return false;