26#include "llvm/IR/IntrinsicsSPIRV.h"
30#define DEBUG_TYPE "spirv-postlegalizer"
60 case TargetOpcode::G_SMAX:
61 case TargetOpcode::G_UMAX:
62 case TargetOpcode::G_SMIN:
63 case TargetOpcode::G_UMIN:
64 case TargetOpcode::G_FMINNUM:
65 case TargetOpcode::G_FMINIMUM:
66 case TargetOpcode::G_FMAXNUM:
67 case TargetOpcode::G_FMAXIMUM:
80 const unsigned Opcode =
I.getOpcode();
81 if (Opcode == TargetOpcode::G_UNMERGE_VALUES) {
82 unsigned ArgI =
I.getNumOperands() - 1;
83 Register SrcReg =
I.getOperand(ArgI).isReg()
84 ?
I.getOperand(ArgI).getReg()
88 if (!DefType || DefType->
getOpcode() != SPIRV::OpTypeVector)
90 "cannot select G_UNMERGE_VALUES with a non-vector argument");
93 for (
unsigned i = 0; i <
I.getNumDefs(); ++i) {
94 Register ResVReg =
I.getOperand(i).getReg();
103 I.getNumOperands() > 1 &&
I.getOperand(1).isReg()) {
107 Register ResVReg =
I.getOperand(0).getReg();
110 if (
MRI.getRegClassOrNull(ResVReg))
134 std::stack<MachineBasicBlock *> ToVisit;
137 ToVisit.push(&Start);
138 Seen.
insert(ToVisit.top());
139 while (ToVisit.size() != 0) {
164 GR->setCurrentFunc(MF);
175char SPIRVPostLegalizer::
ID = 0;
178 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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void visit(MachineFunction &MF, MachineBasicBlock &Start, std::function< void(MachineBasicBlock *)> op)
bool isTypeFoldingSupported(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.
iterator_range< succ_iterator > successors()
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
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
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 setRegClassType(Register Reg, SPIRVType *SpvType, SPIRVGlobalRegistry *GR, MachineRegisterInfo *MRI, const MachineFunction &MF, bool Force)
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)