[clang] [clang][bytecode] Handle bitcasts involving bitfields (PR #116843)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 20 06:38:39 PST 2024
================
@@ -0,0 +1,88 @@
+//===-------------------- Bitcastbuffer.cpp ---------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#include "BitcastBuffer.h"
+
+using namespace clang;
+using namespace clang::interp;
+
+void BitcastBuffer::pushData(const std::byte *In, size_t BitOffset,
+ size_t BitWidth, Endian TargetEndianness) {
+ for (unsigned It = 0; It != BitWidth; ++It) {
+ bool BitValue = bitof(In, It);
+ if (!BitValue)
+ continue;
+
+ unsigned DstBit;
+ if (TargetEndianness == Endian::Little)
+ DstBit = BitOffset + It;
+ else
+ DstBit = size() - BitOffset - BitWidth + It;
+
+ unsigned DstByte = (DstBit / 8);
----------------
AaronBallman wrote:
Someday we're going to have to search the entire code base for the number 8, aren't we? :-D
https://github.com/llvm/llvm-project/pull/116843
More information about the cfe-commits
mailing list