25#include "llvm/IR/IntrinsicsSPIRV.h"
28#define DEBUG_TYPE "spirv-postlegalizer"
57 return Opcode == SPIRV::GET_ID || Opcode == SPIRV::GET_ID64 ||
58 Opcode == SPIRV::GET_fID || Opcode == SPIRV::GET_fID64 ||
59 Opcode == SPIRV::GET_pID32 || Opcode == SPIRV::GET_pID64 ||
60 Opcode == SPIRV::GET_vID || Opcode == SPIRV::GET_vfID ||
61 Opcode == SPIRV::GET_vpID32 || Opcode == SPIRV::GET_vpID64;
66 case TargetOpcode::G_SMAX:
67 case TargetOpcode::G_UMAX:
68 case TargetOpcode::G_SMIN:
69 case TargetOpcode::G_UMIN:
70 case TargetOpcode::G_FMINNUM:
71 case TargetOpcode::G_FMINIMUM:
72 case TargetOpcode::G_FMAXNUM:
73 case TargetOpcode::G_FMAXIMUM:
86 const unsigned Opcode =
I.getOpcode();
87 if (Opcode == TargetOpcode::G_UNMERGE_VALUES) {
88 unsigned ArgI =
I.getNumOperands() - 1;
89 Register SrcReg =
I.getOperand(ArgI).isReg()
90 ?
I.getOperand(ArgI).getReg()
94 if (!DefType || DefType->
getOpcode() != SPIRV::OpTypeVector)
96 "cannot select G_UNMERGE_VALUES with a non-vector argument");
99 for (
unsigned i = 0; i <
I.getNumDefs(); ++i) {
100 Register ResVReg =
I.getOperand(i).getReg();
104 ResType = ScalarType;
105 MRI.setRegClass(ResVReg, &SPIRV::iIDRegClass);
112 I.getNumOperands() > 1 &&
I.getOperand(1).isReg()) {
116 Register ResVReg =
I.getOperand(0).getReg();
127 MRI.setRegClass(ResVReg, &SPIRV::iIDRegClass);
141 MRI.setRegClass(ResVReg,
MRI.getType(ResVReg).isVector()
142 ? &SPIRV::iIDRegClass
143 : &SPIRV::ANYIDRegClass);
157 GR->setCurrentFunc(MF);
168char SPIRVPostLegalizer::
ID = 0;
171 return new SPIRVPostLegalizer();
unsigned const MachineRegisterInfo * MRI
This file contains the simple types necessary to represent the attributes associated with functions a...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
bool isTypeFoldingSupported(unsigned Opcode)
static bool isMetaInstrGET(unsigned Opcode)
static bool mayBeInserted(unsigned Opcode)
static void processNewInstrs(MachineFunction &MF, SPIRVGlobalRegistry *GR, MachineIRBuilder MIB)
FunctionPass class - This class is used to implement most global optimizations.
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Helper class to build MachineInstr.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Wrapper class representing virtual and physical registers.
constexpr bool isValid() const
SPIRVType * getSPIRVTypeForVReg(Register VReg, const MachineFunction *MF=nullptr) const
void assignSPIRVTypeToVReg(SPIRVType *Type, Register VReg, MachineFunction &MF)
unsigned getScalarOrVectorBitWidth(const SPIRVType *Type) const
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
Register insertAssignInstr(Register Reg, Type *Ty, SPIRVType *SpirvTy, SPIRVGlobalRegistry *GR, MachineIRBuilder &MIB, MachineRegisterInfo &MRI)
Helper external function for inserting ASSIGN_TYPE instuction between Reg and its definition,...
FunctionPass * createSPIRVPostLegalizerPass()
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
void initializeSPIRVPostLegalizerPass(PassRegistry &)
void processInstr(MachineInstr &MI, MachineIRBuilder &MIB, MachineRegisterInfo &MRI, SPIRVGlobalRegistry *GR)