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" 12*5ffd83dbSDimitry 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) { 32*5ffd83dbSDimitry Andric StringRef CPUName = CPU; 330b57cec5SDimitry Andric if (CPUName.empty()) 340b57cec5SDimitry Andric CPUName = "generic"; 350b57cec5SDimitry Andric // Parse features string. 360b57cec5SDimitry Andric ParseSubtargetFeatures(CPUName, FS); 37*5ffd83dbSDimitry Andric 38*5ffd83dbSDimitry Andric // -msoft-float implies -mno-vx. 39*5ffd83dbSDimitry Andric if (HasSoftFloat) 40*5ffd83dbSDimitry Andric HasVector = false; 41*5ffd83dbSDimitry Andric 420b57cec5SDimitry Andric return *this; 430b57cec5SDimitry Andric } 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU, 460b57cec5SDimitry Andric const std::string &FS, 470b57cec5SDimitry Andric const TargetMachine &TM) 480b57cec5SDimitry Andric : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false), 490b57cec5SDimitry Andric HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false), 500b57cec5SDimitry Andric HasPopulationCount(false), HasMessageSecurityAssist3(false), 510b57cec5SDimitry Andric HasMessageSecurityAssist4(false), HasResetReferenceBitsMultiple(false), 520b57cec5SDimitry Andric HasFastSerialization(false), HasInterlockedAccess1(false), 530b57cec5SDimitry Andric HasMiscellaneousExtensions(false), 540b57cec5SDimitry Andric HasExecutionHint(false), HasLoadAndTrap(false), 550b57cec5SDimitry Andric HasTransactionalExecution(false), HasProcessorAssist(false), 560b57cec5SDimitry Andric HasDFPZonedConversion(false), HasEnhancedDAT2(false), 570b57cec5SDimitry Andric HasVector(false), HasLoadStoreOnCond2(false), 580b57cec5SDimitry Andric HasLoadAndZeroRightmostByte(false), HasMessageSecurityAssist5(false), 590b57cec5SDimitry Andric HasDFPPackedConversion(false), 600b57cec5SDimitry Andric HasMiscellaneousExtensions2(false), HasGuardedStorage(false), 610b57cec5SDimitry Andric HasMessageSecurityAssist7(false), HasMessageSecurityAssist8(false), 620b57cec5SDimitry Andric HasVectorEnhancements1(false), HasVectorPackedDecimal(false), 630b57cec5SDimitry Andric HasInsertReferenceBitsMultiple(false), 640b57cec5SDimitry Andric HasMiscellaneousExtensions3(false), HasMessageSecurityAssist9(false), 650b57cec5SDimitry Andric HasVectorEnhancements2(false), HasVectorPackedDecimalEnhancement(false), 66*5ffd83dbSDimitry Andric HasEnhancedSort(false), HasDeflateConversion(false), HasSoftFloat(false), 670b57cec5SDimitry Andric TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)), 680b57cec5SDimitry Andric TLInfo(TM, *this), TSInfo(), FrameLowering() {} 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric 710b57cec5SDimitry Andric bool SystemZSubtarget::enableSubRegLiveness() const { 720b57cec5SDimitry Andric return UseSubRegLiveness; 730b57cec5SDimitry Andric } 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV, 760b57cec5SDimitry Andric CodeModel::Model CM) const { 77*5ffd83dbSDimitry Andric // PC32DBL accesses require the low bit to be clear. 78*5ffd83dbSDimitry Andric // 79*5ffd83dbSDimitry Andric // FIXME: Explicitly check for functions: the datalayout is currently 80*5ffd83dbSDimitry Andric // missing information about function pointers. 81*5ffd83dbSDimitry Andric const DataLayout &DL = GV->getParent()->getDataLayout(); 82*5ffd83dbSDimitry Andric if (GV->getPointerAlignment(DL) == 1 && !GV->getValueType()->isFunctionTy()) 830b57cec5SDimitry Andric return false; 840b57cec5SDimitry Andric 850b57cec5SDimitry Andric // For the small model, all locally-binding symbols are in range. 860b57cec5SDimitry Andric if (CM == CodeModel::Small) 870b57cec5SDimitry Andric return TLInfo.getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV); 880b57cec5SDimitry Andric 890b57cec5SDimitry Andric // For Medium and above, assume that the symbol is not within the 4GB range. 900b57cec5SDimitry Andric // Taking the address of locally-defined text would be OK, but that 910b57cec5SDimitry Andric // case isn't easy to detect. 920b57cec5SDimitry Andric return false; 930b57cec5SDimitry Andric } 94