[clang] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)
Sergei Barannikov via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 20 17:49:52 PDT 2025
================
@@ -0,0 +1,107 @@
+//===------ CGBuiltin.h - Emit LLVM Code for builtins ---------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H
+#define LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H
+
+#include "CodeGenFunction.h"
+
+using llvm::Value;
+using llvm::Function;
+using llvm::AtomicOrdering;
+using clang::SmallVector;
+using clang::CallExpr;
+using clang::QualType;
+using clang::CodeGen::Address;
+using clang::CodeGen::CodeGenFunction;
+
+// Many of MSVC builtins are on x64, ARM and AArch64; to avoid repeating code,
+// we handle them here.
+enum class clang::CodeGen::CodeGenFunction::MSVCIntrin {
+ _BitScanForward,
+ _BitScanReverse,
+ _InterlockedAnd,
+ _InterlockedCompareExchange,
+ _InterlockedDecrement,
+ _InterlockedExchange,
+ _InterlockedExchangeAdd,
+ _InterlockedExchangeSub,
+ _InterlockedIncrement,
+ _InterlockedOr,
+ _InterlockedXor,
+ _InterlockedExchangeAdd_acq,
+ _InterlockedExchangeAdd_rel,
+ _InterlockedExchangeAdd_nf,
+ _InterlockedExchange_acq,
+ _InterlockedExchange_rel,
+ _InterlockedExchange_nf,
+ _InterlockedCompareExchange_acq,
+ _InterlockedCompareExchange_rel,
+ _InterlockedCompareExchange_nf,
+ _InterlockedCompareExchange128,
+ _InterlockedCompareExchange128_acq,
+ _InterlockedCompareExchange128_rel,
+ _InterlockedCompareExchange128_nf,
+ _InterlockedOr_acq,
+ _InterlockedOr_rel,
+ _InterlockedOr_nf,
+ _InterlockedXor_acq,
+ _InterlockedXor_rel,
+ _InterlockedXor_nf,
+ _InterlockedAnd_acq,
+ _InterlockedAnd_rel,
+ _InterlockedAnd_nf,
+ _InterlockedIncrement_acq,
+ _InterlockedIncrement_rel,
+ _InterlockedIncrement_nf,
+ _InterlockedDecrement_acq,
+ _InterlockedDecrement_rel,
+ _InterlockedDecrement_nf,
+ __fastfail,
+};
+
+// Emit a simple intrinsic that has N scalar arguments and a return type
+// matching the argument type. It is assumed that only the first argument is
+// overloaded.
+template <unsigned N>
+Value *emitBuiltinWithOneOverloadedType(CodeGenFunction &CGF,
----------------
s-barannikov wrote:
Sorry if I wasn't clear, I meant *all* declarations should be in a namespace, not only the enum.
And there are still `using` directives that could be avoided if the contents of the file was in `namespace clang::CodeGen { }` (except for `using llvm::xxx`, but I think those types should be referred by fully qualified name to avoid potential collisions with clang's same-named types).
I'm not sure if this suggestion is consistent with clang's style. If it isn't, please let me know.
https://github.com/llvm/llvm-project/pull/132252
More information about the cfe-commits
mailing list