Skip to content

[CIR][Dialect] Add OpenCL C language in cir.lang #774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ class CIRUnitAttr<string name, string attrMnemonic, list<Trait> traits = []>

def C : I32EnumAttrCase<"C", 1, "c">;
def CXX : I32EnumAttrCase<"CXX", 2, "cxx">;
def OpenCLC : I32EnumAttrCase<"OpenCLC", 3, "opencl_c">;

def SourceLanguage : I32EnumAttr<"SourceLanguage", "Source language", [
C, CXX
C, CXX, OpenCLC
]> {
let cppNamespace = "::mlir::cir";
let genSpecializedAttr = 0;
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/CIR/CodeGen/CIRGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3048,6 +3048,9 @@ mlir::cir::SourceLanguage CIRGenModule::getCIRSourceLanguage() {
using CIRLang = mlir::cir::SourceLanguage;
auto opts = getLangOpts();

if (opts.OpenCL && !opts.OpenCLCPlusPlus)
return CIRLang::OpenCLC;

if (opts.CPlusPlus || opts.CPlusPlus11 || opts.CPlusPlus14 ||
opts.CPlusPlus17 || opts.CPlusPlus20 || opts.CPlusPlus23 ||
opts.CPlusPlus26)
Expand Down
4 changes: 4 additions & 0 deletions clang/test/CIR/CodeGen/OpenCL/opencl-c-lang.cl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// RUN: %clang_cc1 -cl-std=CL3.0 -O0 -fclangir -emit-cir -triple spirv64-unknown-unknown %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR

// CIR: module{{.*}} attributes {{{.*}}cir.lang = #cir.lang<opencl_c>
Loading