https://github.com/AtariDreams updated https://github.com/llvm/llvm-project/pull/79174
>From 428bd6c4a69a6f4ba5b646086f7ad4d11f33fffa Mon Sep 17 00:00:00 2001 From: Rose <83477269+ataridre...@users.noreply.github.com> Date: Tue, 23 Jan 2024 12:31:49 -0500 Subject: [PATCH] [CodeGen] Update test intrinsic to support immediates --- clang/lib/CodeGen/CGBuiltin.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index e051cbc6486353..e69235f350825b 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -1203,10 +1203,24 @@ static llvm::Value *EmitX86BitTestIntrinsic(CodeGenFunction &CGF, AsmOS << "bt"; if (Action) AsmOS << Action; - AsmOS << SizeSuffix << " $2, ($1)"; - // Build the constraints. FIXME: We should support immediates when possible. - std::string Constraints = "={@ccc},r,r,~{cc},~{memory}"; + // Check if BitPos is a ConstantInt (immediate value) + if (llvm::ConstantInt *CI = llvm::dyn_cast<llvm::ConstantInt>(BitPos)) { + // If it is, use the immediate value in the assembly string + AsmOS << SizeSuffix << " $" << CI->getZExtValue() << ", ($1)"; + } else { + // Otherwise, fall back to the existing behavior + AsmOS << SizeSuffix << " $2, ($1)"; + } + + // Build the constraints. + std::string Constraints; + if (llvm::isa<llvm::ConstantInt>(BitPos)) { + Constraints = "={@ccc},r,~{cc},~{memory}"; + } else { + Constraints = "={@ccc},r,r,~{cc},~{memory}"; + } + std::string_view MachineClobbers = CGF.getTarget().getClobbers(); if (!MachineClobbers.empty()) { Constraints += ','; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits