003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/lib/Target/SystemZ
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
lib
/
Target
/
SystemZ
/
📁
..
📁
AsmParser
📁
Disassembler
📁
MCTargetDesc
📄
README.txt
(3.94 KB)
📄
SystemZ.h
(8.19 KB)
📄
SystemZ.td
(2.86 KB)
📄
SystemZAsmPrinter.cpp
(23.49 KB)
📄
SystemZAsmPrinter.h
(1.88 KB)
📄
SystemZCallingConv.cpp
(710 B)
📄
SystemZCallingConv.h
(4.89 KB)
📄
SystemZCallingConv.td
(6.99 KB)
📄
SystemZConstantPoolValue.cpp
(1.78 KB)
📄
SystemZConstantPoolValue.h
(1.75 KB)
📄
SystemZCopyPhysRegs.cpp
(3.82 KB)
📄
SystemZElimCompare.cpp
(26.21 KB)
📄
SystemZFeatures.td
(12.3 KB)
📄
SystemZFrameLowering.cpp
(29.88 KB)
📄
SystemZFrameLowering.h
(3.02 KB)
📄
SystemZHazardRecognizer.cpp
(14.75 KB)
📄
SystemZHazardRecognizer.h
(5.86 KB)
📄
SystemZISelDAGToDAG.cpp
(68.74 KB)
📄
SystemZISelLowering.cpp
(321.22 KB)
📄
SystemZISelLowering.h
(28.44 KB)
📄
SystemZInstrBuilder.h
(1.63 KB)
📄
SystemZInstrDFP.td
(9.3 KB)
📄
SystemZInstrFP.td
(26.21 KB)
📄
SystemZInstrFormats.td
(182.82 KB)
📄
SystemZInstrHFP.td
(9.46 KB)
📄
SystemZInstrInfo.cpp
(69.75 KB)
📄
SystemZInstrInfo.h
(14.6 KB)
📄
SystemZInstrInfo.td
(103.17 KB)
📄
SystemZInstrSystem.td
(17.18 KB)
📄
SystemZInstrVector.td
(84.36 KB)
📄
SystemZLDCleanup.cpp
(4.91 KB)
📄
SystemZLongBranch.cpp
(16.04 KB)
📄
SystemZMCInstLower.cpp
(3.16 KB)
📄
SystemZMCInstLower.h
(1.28 KB)
📄
SystemZMachineFunctionInfo.cpp
(508 B)
📄
SystemZMachineFunctionInfo.h
(3.77 KB)
📄
SystemZMachineScheduler.cpp
(8.76 KB)
📄
SystemZMachineScheduler.h
(5.05 KB)
📄
SystemZOperands.td
(24.89 KB)
📄
SystemZOperators.td
(48.97 KB)
📄
SystemZPatterns.td
(8.52 KB)
📄
SystemZPostRewrite.cpp
(10.33 KB)
📄
SystemZProcessors.td
(1.78 KB)
📄
SystemZRegisterInfo.cpp
(16.27 KB)
📄
SystemZRegisterInfo.h
(3.52 KB)
📄
SystemZRegisterInfo.td
(12.04 KB)
📄
SystemZSchedule.td
(2.1 KB)
📄
SystemZScheduleZ13.td
(72.43 KB)
📄
SystemZScheduleZ14.td
(78.06 KB)
📄
SystemZScheduleZ15.td
(80.69 KB)
📄
SystemZScheduleZ196.td
(55.68 KB)
📄
SystemZScheduleZEC12.td
(57.44 KB)
📄
SystemZSelectionDAGInfo.cpp
(12.92 KB)
📄
SystemZSelectionDAGInfo.h
(3.15 KB)
📄
SystemZShortenInst.cpp
(12 KB)
📄
SystemZSubtarget.cpp
(3.67 KB)
📄
SystemZSubtarget.h
(9.14 KB)
📄
SystemZTDC.cpp
(13.52 KB)
📄
SystemZTargetMachine.cpp
(11.58 KB)
📄
SystemZTargetMachine.h
(2.09 KB)
📄
SystemZTargetTransformInfo.cpp
(43.51 KB)
📄
SystemZTargetTransformInfo.h
(4.88 KB)
📁
TargetInfo
Editing: SystemZLDCleanup.cpp
//===-- SystemZLDCleanup.cpp - Clean up local-dynamic TLS accesses --------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This pass combines multiple accesses to local-dynamic TLS variables so that // the TLS base address for the module is only fetched once per execution path // through the function. // //===----------------------------------------------------------------------===// #include "SystemZMachineFunctionInfo.h" #include "SystemZTargetMachine.h" #include "llvm/CodeGen/MachineDominators.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/TargetInstrInfo.h" #include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/Target/TargetMachine.h" using namespace llvm; namespace { class SystemZLDCleanup : public MachineFunctionPass { public: static char ID; SystemZLDCleanup(const SystemZTargetMachine &tm) : MachineFunctionPass(ID), TII(nullptr), MF(nullptr) {} StringRef getPassName() const override { return "SystemZ Local Dynamic TLS Access Clean-up"; } bool runOnMachineFunction(MachineFunction &MF) override; void getAnalysisUsage(AnalysisUsage &AU) const override; private: bool VisitNode(MachineDomTreeNode *Node, unsigned TLSBaseAddrReg); MachineInstr *ReplaceTLSCall(MachineInstr *I, unsigned TLSBaseAddrReg); MachineInstr *SetRegister(MachineInstr *I, unsigned *TLSBaseAddrReg); const SystemZInstrInfo *TII; MachineFunction *MF; }; char SystemZLDCleanup::ID = 0; } // end anonymous namespace FunctionPass *llvm::createSystemZLDCleanupPass(SystemZTargetMachine &TM) { return new SystemZLDCleanup(TM); } void SystemZLDCleanup::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); AU.addRequired<MachineDominatorTree>(); MachineFunctionPass::getAnalysisUsage(AU); } bool SystemZLDCleanup::runOnMachineFunction(MachineFunction &F) { if (skipFunction(F.getFunction())) return false; TII = static_cast<const SystemZInstrInfo *>(F.getSubtarget().getInstrInfo()); MF = &F; SystemZMachineFunctionInfo* MFI = F.getInfo<SystemZMachineFunctionInfo>(); if (MFI->getNumLocalDynamicTLSAccesses() < 2) { // No point folding accesses if there isn't at least two. return false; } MachineDominatorTree *DT = &getAnalysis<MachineDominatorTree>(); return VisitNode(DT->getRootNode(), 0); } // Visit the dominator subtree rooted at Node in pre-order. // If TLSBaseAddrReg is non-null, then use that to replace any // TLS_LDCALL instructions. Otherwise, create the register // when the first such instruction is seen, and then use it // as we encounter more instructions. bool SystemZLDCleanup::VisitNode(MachineDomTreeNode *Node, unsigned TLSBaseAddrReg) { MachineBasicBlock *BB = Node->getBlock(); bool Changed = false; // Traverse the current block. for (auto I = BB->begin(), E = BB->end(); I != E; ++I) { switch (I->getOpcode()) { case SystemZ::TLS_LDCALL: if (TLSBaseAddrReg) I = ReplaceTLSCall(&*I, TLSBaseAddrReg); else I = SetRegister(&*I, &TLSBaseAddrReg); Changed = true; break; default: break; } } // Visit the children of this block in the dominator tree. for (auto I = Node->begin(), E = Node->end(); I != E; ++I) Changed |= VisitNode(*I, TLSBaseAddrReg); return Changed; } // Replace the TLS_LDCALL instruction I with a copy from TLSBaseAddrReg, // returning the new instruction. MachineInstr *SystemZLDCleanup::ReplaceTLSCall(MachineInstr *I, unsigned TLSBaseAddrReg) { // Insert a Copy from TLSBaseAddrReg to R2. MachineInstr *Copy = BuildMI(*I->getParent(), I, I->getDebugLoc(), TII->get(TargetOpcode::COPY), SystemZ::R2D) .addReg(TLSBaseAddrReg); // Erase the TLS_LDCALL instruction. I->eraseFromParent(); return Copy; } // Create a virtual register in *TLSBaseAddrReg, and populate it by // inserting a copy instruction after I. Returns the new instruction. MachineInstr *SystemZLDCleanup::SetRegister(MachineInstr *I, unsigned *TLSBaseAddrReg) { // Create a virtual register for the TLS base address. MachineRegisterInfo &RegInfo = MF->getRegInfo(); *TLSBaseAddrReg = RegInfo.createVirtualRegister(&SystemZ::GR64BitRegClass); // Insert a copy from R2 to TLSBaseAddrReg. MachineInstr *Next = I->getNextNode(); MachineInstr *Copy = BuildMI(*I->getParent(), Next, I->getDebugLoc(), TII->get(TargetOpcode::COPY), *TLSBaseAddrReg) .addReg(SystemZ::R2D); return Copy; }
Upload File
Create Folder