AMDGPU: Cleanup custom PseudoSourceValue definitions

Use separate enums for each kind, avoid repeating overloads, and add
missing classof implementation.

llvm-svn: 363558
This commit is contained in:
Matt Arsenault 2019-06-17 13:52:15 +00:00
parent 2dda1ff038
commit e683eba0ed
1 changed files with 23 additions and 16 deletions

View File

@ -39,12 +39,18 @@ class MachineFrameInfo;
class MachineFunction; class MachineFunction;
class TargetRegisterClass; class TargetRegisterClass;
class AMDGPUImagePseudoSourceValue : public PseudoSourceValue { class AMDGPUPseudoSourceValue : public PseudoSourceValue {
public: public:
// TODO: Is the img rsrc useful? enum AMDGPUPSVKind : unsigned {
explicit AMDGPUImagePseudoSourceValue(const TargetInstrInfo &TII) : PSVBuffer = PseudoSourceValue::TargetCustom,
PseudoSourceValue(PseudoSourceValue::TargetCustom, TII) {} PSVImage
};
protected:
AMDGPUPseudoSourceValue(unsigned Kind, const TargetInstrInfo &TII)
: PseudoSourceValue(Kind, TII) {}
public:
bool isConstant(const MachineFrameInfo *) const override { bool isConstant(const MachineFrameInfo *) const override {
// This should probably be true for most images, but we will start by being // This should probably be true for most images, but we will start by being
// conservative. // conservative.
@ -60,23 +66,24 @@ public:
} }
}; };
class AMDGPUBufferPseudoSourceValue : public PseudoSourceValue { class AMDGPUBufferPseudoSourceValue final : public AMDGPUPseudoSourceValue {
public: public:
explicit AMDGPUBufferPseudoSourceValue(const TargetInstrInfo &TII) : explicit AMDGPUBufferPseudoSourceValue(const TargetInstrInfo &TII)
PseudoSourceValue(PseudoSourceValue::TargetCustom, TII) { } : AMDGPUPseudoSourceValue(PSVBuffer, TII) {}
bool isConstant(const MachineFrameInfo *) const override { static bool classof(const PseudoSourceValue *V) {
// This should probably be true for most images, but we will start by being return V->kind() == PSVBuffer;
// conservative.
return false;
} }
};
bool isAliased(const MachineFrameInfo *) const override { class AMDGPUImagePseudoSourceValue final : public AMDGPUPseudoSourceValue {
return true; public:
} // TODO: Is the img rsrc useful?
explicit AMDGPUImagePseudoSourceValue(const TargetInstrInfo &TII)
: AMDGPUPseudoSourceValue(PSVImage, TII) {}
bool mayAlias(const MachineFrameInfo *) const override { static bool classof(const PseudoSourceValue *V) {
return true; return V->kind() == PSVImage;
} }
}; };