aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Schürmann <[email protected]>2020-01-08 12:46:47 +0100
committerMarge Bot <[email protected]>2020-01-10 17:49:18 +0000
commit8b7a42d6d0b15508940e095642136c53d0c7dcee (patch)
tree14a18fd6e206676bc94d6705bfcf95c9fcb751ac
parentffb4790279ca779572ec393ba84d71ef1036b437 (diff)
aco: compact aco::span<T> to use uint16_t offset and size instead of pointer and size_t.
This reduces the size of the Instruction base class from 40 bytes to 16 bytes. No pipelinedb changes. Reviewed-by: Rhys Perry <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3332> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3332>
-rw-r--r--src/amd/compiler/aco_instruction_selection.cpp2
-rw-r--r--src/amd/compiler/aco_ir.h6
-rw-r--r--src/amd/compiler/aco_optimizer.cpp3
-rw-r--r--src/amd/compiler/aco_util.h34
4 files changed, 24 insertions, 21 deletions
diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp
index aa1648f0d1b..cb28dffa65e 100644
--- a/src/amd/compiler/aco_instruction_selection.cpp
+++ b/src/amd/compiler/aco_instruction_selection.cpp
@@ -7964,7 +7964,7 @@ void split_arguments(isel_context *ctx, Pseudo_instruction *startpgm)
/* Split all arguments except for the first (ring_offsets) and the last
* (exec) so that the dead channels don't stay live throughout the program.
*/
- for (unsigned i = 1; i < startpgm->definitions.size() - 1; i++) {
+ for (int i = 1; i < startpgm->definitions.size() - 1; i++) {
if (startpgm->definitions[i].regClass().size() > 1) {
emit_split_vector(ctx, startpgm->definitions[i].getTemp(),
startpgm->definitions[i].regClass().size());
diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h
index 388bf064000..1ee31d23702 100644
--- a/src/amd/compiler/aco_ir.h
+++ b/src/amd/compiler/aco_ir.h
@@ -929,8 +929,10 @@ T* create_instruction(aco_opcode opcode, Format format, uint32_t num_operands, u
inst->opcode = opcode;
inst->format = format;
- inst->operands = aco::span<Operand>((Operand*)(data + sizeof(T)), num_operands);
- inst->definitions = aco::span<Definition>((Definition*)inst->operands.end(), num_definitions);
+ uint16_t operands_offset = data + sizeof(T) - (char*)&inst->operands;
+ inst->operands = aco::span<Operand>(operands_offset, num_operands);
+ uint16_t definitions_offset = (char*)inst->operands.end() - (char*)&inst->definitions;
+ inst->definitions = aco::span<Definition>(definitions_offset, num_definitions);
return inst;
}
diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp
index 41fcc6f27f8..71353aae80b 100644
--- a/src/amd/compiler/aco_optimizer.cpp
+++ b/src/amd/compiler/aco_optimizer.cpp
@@ -829,7 +829,8 @@ void label_instruction(opt_ctx &ctx, Block& block, aco_ptr<Instruction>& instr)
Format format = is_vgpr ? Format::VOP1 : Format::SOP1;
instr->opcode = opcode;
instr->format = format;
- instr->operands = {instr->operands.begin(), 1 };
+ while (instr->operands.size() > 1)
+ instr->operands.pop_back();
instr->operands[0] = vec_op;
if (vec_op.isConstant()) {
diff --git a/src/amd/compiler/aco_util.h b/src/amd/compiler/aco_util.h
index ec77ba55716..8d4c4d390f0 100644
--- a/src/amd/compiler/aco_util.h
+++ b/src/amd/compiler/aco_util.h
@@ -47,8 +47,8 @@ public:
using const_iterator = const_pointer;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
- using size_type = std::size_t;
- using difference_type = std::ptrdiff_t;
+ using size_type = uint16_t;
+ using difference_type = ptrdiff_t;
/*! \brief Compiler generated default constructor
*/
@@ -58,49 +58,49 @@ public:
* \param[in] data Pointer to the underlying data array
* \param[in] length The size of the span
*/
- constexpr span(pointer data, const size_type length)
- : data{ data } , length{ length } {}
+ constexpr span(uint16_t offset, const size_type length)
+ : offset{ offset } , length{ length } {}
/*! \brief Returns an iterator to the begin of the span
* \return data
*/
constexpr iterator begin() noexcept {
- return data;
+ return (pointer)((char*)this + offset);
}
/*! \brief Returns a const_iterator to the begin of the span
* \return data
*/
constexpr const_iterator begin() const noexcept {
- return data;
+ return (const_pointer)((const char *)this + offset);
}
/*! \brief Returns an iterator to the end of the span
* \return data + length
*/
constexpr iterator end() noexcept {
- return std::next(data, length);
+ return std::next(begin(), length);
}
/*! \brief Returns a const_iterator to the end of the span
* \return data + length
*/
constexpr const_iterator end() const noexcept {
- return std::next(data, length);
+ return std::next(begin(), length);
}
/*! \brief Returns a const_iterator to the begin of the span
* \return data
*/
constexpr const_iterator cbegin() const noexcept {
- return data;
+ return begin();
}
/*! \brief Returns a const_iterator to the end of the span
* \return data + length
*/
constexpr const_iterator cend() const noexcept {
- return std::next(data, length);
+ return std::next(begin(), length);
}
/*! \brief Returns a reverse_iterator to the end of the span
@@ -151,7 +151,7 @@ public:
*/
constexpr reference operator[](const size_type index) noexcept {
assert(length > index);
- return *(std::next(data, index));
+ return *(std::next(begin(), index));
}
/*! \brief Unchecked const access operator
@@ -160,7 +160,7 @@ public:
*/
constexpr const_reference operator[](const size_type index) const noexcept {
assert(length > index);
- return *(std::next(data, index));
+ return *(std::next(begin(), index));
}
/*! \brief Returns a reference to the last element of the span
@@ -168,7 +168,7 @@ public:
*/
constexpr reference back() noexcept {
assert(length > 0);
- return *(std::next(data, length - 1));
+ return *(std::next(begin(), length - 1));
}
/*! \brief Returns a const_reference to the last element of the span
@@ -176,7 +176,7 @@ public:
*/
constexpr const_reference back() const noexcept {
assert(length > 0);
- return *(std::next(data, length - 1));
+ return *(std::next(begin(), length - 1));
}
/*! \brief Returns a reference to the first element of the span
@@ -219,15 +219,15 @@ public:
/*! \brief Clears the span
*/
constexpr void clear() noexcept {
- data = nullptr;
+ offset = 0;
length = 0;
}
private:
- pointer data{ nullptr }; //!> Pointer to the underlying data array
+ uint16_t offset{ 0 }; //!> Byte offset from span to data
size_type length{ 0 }; //!> Size of the span
};
} // namespace aco
-#endif // ACO_UTIL_H \ No newline at end of file
+#endif // ACO_UTIL_H