[llvm-branch-commits] [clang] [CIR] Add options to emit ClangIR and enable the ClangIR pipeline (PR #89030)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/89030 >From 21d80d2c5e2d67d54bfb450eb53b1fa73ffb635a Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Wed, 17 Apr 2024 07:26:49 + Subject: [PATCH] fix options.td Created using spr 1.3.5 --- clang/include/clang/Driver/Options.td | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 659650baf218f8..3c64ad45c1f86a 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2876,18 +2876,21 @@ def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group, Group, HelpText<"Force linking the clang builtins runtime library">; -def flto_EQ : Joined<["-"], "flto=">, - Visibility<[ClangOption, CLOption, CC1Option, FC1Option, FlangOption]>, - Group, - HelpText<"Set LTO mode">, Values<"thin,full">; -def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Visibility<[ClangOption, FlangOption]>, Group, - Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; + /// ClangIR-specific options - BEGIN def fclangir_enable : Flag<["-"], "fclangir-enable">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Use ClangIR pipeline to compile">, MarshallingInfoFlag>; def emit_cir : Flag<["-"], "emit-cir">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Build ASTs and then lower to ClangIR, emit the .cir file">; +/// ClangIR-specific options - END + +def flto_EQ : Joined<["-"], "flto=">, + Visibility<[ClangOption, CLOption, CC1Option, FC1Option, FlangOption]>, + Group, + HelpText<"Set LTO mode">, Values<"thin,full">; +def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Visibility<[ClangOption, FlangOption]>, Group, + Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; def flto_EQ_auto : Flag<["-"], "flto=auto">, Visibility<[ClangOption, FlangOption]>, Group, Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; def flto : Flag<["-"], "flto">, ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Add options to emit ClangIR and enable the ClangIR pipeline (PR #89030)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/89030 >From 21d80d2c5e2d67d54bfb450eb53b1fa73ffb635a Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Wed, 17 Apr 2024 07:26:49 + Subject: [PATCH] fix options.td Created using spr 1.3.5 --- clang/include/clang/Driver/Options.td | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 659650baf218f8..3c64ad45c1f86a 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2876,18 +2876,21 @@ def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group, Group, HelpText<"Force linking the clang builtins runtime library">; -def flto_EQ : Joined<["-"], "flto=">, - Visibility<[ClangOption, CLOption, CC1Option, FC1Option, FlangOption]>, - Group, - HelpText<"Set LTO mode">, Values<"thin,full">; -def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Visibility<[ClangOption, FlangOption]>, Group, - Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; + /// ClangIR-specific options - BEGIN def fclangir_enable : Flag<["-"], "fclangir-enable">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Use ClangIR pipeline to compile">, MarshallingInfoFlag>; def emit_cir : Flag<["-"], "emit-cir">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Build ASTs and then lower to ClangIR, emit the .cir file">; +/// ClangIR-specific options - END + +def flto_EQ : Joined<["-"], "flto=">, + Visibility<[ClangOption, CLOption, CC1Option, FC1Option, FlangOption]>, + Group, + HelpText<"Set LTO mode">, Values<"thin,full">; +def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Visibility<[ClangOption, FlangOption]>, Group, + Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; def flto_EQ_auto : Flag<["-"], "flto=auto">, Visibility<[ClangOption, FlangOption]>, Group, Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; def flto : Flag<["-"], "flto">, ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Add options to emit ClangIR and enable the ClangIR pipeline (PR #89030)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/89030 >From 21d80d2c5e2d67d54bfb450eb53b1fa73ffb635a Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Wed, 17 Apr 2024 07:26:49 + Subject: [PATCH] fix options.td Created using spr 1.3.5 --- clang/include/clang/Driver/Options.td | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 659650baf218f8..3c64ad45c1f86a 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2876,18 +2876,21 @@ def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group, Group, HelpText<"Force linking the clang builtins runtime library">; -def flto_EQ : Joined<["-"], "flto=">, - Visibility<[ClangOption, CLOption, CC1Option, FC1Option, FlangOption]>, - Group, - HelpText<"Set LTO mode">, Values<"thin,full">; -def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Visibility<[ClangOption, FlangOption]>, Group, - Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; + /// ClangIR-specific options - BEGIN def fclangir_enable : Flag<["-"], "fclangir-enable">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Use ClangIR pipeline to compile">, MarshallingInfoFlag>; def emit_cir : Flag<["-"], "emit-cir">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Build ASTs and then lower to ClangIR, emit the .cir file">; +/// ClangIR-specific options - END + +def flto_EQ : Joined<["-"], "flto=">, + Visibility<[ClangOption, CLOption, CC1Option, FC1Option, FlangOption]>, + Group, + HelpText<"Set LTO mode">, Values<"thin,full">; +def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Visibility<[ClangOption, FlangOption]>, Group, + Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; def flto_EQ_auto : Flag<["-"], "flto=auto">, Visibility<[ClangOption, FlangOption]>, Group, Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; def flto : Flag<["-"], "flto">, ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Add options to emit ClangIR and enable the ClangIR pipeline (PR #89030)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/89030 >From 21d80d2c5e2d67d54bfb450eb53b1fa73ffb635a Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Wed, 17 Apr 2024 07:26:49 + Subject: [PATCH] fix options.td Created using spr 1.3.5 --- clang/include/clang/Driver/Options.td | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 659650baf218f8..3c64ad45c1f86a 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2876,18 +2876,21 @@ def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group, Group, HelpText<"Force linking the clang builtins runtime library">; -def flto_EQ : Joined<["-"], "flto=">, - Visibility<[ClangOption, CLOption, CC1Option, FC1Option, FlangOption]>, - Group, - HelpText<"Set LTO mode">, Values<"thin,full">; -def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Visibility<[ClangOption, FlangOption]>, Group, - Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; + /// ClangIR-specific options - BEGIN def fclangir_enable : Flag<["-"], "fclangir-enable">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Use ClangIR pipeline to compile">, MarshallingInfoFlag>; def emit_cir : Flag<["-"], "emit-cir">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Build ASTs and then lower to ClangIR, emit the .cir file">; +/// ClangIR-specific options - END + +def flto_EQ : Joined<["-"], "flto=">, + Visibility<[ClangOption, CLOption, CC1Option, FC1Option, FlangOption]>, + Group, + HelpText<"Set LTO mode">, Values<"thin,full">; +def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Visibility<[ClangOption, FlangOption]>, Group, + Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; def flto_EQ_auto : Flag<["-"], "flto=auto">, Visibility<[ClangOption, FlangOption]>, Group, Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; def flto : Flag<["-"], "flto">, ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Add options to emit ClangIR and enable the ClangIR pipeline (PR #89030)
@@ -408,6 +411,9 @@ class FrontendOptions { LLVM_PREFERRED_TYPE(bool) unsigned GenReducedBMI : 1; + /// Use Clang IR pipeline to emit code + unsigned UseClangIRPipeline : 1; lanza wrote: Ah I guess this is why we didn't have the `false` defualt before. This was added a few months ago @bcardosolopes https://github.com/llvm/llvm-project/pull/89030 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR] Add options to emit ClangIR and enable the ClangIR pipeline (PR #89030)
@@ -2876,6 +2876,15 @@ def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group, Group, HelpText<"Force linking the clang builtins runtime library">; + +/// ClangIR-specific options - BEGIN +def fclangir_enable : Flag<["-"], "fclangir-enable">, Visibility<[ClangOption, CC1Option]>, + Group, HelpText<"Use ClangIR pipeline to compile">, + MarshallingInfoFlag>; +def emit_cir : Flag<["-"], "emit-cir">, Visibility<[ClangOption, CC1Option]>, lanza wrote: > Should this be a cc1-only option, same as -emit-obj and -emit-llvm-bc? (It's > always struck me as odd that -emit-llvm is not a cc1-only option...) I prefer it being a driver flag as well if there's no strong protest. https://github.com/llvm/llvm-project/pull/89030 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/4] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/4] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) >From 0e195548f24fb3748e22141739f914676b1d56d5 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Wed, 17 Apr 2024 18:59:53 + Subject: [PATCH 3/4] include dialect and add include guards Created using spr 1.3.5 --- clang/include/clang/CIR/Dialect/IR/CIRDialect.h | 5 +
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/4] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/4] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) >From 0e195548f24fb3748e22141739f914676b1d56d5 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Wed, 17 Apr 2024 18:59:53 + Subject: [PATCH 3/4] include dialect and add include guards Created using spr 1.3.5 --- clang/include/clang/CIR/Dialect/IR/CIRDialect.h | 5 +
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/4] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/4] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) >From 0e195548f24fb3748e22141739f914676b1d56d5 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Wed, 17 Apr 2024 18:59:53 + Subject: [PATCH 3/4] include dialect and add include guards Created using spr 1.3.5 --- clang/include/clang/CIR/Dialect/IR/CIRDialect.h | 5 +
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,6 @@ +set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --includedir +set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include) lanza wrote: @Ericson2314 any protest against marking that as just "not yet supported?" e.g. ``` if (CLANG_ENABLE_CIR && CLANG_STANDALONE_BUILD) message(ERROR "ClangIR is not yet supported in the standalone build") endif() ``` https://github.com/llvm/llvm-project/pull/86080 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
lanza wrote: > LGTM, though it would be nice if @petrhosek or @Ericson2314 could validate > the cmake changes (they look sensible to me, but I never know if there's a > better way to do things in CMake). We already did that above. Petr left a comment and it was fixed :p https://github.com/llvm/llvm-project/pull/86080 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/3] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/3] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) >From 0e195548f24fb3748e22141739f914676b1d56d5 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Wed, 17 Apr 2024 18:59:53 + Subject: [PATCH 3/3] include dialect and add include guards Created using spr 1.3.5 --- clang/include/clang/CIR/Dialect/IR/CIRDialect.h | 5 +
[llvm-branch-commits] [clang] [CIR] Add options to emit ClangIR and enable the ClangIR pipeline (PR #89030)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/89030 >From 21d80d2c5e2d67d54bfb450eb53b1fa73ffb635a Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Wed, 17 Apr 2024 07:26:49 + Subject: [PATCH] fix options.td Created using spr 1.3.5 --- clang/include/clang/Driver/Options.td | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 659650baf218f8..3c64ad45c1f86a 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2876,18 +2876,21 @@ def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group, Group, HelpText<"Force linking the clang builtins runtime library">; -def flto_EQ : Joined<["-"], "flto=">, - Visibility<[ClangOption, CLOption, CC1Option, FC1Option, FlangOption]>, - Group, - HelpText<"Set LTO mode">, Values<"thin,full">; -def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Visibility<[ClangOption, FlangOption]>, Group, - Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; + /// ClangIR-specific options - BEGIN def fclangir_enable : Flag<["-"], "fclangir-enable">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Use ClangIR pipeline to compile">, MarshallingInfoFlag>; def emit_cir : Flag<["-"], "emit-cir">, Visibility<[ClangOption, CC1Option]>, Group, HelpText<"Build ASTs and then lower to ClangIR, emit the .cir file">; +/// ClangIR-specific options - END + +def flto_EQ : Joined<["-"], "flto=">, + Visibility<[ClangOption, CLOption, CC1Option, FC1Option, FlangOption]>, + Group, + HelpText<"Set LTO mode">, Values<"thin,full">; +def flto_EQ_jobserver : Flag<["-"], "flto=jobserver">, Visibility<[ClangOption, FlangOption]>, Group, + Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; def flto_EQ_auto : Flag<["-"], "flto=auto">, Visibility<[ClangOption, FlangOption]>, Group, Alias, AliasArgs<["full"]>, HelpText<"Enable LTO in 'full' mode">; def flto : Flag<["-"], "flto">, ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [CIR] Add options to emit ClangIR and enable the ClangIR pipeline (PR #89030)
https://github.com/lanza created https://github.com/llvm/llvm-project/pull/89030 Introduce just the option definitions and support for their existance at a few different points in the frontend. This will be followed soon by functionality that uses it. ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/2] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/2] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/2] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/2] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,16 @@ +# This replicates part of the add_mlir_dialect cmake function from MLIR that +# cannot be used here. This happens because it expects to be run inside MLIR +# directory which is not the case for CIR (and also FIR, both have similar +# workarounds). + +# Equivalent to add_mlir_dialect(CIROps cir) +set(LLVM_TARGET_DEFINITIONS CIROps.td) +mlir_tablegen(CIROps.h.inc -gen-op-decls) +mlir_tablegen(CIROps.cpp.inc -gen-op-defs) +mlir_tablegen(CIROpsTypes.h.inc -gen-typedef-decls) +mlir_tablegen(CIROpsTypes.cpp.inc -gen-typedef-defs) +mlir_tablegen(CIROpsDialect.h.inc -gen-dialect-decls) +mlir_tablegen(CIROpsDialect.cpp.inc -gen-dialect-defs) +add_public_tablegen_target(MLIRCIROpsIncGen) +add_dependencies(mlir-headers MLIRCIROpsIncGen) lanza wrote: > You're not generating the dialect doc? These series of diffs are made by taking the tip of clangir and removing what we don't need to get a reviewable chunk of code up for a single diff. I guess while chunking this I just excluded it. It's in upstream clangir. (See https://github.com/llvm/clangir/blob/main/clang/include/clang/CIR/Dialect/IR/CMakeLists.txt#L17). > Also: can these lines be abstracted by just calling the add_mlir_dialect > macro? For reasons described at the top of the file that did not work. Perhaps that suggests a refactor of `add_mlir_dialect`, but don't intend to address that here. https://github.com/llvm/llvm-project/pull/86080 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/2] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/2] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/2] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/2] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
@@ -0,0 +1,7 @@ +set(MLIR_MAIN_SRC_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --src-root +set(MLIR_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/../mlir/include ) # --includedir +set(MLIR_TABLEGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/tools/mlir/include) +include_directories(SYSTEM ${MLIR_INCLUDE_DIR}) +include_directories(SYSTEM ${MLIR_TABLEGEN_OUTPUT_DIR}) lanza wrote: `SYSTEM` wasn't necessary! Removing in update. https://github.com/llvm/llvm-project/pull/86080 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86078 >From 0118187ba99172c6d892e4a05596085c0e637eb9 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:09:56 + Subject: [PATCH] add lit usage Created using spr 1.3.5 --- clang/test/lit.site.cfg.py.in | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index ef75770a2c3c9a..6641811c588395 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@ config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@" config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@ +config.clang_enable_cir = @CLANG_ENABLE_CIR@ config.clang_examples = @CLANG_BUILD_EXAMPLES@ config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86078 >From 0118187ba99172c6d892e4a05596085c0e637eb9 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:09:56 + Subject: [PATCH] add lit usage Created using spr 1.3.5 --- clang/test/lit.site.cfg.py.in | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index ef75770a2c3c9a..6641811c588395 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@ config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@" config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@ +config.clang_enable_cir = @CLANG_ENABLE_CIR@ config.clang_examples = @CLANG_BUILD_EXAMPLES@ config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [llvm] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86072 >From 115f1dcca7b20dacdc5beef0e73819aef94f0ec1 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 03:24:54 + Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5 --- clang/include/clang/Basic/LangStandard.h| 1 + clang/include/clang/Driver/Types.def| 1 + clang/lib/Basic/LangStandards.cpp | 3 +++ .../Serialization/SymbolGraphSerializer.cpp | 1 + clang/lib/Frontend/CompilerInvocation.cpp | 13 +++-- clang/lib/Frontend/FrontendActions.cpp | 1 + clang/lib/Frontend/FrontendOptions.cpp | 1 + 7 files changed, 19 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/LangStandard.h b/clang/include/clang/Basic/LangStandard.h index 199e24c6731603..ed9572672f0563 100644 --- a/clang/include/clang/Basic/LangStandard.h +++ b/clang/include/clang/Basic/LangStandard.h @@ -41,6 +41,7 @@ enum class Language : uint8_t { RenderScript, HIP, HLSL, + CIR, ///@} }; StringRef languageToString(Language L); diff --git a/clang/include/clang/Driver/Types.def b/clang/include/clang/Driver/Types.def index f72c27e1ee7019..0e0cae5fb7068d 100644 --- a/clang/include/clang/Driver/Types.def +++ b/clang/include/clang/Driver/Types.def @@ -90,6 +90,7 @@ TYPE("ir", LLVM_BC, INVALID, "bc", phases TYPE("lto-ir", LTO_IR, INVALID, "s", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("lto-bc", LTO_BC, INVALID, "o", phases::Compile, phases::Backend, phases::Assemble, phases::Link) +TYPE("cir", CIR, INVALID, "cir", phases::Compile, phases::Backend, phases::Assemble, phases::Link) // Misc. TYPE("ast", AST, INVALID, "ast", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("ifs", IFS, INVALID, "ifs", phases::IfsMerge) diff --git a/clang/lib/Basic/LangStandards.cpp b/clang/lib/Basic/LangStandards.cpp index cb2c0772349982..c8c9292abcb22b 100644 --- a/clang/lib/Basic/LangStandards.cpp +++ b/clang/lib/Basic/LangStandards.cpp @@ -21,6 +21,8 @@ StringRef clang::languageToString(Language L) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "ClangIR"; case Language::C: return "C"; case Language::CXX: @@ -92,6 +94,7 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang, switch (Lang) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Invalid input kind!"); case Language::OpenCL: return LangStandard::lang_opencl12; diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp index 349b93e2a2326f..545860acb7db80 100644 --- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp +++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp @@ -208,6 +208,7 @@ StringRef getLanguageName(Language Lang) { case Language::Unknown: case Language::Asm: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Unsupported language kind"); } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 0df6a82ccd8933..7bd91d4791ecf0 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2757,6 +2757,9 @@ static void GenerateFrontendArgs(const FrontendOptions , case Language::HLSL: Lang = "hlsl"; break; +case Language::CIR: + Lang = "cir"; + break; } GenerateArg(Consumer, OPT_x, @@ -2958,6 +2961,7 @@ static bool ParseFrontendArgs(FrontendOptions , ArgList , .Cases("ast", "pcm", "precompiled-header", InputKind(Language::Unknown, InputKind::Precompiled)) .Case("ir", Language::LLVM_IR) + .Case("cir", Language::CIR) .Default(Language::Unknown); if (DashX.isUnknown()) @@ -3323,6 +3327,7 @@ static bool IsInputCompatibleWithStandard(InputKind IK, switch (IK.getLanguage()) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("should not parse language flags for this input"); case Language::C: @@ -3388,6 +3393,8 @@ static StringRef GetInputKindName(InputKind IK) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "Clang IR"; case Language::HLSL: return "HLSL"; @@
[llvm-branch-commits] [clang] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86078 >From 0118187ba99172c6d892e4a05596085c0e637eb9 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:09:56 + Subject: [PATCH] add lit usage Created using spr 1.3.5 --- clang/test/lit.site.cfg.py.in | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index ef75770a2c3c9a..6641811c588395 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@ config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@" config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@ +config.clang_enable_cir = @CLANG_ENABLE_CIR@ config.clang_examples = @CLANG_BUILD_EXAMPLES@ config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/2] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/2] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/2] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/2] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86078 >From 0118187ba99172c6d892e4a05596085c0e637eb9 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:09:56 + Subject: [PATCH] add lit usage Created using spr 1.3.5 --- clang/test/lit.site.cfg.py.in | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index ef75770a2c3c9a..6641811c588395 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@ config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@" config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@ +config.clang_enable_cir = @CLANG_ENABLE_CIR@ config.clang_examples = @CLANG_BUILD_EXAMPLES@ config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86072 >From 115f1dcca7b20dacdc5beef0e73819aef94f0ec1 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 03:24:54 + Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5 --- clang/include/clang/Basic/LangStandard.h| 1 + clang/include/clang/Driver/Types.def| 1 + clang/lib/Basic/LangStandards.cpp | 3 +++ .../Serialization/SymbolGraphSerializer.cpp | 1 + clang/lib/Frontend/CompilerInvocation.cpp | 13 +++-- clang/lib/Frontend/FrontendActions.cpp | 1 + clang/lib/Frontend/FrontendOptions.cpp | 1 + 7 files changed, 19 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/LangStandard.h b/clang/include/clang/Basic/LangStandard.h index 199e24c6731603..ed9572672f0563 100644 --- a/clang/include/clang/Basic/LangStandard.h +++ b/clang/include/clang/Basic/LangStandard.h @@ -41,6 +41,7 @@ enum class Language : uint8_t { RenderScript, HIP, HLSL, + CIR, ///@} }; StringRef languageToString(Language L); diff --git a/clang/include/clang/Driver/Types.def b/clang/include/clang/Driver/Types.def index f72c27e1ee7019..0e0cae5fb7068d 100644 --- a/clang/include/clang/Driver/Types.def +++ b/clang/include/clang/Driver/Types.def @@ -90,6 +90,7 @@ TYPE("ir", LLVM_BC, INVALID, "bc", phases TYPE("lto-ir", LTO_IR, INVALID, "s", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("lto-bc", LTO_BC, INVALID, "o", phases::Compile, phases::Backend, phases::Assemble, phases::Link) +TYPE("cir", CIR, INVALID, "cir", phases::Compile, phases::Backend, phases::Assemble, phases::Link) // Misc. TYPE("ast", AST, INVALID, "ast", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("ifs", IFS, INVALID, "ifs", phases::IfsMerge) diff --git a/clang/lib/Basic/LangStandards.cpp b/clang/lib/Basic/LangStandards.cpp index cb2c0772349982..c8c9292abcb22b 100644 --- a/clang/lib/Basic/LangStandards.cpp +++ b/clang/lib/Basic/LangStandards.cpp @@ -21,6 +21,8 @@ StringRef clang::languageToString(Language L) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "ClangIR"; case Language::C: return "C"; case Language::CXX: @@ -92,6 +94,7 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang, switch (Lang) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Invalid input kind!"); case Language::OpenCL: return LangStandard::lang_opencl12; diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp index 349b93e2a2326f..545860acb7db80 100644 --- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp +++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp @@ -208,6 +208,7 @@ StringRef getLanguageName(Language Lang) { case Language::Unknown: case Language::Asm: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Unsupported language kind"); } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 0df6a82ccd8933..7bd91d4791ecf0 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2757,6 +2757,9 @@ static void GenerateFrontendArgs(const FrontendOptions , case Language::HLSL: Lang = "hlsl"; break; +case Language::CIR: + Lang = "cir"; + break; } GenerateArg(Consumer, OPT_x, @@ -2958,6 +2961,7 @@ static bool ParseFrontendArgs(FrontendOptions , ArgList , .Cases("ast", "pcm", "precompiled-header", InputKind(Language::Unknown, InputKind::Precompiled)) .Case("ir", Language::LLVM_IR) + .Case("cir", Language::CIR) .Default(Language::Unknown); if (DashX.isUnknown()) @@ -3323,6 +3327,7 @@ static bool IsInputCompatibleWithStandard(InputKind IK, switch (IK.getLanguage()) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("should not parse language flags for this input"); case Language::C: @@ -3388,6 +3393,8 @@ static StringRef GetInputKindName(InputKind IK) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "Clang IR"; case Language::HLSL: return "HLSL"; @@
[llvm-branch-commits] [clang] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86072 >From 115f1dcca7b20dacdc5beef0e73819aef94f0ec1 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 03:24:54 + Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5 --- clang/include/clang/Basic/LangStandard.h| 1 + clang/include/clang/Driver/Types.def| 1 + clang/lib/Basic/LangStandards.cpp | 3 +++ .../Serialization/SymbolGraphSerializer.cpp | 1 + clang/lib/Frontend/CompilerInvocation.cpp | 13 +++-- clang/lib/Frontend/FrontendActions.cpp | 1 + clang/lib/Frontend/FrontendOptions.cpp | 1 + 7 files changed, 19 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/LangStandard.h b/clang/include/clang/Basic/LangStandard.h index 199e24c6731603..ed9572672f0563 100644 --- a/clang/include/clang/Basic/LangStandard.h +++ b/clang/include/clang/Basic/LangStandard.h @@ -41,6 +41,7 @@ enum class Language : uint8_t { RenderScript, HIP, HLSL, + CIR, ///@} }; StringRef languageToString(Language L); diff --git a/clang/include/clang/Driver/Types.def b/clang/include/clang/Driver/Types.def index f72c27e1ee7019..0e0cae5fb7068d 100644 --- a/clang/include/clang/Driver/Types.def +++ b/clang/include/clang/Driver/Types.def @@ -90,6 +90,7 @@ TYPE("ir", LLVM_BC, INVALID, "bc", phases TYPE("lto-ir", LTO_IR, INVALID, "s", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("lto-bc", LTO_BC, INVALID, "o", phases::Compile, phases::Backend, phases::Assemble, phases::Link) +TYPE("cir", CIR, INVALID, "cir", phases::Compile, phases::Backend, phases::Assemble, phases::Link) // Misc. TYPE("ast", AST, INVALID, "ast", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("ifs", IFS, INVALID, "ifs", phases::IfsMerge) diff --git a/clang/lib/Basic/LangStandards.cpp b/clang/lib/Basic/LangStandards.cpp index cb2c0772349982..c8c9292abcb22b 100644 --- a/clang/lib/Basic/LangStandards.cpp +++ b/clang/lib/Basic/LangStandards.cpp @@ -21,6 +21,8 @@ StringRef clang::languageToString(Language L) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "ClangIR"; case Language::C: return "C"; case Language::CXX: @@ -92,6 +94,7 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang, switch (Lang) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Invalid input kind!"); case Language::OpenCL: return LangStandard::lang_opencl12; diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp index 349b93e2a2326f..545860acb7db80 100644 --- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp +++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp @@ -208,6 +208,7 @@ StringRef getLanguageName(Language Lang) { case Language::Unknown: case Language::Asm: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Unsupported language kind"); } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 0df6a82ccd8933..7bd91d4791ecf0 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2757,6 +2757,9 @@ static void GenerateFrontendArgs(const FrontendOptions , case Language::HLSL: Lang = "hlsl"; break; +case Language::CIR: + Lang = "cir"; + break; } GenerateArg(Consumer, OPT_x, @@ -2958,6 +2961,7 @@ static bool ParseFrontendArgs(FrontendOptions , ArgList , .Cases("ast", "pcm", "precompiled-header", InputKind(Language::Unknown, InputKind::Precompiled)) .Case("ir", Language::LLVM_IR) + .Case("cir", Language::CIR) .Default(Language::Unknown); if (DashX.isUnknown()) @@ -3323,6 +3327,7 @@ static bool IsInputCompatibleWithStandard(InputKind IK, switch (IK.getLanguage()) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("should not parse language flags for this input"); case Language::C: @@ -3388,6 +3393,8 @@ static StringRef GetInputKindName(InputKind IK) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "Clang IR"; case Language::HLSL: return "HLSL"; @@
[llvm-branch-commits] [clang] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)
lanza wrote: > Could you remove the commit-id line from the commit message, as it doesn’t > seem relevant? That's [spr](https://github.com/getcord/spr)'s bookkeeping. It doesn't make it into the final commit. https://github.com/llvm/llvm-project/pull/86072 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/2] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/2] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/2] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/2] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86078 >From 0118187ba99172c6d892e4a05596085c0e637eb9 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:09:56 + Subject: [PATCH] add lit usage Created using spr 1.3.5 --- clang/test/lit.site.cfg.py.in | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index ef75770a2c3c9a..6641811c588395 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@ config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@" config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@ +config.clang_enable_cir = @CLANG_ENABLE_CIR@ config.clang_examples = @CLANG_BUILD_EXAMPLES@ config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86078 >From 0118187ba99172c6d892e4a05596085c0e637eb9 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:09:56 + Subject: [PATCH] add lit usage Created using spr 1.3.5 --- clang/test/lit.site.cfg.py.in | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index ef75770a2c3c9a..6641811c588395 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@ config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@" config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@ +config.clang_enable_cir = @CLANG_ENABLE_CIR@ config.clang_examples = @CLANG_BUILD_EXAMPLES@ config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86072 >From 115f1dcca7b20dacdc5beef0e73819aef94f0ec1 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 03:24:54 + Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5 --- clang/include/clang/Basic/LangStandard.h| 1 + clang/include/clang/Driver/Types.def| 1 + clang/lib/Basic/LangStandards.cpp | 3 +++ .../Serialization/SymbolGraphSerializer.cpp | 1 + clang/lib/Frontend/CompilerInvocation.cpp | 13 +++-- clang/lib/Frontend/FrontendActions.cpp | 1 + clang/lib/Frontend/FrontendOptions.cpp | 1 + 7 files changed, 19 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/LangStandard.h b/clang/include/clang/Basic/LangStandard.h index 199e24c6731603..ed9572672f0563 100644 --- a/clang/include/clang/Basic/LangStandard.h +++ b/clang/include/clang/Basic/LangStandard.h @@ -41,6 +41,7 @@ enum class Language : uint8_t { RenderScript, HIP, HLSL, + CIR, ///@} }; StringRef languageToString(Language L); diff --git a/clang/include/clang/Driver/Types.def b/clang/include/clang/Driver/Types.def index f72c27e1ee7019..0e0cae5fb7068d 100644 --- a/clang/include/clang/Driver/Types.def +++ b/clang/include/clang/Driver/Types.def @@ -90,6 +90,7 @@ TYPE("ir", LLVM_BC, INVALID, "bc", phases TYPE("lto-ir", LTO_IR, INVALID, "s", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("lto-bc", LTO_BC, INVALID, "o", phases::Compile, phases::Backend, phases::Assemble, phases::Link) +TYPE("cir", CIR, INVALID, "cir", phases::Compile, phases::Backend, phases::Assemble, phases::Link) // Misc. TYPE("ast", AST, INVALID, "ast", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("ifs", IFS, INVALID, "ifs", phases::IfsMerge) diff --git a/clang/lib/Basic/LangStandards.cpp b/clang/lib/Basic/LangStandards.cpp index cb2c0772349982..c8c9292abcb22b 100644 --- a/clang/lib/Basic/LangStandards.cpp +++ b/clang/lib/Basic/LangStandards.cpp @@ -21,6 +21,8 @@ StringRef clang::languageToString(Language L) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "ClangIR"; case Language::C: return "C"; case Language::CXX: @@ -92,6 +94,7 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang, switch (Lang) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Invalid input kind!"); case Language::OpenCL: return LangStandard::lang_opencl12; diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp index 349b93e2a2326f..545860acb7db80 100644 --- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp +++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp @@ -208,6 +208,7 @@ StringRef getLanguageName(Language Lang) { case Language::Unknown: case Language::Asm: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Unsupported language kind"); } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 0df6a82ccd8933..7bd91d4791ecf0 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2757,6 +2757,9 @@ static void GenerateFrontendArgs(const FrontendOptions , case Language::HLSL: Lang = "hlsl"; break; +case Language::CIR: + Lang = "cir"; + break; } GenerateArg(Consumer, OPT_x, @@ -2958,6 +2961,7 @@ static bool ParseFrontendArgs(FrontendOptions , ArgList , .Cases("ast", "pcm", "precompiled-header", InputKind(Language::Unknown, InputKind::Precompiled)) .Case("ir", Language::LLVM_IR) + .Case("cir", Language::CIR) .Default(Language::Unknown); if (DashX.isUnknown()) @@ -3323,6 +3327,7 @@ static bool IsInputCompatibleWithStandard(InputKind IK, switch (IK.getLanguage()) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("should not parse language flags for this input"); case Language::C: @@ -3388,6 +3393,8 @@ static StringRef GetInputKindName(InputKind IK) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "Clang IR"; case Language::HLSL: return "HLSL"; @@
[llvm-branch-commits] [clang] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86072 >From 115f1dcca7b20dacdc5beef0e73819aef94f0ec1 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 03:24:54 + Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5 --- clang/include/clang/Basic/LangStandard.h| 1 + clang/include/clang/Driver/Types.def| 1 + clang/lib/Basic/LangStandards.cpp | 3 +++ .../Serialization/SymbolGraphSerializer.cpp | 1 + clang/lib/Frontend/CompilerInvocation.cpp | 13 +++-- clang/lib/Frontend/FrontendActions.cpp | 1 + clang/lib/Frontend/FrontendOptions.cpp | 1 + 7 files changed, 19 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/LangStandard.h b/clang/include/clang/Basic/LangStandard.h index 199e24c6731603..ed9572672f0563 100644 --- a/clang/include/clang/Basic/LangStandard.h +++ b/clang/include/clang/Basic/LangStandard.h @@ -41,6 +41,7 @@ enum class Language : uint8_t { RenderScript, HIP, HLSL, + CIR, ///@} }; StringRef languageToString(Language L); diff --git a/clang/include/clang/Driver/Types.def b/clang/include/clang/Driver/Types.def index f72c27e1ee7019..0e0cae5fb7068d 100644 --- a/clang/include/clang/Driver/Types.def +++ b/clang/include/clang/Driver/Types.def @@ -90,6 +90,7 @@ TYPE("ir", LLVM_BC, INVALID, "bc", phases TYPE("lto-ir", LTO_IR, INVALID, "s", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("lto-bc", LTO_BC, INVALID, "o", phases::Compile, phases::Backend, phases::Assemble, phases::Link) +TYPE("cir", CIR, INVALID, "cir", phases::Compile, phases::Backend, phases::Assemble, phases::Link) // Misc. TYPE("ast", AST, INVALID, "ast", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("ifs", IFS, INVALID, "ifs", phases::IfsMerge) diff --git a/clang/lib/Basic/LangStandards.cpp b/clang/lib/Basic/LangStandards.cpp index cb2c0772349982..c8c9292abcb22b 100644 --- a/clang/lib/Basic/LangStandards.cpp +++ b/clang/lib/Basic/LangStandards.cpp @@ -21,6 +21,8 @@ StringRef clang::languageToString(Language L) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "ClangIR"; case Language::C: return "C"; case Language::CXX: @@ -92,6 +94,7 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang, switch (Lang) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Invalid input kind!"); case Language::OpenCL: return LangStandard::lang_opencl12; diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp index 349b93e2a2326f..545860acb7db80 100644 --- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp +++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp @@ -208,6 +208,7 @@ StringRef getLanguageName(Language Lang) { case Language::Unknown: case Language::Asm: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Unsupported language kind"); } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 0df6a82ccd8933..7bd91d4791ecf0 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2757,6 +2757,9 @@ static void GenerateFrontendArgs(const FrontendOptions , case Language::HLSL: Lang = "hlsl"; break; +case Language::CIR: + Lang = "cir"; + break; } GenerateArg(Consumer, OPT_x, @@ -2958,6 +2961,7 @@ static bool ParseFrontendArgs(FrontendOptions , ArgList , .Cases("ast", "pcm", "precompiled-header", InputKind(Language::Unknown, InputKind::Precompiled)) .Case("ir", Language::LLVM_IR) + .Case("cir", Language::CIR) .Default(Language::Unknown); if (DashX.isUnknown()) @@ -3323,6 +3327,7 @@ static bool IsInputCompatibleWithStandard(InputKind IK, switch (IK.getLanguage()) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("should not parse language flags for this input"); case Language::C: @@ -3388,6 +3393,8 @@ static StringRef GetInputKindName(InputKind IK) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "Clang IR"; case Language::HLSL: return "HLSL"; @@
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/2] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/2] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/2] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/2] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86078 >From 0118187ba99172c6d892e4a05596085c0e637eb9 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:09:56 + Subject: [PATCH] add lit usage Created using spr 1.3.5 --- clang/test/lit.site.cfg.py.in | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index ef75770a2c3c9a..6641811c588395 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@ config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@" config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@ +config.clang_enable_cir = @CLANG_ENABLE_CIR@ config.clang_examples = @CLANG_BUILD_EXAMPLES@ config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86078 >From 0118187ba99172c6d892e4a05596085c0e637eb9 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:09:56 + Subject: [PATCH] add lit usage Created using spr 1.3.5 --- clang/test/lit.site.cfg.py.in | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index ef75770a2c3c9a..6641811c588395 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@ config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@" config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@ +config.clang_enable_cir = @CLANG_ENABLE_CIR@ config.clang_examples = @CLANG_BUILD_EXAMPLES@ config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86072 >From 115f1dcca7b20dacdc5beef0e73819aef94f0ec1 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 03:24:54 + Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5 --- clang/include/clang/Basic/LangStandard.h| 1 + clang/include/clang/Driver/Types.def| 1 + clang/lib/Basic/LangStandards.cpp | 3 +++ .../Serialization/SymbolGraphSerializer.cpp | 1 + clang/lib/Frontend/CompilerInvocation.cpp | 13 +++-- clang/lib/Frontend/FrontendActions.cpp | 1 + clang/lib/Frontend/FrontendOptions.cpp | 1 + 7 files changed, 19 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/LangStandard.h b/clang/include/clang/Basic/LangStandard.h index 199e24c6731603..ed9572672f0563 100644 --- a/clang/include/clang/Basic/LangStandard.h +++ b/clang/include/clang/Basic/LangStandard.h @@ -41,6 +41,7 @@ enum class Language : uint8_t { RenderScript, HIP, HLSL, + CIR, ///@} }; StringRef languageToString(Language L); diff --git a/clang/include/clang/Driver/Types.def b/clang/include/clang/Driver/Types.def index f72c27e1ee7019..0e0cae5fb7068d 100644 --- a/clang/include/clang/Driver/Types.def +++ b/clang/include/clang/Driver/Types.def @@ -90,6 +90,7 @@ TYPE("ir", LLVM_BC, INVALID, "bc", phases TYPE("lto-ir", LTO_IR, INVALID, "s", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("lto-bc", LTO_BC, INVALID, "o", phases::Compile, phases::Backend, phases::Assemble, phases::Link) +TYPE("cir", CIR, INVALID, "cir", phases::Compile, phases::Backend, phases::Assemble, phases::Link) // Misc. TYPE("ast", AST, INVALID, "ast", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("ifs", IFS, INVALID, "ifs", phases::IfsMerge) diff --git a/clang/lib/Basic/LangStandards.cpp b/clang/lib/Basic/LangStandards.cpp index cb2c0772349982..c8c9292abcb22b 100644 --- a/clang/lib/Basic/LangStandards.cpp +++ b/clang/lib/Basic/LangStandards.cpp @@ -21,6 +21,8 @@ StringRef clang::languageToString(Language L) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "ClangIR"; case Language::C: return "C"; case Language::CXX: @@ -92,6 +94,7 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang, switch (Lang) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Invalid input kind!"); case Language::OpenCL: return LangStandard::lang_opencl12; diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp index 349b93e2a2326f..545860acb7db80 100644 --- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp +++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp @@ -208,6 +208,7 @@ StringRef getLanguageName(Language Lang) { case Language::Unknown: case Language::Asm: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Unsupported language kind"); } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 0df6a82ccd8933..7bd91d4791ecf0 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2757,6 +2757,9 @@ static void GenerateFrontendArgs(const FrontendOptions , case Language::HLSL: Lang = "hlsl"; break; +case Language::CIR: + Lang = "cir"; + break; } GenerateArg(Consumer, OPT_x, @@ -2958,6 +2961,7 @@ static bool ParseFrontendArgs(FrontendOptions , ArgList , .Cases("ast", "pcm", "precompiled-header", InputKind(Language::Unknown, InputKind::Precompiled)) .Case("ir", Language::LLVM_IR) + .Case("cir", Language::CIR) .Default(Language::Unknown); if (DashX.isUnknown()) @@ -3323,6 +3327,7 @@ static bool IsInputCompatibleWithStandard(InputKind IK, switch (IK.getLanguage()) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("should not parse language flags for this input"); case Language::C: @@ -3388,6 +3393,8 @@ static StringRef GetInputKindName(InputKind IK) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "Clang IR"; case Language::HLSL: return "HLSL"; @@
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH 1/2] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS >From fe44284534be0752d95634251289a5c74c06afe7 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:12:26 + Subject: [PATCH 2/2] add some guts to CIRDialect.cpp and MLIRCIR lib Created using spr 1.3.5 --- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 11 +++ clang/lib/CIR/Dialect/IR/CMakeLists.txt | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index e69de29bb2d1d6..8abf39119e04f7 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -0,0 +1,11 @@ +//===- CIRDialect.cpp - MLIR CIR ops implementation ---===// +// +// 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 file implements the CIR dialect and its operations. +// +//===--===// diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index e69de29bb2d1d6..0d7476b555705d 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -0,0 +1,3 @@ +add_clang_library(MLIRCIR + CIRDialect.cpp + ) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza edited https://github.com/llvm/llvm-project/pull/86080 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86072 >From 115f1dcca7b20dacdc5beef0e73819aef94f0ec1 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 03:24:54 + Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5 --- clang/include/clang/Basic/LangStandard.h| 1 + clang/include/clang/Driver/Types.def| 1 + clang/lib/Basic/LangStandards.cpp | 3 +++ .../Serialization/SymbolGraphSerializer.cpp | 1 + clang/lib/Frontend/CompilerInvocation.cpp | 13 +++-- clang/lib/Frontend/FrontendActions.cpp | 1 + clang/lib/Frontend/FrontendOptions.cpp | 1 + 7 files changed, 19 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Basic/LangStandard.h b/clang/include/clang/Basic/LangStandard.h index 199e24c6731603..ed9572672f0563 100644 --- a/clang/include/clang/Basic/LangStandard.h +++ b/clang/include/clang/Basic/LangStandard.h @@ -41,6 +41,7 @@ enum class Language : uint8_t { RenderScript, HIP, HLSL, + CIR, ///@} }; StringRef languageToString(Language L); diff --git a/clang/include/clang/Driver/Types.def b/clang/include/clang/Driver/Types.def index f72c27e1ee7019..0e0cae5fb7068d 100644 --- a/clang/include/clang/Driver/Types.def +++ b/clang/include/clang/Driver/Types.def @@ -90,6 +90,7 @@ TYPE("ir", LLVM_BC, INVALID, "bc", phases TYPE("lto-ir", LTO_IR, INVALID, "s", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("lto-bc", LTO_BC, INVALID, "o", phases::Compile, phases::Backend, phases::Assemble, phases::Link) +TYPE("cir", CIR, INVALID, "cir", phases::Compile, phases::Backend, phases::Assemble, phases::Link) // Misc. TYPE("ast", AST, INVALID, "ast", phases::Compile, phases::Backend, phases::Assemble, phases::Link) TYPE("ifs", IFS, INVALID, "ifs", phases::IfsMerge) diff --git a/clang/lib/Basic/LangStandards.cpp b/clang/lib/Basic/LangStandards.cpp index cb2c0772349982..c8c9292abcb22b 100644 --- a/clang/lib/Basic/LangStandards.cpp +++ b/clang/lib/Basic/LangStandards.cpp @@ -21,6 +21,8 @@ StringRef clang::languageToString(Language L) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "ClangIR"; case Language::C: return "C"; case Language::CXX: @@ -92,6 +94,7 @@ LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang, switch (Lang) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Invalid input kind!"); case Language::OpenCL: return LangStandard::lang_opencl12; diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp index 349b93e2a2326f..545860acb7db80 100644 --- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp +++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp @@ -208,6 +208,7 @@ StringRef getLanguageName(Language Lang) { case Language::Unknown: case Language::Asm: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("Unsupported language kind"); } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 0df6a82ccd8933..7bd91d4791ecf0 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2757,6 +2757,9 @@ static void GenerateFrontendArgs(const FrontendOptions , case Language::HLSL: Lang = "hlsl"; break; +case Language::CIR: + Lang = "cir"; + break; } GenerateArg(Consumer, OPT_x, @@ -2958,6 +2961,7 @@ static bool ParseFrontendArgs(FrontendOptions , ArgList , .Cases("ast", "pcm", "precompiled-header", InputKind(Language::Unknown, InputKind::Precompiled)) .Case("ir", Language::LLVM_IR) + .Case("cir", Language::CIR) .Default(Language::Unknown); if (DashX.isUnknown()) @@ -3323,6 +3327,7 @@ static bool IsInputCompatibleWithStandard(InputKind IK, switch (IK.getLanguage()) { case Language::Unknown: case Language::LLVM_IR: + case Language::CIR: llvm_unreachable("should not parse language flags for this input"); case Language::C: @@ -3388,6 +3393,8 @@ static StringRef GetInputKindName(InputKind IK) { return "Asm"; case Language::LLVM_IR: return "LLVM IR"; + case Language::CIR: +return "Clang IR"; case Language::HLSL: return "HLSL"; @@ -3403,7
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86080 >From 435869501bb0788d8b22d847c3a870dbfbf94126 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:57:16 + Subject: [PATCH] fix MLIRCIROpsIncGen Created using spr 1.3.5 --- .../clang/CIR/Dialect/IR/CIRDialect.td| 46 +++ clang/include/clang/CIR/Dialect/IR/CIROps.td | 18 2 files changed, 64 insertions(+) create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRDialect.td diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td new file mode 100644 index 00..8f756fa422e5f3 --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -0,0 +1,46 @@ +//===- CIRTypes.td - CIR dialect types -*- tablegen -*-===// +// +// 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 file declares the CIR dialect. +// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR +#define MLIR_CIR_DIALECT_CIR + +include "mlir/IR/OpBase.td" + +def CIR_Dialect : Dialect { + let name = "cir"; + + // A short one-line summary of our dialect. + let summary = "A high-level dialect for analyzing and optimizing Clang " +"supported languages"; + + let cppNamespace = "::mlir::cir"; + + let useDefaultAttributePrinterParser = 0; + let useDefaultTypePrinterParser = 0; + + let extraClassDeclaration = [{ +void registerAttributes(); +void registerTypes(); + +::mlir::Type parseType(::mlir::DialectAsmParser ) const override; +void printType(::mlir::Type type, + ::mlir::DialectAsmPrinter ) const override; + +::mlir::Attribute parseAttribute(::mlir::DialectAsmParser , + ::mlir::Type type) const override; + +void printAttribute(::mlir::Attribute attr, +::mlir::DialectAsmPrinter ) const override; + }]; +} + +#endif // MLIR_CIR_DIALECT_CIR diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index e69de29bb2d1d6..cfc62986b0b9d1 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -0,0 +1,18 @@ +//===-- CIROps.td - CIR dialect definition -*- tablegen -*-===// +// +// 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 +// +//===--===// +/// +/// \file +/// Definition of the CIR dialect +/// +//===--===// + +#ifndef MLIR_CIR_DIALECT_CIR_OPS +#define MLIR_CIR_DIALECT_CIR_OPS + +include "clang/CIR/Dialect/IR/CIRDialect.td" +#endif // MLIR_CIR_DIALECT_CIR_OPS ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza edited https://github.com/llvm/llvm-project/pull/86080 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza created https://github.com/llvm/llvm-project/pull/86080 This adds no real content, it just incrementally adds some scaffolding necessary to enable a future patch to just add our first few ops. ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86078 >From 0118187ba99172c6d892e4a05596085c0e637eb9 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:09:56 + Subject: [PATCH] add lit usage Created using spr 1.3.5 --- clang/test/lit.site.cfg.py.in | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index ef75770a2c3c9a..6641811c588395 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@ config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@" config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@ +config.clang_enable_cir = @CLANG_ENABLE_CIR@ config.clang_examples = @CLANG_BUILD_EXAMPLES@ config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)
https://github.com/lanza edited https://github.com/llvm/llvm-project/pull/86072 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/86078 >From 0118187ba99172c6d892e4a05596085c0e637eb9 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 04:09:56 + Subject: [PATCH] add lit usage Created using spr 1.3.5 --- clang/test/lit.site.cfg.py.in | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index ef75770a2c3c9a..6641811c588395 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -27,6 +27,7 @@ config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@ config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@" config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@ +config.clang_enable_cir = @CLANG_ENABLE_CIR@ config.clang_examples = @CLANG_BUILD_EXAMPLES@ config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)
https://github.com/lanza created https://github.com/llvm/llvm-project/pull/86078 Introduce a cmake variable that guards the inclusion of ClangIR into the build of clang. Guard that we aren't trying to build without MLIR. Add two subdirectories that, as of now, don't do anything. ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 75f10c9 - NFC: Remove simple_ilist comment mentioning ilist/iplist allocating
Author: Nathan Lanza Date: 2021-01-22T03:24:54-05:00 New Revision: 75f10c957477b269d9b954a686231342aeb8004b URL: https://github.com/llvm/llvm-project/commit/75f10c957477b269d9b954a686231342aeb8004b DIFF: https://github.com/llvm/llvm-project/commit/75f10c957477b269d9b954a686231342aeb8004b.diff LOG: NFC: Remove simple_ilist comment mentioning ilist/iplist allocating Allocation was removed from ilist in 2016 in the git commit b5da00533510. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D93953 Added: Modified: llvm/include/llvm/ADT/simple_ilist.h Removed: diff --git a/llvm/include/llvm/ADT/simple_ilist.h b/llvm/include/llvm/ADT/simple_ilist.h index d5ae20cd455ba..d4b6be3472191 100644 --- a/llvm/include/llvm/ADT/simple_ilist.h +++ b/llvm/include/llvm/ADT/simple_ilist.h @@ -28,8 +28,8 @@ namespace llvm { /// This is a simple intrusive list for a \c T that inherits from \c /// ilist_node. The list never takes ownership of anything inserted in it. /// -/// Unlike \a iplist and \a ilist, \a simple_ilist never allocates or -/// deletes values, and has no callback traits. +/// Unlike \a iplist and \a ilist, \a simple_ilist never deletes +/// values, and has no callback traits. /// /// The API for adding nodes include \a push_front(), \a push_back(), and \a /// insert(). These all take values by reference (not by pointer), except for ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 54971c3 - [llvm] Update WinMsvc.cmake's fms-compatability to match llvm's prereqs
Author: Nathan Lanza Date: 2020-12-04T16:35:05-08:00 New Revision: 54971c3a75594a7055efbad22923e581e6e4e7f7 URL: https://github.com/llvm/llvm-project/commit/54971c3a75594a7055efbad22923e581e6e4e7f7 DIFF: https://github.com/llvm/llvm-project/commit/54971c3a75594a7055efbad22923e581e6e4e7f7.diff LOG: [llvm] Update WinMsvc.cmake's fms-compatability to match llvm's prereqs llvm's minimum fms-compatability-version was just bumped to 19.14 and thus the WinMsvc.cmake file needs to be adjusted accordingly. Added: Modified: llvm/cmake/platforms/WinMsvc.cmake Removed: diff --git a/llvm/cmake/platforms/WinMsvc.cmake b/llvm/cmake/platforms/WinMsvc.cmake index 4a6bef2e01cc..b538d65f0f81 100644 --- a/llvm/cmake/platforms/WinMsvc.cmake +++ b/llvm/cmake/platforms/WinMsvc.cmake @@ -248,7 +248,7 @@ set(CROSS_TOOLCHAIN_FLAGS_NATIVE "${_CTF_NATIVE_DEFAULT}" CACHE STRING "") set(COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS --target=${TRIPLE_ARCH}-windows-msvc --fms-compatibility-version=19.11 +-fms-compatibility-version=19.14 -imsvc "${ATLMFC_INCLUDE}" -imsvc "${MSVC_INCLUDE}" -imsvc "${WINSDK_INCLUDE}/ucrt" ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits