Skip to content

Commit 301afcf

Browse files
committed
[lldb] Architecture plugins should report the vector element order. NFC
Some targets like PowerPC store their - PowerPC little endian: little endian elements ordered 0, 1, 2, ... - PowerPC big endian: big endian elements ordered n-1, n-2, n-3, ... - ARM/MIPS little endian: little endian elements ordered 0, 1, 2, ... - ARM/MIPS big endian: big endian elements ordered 0, 1, 2, ... This matters when LLVM-IR values are transferred to/from target memory since LLVM-IR orders elements 0, 1, 2, ... regardless of endianness. This will be used in llvm#155000 by changes to the IRInterpreter to allow it to evaluate some vectors without executing on the target
1 parent dc170c7 commit 301afcf

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

lldb/include/lldb/Core/Architecture.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ class Architecture : public PluginInterface {
129129
RegisterContext &reg_context) const {
130130
return false;
131131
}
132+
133+
/// Get the vector element order for this architecture. This determines how
134+
/// vector elements are indexed. This matters in a few places such as reading/
135+
/// writing LLVM-IR values to/from target memory. Some architectures use
136+
/// little-endian element ordering where element 0 is at the lowest address
137+
/// even when the architecture is otherwise big-endian (e.g. MIPS MSA, ARM
138+
/// NEON), but some architectures like PowerPC may use big-endian element
139+
/// ordering where element 0 is at the highest address.
140+
virtual lldb::ByteOrder GetVectorElementOrder() const {
141+
return lldb::eByteOrderLittle;
142+
}
132143
};
133144

134145
} // namespace lldb_private

lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ void ArchitecturePPC64::Terminate() {
3535
std::unique_ptr<Architecture> ArchitecturePPC64::Create(const ArchSpec &arch) {
3636
if (arch.GetTriple().isPPC64() &&
3737
arch.GetTriple().getObjectFormat() == llvm::Triple::ObjectFormatType::ELF)
38-
return std::unique_ptr<Architecture>(new ArchitecturePPC64());
38+
return std::unique_ptr<Architecture>(
39+
new ArchitecturePPC64(arch.GetByteOrder()));
3940
return nullptr;
4041
}
4142

@@ -60,3 +61,7 @@ void ArchitecturePPC64::AdjustBreakpointAddress(const Symbol &func,
6061

6162
addr.SetOffset(addr.GetOffset() + loffs);
6263
}
64+
65+
lldb::ByteOrder ArchitecturePPC64::GetVectorElementOrder() const {
66+
return m_vector_element_order;
67+
}

lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ class ArchitecturePPC64 : public Architecture {
3030
void AdjustBreakpointAddress(const Symbol &func,
3131
Address &addr) const override;
3232

33+
lldb::ByteOrder GetVectorElementOrder() const override;
34+
3335
private:
3436
static std::unique_ptr<Architecture> Create(const ArchSpec &arch);
35-
ArchitecturePPC64() = default;
37+
ArchitecturePPC64(lldb::ByteOrder vector_element_order)
38+
: m_vector_element_order(vector_element_order) {}
39+
40+
lldb::ByteOrder m_vector_element_order;
3641
};
3742

3843
} // namespace lldb_private

0 commit comments

Comments
 (0)