@@ -55,13 +55,6 @@ extern void processInstr(MachineInstr &MI, MachineIRBuilder &MIB,
5555 MachineRegisterInfo &MRI, SPIRVGlobalRegistry *GR);
5656} // namespace llvm
5757
58- static bool isMetaInstr (unsigned Opcode) {
59- return Opcode == SPIRV::GET_ID || Opcode == SPIRV::GET_fID ||
60- Opcode == SPIRV::GET_pID || Opcode == SPIRV::GET_vID ||
61- Opcode == SPIRV::GET_vfID || Opcode == SPIRV::GET_vpID ||
62- Opcode == SPIRV::ASSIGN_TYPE;
63- }
64-
6558static bool mayBeInserted (unsigned Opcode) {
6659 switch (Opcode) {
6760 case TargetOpcode::G_SMAX:
@@ -112,27 +105,20 @@ static void processNewInstrs(MachineFunction &MF, SPIRVGlobalRegistry *GR,
112105 // registers, we must decorate them as if they were introduced in a
113106 // non-automatic way
114107 Register ResVReg = I.getOperand (0 ).getReg ();
115- SPIRVType *ResVType = GR->getSPIRVTypeForVReg (ResVReg);
116108 // Check if the register defined by the instruction is newly generated
117109 // or already processed
118- if (!ResVType) {
119- // Set type of the defined register
120- ResVType = GR->getSPIRVTypeForVReg (I. getOperand ( 1 ). getReg () );
121- // Check if we have type defined for operands of the new instruction
122- if (!ResVType)
123- continue ;
124- // Set type & class
125- setRegClassType (ResVReg, ResVType, GR, &MRI, *GR-> CurMF , true );
126- }
110+ if (MRI. getRegClassOrNull (ResVReg))
111+ continue ;
112+ assert ( GR->getSPIRVTypeForVReg (ResVReg) == nullptr );
113+ // Check if we have type defined for operands of the new instruction
114+ SPIRVType *ResVType = GR-> getSPIRVTypeForVReg (I. getOperand ( 1 ). getReg ());
115+ if (!ResVType)
116+ continue ;
117+ // Set type & class
118+ setRegClassType (ResVReg, ResVType, GR, &MRI, *GR-> CurMF , true );
127119 // If this is a simple operation that is to be reduced by TableGen
128120 // definition we must apply some of pre-legalizer rules here
129121 if (isTypeFoldingSupported (Opcode)) {
130- // Check if the instruction newly generated or already processed
131- MachineInstr *NextMI = I.getNextNode ();
132- if (NextMI && isMetaInstr (NextMI->getOpcode ()))
133- continue ;
134- // Restore usual instructions pattern for the newly inserted
135- // instruction
136122 insertAssignInstr (ResVReg, nullptr , ResVType, GR, MIB, MRI);
137123 processInstr (I, MIB, MRI, GR);
138124 }
0 commit comments