brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 7caafa1 Raw
49 lines · cpp
1//===-- AMDGPUInstrInfo.cpp - Base class for AMD GPU InstrInfo ------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9/// \file10/// \brief Implementation of the TargetInstrInfo class that is common to all11/// AMD GPUs.12//13//===----------------------------------------------------------------------===//14 15#include "AMDGPUInstrInfo.h"16#include "AMDGPU.h"17#include "llvm/CodeGen/MachineInstr.h"18#include "llvm/CodeGen/MachineMemOperand.h"19#include "llvm/IR/Constants.h"20#include "llvm/IR/Instruction.h"21#include "llvm/IR/Value.h"22 23using namespace llvm;24 25Intrinsic::ID AMDGPU::getIntrinsicID(const MachineInstr &I) {26  return I.getOperand(I.getNumExplicitDefs()).getIntrinsicID();27}28 29// TODO: Should largely merge with AMDGPUTTIImpl::isSourceOfDivergence.30bool AMDGPU::isUniformMMO(const MachineMemOperand *MMO) {31  // FIXME: null value is should be treated as unknown, not as uniform.32  const Value *Ptr = MMO->getValue();33  // UndefValue means this is a load of a kernel input.  These are uniform.34  // Sometimes LDS instructions have constant pointers.35  // If Ptr is null, then that means this mem operand contains a36  // PseudoSourceValue like GOT.37  if (!Ptr || isa<UndefValue, Constant, GlobalValue>(Ptr))38    return true;39 40  if (MMO->getAddrSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT)41    return true;42 43  if (const Argument *Arg = dyn_cast<Argument>(Ptr))44    return AMDGPU::isArgPassedInSGPR(Arg);45 46  const Instruction *I = dyn_cast<Instruction>(Ptr);47  return I && I->getMetadata("amdgpu.uniform");48}49