#define __ARCH_GCN3_GPU_ISA_HH__
#include <array>
+#include <type_traits>
#include "arch/gcn3/registers.hh"
#include "gpu-compute/dispatcher.hh"
public:
GPUISA(Wavefront &wf);
+ template<typename T> T
+ readConstVal(int opIdx) const
+ {
+ panic_if(!std::is_integral<T>::value, "Constant values must "
+ "be an integer.\n");
+ T val(0);
+
+ if (isPosConstVal(opIdx)) {
+ val = (T)readPosConstReg(opIdx);
+ }
+
+ if (isNegConstVal(opIdx)) {
+ val = (T)readNegConstReg(opIdx);
+ }
+
+ return val;
+ }
+
ScalarRegU32 readMiscReg(int opIdx) const;
void writeMiscReg(int opIdx, ScalarRegU32 operandVal);
bool hasScalarUnit() const { return true; }
return posConstRegs[opIdx - REG_INT_CONST_POS_MIN];
}
- ScalarRegU32 readNegConstReg(int opIdx) const
+ ScalarRegI32 readNegConstReg(int opIdx) const
{
- return *((ScalarRegU32*)
- &negConstRegs[opIdx - REG_INT_CONST_NEG_MIN]);
+ return negConstRegs[opIdx - REG_INT_CONST_NEG_MIN];
}
static const std::array<const ScalarRegU32, NumPosConstRegs>
/*
- * Copyright (c) 2016-2017 Advanced Micro Devices, Inc.
+ * Copyright (c) 2016-2018 Advanced Micro Devices, Inc.
* All rights reserved.
*
* For use for simulation and test purposes only
ScalarRegU32
GPUISA::readMiscReg(int opIdx) const
{
- if (opIdx >= REG_INT_CONST_POS_MIN && opIdx <= REG_INT_CONST_POS_MAX) {
- return readPosConstReg(opIdx);
- }
-
- if (opIdx >= REG_INT_CONST_NEG_MIN && opIdx <= REG_INT_CONST_NEG_MAX) {
- return readNegConstReg(opIdx);
- }
-
switch (opIdx) {
case REG_M0:
return m0;
/*
- * Copyright (c) 2017 Advanced Micro Devices, Inc.
+ * Copyright (c) 2017-2018 Advanced Micro Devices, Inc.
* All rights reserved.
*
* For use for simulation and test purposes only
default:
{
assert(sizeof(DataType) <= sizeof(srfData));
- DataType misc_val
- = (DataType)_gpuDynInst->readMiscReg(_opIdx);
+ DataType misc_val(0);
+ if (isConstVal(_opIdx)) {
+ misc_val = (DataType)_gpuDynInst
+ ->readConstVal<DataType>(_opIdx);
+ } else {
+ misc_val = (DataType)_gpuDynInst->readMiscReg(_opIdx);
+ }
std::memcpy((void*)srfData.data(), (void*)&misc_val,
- sizeof(DataType));
+ sizeof(DataType));
}
}
}
return regIdx;
}
+ bool
+ isPosConstVal(int opIdx)
+ {
+ bool is_pos_const_val = (opIdx >= REG_INT_CONST_POS_MIN
+ && opIdx <= REG_INT_CONST_POS_MAX);
+
+ return is_pos_const_val;
+ }
+
+ bool
+ isNegConstVal(int opIdx)
+ {
+ bool is_neg_const_val = (opIdx >= REG_INT_CONST_NEG_MIN
+ && opIdx <= REG_INT_CONST_NEG_MAX);
+
+ return is_neg_const_val;
+ }
+
+ bool
+ isConstVal(int opIdx)
+ {
+ bool is_const_val = isPosConstVal(opIdx) || isNegConstVal(opIdx);
+ return is_const_val;
+ }
+
bool
isLiteral(int opIdx)
{
std::string opSelectorToRegSym(int opIdx, int numRegs=0);
int opSelectorToRegIdx(int opIdx, int numScalarRegs);
+ bool isPosConstVal(int opIdx);
+ bool isNegConstVal(int opIdx);
+ bool isConstVal(int opIdx);
bool isLiteral(int opIdx);
bool isScalarReg(int opIdx);
bool isVectorReg(int opIdx);
/*
- * Copyright (c) 2015 Advanced Micro Devices, Inc.
+ * Copyright (c) 2015-2018 Advanced Micro Devices, Inc.
* All rights reserved.
*
* For use for simulation and test purposes only
Wavefront* wavefront();
ComputeUnit* computeUnit();
+ template<typename T> T
+ readConstVal(int opIdx) const
+ {
+ return gpuISA->readConstVal<T>(opIdx);
+ }
+
RegVal readMiscReg(int opIdx) const;
void writeMiscReg(int opIdx, RegVal operandVal);