[clang] [clang] Implement C2y stdc_load8_* endian-aware 8-bit load functions (PR #203666)

NagaChaitanya Vellanki via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 13 22:05:17 PDT 2026


================
@@ -2103,6 +2103,91 @@ static bool isOneByteCharacterType(QualType T) {
   return T->isCharType() || T->isChar8Type();
 }
 
+static bool interp__builtin_load8(InterpState &S, CodePtr OpPC,
+                                  const InterpFrame *Frame,
+                                  const CallExpr *Call, bool IsBigEndian,
+                                  bool IsAligned) {
+  Pointer Ptr = S.Stk.pop<Pointer>();
+
+  if (Ptr.isZero()) {
+    S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_access_null)
+        << AK_Read;
+    return false;
+  }
+
+  if (!isReadable(Ptr) && !Ptr.isOnePastEnd())
+    return false;
+
+  if (IsAligned) {
+    CharUnits RequiredAlign =
+        S.getASTContext().getTypeAlignInChars(Call->getType());
+    APValue AV = Ptr.toAPValue(S.getASTContext());
+    CharUnits BaseAlignment =
+        GetBaseAlignment(S.getASTContext(), AV.getLValueBase());
----------------
chaitanyav wrote:

@tbaederr I will re-use the code, working on it.

https://github.com/llvm/llvm-project/pull/203666


More information about the cfe-commits mailing list