[clang] [CIR][AMDGPU][NFC] Add CIRGenBuiltinAMDGPU file to support AMDGPU builtins codegen (PR #179237)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 3 11:46:39 PST 2026


================
@@ -0,0 +1,609 @@
+//===---- CIRGenBuiltinAMDGPU.cpp - Emit CIR for AMDGPU 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This contains code to emit AMDGPU Builtin calls.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CIRGenFunction.h"
+
+#include "mlir/IR/Value.h"
+#include "clang/Basic/TargetBuiltins.h"
+#include "llvm/Support/ErrorHandling.h"
+
+using namespace clang;
+using namespace clang::CIRGen;
+using namespace cir;
+
+mlir::Value CIRGenFunction::emitAMDGPUBuiltinExpr(unsigned builtinId,
----------------
andykaylor wrote:

```suggestion
std::optional<mlir::Value> CIRGenFunction::emitAMDGPUBuiltinExpr(unsigned builtinId,
```
We're using `std::optional` so that we can distinguish between a builtin that has been handled but doesn't return a value (which returns a null `mlir::Value`) and a builtin that we didn't handle (which returns `std::nullopt`). For builtins that will be handled here but have reported a diagnostic instead, return a null `mlir::Value` so the caller doesn't do any further handling.

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


More information about the cfe-commits mailing list