Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
Show First 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | |||||
bool AMDGPUAsmPrinter::lowerOperand(const MachineOperand &MO, | bool AMDGPUAsmPrinter::lowerOperand(const MachineOperand &MO, | ||||
MCOperand &MCOp) const { | MCOperand &MCOp) const { | ||||
const GCNSubtarget &STI = MF->getSubtarget<GCNSubtarget>(); | const GCNSubtarget &STI = MF->getSubtarget<GCNSubtarget>(); | ||||
AMDGPUMCInstLower MCInstLowering(OutContext, STI, *this); | AMDGPUMCInstLower MCInstLowering(OutContext, STI, *this); | ||||
return MCInstLowering.lowerOperand(MO, MCOp); | return MCInstLowering.lowerOperand(MO, MCOp); | ||||
} | } | ||||
Constant *AMDGPUAsmPrinter::constantFoldForPrint(const Constant *CV) { | |||||
// TargetMachine does not support llvm-style cast. Use C++-style cast. | |||||
// This is safe since TM is always of type AMDGPUTargetMachine or its | |||||
// derived class. | |||||
auto &AT = static_cast<const AMDGPUTargetMachine &>(TM); | |||||
auto *CE = dyn_cast<ConstantExpr>(CV); | |||||
if (CE && CE->getOpcode() == Instruction::AddrSpaceCast) { | |||||
auto *Op = CE->getOperand(0); | |||||
auto SrcAddr = Op->getType()->getPointerAddressSpace(); | |||||
auto DstAddr = CE->getType()->getPointerAddressSpace(); | |||||
if (Op->isNullValue() && AT.getNullPointerValue(SrcAddr) == 0 && | |||||
arsenm: Don't hardcode to generic, check the null pointer representation | |||||
AT.getPointerSizeInBits(DstAddr) > 64) | |||||
return ConstantPointerNull::get(cast<PointerType>(CE->getType())); | |||||
} | |||||
return AsmPrinter::constantFoldForPrint(CV); | |||||
} | |||||
const MCExpr *AMDGPUAsmPrinter::lowerConstant(const Constant *CV) { | const MCExpr *AMDGPUAsmPrinter::lowerConstant(const Constant *CV) { | ||||
// Intercept LDS variables with known addresses | // Intercept LDS variables with known addresses | ||||
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(CV)) { | if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(CV)) { | ||||
if (AMDGPUMachineFunction::isKnownAddressLDSGlobal(*GV)) { | if (AMDGPUMachineFunction::isKnownAddressLDSGlobal(*GV)) { | ||||
unsigned offset = | unsigned offset = | ||||
AMDGPUMachineFunction::calculateKnownAddressOfLDSGlobal(*GV); | AMDGPUMachineFunction::calculateKnownAddressOfLDSGlobal(*GV); | ||||
Constant *C = ConstantInt::get(CV->getContext(), APInt(32, offset)); | Constant *C = ConstantInt::get(CV->getContext(), APInt(32, offset)); | ||||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |
Don't hardcode to generic, check the null pointer representation