LLVM 24.0.0git
AMDGPUInstrInfo.cpp
Go to the documentation of this file.
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"
18#include "llvm/IR/Constants.h"
19#include "llvm/IR/Instruction.h"
20#include "llvm/IR/Value.h"
21
22using namespace llvm;
23
25 return I.getOperand(I.getNumExplicitDefs()).getIntrinsicID();
26}
27
28unsigned AMDGPU::getMIROperandIdx(const MachineInstr &MI, unsigned Arg) {
29 // The defs and the intrinsic ID precede the arguments.
30 return Arg + MI.getNumExplicitDefs() + 1;
31}
32
33// TODO: Should largely merge with AMDGPUTTIImpl::isSourceOfDivergence.
35 const Value *Ptr = MMO->getValue();
36 if (!Ptr) {
37 if (const PseudoSourceValue *PSV = MMO->getPseudoValue()) {
38 return PSV->isConstantPool() || PSV->isStack() || PSV->isGOT() ||
39 PSV->isJumpTable();
40 }
41
42 // Unknown value.
43 return false;
44 }
45
46 // UndefValue means this is a load of a kernel input. These are uniform.
47 // Sometimes LDS instructions have constant pointers.
49 return true;
50
52 return true;
53
54 if (const Argument *Arg = dyn_cast<Argument>(Ptr))
55 return AMDGPU::isArgPassedInSGPR(Arg);
56
58 return I && I->getMetadata("amdgpu.uniform");
59}
Contains the definition of a TargetInstrInfo class that is common to all AMD GPUs.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
IRTranslator LLVM IR MI
This class represents an incoming formal argument to a Function.
Definition Argument.h:32
Representation of each machine instruction.
A description of a memory reference used in the backend.
const PseudoSourceValue * getPseudoValue() const
unsigned getAddrSpace() const
const Value * getValue() const
Return the base address of the memory access.
Special value supplied for machine level alias analysis.
LLVM Value Representation.
Definition Value.h:75
@ CONSTANT_ADDRESS_32BIT
Address space for 32-bit constant memory.
bool isArgPassedInSGPR(const Argument *A)
unsigned getMIROperandIdx(const MachineInstr &MI, unsigned Arg)
Convert IR argument index Arg of the intrinsic called by MI, a G_INTRINSIC* instruction,...
bool isUniformMMO(const MachineMemOperand *MMO)
Intrinsic::ID getIntrinsicID(const MachineInstr &I)
Return the intrinsic ID for opcodes with the G_AMDGPU_INTRIN_ prefix.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547