Changeset View
Changeset View
Standalone View
Standalone View
lib/Target/NVPTX/NVPTXFrameLowering.cpp
Show All 10 Lines | |||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#include "NVPTXFrameLowering.h" | #include "NVPTXFrameLowering.h" | ||||
#include "NVPTX.h" | #include "NVPTX.h" | ||||
#include "NVPTXRegisterInfo.h" | #include "NVPTXRegisterInfo.h" | ||||
#include "NVPTXSubtarget.h" | #include "NVPTXSubtarget.h" | ||||
#include "NVPTXTargetMachine.h" | #include "NVPTXTargetMachine.h" | ||||
#include "NVPTXUtilities.h" | |||||
#include "llvm/CodeGen/MachineFrameInfo.h" | #include "llvm/CodeGen/MachineFrameInfo.h" | ||||
#include "llvm/CodeGen/MachineFunction.h" | #include "llvm/CodeGen/MachineFunction.h" | ||||
#include "llvm/CodeGen/MachineInstrBuilder.h" | #include "llvm/CodeGen/MachineInstrBuilder.h" | ||||
#include "llvm/CodeGen/MachineRegisterInfo.h" | #include "llvm/CodeGen/MachineRegisterInfo.h" | ||||
#include "llvm/CodeGen/TargetInstrInfo.h" | #include "llvm/CodeGen/TargetInstrInfo.h" | ||||
#include "llvm/MC/MachineLocation.h" | #include "llvm/MC/MachineLocation.h" | ||||
using namespace llvm; | using namespace llvm; | ||||
Show All 29 Lines | if (!MR.use_empty(NVPTX::VRFrame)) { | ||||
MI = BuildMI(MBB, MI, dl, | MI = BuildMI(MBB, MI, dl, | ||||
MF.getSubtarget().getInstrInfo()->get(CvtaLocalOpcode), | MF.getSubtarget().getInstrInfo()->get(CvtaLocalOpcode), | ||||
NVPTX::VRFrame) | NVPTX::VRFrame) | ||||
.addReg(NVPTX::VRFrameLocal); | .addReg(NVPTX::VRFrameLocal); | ||||
} | } | ||||
BuildMI(MBB, MI, dl, MF.getSubtarget().getInstrInfo()->get(MovDepotOpcode), | BuildMI(MBB, MI, dl, MF.getSubtarget().getInstrInfo()->get(MovDepotOpcode), | ||||
NVPTX::VRFrameLocal) | NVPTX::VRFrameLocal) | ||||
.addImm(MF.getFunctionNumber()); | .addImm(MF.getFunctionNumber()); | ||||
bool SharedStackPointerInit = | |||||
MF.getFunction().hasFnAttribute("has-nvptx-shared-depot"); | |||||
// Only emit a shared depot for the main kernel function. | |||||
// The other device functions need to get a handle on this shared depot | |||||
// by interacting with a runtime library. | |||||
hfinkel: In other places in this patch you refer explicitly to OpenMP, so it probably makes sense to say… | |||||
// | |||||
// Clang can trigger this at any point via the has-nvptx-shared-depot function | |||||
// attribute. | |||||
// | |||||
// Currently this situation arises as a consequence of OpenMP semantics. | |||||
// The interaction in that case invovles the OpenMP runtime. | |||||
if (isKernelFunction(MF.getFunction()) && SharedStackPointerInit) { | |||||
// Emits | |||||
// mov %SHSPL, %shared_depot; | |||||
// cvta.shared %SHSP, %SHSPL; | |||||
// For the time being just emit it even if it's not used. | |||||
unsigned CvtaSharedOpcode = | |||||
Is64Bit ? NVPTX::cvta_shared_yes_64 : NVPTX::cvta_shared_yes; | |||||
unsigned MovSharedDepotOpcode = | |||||
Line too long. hfinkel: Line too long. | |||||
Is64Bit ? NVPTX::MOV_SHARED_DEPOT_ADDR_64 : NVPTX::MOV_SHARED_DEPOT_ADDR; | |||||
MI = BuildMI(MBB, MI, dl, | |||||
MF.getSubtarget().getInstrInfo()->get(CvtaSharedOpcode), | |||||
NVPTX::VRShared) | |||||
.addReg(NVPTX::VRFrameShared); | |||||
BuildMI(MBB, MI, dl, | |||||
MF.getSubtarget().getInstrInfo()->get(MovSharedDepotOpcode), | |||||
NVPTX::VRFrameShared) | |||||
.addImm(MF.getFunctionNumber()); | |||||
} | |||||
} | } | ||||
} | } | ||||
void NVPTXFrameLowering::emitEpilogue(MachineFunction &MF, | void NVPTXFrameLowering::emitEpilogue(MachineFunction &MF, | ||||
MachineBasicBlock &MBB) const {} | MachineBasicBlock &MBB) const {} | ||||
// This function eliminates ADJCALLSTACKDOWN, | // This function eliminates ADJCALLSTACKDOWN, | ||||
// ADJCALLSTACKUP pseudo instructions | // ADJCALLSTACKUP pseudo instructions | ||||
MachineBasicBlock::iterator NVPTXFrameLowering::eliminateCallFramePseudoInstr( | MachineBasicBlock::iterator NVPTXFrameLowering::eliminateCallFramePseudoInstr( | ||||
MachineFunction &MF, MachineBasicBlock &MBB, | MachineFunction &MF, MachineBasicBlock &MBB, | ||||
MachineBasicBlock::iterator I) const { | MachineBasicBlock::iterator I) const { | ||||
// Simply discard ADJCALLSTACKDOWN, | // Simply discard ADJCALLSTACKDOWN, | ||||
// ADJCALLSTACKUP instructions. | // ADJCALLSTACKUP instructions. | ||||
return MBB.erase(I); | return MBB.erase(I); | ||||
} | } |
In other places in this patch you refer explicitly to OpenMP, so it probably makes sense to say "the OpenMP runtime" here as well (but just saying "the runtime" seems potentially confusing).