Skip to content

[support] Add packed_endian_specific_integral::value() #147974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/include/llvm/Support/Endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,11 @@ struct packed_endian_specific_integral {

explicit packed_endian_specific_integral(value_type val) { *this = val; }

operator value_type() const {
value_type value() const {
return endian::read<value_type, endian, alignment>(
(const void*)Value.buffer);
}
operator value_type() const { return value(); }

void operator=(value_type newValue) {
endian::write<value_type, endian, alignment>(
Expand Down
7 changes: 3 additions & 4 deletions llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,14 @@ Error makeUnexpectedOpcodeError(const LinkGraph &G, const ThumbRelocation &R,
Edge::Kind Kind) {
return make_error<JITLinkError>(
formatv("Invalid opcode [ {0:x4}, {1:x4} ] for relocation: {2}",
static_cast<uint16_t>(R.Hi), static_cast<uint16_t>(R.Lo),
G.getEdgeKindName(Kind)));
R.Hi.value(), R.Lo.value(), G.getEdgeKindName(Kind)));
}

Error makeUnexpectedOpcodeError(const LinkGraph &G, const ArmRelocation &R,
Edge::Kind Kind) {
return make_error<JITLinkError>(
formatv("Invalid opcode {0:x8} for relocation: {1}",
static_cast<uint32_t>(R.Wd), G.getEdgeKindName(Kind)));
formatv("Invalid opcode {0:x8} for relocation: {1}", R.Wd.value(),
G.getEdgeKindName(Kind)));
}

template <EdgeKind_aarch32 K> constexpr bool isArm() {
Expand Down
1 change: 1 addition & 0 deletions llvm/unittests/Support/EndianTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ TEST(Endian, PackedEndianSpecificIntegral) {
reinterpret_cast<little32_t *>(little + 1);

EXPECT_EQ(*big_val, *little_val);
EXPECT_EQ(big_val->value(), little_val->value());
}

TEST(Endian, PacketEndianSpecificIntegralAsEnum) {
Expand Down