llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clangir

Author: Andrzej Warzyński (banach-space)

<details>
<summary>Changes</summary>

Extract `emitIntrinsicCallOp`, which was previously defined
independently in CIRGenBuiltinAArch64.cpp and CIRGenBuiltinX86.cpp, into
a shared header (CIRGenUtils.h).


---
Full diff: https://github.com/llvm/llvm-project/pull/172735.diff


3 Files Affected:

- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp (+1-11) 
- (modified) clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp (+1-11) 
- (added) clang/lib/CIR/CodeGen/CIRGenUtils.h (+34) 


``````````diff
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
index e28b3c6cdc2ff..3e4b31ce3fbf2 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
@@ -13,6 +13,7 @@
 
 #include "CIRGenBuilder.h"
 #include "CIRGenFunction.h"
+#include "CIRGenUtils.h"
 #include "clang/CIR/MissingFeatures.h"
 
 // TODO(cir): once all builtins are covered, decide whether we still
@@ -31,17 +32,6 @@ using namespace clang;
 using namespace clang::CIRGen;
 using namespace llvm;
 
-template <typename... Operands>
-static mlir::Value emitIntrinsicCallOp(CIRGenBuilderTy &builder,
-                                       mlir::Location loc, const StringRef str,
-                                       const mlir::Type &resTy,
-                                       Operands &&...op) {
-  return cir::LLVMIntrinsicCallOp::create(builder, loc,
-                                          builder.getStringAttr(str), resTy,
-                                          std::forward<Operands>(op)...)
-      .getResult();
-}
-
 // Generate vscale * scalingFactor
 static mlir::Value genVscaleTimesFactor(mlir::Location loc,
                                         CIRGenBuilderTy builder,
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp 
b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index 72e6bea244802..3e13dea9b4811 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -14,6 +14,7 @@
 #include "CIRGenBuilder.h"
 #include "CIRGenFunction.h"
 #include "CIRGenModule.h"
+#include "CIRGenUtils.h"
 #include "mlir/IR/Location.h"
 #include "mlir/IR/ValueRange.h"
 #include "clang/Basic/Builtins.h"
@@ -25,17 +26,6 @@
 using namespace clang;
 using namespace clang::CIRGen;
 
-template <typename... Operands>
-static mlir::Value emitIntrinsicCallOp(CIRGenBuilderTy &builder,
-                                       mlir::Location loc, const StringRef str,
-                                       const mlir::Type &resTy,
-                                       Operands &&...op) {
-  return cir::LLVMIntrinsicCallOp::create(builder, loc,
-                                          builder.getStringAttr(str), resTy,
-                                          std::forward<Operands>(op)...)
-      .getResult();
-}
-
 // OG has unordered comparison as a form of optimization in addition to
 // ordered comparison, while CIR doesn't.
 //
diff --git a/clang/lib/CIR/CodeGen/CIRGenUtils.h 
b/clang/lib/CIR/CodeGen/CIRGenUtils.h
new file mode 100644
index 0000000000000..054c5d6ade5e2
--- /dev/null
+++ b/clang/lib/CIR/CodeGen/CIRGenUtils.h
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// Miscellaneous utility functions used by CIR code-gen.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENUTILS_H
+#define LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENUTILS_H
+
+#include "CIRGenBuilder.h"
+#include "mlir/IR/Value.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace clang::CIRGen {
+
+template <typename... Operands>
+mlir::Value emitIntrinsicCallOp(CIRGenBuilderTy &builder, mlir::Location loc,
+                                const llvm::StringRef str,
+                                const mlir::Type &resTy, Operands &&...op) {
+  return cir::LLVMIntrinsicCallOp::create(builder, loc,
+                                          builder.getStringAttr(str), resTy,
+                                          std::forward<Operands>(op)...)
+      .getResult();
+}
+
+} // namespace clang::CIRGen
+
+#endif

``````````

</details>


https://github.com/llvm/llvm-project/pull/172735
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to