10b57cec5SDimitry Andric //===-- SystemZSubtarget.cpp - SystemZ subtarget information --------------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #include "SystemZSubtarget.h" 100b57cec5SDimitry Andric #include "MCTargetDesc/SystemZMCTargetDesc.h" 110b57cec5SDimitry Andric #include "llvm/IR/GlobalValue.h" 125ffd83dbSDimitry Andric #include "llvm/Target/TargetMachine.h" 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric using namespace llvm; 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #define DEBUG_TYPE "systemz-subtarget" 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric #define GET_SUBTARGETINFO_TARGET_DESC 190b57cec5SDimitry Andric #define GET_SUBTARGETINFO_CTOR 200b57cec5SDimitry Andric #include "SystemZGenSubtargetInfo.inc" 210b57cec5SDimitry Andric 220b57cec5SDimitry Andric static cl::opt<bool> UseSubRegLiveness( 230b57cec5SDimitry Andric "systemz-subreg-liveness", 240b57cec5SDimitry Andric cl::desc("Enable subregister liveness tracking for SystemZ (experimental)"), 250b57cec5SDimitry Andric cl::Hidden); 260b57cec5SDimitry Andric 270b57cec5SDimitry Andric // Pin the vtable to this file. 280b57cec5SDimitry Andric void SystemZSubtarget::anchor() {} 290b57cec5SDimitry Andric 300b57cec5SDimitry Andric SystemZSubtarget & 310b57cec5SDimitry Andric SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) { 325ffd83dbSDimitry Andric StringRef CPUName = CPU; 330b57cec5SDimitry Andric if (CPUName.empty()) 340b57cec5SDimitry Andric CPUName = "generic"; 350b57cec5SDimitry Andric // Parse features string. 36*e8d8bef9SDimitry Andric ParseSubtargetFeatures(CPUName, /*TuneCPU*/ CPUName, FS); 375ffd83dbSDimitry Andric 385ffd83dbSDimitry Andric // -msoft-float implies -mno-vx. 395ffd83dbSDimitry Andric if (HasSoftFloat) 405ffd83dbSDimitry Andric HasVector = false; 415ffd83dbSDimitry Andric 42*e8d8bef9SDimitry Andric // -mno-vx implicitly disables all vector-related features. 43*e8d8bef9SDimitry Andric if (!HasVector) { 44*e8d8bef9SDimitry Andric HasVectorEnhancements1 = false; 45*e8d8bef9SDimitry Andric HasVectorEnhancements2 = false; 46*e8d8bef9SDimitry Andric HasVectorPackedDecimal = false; 47*e8d8bef9SDimitry Andric HasVectorPackedDecimalEnhancement = false; 48*e8d8bef9SDimitry Andric } 49*e8d8bef9SDimitry Andric 500b57cec5SDimitry Andric return *this; 510b57cec5SDimitry Andric } 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU, 540b57cec5SDimitry Andric const std::string &FS, 550b57cec5SDimitry Andric const TargetMachine &TM) 56*e8d8bef9SDimitry Andric : SystemZGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), 57*e8d8bef9SDimitry Andric HasDistinctOps(false), HasLoadStoreOnCond(false), HasHighWord(false), 58*e8d8bef9SDimitry Andric HasFPExtension(false), HasPopulationCount(false), 59*e8d8bef9SDimitry Andric HasMessageSecurityAssist3(false), HasMessageSecurityAssist4(false), 60*e8d8bef9SDimitry Andric HasResetReferenceBitsMultiple(false), HasFastSerialization(false), 61*e8d8bef9SDimitry Andric HasInterlockedAccess1(false), HasMiscellaneousExtensions(false), 620b57cec5SDimitry Andric HasExecutionHint(false), HasLoadAndTrap(false), 630b57cec5SDimitry Andric HasTransactionalExecution(false), HasProcessorAssist(false), 640b57cec5SDimitry Andric HasDFPZonedConversion(false), HasEnhancedDAT2(false), 650b57cec5SDimitry Andric HasVector(false), HasLoadStoreOnCond2(false), 660b57cec5SDimitry Andric HasLoadAndZeroRightmostByte(false), HasMessageSecurityAssist5(false), 670b57cec5SDimitry Andric HasDFPPackedConversion(false), 680b57cec5SDimitry Andric HasMiscellaneousExtensions2(false), HasGuardedStorage(false), 690b57cec5SDimitry Andric HasMessageSecurityAssist7(false), HasMessageSecurityAssist8(false), 700b57cec5SDimitry Andric HasVectorEnhancements1(false), HasVectorPackedDecimal(false), 710b57cec5SDimitry Andric HasInsertReferenceBitsMultiple(false), 720b57cec5SDimitry Andric HasMiscellaneousExtensions3(false), HasMessageSecurityAssist9(false), 730b57cec5SDimitry Andric HasVectorEnhancements2(false), HasVectorPackedDecimalEnhancement(false), 745ffd83dbSDimitry Andric HasEnhancedSort(false), HasDeflateConversion(false), HasSoftFloat(false), 750b57cec5SDimitry Andric TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)), 760b57cec5SDimitry Andric TLInfo(TM, *this), TSInfo(), FrameLowering() {} 770b57cec5SDimitry Andric 780b57cec5SDimitry Andric 790b57cec5SDimitry Andric bool SystemZSubtarget::enableSubRegLiveness() const { 800b57cec5SDimitry Andric return UseSubRegLiveness; 810b57cec5SDimitry Andric } 820b57cec5SDimitry Andric 830b57cec5SDimitry Andric bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV, 840b57cec5SDimitry Andric CodeModel::Model CM) const { 855ffd83dbSDimitry Andric // PC32DBL accesses require the low bit to be clear. 865ffd83dbSDimitry Andric // 875ffd83dbSDimitry Andric // FIXME: Explicitly check for functions: the datalayout is currently 885ffd83dbSDimitry Andric // missing information about function pointers. 895ffd83dbSDimitry Andric const DataLayout &DL = GV->getParent()->getDataLayout(); 905ffd83dbSDimitry Andric if (GV->getPointerAlignment(DL) == 1 && !GV->getValueType()->isFunctionTy()) 910b57cec5SDimitry Andric return false; 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric // For the small model, all locally-binding symbols are in range. 940b57cec5SDimitry Andric if (CM == CodeModel::Small) 950b57cec5SDimitry Andric return TLInfo.getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV); 960b57cec5SDimitry Andric 970b57cec5SDimitry Andric // For Medium and above, assume that the symbol is not within the 4GB range. 980b57cec5SDimitry Andric // Taking the address of locally-defined text would be OK, but that 990b57cec5SDimitry Andric // case isn't easy to detect. 1000b57cec5SDimitry Andric return false; 1010b57cec5SDimitry Andric } 102