llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/110675.diff 1 Files Affected: - (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+54) ``````````diff diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 347b23d7b89c46..ebc800623f0d48 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1219,6 +1219,48 @@ static bool interp__builtin_ia32_tzcnt(InterpState &S, CodePtr OpPC, return true; } +static bool interp__builtin_ia32_pdep(InterpState &S, CodePtr OpPC, + const InterpFrame *Frame, + const Function *Func, + const CallExpr *Call) { + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); + PrimType MaskT = *S.Ctx.classify(Call->getArg(1)); + + APSInt Val = + peekToAPSInt(S.Stk, ValT, align(primSize(ValT)) + align(primSize(MaskT))); + APSInt Mask = peekToAPSInt(S.Stk, MaskT); + + unsigned BitWidth = Val.getBitWidth(); + APInt Result = APInt::getZero(BitWidth); + for (unsigned I = 0, P = 0; I != BitWidth; ++I) { + if (Mask[I]) + Result.setBitVal(I, Val[P++]); + } + pushInteger(S, Result, Call->getType()); + return true; +} + +static bool interp__builtin_ia32_pext(InterpState &S, CodePtr OpPC, + const InterpFrame *Frame, + const Function *Func, + const CallExpr *Call) { + PrimType ValT = *S.Ctx.classify(Call->getArg(0)); + PrimType MaskT = *S.Ctx.classify(Call->getArg(1)); + + APSInt Val = + peekToAPSInt(S.Stk, ValT, align(primSize(ValT)) + align(primSize(MaskT))); + APSInt Mask = peekToAPSInt(S.Stk, MaskT); + + unsigned BitWidth = Val.getBitWidth(); + APInt Result = APInt::getZero(BitWidth); + for (unsigned I = 0, P = 0; I != BitWidth; ++I) { + if (Mask[I]) + Result.setBitVal(P++, Val[I]); + } + pushInteger(S, Result, Call->getType()); + return true; +} + static bool interp__builtin_os_log_format_buffer_size(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, @@ -1832,6 +1874,18 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F, return false; break; + case clang::X86::BI__builtin_ia32_pdep_si: + case clang::X86::BI__builtin_ia32_pdep_di: + if (!interp__builtin_ia32_pdep(S, OpPC, Frame, F, Call)) + return false; + break; + + case clang::X86::BI__builtin_ia32_pext_si: + case clang::X86::BI__builtin_ia32_pext_di: + if (!interp__builtin_ia32_pext(S, OpPC, Frame, F, Call)) + return false; + break; + case Builtin::BI__builtin_os_log_format_buffer_size: if (!interp__builtin_os_log_format_buffer_size(S, OpPC, Frame, F, Call)) return false; `````````` </details> https://github.com/llvm/llvm-project/pull/110675 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits