| Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 1 | //===-- 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 Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 11 | /// \brief Implementation of the TargetInstrInfo class that is common to all | 
| Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 12 | /// AMD GPUs. | 
|  | 13 | // | 
|  | 14 | //===----------------------------------------------------------------------===// | 
|  | 15 |  | 
|  | 16 | #include "AMDGPUInstrInfo.h" | 
|  | 17 | #include "AMDGPURegisterInfo.h" | 
|  | 18 | #include "AMDGPUTargetMachine.h" | 
| Tom Stellard | 44b30b4 | 2018-05-22 02:03:23 +0000 | [diff] [blame] | 19 | #include "MCTargetDesc/AMDGPUMCTargetDesc.h" | 
| Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/MachineFrameInfo.h" | 
|  | 21 | #include "llvm/CodeGen/MachineInstrBuilder.h" | 
|  | 22 | #include "llvm/CodeGen/MachineRegisterInfo.h" | 
|  | 23 |  | 
| Chandler Carruth | d174b72 | 2014-04-22 02:03:14 +0000 | [diff] [blame] | 24 | using namespace llvm; | 
|  | 25 |  | 
| Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 26 | // Pin the vtable to this file. | 
| Tom Stellard | c5a154d | 2018-06-28 23:47:12 +0000 | [diff] [blame] | 27 | //void AMDGPUInstrInfo::anchor() {} | 
| Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 28 |  | 
| Tom Stellard | 5bfbae5 | 2018-07-11 20:59:01 +0000 | [diff] [blame] | 29 | AMDGPUInstrInfo::AMDGPUInstrInfo(const GCNSubtarget &ST) { } | 
| Tom Stellard | 75aadc2 | 2012-12-11 21:25:42 +0000 | [diff] [blame] | 30 |  | 
| Matt Arsenault | bcf7bec | 2018-02-09 16:57:48 +0000 | [diff] [blame] | 31 |  | 
|  | 32 | // TODO: Should largely merge with AMDGPUTTIImpl::isSourceOfDivergence. | 
|  | 33 | bool 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 Arsenault | 923712b | 2018-02-09 16:57:57 +0000 | [diff] [blame] | 43 | if (MMO->getAddrSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT) | 
|  | 44 | return true; | 
|  | 45 |  | 
| Matt Arsenault | bcf7bec | 2018-02-09 16:57:48 +0000 | [diff] [blame] | 46 | 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 | } |