Coverage Report

Created: 2024-01-17 10:31

/src/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.cpp
Line
Count
Source (jump to first uncovered line)
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-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
/// \file
10
/// \brief Implementation of the TargetInstrInfo class that is common to all
11
/// 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
23
using namespace llvm;
24
25
// Pin the vtable to this file.
26
//void AMDGPUInstrInfo::anchor() {}
27
28
0
AMDGPUInstrInfo::AMDGPUInstrInfo(const GCNSubtarget &ST) { }
29
30
0
Intrinsic::ID AMDGPU::getIntrinsicID(const MachineInstr &I) {
31
0
  return I.getOperand(I.getNumExplicitDefs()).getIntrinsicID();
32
0
}
33
34
// TODO: Should largely merge with AMDGPUTTIImpl::isSourceOfDivergence.
35
0
bool AMDGPUInstrInfo::isUniformMMO(const MachineMemOperand *MMO) {
36
0
  const Value *Ptr = MMO->getValue();
37
  // UndefValue means this is a load of a kernel input.  These are uniform.
38
  // Sometimes LDS instructions have constant pointers.
39
  // If Ptr is null, then that means this mem operand contains a
40
  // PseudoSourceValue like GOT.
41
0
  if (!Ptr || isa<UndefValue>(Ptr) ||
42
0
      isa<Constant>(Ptr) || isa<GlobalValue>(Ptr))
43
0
    return true;
44
45
0
  if (MMO->getAddrSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT)
46
0
    return true;
47
48
0
  if (const Argument *Arg = dyn_cast<Argument>(Ptr))
49
0
    return AMDGPU::isArgPassedInSGPR(Arg);
50
51
0
  const Instruction *I = dyn_cast<Instruction>(Ptr);
52
0
  return I && I->getMetadata("amdgpu.uniform");
53
0
}