@@ -165,6 +165,63 @@ void IR_Builder::bindInputDecl(
165165  }
166166}
167167
168+ bool  IR_Builder::isGRFDstAligned (G4_Operand* opnd, int  alignByte) const 
169+ {
170+   bool  isAligned = true ;
171+   unsigned  short  offset = 0 ;
172+   int  type_size = opnd->getTypeSize ();
173+   G4_Declare *dcl = NULL ;
174+ 
175+   dcl = opnd->getBase ()->asRegVar ()->getDeclare ();
176+   while  (dcl && dcl->getAliasDeclare ()) {
177+     if  (dcl->getSubRegAlign () != Any &&
178+         (((dcl->getSubRegAlign () * 2 ) >= alignByte &&
179+           (dcl->getSubRegAlign () * 2 ) % alignByte != 0 ) ||
180+          ((dcl->getSubRegAlign () * 2 ) < alignByte &&
181+           alignByte % (dcl->getSubRegAlign () * 2 ) != 0 ))) {
182+       isAligned = false ;
183+       break ;
184+     }
185+     offset += (unsigned  short )dcl->getAliasOffset ();
186+     dcl = dcl->getAliasDeclare ();
187+   }
188+ 
189+   if  (dcl && dcl->getRegVar () && dcl->getRegVar ()->isPhyRegAssigned ()) {
190+     offset += static_cast <unsigned  short >(dcl->getRegVar ()->getByteAddr (*this ));
191+   }
192+ 
193+   if  (!isAligned) {
194+     return  false ;
195+   }
196+ 
197+   if  (opnd->isDstRegRegion ()) {
198+     if  (opnd->asDstRegRegion ()->getRegAccess () != Direct) {
199+       isAligned = false ;
200+     }
201+     offset += opnd->asDstRegRegion ()->getRegOff () * numEltPerGRF<Type_UB>() +
202+               opnd->asDstRegRegion ()->getSubRegOff () * type_size;
203+   }
204+ 
205+   if  (offset % alignByte != 0 ) {
206+     return  false ;
207+   }
208+ 
209+   if  (dcl && dcl->getRegFile () == G4_GRF) {
210+     if  (dcl->getSubRegAlign () == Any ||
211+         ((dcl->getSubRegAlign () * 2 ) < alignByte &&
212+          alignByte % (dcl->getSubRegAlign () * 2 ) == 0 )) {
213+       isAligned = false ;
214+     } else  if  ((dcl->getSubRegAlign () * 2 ) < alignByte ||
215+                (dcl->getSubRegAlign () * 2 ) % alignByte != 0 ) {
216+       isAligned = false ;
217+     }
218+   } else  {
219+     isAligned = false ;
220+   }
221+ 
222+   return  isAligned;
223+ }
224+ 
168225//  check if an operand is aligned to <alignByte>
169226bool  IR_Builder::tryToAlignOperand (G4_Operand *opnd, unsigned  short  &offset,
170227                                   int  alignByte) const  {
0 commit comments