LLVM  5.0.0
Functions | Variables
SIISelLowering.cpp File Reference

Custom DAG lowering for SI. More...

#include "SIISelLowering.h"
#include "AMDGPU.h"
#include "AMDGPUIntrinsicInfo.h"
#include "AMDGPUSubtarget.h"
#include "AMDGPUTargetMachine.h"
#include "SIDefines.h"
#include "SIInstrInfo.h"
#include "SIMachineFunctionInfo.h"
#include "SIRegisterInfo.h"
#include "Utils/AMDGPUBaseInfo.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/CodeGen/DAGCombine.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/MachineValueType.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/CodeGen/SelectionDAGNodes.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Target/TargetCallingConv.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include <cassert>
#include <cmath>
#include <cstdint>
#include <iterator>
#include <tuple>
#include <utility>
#include <vector>

Go to the source code of this file.

Functions

static unsigned findFirstFreeSGPR (CCState &CCInfo)
 
static bool isFlatGlobalAddrSpace (unsigned AS, AMDGPUAS AMDGPUASI)
 
static void processShaderInputArgs (SmallVectorImpl< ISD::InputArg > &Splits, CallingConv::ID CallConv, ArrayRef< ISD::InputArg > Ins, BitVector &Skipped, FunctionType *FType, SIMachineFunctionInfo *Info)
 
static void allocateSpecialInputVGPRs (CCState &CCInfo, MachineFunction &MF, const SIRegisterInfo &TRI, SIMachineFunctionInfo &Info)
 
static void allocateHSAUserSGPRs (CCState &CCInfo, MachineFunction &MF, const SIRegisterInfo &TRI, SIMachineFunctionInfo &Info)
 
static void allocateSystemSGPRs (CCState &CCInfo, MachineFunction &MF, SIMachineFunctionInfo &Info, CallingConv::ID CallConv, bool IsShader)
 
static void reservePrivateMemoryRegs (const TargetMachine &TM, MachineFunction &MF, const SIRegisterInfo &TRI, SIMachineFunctionInfo &Info)
 
static MachineBasicBlock::iterator emitLoadM0FromVGPRLoop (const SIInstrInfo *TII, MachineRegisterInfo &MRI, MachineBasicBlock &OrigBB, MachineBasicBlock &LoopBB, const DebugLoc &DL, const MachineOperand &IdxReg, unsigned InitReg, unsigned ResultReg, unsigned PhiReg, unsigned InitSaveExecReg, int Offset, bool UseGPRIdxMode)
 
static MachineBasicBlock::iterator loadM0FromVGPR (const SIInstrInfo *TII, MachineBasicBlock &MBB, MachineInstr &MI, unsigned InitResultReg, unsigned PhiReg, int Offset, bool UseGPRIdxMode)
 
static std::pair< unsigned, int > computeIndirectRegAndOffset (const SIRegisterInfo &TRI, const TargetRegisterClass *SuperRC, unsigned VecReg, int Offset)
 
static bool setM0ToIndexFromSGPR (const SIInstrInfo *TII, MachineRegisterInfo &MRI, MachineInstr &MI, int Offset, bool UseGPRIdxMode, bool IsIndirectSrc)
 
static MachineBasicBlock * emitIndirectSrc (MachineInstr &MI, MachineBasicBlock &MBB, const SISubtarget &ST)
 
static unsigned getMOVRELDPseudo (const SIRegisterInfo &TRI, const TargetRegisterClass *VecRC)
 
static MachineBasicBlock * emitIndirectDst (MachineInstr &MI, MachineBasicBlock &MBB, const SISubtarget &ST)
 
static SDNode * findUser (SDValue Value, unsigned Opcode)
 Helper function for LowerBRCOND. More...
 
static SDValue buildPCRelGlobalAddress (SelectionDAG &DAG, const GlobalValue *GV, const SDLoc &DL, unsigned Offset, EVT PtrVT, unsigned GAFlags=SIInstrInfo::MO_NONE)
 
static SDValue emitNonHSAIntrinsicError (SelectionDAG &DAG, const SDLoc &DL, EVT VT)
 
static SDValue emitRemovedIntrinsicError (SelectionDAG &DAG, const SDLoc &DL, EVT VT)
 
static SDValue getFPBinOp (SelectionDAG &DAG, unsigned Opcode, const SDLoc &SL, EVT VT, SDValue A, SDValue B, SDValue GlueChain)
 
static SDValue getFPTernOp (SelectionDAG &DAG, unsigned Opcode, const SDLoc &SL, EVT VT, SDValue A, SDValue B, SDValue C, SDValue GlueChain)
 
static bool canFoldOffset (unsigned OffsetSize, unsigned AS, const SISubtarget &STI)
 Return true if the given offset Size in bytes can be folded into the immediate offsets of a memory instruction for the given address space. More...
 
static bool bitOpWithConstantIsReducible (unsigned Opc, uint32_t Val)
 
static bool isBoolSGPR (SDValue V)
 
static bool fp16SrcZerosHighBits (unsigned Opc)
 
static bool isKnownNeverSNan (SelectionDAG &DAG, SDValue Op)
 
static bool isCanonicalized (SelectionDAG &DAG, SDValue Op, const SISubtarget *ST, unsigned MaxDepth=5)
 
static unsigned minMaxOpcToMin3Max3Opc (unsigned Opc)
 
static bool isClampZeroToOne (SDValue A, SDValue B)
 
static unsigned SubIdx2Lane (unsigned Idx)
 Helper function for adjustWritemask. More...
 
static bool isFrameIndexOp (SDValue Op)
 
static SDValue buildSMovImm32 (SelectionDAG &DAG, const SDLoc &DL, uint64_t Val)
 

Variables

static cl::opt< bool > EnableVGPRIndexMode ("amdgpu-vgpr-index-mode", cl::desc("Use GPR indexing mode instead of movrel for vector indexing"), cl::init(false))
 

Detailed Description

Custom DAG lowering for SI.

Definition in file SIISelLowering.cpp.

Function Documentation

static void allocateHSAUserSGPRs ( CCState &  CCInfo,
MachineFunction &  MF,
const SIRegisterInfo &  TRI,
SIMachineFunctionInfo &  Info 
)
static
static void allocateSpecialInputVGPRs ( CCState &  CCInfo,
MachineFunction &  MF,
const SIRegisterInfo &  TRI,
SIMachineFunctionInfo &  Info 
)
static
static void allocateSystemSGPRs ( CCState &  CCInfo,
MachineFunction &  MF,
SIMachineFunctionInfo &  Info,
CallingConv::ID  CallConv,
bool  IsShader 
)
static
static bool bitOpWithConstantIsReducible ( unsigned  Opc,
uint32_t  Val 
)
static

Definition at line 4284 of file SIISelLowering.cpp.

References llvm::ISD::AND, llvm::ISD::OR, and llvm::ISD::XOR.

static SDValue buildPCRelGlobalAddress ( SelectionDAG &  DAG,
const GlobalValue *  GV,
const SDLoc &  DL,
unsigned  Offset,
EVT  PtrVT,
unsigned  GAFlags = SIInstrInfo::MO_NONE 
)
static
static SDValue buildSMovImm32 ( SelectionDAG &  DAG,
const SDLoc &  DL,
uint64_t  Val 
)
static
static bool canFoldOffset ( unsigned  OffsetSize,
unsigned  AS,
const SISubtarget &  STI 
)
static

Return true if the given offset Size in bytes can be folded into the immediate offsets of a memory instruction for the given address space.

Definition at line 4192 of file SIISelLowering.cpp.

References llvm::AMDGPUTargetLowering::AMDGPUASI, AMDGPUAS::CONSTANT_ADDRESS, llvm::AMDGPUSubtarget::getAMDGPUAS(), llvm::AMDGPUSubtarget::getGeneration(), AMDGPUAS::GLOBAL_ADDRESS, llvm::isUInt< 16 >(), llvm::isUInt< 8 >(), AMDGPUAS::LOCAL_ADDRESS, AMDGPUAS::REGION_ADDRESS, and llvm::AMDGPUSubtarget::VOLCANIC_ISLANDS.

static std::pair<unsigned, int> computeIndirectRegAndOffset ( const SIRegisterInfo &  TRI,
const TargetRegisterClass *  SuperRC,
unsigned  VecReg,
int  Offset 
)
static

Definition at line 1821 of file SIISelLowering.cpp.

Referenced by emitIndirectDst(), and emitIndirectSrc().

static MachineBasicBlock* emitIndirectDst ( MachineInstr &  MI,
MachineBasicBlock &  MBB,
const SISubtarget &  ST 
)
static
static MachineBasicBlock* emitIndirectSrc ( MachineInstr &  MI,
MachineBasicBlock &  MBB,
const SISubtarget &  ST 
)
static
static MachineBasicBlock::iterator emitLoadM0FromVGPRLoop ( const SIInstrInfo *  TII,
MachineRegisterInfo &  MRI,
MachineBasicBlock &  OrigBB,
MachineBasicBlock &  LoopBB,
const DebugLoc &  DL,
const MachineOperand &  IdxReg,
unsigned  InitReg,
unsigned  ResultReg,
unsigned  PhiReg,
unsigned  InitSaveExecReg,
int  Offset,
bool  UseGPRIdxMode 
)
static
static SDValue emitNonHSAIntrinsicError ( SelectionDAG &  DAG,
const SDLoc &  DL,
EVT  VT 
)
static
static SDValue emitRemovedIntrinsicError ( SelectionDAG &  DAG,
const SDLoc &  DL,
EVT  VT 
)
static
static unsigned findFirstFreeSGPR ( CCState &  CCInfo)
static

Definition at line 91 of file SIISelLowering.cpp.

References llvm::CCState::isAllocated(), and llvm_unreachable().

Referenced by allocateSystemSGPRs().

static SDNode* findUser ( SDValue  Value,
unsigned  Opcode 
)
static

Helper function for LowerBRCOND.

Definition at line 2422 of file SIISelLowering.cpp.

References E, llvm::SDValue::getNode(), I, llvm::SDNode::use_begin(), and llvm::SDNode::use_end().

static bool fp16SrcZerosHighBits ( unsigned  Opc)
static
static SDValue getFPBinOp ( SelectionDAG &  DAG,
unsigned  Opcode,
const SDLoc &  SL,
EVT  VT,
SDValue  A,
SDValue  B,
SDValue  GlueChain 
)
static
static SDValue getFPTernOp ( SelectionDAG &  DAG,
unsigned  Opcode,
const SDLoc &  SL,
EVT  VT,
SDValue  A,
SDValue  B,
SDValue  C,
SDValue  GlueChain 
)
static
static unsigned getMOVRELDPseudo ( const SIRegisterInfo &  TRI,
const TargetRegisterClass *  VecRC 
)
static

Definition at line 1974 of file SIISelLowering.cpp.

References llvm_unreachable().

Referenced by emitIndirectDst().

static bool isBoolSGPR ( SDValue  V)
static
static bool isCanonicalized ( SelectionDAG &  DAG,
SDValue  Op,
const SISubtarget *  ST,
unsigned  MaxDepth = 5 
)
static
static bool isClampZeroToOne ( SDValue  A,
SDValue  B 
)
static

Definition at line 4930 of file SIISelLowering.cpp.

static bool isFlatGlobalAddrSpace ( unsigned  AS,
AMDGPUAS  AMDGPUASI 
)
static
static bool isFrameIndexOp ( SDValue  Op)
static
static bool isKnownNeverSNan ( SelectionDAG &  DAG,
SDValue  Op 
)
static
static MachineBasicBlock::iterator loadM0FromVGPR ( const SIInstrInfo *  TII,
MachineBasicBlock &  MBB,
MachineInstr &  MI,
unsigned  InitResultReg,
unsigned  PhiReg,
int  Offset,
bool  UseGPRIdxMode 
)
static
static unsigned minMaxOpcToMin3Max3Opc ( unsigned  Opc)
static
static void processShaderInputArgs ( SmallVectorImpl< ISD::InputArg > &  Splits,
CallingConv::ID  CallConv,
ArrayRef< ISD::InputArg >  Ins,
BitVector &  Skipped,
FunctionType *  FType,
SIMachineFunctionInfo *  Info 
)
static
static void reservePrivateMemoryRegs ( const TargetMachine &  TM,
MachineFunction &  MF,
const SIRegisterInfo &  TRI,
SIMachineFunctionInfo &  Info 
)
static
static bool setM0ToIndexFromSGPR ( const SIInstrInfo *  TII,
MachineRegisterInfo &  MRI,
MachineInstr &  MI,
int  Offset,
bool  UseGPRIdxMode,
bool  IsIndirectSrc 
)
static
static unsigned SubIdx2Lane ( unsigned  Idx)
static

Helper function for adjustWritemask.

Definition at line 5436 of file SIISelLowering.cpp.

Variable Documentation

cl::opt<bool> EnableVGPRIndexMode("amdgpu-vgpr-index-mode", cl::desc("Use GPR indexing mode instead of movrel for vector indexing"), cl::init(false))
static

Referenced by emitIndirectDst(), and emitIndirectSrc().