From 1dfaa224ffb6b62b7a1e72a022f36db40c09c599 Mon Sep 17 00:00:00 2001 From: Matthew Poremba Date: Tue, 28 May 2024 07:58:28 -0700 Subject: [PATCH] arch-vega: Fix GCC 13 build errors (#1162) The new static analysis in GCC 13 finds issues with operand.hh. This commit fixes the error so that gem5 compiles when BUILD_GPU is true. Change-Id: I6f4b0d350f0cabb6e356de20a46e1ca65fd0da55 --- src/arch/amdgpu/vega/operand.hh | 37 ++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/arch/amdgpu/vega/operand.hh b/src/arch/amdgpu/vega/operand.hh index 6a10812fa7..593f0e34fd 100644 --- a/src/arch/amdgpu/vega/operand.hh +++ b/src/arch/amdgpu/vega/operand.hh @@ -514,6 +514,29 @@ namespace VegaISA { assert(NumDwords == 1 || NumDwords == 2); + if (_opIdx >= REG_INT_CONST_POS_MIN && + _opIdx <= REG_INT_CONST_NEG_MAX) { + assert(sizeof(DataType) <= sizeof(srfData)); + DataType misc_val(0); + assert(isConstVal(_opIdx)); + misc_val = (DataType)_gpuDynInst + ->readConstVal(_opIdx); + std::memcpy((void*)srfData.data(), (void*)&misc_val, + sizeof(DataType)); + + return; + } + + if (_opIdx == REG_M0 || _opIdx == REG_ZERO || _opIdx == REG_SCC) { + assert(sizeof(DataType) <= sizeof(srfData)); + DataType misc_val(0); + misc_val = (DataType)_gpuDynInst->readMiscReg(_opIdx); + std::memcpy((void*)srfData.data(), (void*)&misc_val, + sizeof(DataType)); + + return; + } + switch(_opIdx) { case REG_EXEC_LO: { @@ -682,18 +705,8 @@ namespace VegaISA } break; default: - { - assert(sizeof(DataType) <= sizeof(srfData)); - DataType misc_val(0); - if (isConstVal(_opIdx)) { - misc_val = (DataType)_gpuDynInst - ->readConstVal(_opIdx); - } else { - misc_val = (DataType)_gpuDynInst->readMiscReg(_opIdx); - } - std::memcpy((void*)srfData.data(), (void*)&misc_val, - sizeof(DataType)); - } + panic("Invalid special register index: %d\n", _opIdx); + break; } }