Skip to content

Commit bcf7bec

Browse files
committed
AMDGPU: Fix layering issue
Move utility function that depends on codegen. Fixes build with r324487 reapplied. llvm-svn: 324746
1 parent b5f1209 commit bcf7bec

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed

llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,21 @@ int AMDGPUInstrInfo::pseudoToMCOpcode(int Opcode) const {
115115

116116
return MCOp;
117117
}
118+
119+
// TODO: Should largely merge with AMDGPUTTIImpl::isSourceOfDivergence.
120+
bool AMDGPUInstrInfo::isUniformMMO(const MachineMemOperand *MMO) {
121+
const Value *Ptr = MMO->getValue();
122+
// UndefValue means this is a load of a kernel input. These are uniform.
123+
// Sometimes LDS instructions have constant pointers.
124+
// If Ptr is null, then that means this mem operand contains a
125+
// PseudoSourceValue like GOT.
126+
if (!Ptr || isa<UndefValue>(Ptr) ||
127+
isa<Constant>(Ptr) || isa<GlobalValue>(Ptr))
128+
return true;
129+
130+
if (const Argument *Arg = dyn_cast<Argument>(Ptr))
131+
return AMDGPU::isArgPassedInSGPR(Arg);
132+
133+
const Instruction *I = dyn_cast<Instruction>(Ptr);
134+
return I && I->getMetadata("amdgpu.uniform");
135+
}

llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class AMDGPUInstrInfo : public AMDGPUGenInstrInfo {
5050
/// Return -1 if the target-specific opcode for the pseudo instruction does
5151
/// not exist. If Opcode is not a pseudo instruction, this is identity.
5252
int pseudoToMCOpcode(int Opcode) const;
53+
54+
static bool isUniformMMO(const MachineMemOperand *MMO);
5355
};
5456
} // End llvm namespace
5557

llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static bool isInstrUniform(const MachineInstr &MI) {
120120
return false;
121121

122122
const MachineMemOperand *MMO = *MI.memoperands_begin();
123-
return AMDGPU::isUniformMMO(MMO);
123+
return AMDGPUInstrInfo::isUniformMMO(MMO);
124124
}
125125

126126
const RegisterBankInfo::InstructionMapping &

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ bool SITargetLowering::isCheapAddrSpaceCast(unsigned SrcAS,
10951095
bool SITargetLowering::isMemOpUniform(const SDNode *N) const {
10961096
const MemSDNode *MemNode = cast<MemSDNode>(N);
10971097

1098-
return AMDGPU::isUniformMMO(MemNode->getMemOperand());
1098+
return AMDGPUInstrInfo::isUniformMMO(MemNode->getMemOperand());
10991099
}
11001100

11011101
TargetLoweringBase::LegalizeTypeAction

llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -905,24 +905,6 @@ bool isArgPassedInSGPR(const Argument *A) {
905905
}
906906
}
907907

908-
// TODO: Should largely merge with AMDGPUTTIImpl::isSourceOfDivergence.
909-
bool isUniformMMO(const MachineMemOperand *MMO) {
910-
const Value *Ptr = MMO->getValue();
911-
// UndefValue means this is a load of a kernel input. These are uniform.
912-
// Sometimes LDS instructions have constant pointers.
913-
// If Ptr is null, then that means this mem operand contains a
914-
// PseudoSourceValue like GOT.
915-
if (!Ptr || isa<UndefValue>(Ptr) ||
916-
isa<Constant>(Ptr) || isa<GlobalValue>(Ptr))
917-
return true;
918-
919-
if (const Argument *Arg = dyn_cast<Argument>(Ptr))
920-
return isArgPassedInSGPR(Arg);
921-
922-
const Instruction *I = dyn_cast<Instruction>(Ptr);
923-
return I && I->getMetadata("amdgpu.uniform");
924-
}
925-
926908
int64_t getSMRDEncodedOffset(const MCSubtargetInfo &ST, int64_t ByteOffset) {
927909
if (isGCN3Encoding(ST))
928910
return ByteOffset;

llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ LLVM_READNONE
372372
bool isInlinableLiteralV216(int32_t Literal, bool HasInv2Pi);
373373

374374
bool isArgPassedInSGPR(const Argument *Arg);
375-
bool isUniformMMO(const MachineMemOperand *MMO);
376375

377376
/// \returns The encoding that will be used for \p ByteOffset in the SMRD
378377
/// offset field.

0 commit comments

Comments
 (0)