File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -984,16 +984,22 @@ std::string G4_Kernel::getDebugSrcLine(const std::string &fileName,
984984 return lines[srcLine - 1 ];
985985}
986986
987+ // Among all the input registers, get the largest one.
988+ // This accounts for input arguments as well as pseudo
989+ // input declarations.
987990unsigned G4_Kernel::getLargestInputRegister () {
991+ unsigned maxRegNum = 0 ;
988992 const unsigned inputCount = fg.builder ->getInputCount ();
989- unsigned regNum = 0 ;
990- if (inputCount) {
991- const input_info_t *ii = fg.builder ->getInputArg (inputCount - 1 );
992- regNum = (ii->offset + ii->dcl ->getByteSize ()) /
993- fg.builder ->numEltPerGRF <Type_UB>();
994- }
995-
996- return regNum;
993+ // Iterate over all the inputs because they can be defined
994+ // in any order by the programmer.
995+ for (unsigned i = 0 ; i < inputCount; i++) {
996+ const input_info_t *ii = fg.builder ->getInputArg (i);
997+ unsigned reg = (ii->offset + ii->dcl ->getByteSize ()) /
998+ fg.builder ->numEltPerGRF <Type_UB>();
999+ if (reg > maxRegNum)
1000+ maxRegNum = reg;
1001+ }
1002+ return maxRegNum;
9971003}
9981004
9991005void G4_Kernel::setKernelParameters (unsigned newGRF) {
You can’t perform that action at this time.
0 commit comments