Skip to content

Commit 3a79aa4

Browse files
pratikasharigcbot
authored andcommitted
No change
No change
1 parent 3742abe commit 3a79aa4

File tree

5 files changed

+55
-6
lines changed

5 files changed

+55
-6
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4488,6 +4488,15 @@ namespace IGC
44884488
SaveOption(vISA_TotalGRFNum, context->getNumGRFPerThread());
44894489
}
44904490

4491+
if (m_program->HasStackCalls())
4492+
{
4493+
bool ZEBinEnabled = IGC_IS_FLAG_ENABLED(EnableZEBinary) || context->getCompilerOption().EnableZEBinary;
4494+
4495+
// pass higher ABI version when using ZEBinary
4496+
if (ZEBinEnabled)
4497+
SaveOption(vISA_StackCallABIVer, (uint32_t)2);
4498+
}
4499+
44914500
//
44924501
// Setting number of GRF and threads per EU is restricted to OCL only
44934502
// Number of threads can be set by:

IGC/ZEBinWriter/zebin/source/ZEELFObjectBuilder.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,15 @@ void ELFWriter::writeHeader()
815815
// e_ident[EI_VERSION]
816816
m_W.OS << char(ELF::EV_CURRENT);
817817

818+
// e_ident[EI_OSABI]
819+
m_W.OS << char(ELF::ELFOSABI_NONE);
820+
821+
// ABI version is hard coded right now. In future, if more ABI versions exist then revisit this.
822+
// e_ident[EI_ABIVERSION]
823+
m_W.OS << char(1);
824+
818825
// e_ident padding
819-
m_W.OS.write_zeros(ELF::EI_NIDENT - ELF::EI_OSABI);
826+
m_W.OS.write_zeros(ELF::EI_NIDENT - ELF::EI_PAD);
820827

821828
// e_type: Currently IGC always emits a relocatable file
822829
m_W.write<uint16_t>(ELF::ET_REL);

visa/G4_Kernel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ KernelDebugInfo* G4_Kernel::getKernelDebugInfo()
863863

864864
unsigned G4_Kernel::getStackCallStartReg() const
865865
{
866-
// Last 3 GRFs to be used as scratch
866+
// Last 3 (or 2) GRFs reserved for stack call purpose
867867
unsigned totalGRFs = getNumRegTotal();
868868
unsigned startReg = totalGRFs - numReservedABIGRF();
869869
return startReg;

visa/G4_Kernel.hpp

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ class G4_Kernel
344344
return getKernelAttrs()->getInt32KernelAttr(aID);
345345
}
346346
bool getOption(vISAOptions opt) const { return m_options->getOption(opt); }
347+
uint32_t getuInt32Option(vISAOptions opt) const { return m_options->getuInt32Option(opt); }
347348
void computeChannelSlicing();
348349
void calculateSimdSize();
349350
G4_ExecSize getSimdSize() { return simdSize; }
@@ -388,10 +389,26 @@ class G4_Kernel
388389
unsigned calleeSaveStart() const;
389390
unsigned getNumCalleeSaveRegs() const;
390391

392+
enum StackCallABIVersion
393+
{
394+
VER_1 = 1, // This version is used pre-zebin
395+
VER_2 = 2, // This version is used for zebin
396+
};
397+
391398
// return the number of reserved GRFs for stack call ABI
392399
// the reserved registers are at the end of the GRF file (e.g., r125-r127)
400+
// for some architectures/ABI version, we dont need a copy of r0 and
401+
// instructions can directly refer to r0 in code (eg, sends).
393402
uint32_t numReservedABIGRF() const {
394-
return 3;
403+
if (getuInt32Option(vISA_StackCallABIVer) == VER_1)
404+
return 3;
405+
else
406+
{
407+
// for ABI version > 1,
408+
if (getOption(vISA_PreserveR0InR0))
409+
return 2;
410+
return 3;
411+
}
395412
}
396413

397414
// purpose of the GRFs reserved for stack call ABI
@@ -400,15 +417,30 @@ class G4_Kernel
400417
const int ThreadHeaderGRF = 2;
401418

402419
uint32_t getFPSPGRF() const{
403-
return getStackCallStartReg() + FPSPGRF;
420+
// For ABI V1 return r125.
421+
// For ABI V2 return r127.
422+
if(getuInt32Option(vISA_StackCallABIVer) == VER_1)
423+
return getStackCallStartReg() + FPSPGRF;
424+
else
425+
return (getNumRegTotal() - 1) - FPSPGRF;
404426
}
405427

406428
uint32_t getSpillHeaderGRF() const{
407-
return getStackCallStartReg() + SpillHeaderGRF;
429+
// For ABI V1 return r126.
430+
// For ABI V2 return r126.
431+
if (getuInt32Option(vISA_StackCallABIVer) == VER_1)
432+
return getStackCallStartReg() + SpillHeaderGRF;
433+
else
434+
return (getNumRegTotal() - 1) - SpillHeaderGRF;
408435
}
409436

410437
uint32_t getThreadHeaderGRF() const{
411-
return getStackCallStartReg() + ThreadHeaderGRF;
438+
// For ABI V1 return r127.
439+
// For ABI V2 return r125.
440+
if (getuInt32Option(vISA_StackCallABIVer) == VER_1)
441+
return getStackCallStartReg() + ThreadHeaderGRF;
442+
else
443+
return (getNumRegTotal() - 1) - ThreadHeaderGRF;
412444
}
413445

414446
void renameAliasDeclares();

visa/include/VISAOptionsDefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ DEF_VISA_OPTION(vISA_CodePatch, ET_INT32, "-codePatch", UNUSED, 0)
134134
DEF_VISA_OPTION(vISA_Linker, ET_INT32, "-linker", UNUSED, 0)
135135
DEF_VISA_OPTION(vISA_lscEnableImmOffsFor, ET_INT32, "-lscEnableImmOffsFor", UNUSED, 0x3001E)
136136
DEF_VISA_OPTION(vISA_PreserveR0InR0, ET_BOOL, "-preserver0", UNUSED, false)
137+
DEF_VISA_OPTION(vISA_StackCallABIVer, ET_INT32, "-abiver", UNUSED, 1)
137138

138139
//=== RA options ===
139140
DEF_VISA_OPTION(vISA_RoundRobin, ET_BOOL, "-noroundrobin", UNUSED, true)

0 commit comments

Comments
 (0)