Path: blob/main/contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.cpp
35266 views
//===-- AMDGPUInstrInfo.cpp - Base class for AMD GPU InstrInfo ------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8/// \file9/// \brief Implementation of the TargetInstrInfo class that is common to all10/// AMD GPUs.11//12//===----------------------------------------------------------------------===//1314#include "AMDGPUInstrInfo.h"15#include "AMDGPU.h"16#include "llvm/CodeGen/MachineInstr.h"17#include "llvm/CodeGen/MachineMemOperand.h"18#include "llvm/IR/Constants.h"19#include "llvm/IR/Instruction.h"20#include "llvm/IR/Value.h"2122using namespace llvm;2324// Pin the vtable to this file.25//void AMDGPUInstrInfo::anchor() {}2627AMDGPUInstrInfo::AMDGPUInstrInfo(const GCNSubtarget &ST) { }2829Intrinsic::ID AMDGPU::getIntrinsicID(const MachineInstr &I) {30return I.getOperand(I.getNumExplicitDefs()).getIntrinsicID();31}3233// TODO: Should largely merge with AMDGPUTTIImpl::isSourceOfDivergence.34bool AMDGPUInstrInfo::isUniformMMO(const MachineMemOperand *MMO) {35const Value *Ptr = MMO->getValue();36// UndefValue means this is a load of a kernel input. These are uniform.37// Sometimes LDS instructions have constant pointers.38// If Ptr is null, then that means this mem operand contains a39// PseudoSourceValue like GOT.40if (!Ptr || isa<UndefValue>(Ptr) ||41isa<Constant>(Ptr) || isa<GlobalValue>(Ptr))42return true;4344if (MMO->getAddrSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT)45return true;4647if (const Argument *Arg = dyn_cast<Argument>(Ptr))48return AMDGPU::isArgPassedInSGPR(Arg);4950const Instruction *I = dyn_cast<Instruction>(Ptr);51return I && I->getMetadata("amdgpu.uniform");52}535455