blob: 9951cbf2326e35ee94d8eabc19d5dc7a45013161 [file] [log] [blame]
Tom Stellard75aadc22012-12-11 21:25:42 +00001//===-- AMDGPUInstrInfo.cpp - Base class for AMD GPU InstrInfo ------------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Tom Stellard75aadc22012-12-11 21:25:42 +00006//
7//===----------------------------------------------------------------------===//
8//
9/// \file
Tom Stellardc5a154d2018-06-28 23:47:12 +000010/// \brief Implementation of the TargetInstrInfo class that is common to all
Tom Stellard75aadc22012-12-11 21:25:42 +000011/// AMD GPUs.
12//
13//===----------------------------------------------------------------------===//
14
15#include "AMDGPUInstrInfo.h"
16#include "AMDGPURegisterInfo.h"
17#include "AMDGPUTargetMachine.h"
Tom Stellard44b30b42018-05-22 02:03:23 +000018#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000019#include "llvm/CodeGen/MachineFrameInfo.h"
20#include "llvm/CodeGen/MachineInstrBuilder.h"
21#include "llvm/CodeGen/MachineRegisterInfo.h"
22
Chandler Carruthd174b722014-04-22 02:03:14 +000023using namespace llvm;
24
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000025// Pin the vtable to this file.
Tom Stellardc5a154d2018-06-28 23:47:12 +000026//void AMDGPUInstrInfo::anchor() {}
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000027
Tom Stellard5bfbae52018-07-11 20:59:01 +000028AMDGPUInstrInfo::AMDGPUInstrInfo(const GCNSubtarget &ST) { }
Tom Stellard75aadc22012-12-11 21:25:42 +000029
Matt Arsenaultbcf7bec2018-02-09 16:57:48 +000030
31// TODO: Should largely merge with AMDGPUTTIImpl::isSourceOfDivergence.
32bool AMDGPUInstrInfo::isUniformMMO(const MachineMemOperand *MMO) {
33 const Value *Ptr = MMO->getValue();
34 // UndefValue means this is a load of a kernel input. These are uniform.
35 // Sometimes LDS instructions have constant pointers.
36 // If Ptr is null, then that means this mem operand contains a
37 // PseudoSourceValue like GOT.
38 if (!Ptr || isa<UndefValue>(Ptr) ||
39 isa<Constant>(Ptr) || isa<GlobalValue>(Ptr))
40 return true;
41
Matt Arsenault923712b2018-02-09 16:57:57 +000042 if (MMO->getAddrSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT)
43 return true;
44
Matt Arsenaultbcf7bec2018-02-09 16:57:48 +000045 if (const Argument *Arg = dyn_cast<Argument>(Ptr))
46 return AMDGPU::isArgPassedInSGPR(Arg);
47
48 const Instruction *I = dyn_cast<Instruction>(Ptr);
49 return I && I->getMetadata("amdgpu.uniform");
50}