blob: 07aa7c2cc8ada5be034a6b07fba41a9a4a54be01 [file] [log] [blame]
Tom Stellard75aadc22012-12-11 21:25:42 +00001//===-- AMDGPUInstrInfo.cpp - Base class for AMD GPU InstrInfo ------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10/// \file
Tom Stellardc5a154d2018-06-28 23:47:12 +000011/// \brief Implementation of the TargetInstrInfo class that is common to all
Tom Stellard75aadc22012-12-11 21:25:42 +000012/// AMD GPUs.
13//
14//===----------------------------------------------------------------------===//
15
16#include "AMDGPUInstrInfo.h"
17#include "AMDGPURegisterInfo.h"
18#include "AMDGPUTargetMachine.h"
Tom Stellard44b30b42018-05-22 02:03:23 +000019#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000020#include "llvm/CodeGen/MachineFrameInfo.h"
21#include "llvm/CodeGen/MachineInstrBuilder.h"
22#include "llvm/CodeGen/MachineRegisterInfo.h"
23
Chandler Carruthd174b722014-04-22 02:03:14 +000024using namespace llvm;
25
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000026// Pin the vtable to this file.
Tom Stellardc5a154d2018-06-28 23:47:12 +000027//void AMDGPUInstrInfo::anchor() {}
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000028
Tom Stellard5bfbae52018-07-11 20:59:01 +000029AMDGPUInstrInfo::AMDGPUInstrInfo(const GCNSubtarget &ST) { }
Tom Stellard75aadc22012-12-11 21:25:42 +000030
Matt Arsenaultbcf7bec2018-02-09 16:57:48 +000031
32// TODO: Should largely merge with AMDGPUTTIImpl::isSourceOfDivergence.
33bool AMDGPUInstrInfo::isUniformMMO(const MachineMemOperand *MMO) {
34 const Value *Ptr = MMO->getValue();
35 // UndefValue means this is a load of a kernel input. These are uniform.
36 // Sometimes LDS instructions have constant pointers.
37 // If Ptr is null, then that means this mem operand contains a
38 // PseudoSourceValue like GOT.
39 if (!Ptr || isa<UndefValue>(Ptr) ||
40 isa<Constant>(Ptr) || isa<GlobalValue>(Ptr))
41 return true;
42
Matt Arsenault923712b2018-02-09 16:57:57 +000043 if (MMO->getAddrSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT)
44 return true;
45
Matt Arsenaultbcf7bec2018-02-09 16:57:48 +000046 if (const Argument *Arg = dyn_cast<Argument>(Ptr))
47 return AMDGPU::isArgPassedInSGPR(Arg);
48
49 const Instruction *I = dyn_cast<Instruction>(Ptr);
50 return I && I->getMetadata("amdgpu.uniform");
51}