[clang] [CIR] Call code gen; create empty cir.func op (PR #113483)
https://github.com/lanza approved this pull request. https://github.com/llvm/llvm-project/pull/113483 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Call code gen; create empty cir.func op (PR #113483)
@@ -31,9 +34,14 @@ void CIRGenerator::Initialize(ASTContext &astCtx) { this->astCtx = &astCtx; - cgm = std::make_unique(*mlirCtx, astCtx, codeGenOpts, diags); + mlirCtx = std::make_unique(); + mlirCtx->getOrLoadDialect(); lanza wrote: There's a `loadDialect` equivalent that we can switch to. https://github.com/llvm/llvm-project/pull/113483 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)
https://github.com/lanza closed https://github.com/llvm/llvm-project/pull/91007 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/91007 >From 17c81f79ede403e63010a39622d61937fcf898b4 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Fri, 3 May 2024 20:19:45 + Subject: [PATCH 1/5] =?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/CIR/CIRGenerator.h| 59 + .../clang/CIRFrontendAction/CIRGenAction.h| 61 + clang/include/clang/Driver/Options.td | 2 +- clang/lib/CIR/CMakeLists.txt | 2 + clang/lib/CIR/CodeGen/CIRGenModule.cpp| 35 clang/lib/CIR/CodeGen/CIRGenModule.h | 61 + clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 27 ++ clang/lib/CIR/CodeGen/CIRGenerator.cpp| 46 ++ clang/lib/CIR/CodeGen/CMakeLists.txt | 23 + clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 88 +++ clang/lib/CIR/FrontendAction/CMakeLists.txt | 17 clang/lib/Driver/ToolChains/Clang.cpp | 3 + clang/lib/FrontendTool/CMakeLists.txt | 15 .../ExecuteCompilerInvocation.cpp | 18 clang/test/CIR/hello.c| 4 + clang/test/CIR/lit.local.cfg | 2 + 16 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 clang/include/clang/CIR/CIRGenerator.h create mode 100644 clang/include/clang/CIRFrontendAction/CIRGenAction.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.cpp create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenTypeCache.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenerator.cpp create mode 100644 clang/lib/CIR/CodeGen/CMakeLists.txt create mode 100644 clang/lib/CIR/FrontendAction/CIRGenAction.cpp create mode 100644 clang/lib/CIR/FrontendAction/CMakeLists.txt create mode 100644 clang/test/CIR/hello.c create mode 100644 clang/test/CIR/lit.local.cfg diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h new file mode 100644 index 00..c9505d2473b437 --- /dev/null +++ b/clang/include/clang/CIR/CIRGenerator.h @@ -0,0 +1,59 @@ +//===- CIRGenerator.h - CIR Generation from Clang AST -===// +// +// 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 a simple interface to perform CIR generation from Clang +// AST +// +//===--===// + +#ifndef CLANG_CIRGENERATOR_H_ +#define CLANG_CIRGENERATOR_H_ + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/DeclGroup.h" +#include "clang/Basic/CodeGenOptions.h" +#include "clang/Basic/Diagnostic.h" + +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/Support/VirtualFileSystem.h" + +#include + +namespace mlir { +class MLIRContext; +} // namespace mlir +namespace cir { +class CIRGenModule; + +class CIRGenerator : public clang::ASTConsumer { + virtual void anchor(); + clang::DiagnosticsEngine &Diags; + clang::ASTContext *astCtx; + llvm::IntrusiveRefCntPtr + fs; // Only used for debug info. + + const clang::CodeGenOptions codeGenOpts; // Intentionally copied in. + + [[maybe_unused]] unsigned HandlingTopLevelDecls; + +protected: + std::unique_ptr mlirCtx; + std::unique_ptr CGM; + +public: + CIRGenerator(clang::DiagnosticsEngine &diags, + llvm::IntrusiveRefCntPtr FS, + const clang::CodeGenOptions &CGO); + ~CIRGenerator(); + void Initialize(clang::ASTContext &Context) override; + bool HandleTopLevelDecl(clang::DeclGroupRef D) override; +}; + +} // namespace cir + +#endif // CLANG_CIRGENERATOR_H_ diff --git a/clang/include/clang/CIRFrontendAction/CIRGenAction.h b/clang/include/clang/CIRFrontendAction/CIRGenAction.h new file mode 100644 index 00..aaf73ec2bffc47 --- /dev/null +++ b/clang/include/clang/CIRFrontendAction/CIRGenAction.h @@ -0,0 +1,61 @@ +//=== CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_CIR_CIRGENACTION_H +#define LLVM_CLANG_CIR_CIRGENACTION_H + +#include "clang/Frontend/FrontendAction.h" + +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/OwningOpRef.h" + +namespace mlir { +class MLIRContext; +class ModuleOp; +} // namespace mlir + +namespace cir { +class CIRGe
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #111732)
https://github.com/lanza closed https://github.com/llvm/llvm-project/pull/111732 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #111732)
https://github.com/lanza created https://github.com/llvm/llvm-project/pull/111732 Build out the necessary infrastructure for the main entry point into ClangIR generation -- CIRGenModule. A set of boilerplate classes exist to facilitate this -- CIRGenerator, CIRGenAction, EmitCIRAction and CIRGenConsumer. These all mirror the corresponding types from LLVM generation by Clang's CodeGen. The main entry point to CIR generation is `CIRGenModule::buildTopLevelDecl`. It is currently just an empty function. We've added a test to ensure that the pipeline reaches this point and doesn't fail, but does nothing else. This will be removed in one of the subsequent patches that'll add basic `cir.func` emission. This patch also re-adds `-emit-cir` to the driver. lib/Driver/Driver.cpp requires that a driver flag exists to facilirate the selection of the right actions for the driver to create. Without a driver flag you get the standard behaviors of `-S`, `-c`, etc. If we want to emit CIR IR and, eventually, bytecode we'll need a driver flag to force this. This is why `-emit-llvm` is a driver flag. Notably, `-emit-llvm-bc` as a cc1 flag doesn't ever do the right thing. Without a driver flag it is incorrectly ignored and an executable is emitted. With `-S` a file named `something.s` is emitted which actually contains bitcode. >From 02030cfb6b11257da948d65d1efa03401f5eda94 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Wed, 9 Oct 2024 14:14:40 -0400 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/CIR/CIRGenerator.h| 60 .../clang/CIR/FrontendAction/CIRGenAction.h | 60 clang/include/clang/Driver/Options.td | 2 +- clang/lib/CIR/CMakeLists.txt | 2 + clang/lib/CIR/CodeGen/CIRGenModule.cpp| 32 + clang/lib/CIR/CodeGen/CIRGenModule.h | 62 clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 27 +++ clang/lib/CIR/CodeGen/CIRGenerator.cpp| 43 +++ clang/lib/CIR/CodeGen/CMakeLists.txt | 23 ++ clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 72 +++ clang/lib/CIR/FrontendAction/CMakeLists.txt | 17 + clang/lib/Driver/ToolChains/Clang.cpp | 3 + clang/lib/FrontendTool/CMakeLists.txt | 15 .../ExecuteCompilerInvocation.cpp | 16 + clang/test/CIR/hello.c| 5 ++ clang/test/CIR/lit.local.cfg | 2 + 16 files changed, 440 insertions(+), 1 deletion(-) create mode 100644 clang/include/clang/CIR/CIRGenerator.h create mode 100644 clang/include/clang/CIR/FrontendAction/CIRGenAction.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.cpp create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenTypeCache.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenerator.cpp create mode 100644 clang/lib/CIR/CodeGen/CMakeLists.txt create mode 100644 clang/lib/CIR/FrontendAction/CIRGenAction.cpp create mode 100644 clang/lib/CIR/FrontendAction/CMakeLists.txt create mode 100644 clang/test/CIR/hello.c create mode 100644 clang/test/CIR/lit.local.cfg diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h new file mode 100644 index 00..9a8930ac46ea9c --- /dev/null +++ b/clang/include/clang/CIR/CIRGenerator.h @@ -0,0 +1,60 @@ +//===- CIRGenerator.h - CIR Generation from Clang AST -===// +// +// 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 a simple interface to perform CIR generation from Clang +// AST +// +//===--===// + +#ifndef LLVM_CLANG_CIR_CIRGENERATOR_H +#define LLVM_CLANG_CIR_CIRGENERATOR_H + +#include "clang/AST/ASTConsumer.h" +#include "clang/Basic/CodeGenOptions.h" + +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/Support/VirtualFileSystem.h" + +#include + +namespace clang { +class DeclGroupRef; +class DiagnosticsEngine; +} // namespace clang + +namespace mlir { +class MLIRContext; +} // namespace mlir +namespace cir { +class CIRGenModule; + +class CIRGenerator : public clang::ASTConsumer { + virtual void anchor(); + clang::DiagnosticsEngine &diags; + clang::ASTContext *astCtx; + // Only used for debug info. + llvm::IntrusiveRefCntPtr fs; + + const clang::CodeGenOptions &codeGenOpts; + +protected: + std::unique_ptr mlirCtx; + std::unique_ptr cgm; + +public: + CIRGenerator(clang::DiagnosticsEngine &diags, + llvm::IntrusiveR
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)
lanza wrote: @AaronBallman any gripes with moving forward and landing this after a month? https://github.com/llvm/llvm-project/pull/91007 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Add .clang-tidy files for ClangIR specific coding style rules (PR #111417)
https://github.com/lanza closed https://github.com/llvm/llvm-project/pull/111417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Add .clang-tidy files for ClangIR specific coding style rules (PR #111417)
lanza wrote: > I am not familiar with how clang-tidy works. (I expect that will have to > change and I should start using it.) So I can't meaningfully review this. If you use clangd then the clang-tidy based warnings will just show up in your editor. These files are just enforcing the ClangIR specific rules. https://github.com/llvm/llvm-project/pull/111417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Add .clang-tidy files for ClangIR specific coding style rules (PR #111417)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/111417 >From 68b7427f371db198a1dc69c36c39192f2f9ab6a9 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Mon, 7 Oct 2024 18:27:46 + 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/CIR/.clang-tidy | 61 +++ .../clang/CIRFrontendAction/.clang-tidy | 52 clang/lib/CIR/.clang-tidy | 61 +++ 3 files changed, 174 insertions(+) create mode 100644 clang/include/clang/CIR/.clang-tidy create mode 100644 clang/include/clang/CIRFrontendAction/.clang-tidy create mode 100644 clang/lib/CIR/.clang-tidy diff --git a/clang/include/clang/CIR/.clang-tidy b/clang/include/clang/CIR/.clang-tidy new file mode 100644 index 00..dfbcf9ccf7c217 --- /dev/null +++ b/clang/include/clang/CIR/.clang-tidy @@ -0,0 +1,61 @@ +InheritParentConfig: true +Checks: > +-misc-const-correctness, +bugprone-argument-comment, +bugprone-assert-side-effect, +bugprone-branch-clone, +bugprone-copy-constructor-init, +bugprone-dangling-handle, +bugprone-dynamic-static-initializers, +bugprone-macro-parentheses, +bugprone-macro-repeated-side-effects, +bugprone-misplaced-widening-cast, +bugprone-move-forwarding-reference, +bugprone-multiple-statement-macro, +bugprone-suspicious-semicolon, +bugprone-swapped-arguments, +bugprone-terminating-continue, +bugprone-unused-raii, +bugprone-unused-return-value, +misc-redundant-expression, +misc-static-assert, +misc-unused-using-decls, +modernize-use-bool-literals, +modernize-loop-convert, +modernize-make-unique, +modernize-raw-string-literal, +modernize-use-equals-default, +modernize-use-default-member-init, +modernize-use-emplace, +modernize-use-nullptr, +modernize-use-override, +modernize-use-using, +performance-for-range-copy, +performance-implicit-conversion-in-loop, +performance-inefficient-algorithm, +performance-inefficient-vector-operation, +performance-move-const-arg, +performance-no-automatic-move, +performance-trivially-destructible, +performance-unnecessary-copy-initialization, +performance-unnecessary-value-param, +readability-avoid-const-params-in-decls, +readability-const-return-type, +readability-container-size-empty, +readability-identifier-naming, +readability-inconsistent-declaration-parameter-name, +readability-misleading-indentation, +readability-redundant-control-flow, +readability-redundant-smartptr-get, +readability-simplify-boolean-expr, +readability-simplify-subscript-expr, +readability-use-anyofallof + + +CheckOptions: + - key: readability-identifier-naming.MemberCase +value: camelBack + - key: readability-identifier-naming.ParameterCase +value: camelBack + - key: readability-identifier-naming.VariableCase +value: camelBack diff --git a/clang/include/clang/CIRFrontendAction/.clang-tidy b/clang/include/clang/CIRFrontendAction/.clang-tidy new file mode 100644 index 00..ffcc0a2903fe32 --- /dev/null +++ b/clang/include/clang/CIRFrontendAction/.clang-tidy @@ -0,0 +1,52 @@ +InheritParentConfig: true +Checks: > +-misc-const-correctness, +bugprone-argument-comment, +bugprone-assert-side-effect, +bugprone-branch-clone, +bugprone-copy-constructor-init, +bugprone-dangling-handle, +bugprone-dynamic-static-initializers, +bugprone-macro-parentheses, +bugprone-macro-repeated-side-effects, +bugprone-misplaced-widening-cast, +bugprone-move-forwarding-reference, +bugprone-multiple-statement-macro, +bugprone-suspicious-semicolon, +bugprone-swapped-arguments, +bugprone-terminating-continue, +bugprone-unused-raii, +bugprone-unused-return-value, +misc-redundant-expression, +misc-static-assert, +misc-unused-using-decls, +modernize-use-bool-literals, +modernize-loop-convert, +modernize-make-unique, +modernize-raw-string-literal, +modernize-use-equals-default, +modernize-use-default-member-init, +modernize-use-emplace, +modernize-use-nullptr, +modernize-use-override, +modernize-use-using, +performance-for-range-copy, +performance-implicit-conversion-in-loop, +performance-inefficient-algorithm, +
[clang] [CIR] Add .clang-tidy files for ClangIR specific coding style rules (PR #111417)
https://github.com/lanza created https://github.com/llvm/llvm-project/pull/111417 https://llvm.github.io/clangir/GettingStarted/coding-guideline.html >From 68b7427f371db198a1dc69c36c39192f2f9ab6a9 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Mon, 7 Oct 2024 18:27:46 + 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/CIR/.clang-tidy | 61 +++ .../clang/CIRFrontendAction/.clang-tidy | 52 clang/lib/CIR/.clang-tidy | 61 +++ 3 files changed, 174 insertions(+) create mode 100644 clang/include/clang/CIR/.clang-tidy create mode 100644 clang/include/clang/CIRFrontendAction/.clang-tidy create mode 100644 clang/lib/CIR/.clang-tidy diff --git a/clang/include/clang/CIR/.clang-tidy b/clang/include/clang/CIR/.clang-tidy new file mode 100644 index 00..dfbcf9ccf7c217 --- /dev/null +++ b/clang/include/clang/CIR/.clang-tidy @@ -0,0 +1,61 @@ +InheritParentConfig: true +Checks: > +-misc-const-correctness, +bugprone-argument-comment, +bugprone-assert-side-effect, +bugprone-branch-clone, +bugprone-copy-constructor-init, +bugprone-dangling-handle, +bugprone-dynamic-static-initializers, +bugprone-macro-parentheses, +bugprone-macro-repeated-side-effects, +bugprone-misplaced-widening-cast, +bugprone-move-forwarding-reference, +bugprone-multiple-statement-macro, +bugprone-suspicious-semicolon, +bugprone-swapped-arguments, +bugprone-terminating-continue, +bugprone-unused-raii, +bugprone-unused-return-value, +misc-redundant-expression, +misc-static-assert, +misc-unused-using-decls, +modernize-use-bool-literals, +modernize-loop-convert, +modernize-make-unique, +modernize-raw-string-literal, +modernize-use-equals-default, +modernize-use-default-member-init, +modernize-use-emplace, +modernize-use-nullptr, +modernize-use-override, +modernize-use-using, +performance-for-range-copy, +performance-implicit-conversion-in-loop, +performance-inefficient-algorithm, +performance-inefficient-vector-operation, +performance-move-const-arg, +performance-no-automatic-move, +performance-trivially-destructible, +performance-unnecessary-copy-initialization, +performance-unnecessary-value-param, +readability-avoid-const-params-in-decls, +readability-const-return-type, +readability-container-size-empty, +readability-identifier-naming, +readability-inconsistent-declaration-parameter-name, +readability-misleading-indentation, +readability-redundant-control-flow, +readability-redundant-smartptr-get, +readability-simplify-boolean-expr, +readability-simplify-subscript-expr, +readability-use-anyofallof + + +CheckOptions: + - key: readability-identifier-naming.MemberCase +value: camelBack + - key: readability-identifier-naming.ParameterCase +value: camelBack + - key: readability-identifier-naming.VariableCase +value: camelBack diff --git a/clang/include/clang/CIRFrontendAction/.clang-tidy b/clang/include/clang/CIRFrontendAction/.clang-tidy new file mode 100644 index 00..ffcc0a2903fe32 --- /dev/null +++ b/clang/include/clang/CIRFrontendAction/.clang-tidy @@ -0,0 +1,52 @@ +InheritParentConfig: true +Checks: > +-misc-const-correctness, +bugprone-argument-comment, +bugprone-assert-side-effect, +bugprone-branch-clone, +bugprone-copy-constructor-init, +bugprone-dangling-handle, +bugprone-dynamic-static-initializers, +bugprone-macro-parentheses, +bugprone-macro-repeated-side-effects, +bugprone-misplaced-widening-cast, +bugprone-move-forwarding-reference, +bugprone-multiple-statement-macro, +bugprone-suspicious-semicolon, +bugprone-swapped-arguments, +bugprone-terminating-continue, +bugprone-unused-raii, +bugprone-unused-return-value, +misc-redundant-expression, +misc-static-assert, +misc-unused-using-decls, +modernize-use-bool-literals, +modernize-loop-convert, +modernize-make-unique, +modernize-raw-string-literal, +modernize-use-equals-default, +modernize-use-default-member-init, +modernize-use-emplace, +modernize-use-nullptr, +modernize-use-override, +modernize-use-using, +performance-for-range-copy, +performance-implicit-conver
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/91007 >From 17c81f79ede403e63010a39622d61937fcf898b4 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Fri, 3 May 2024 20:19:45 + Subject: [PATCH 1/5] =?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/CIR/CIRGenerator.h| 59 + .../clang/CIRFrontendAction/CIRGenAction.h| 61 + clang/include/clang/Driver/Options.td | 2 +- clang/lib/CIR/CMakeLists.txt | 2 + clang/lib/CIR/CodeGen/CIRGenModule.cpp| 35 clang/lib/CIR/CodeGen/CIRGenModule.h | 61 + clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 27 ++ clang/lib/CIR/CodeGen/CIRGenerator.cpp| 46 ++ clang/lib/CIR/CodeGen/CMakeLists.txt | 23 + clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 88 +++ clang/lib/CIR/FrontendAction/CMakeLists.txt | 17 clang/lib/Driver/ToolChains/Clang.cpp | 3 + clang/lib/FrontendTool/CMakeLists.txt | 15 .../ExecuteCompilerInvocation.cpp | 18 clang/test/CIR/hello.c| 4 + clang/test/CIR/lit.local.cfg | 2 + 16 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 clang/include/clang/CIR/CIRGenerator.h create mode 100644 clang/include/clang/CIRFrontendAction/CIRGenAction.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.cpp create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenTypeCache.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenerator.cpp create mode 100644 clang/lib/CIR/CodeGen/CMakeLists.txt create mode 100644 clang/lib/CIR/FrontendAction/CIRGenAction.cpp create mode 100644 clang/lib/CIR/FrontendAction/CMakeLists.txt create mode 100644 clang/test/CIR/hello.c create mode 100644 clang/test/CIR/lit.local.cfg diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h new file mode 100644 index 00..c9505d2473b437 --- /dev/null +++ b/clang/include/clang/CIR/CIRGenerator.h @@ -0,0 +1,59 @@ +//===- CIRGenerator.h - CIR Generation from Clang AST -===// +// +// 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 a simple interface to perform CIR generation from Clang +// AST +// +//===--===// + +#ifndef CLANG_CIRGENERATOR_H_ +#define CLANG_CIRGENERATOR_H_ + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/DeclGroup.h" +#include "clang/Basic/CodeGenOptions.h" +#include "clang/Basic/Diagnostic.h" + +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/Support/VirtualFileSystem.h" + +#include + +namespace mlir { +class MLIRContext; +} // namespace mlir +namespace cir { +class CIRGenModule; + +class CIRGenerator : public clang::ASTConsumer { + virtual void anchor(); + clang::DiagnosticsEngine &Diags; + clang::ASTContext *astCtx; + llvm::IntrusiveRefCntPtr + fs; // Only used for debug info. + + const clang::CodeGenOptions codeGenOpts; // Intentionally copied in. + + [[maybe_unused]] unsigned HandlingTopLevelDecls; + +protected: + std::unique_ptr mlirCtx; + std::unique_ptr CGM; + +public: + CIRGenerator(clang::DiagnosticsEngine &diags, + llvm::IntrusiveRefCntPtr FS, + const clang::CodeGenOptions &CGO); + ~CIRGenerator(); + void Initialize(clang::ASTContext &Context) override; + bool HandleTopLevelDecl(clang::DeclGroupRef D) override; +}; + +} // namespace cir + +#endif // CLANG_CIRGENERATOR_H_ diff --git a/clang/include/clang/CIRFrontendAction/CIRGenAction.h b/clang/include/clang/CIRFrontendAction/CIRGenAction.h new file mode 100644 index 00..aaf73ec2bffc47 --- /dev/null +++ b/clang/include/clang/CIRFrontendAction/CIRGenAction.h @@ -0,0 +1,61 @@ +//=== CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_CIR_CIRGENACTION_H +#define LLVM_CLANG_CIR_CIRGENACTION_H + +#include "clang/Frontend/FrontendAction.h" + +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/OwningOpRef.h" + +namespace mlir { +class MLIRContext; +class ModuleOp; +} // namespace mlir + +namespace cir { +class CIRGe
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/91007 >From 17c81f79ede403e63010a39622d61937fcf898b4 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Fri, 3 May 2024 20:19:45 + Subject: [PATCH 1/5] =?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/CIR/CIRGenerator.h| 59 + .../clang/CIRFrontendAction/CIRGenAction.h| 61 + clang/include/clang/Driver/Options.td | 2 +- clang/lib/CIR/CMakeLists.txt | 2 + clang/lib/CIR/CodeGen/CIRGenModule.cpp| 35 clang/lib/CIR/CodeGen/CIRGenModule.h | 61 + clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 27 ++ clang/lib/CIR/CodeGen/CIRGenerator.cpp| 46 ++ clang/lib/CIR/CodeGen/CMakeLists.txt | 23 + clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 88 +++ clang/lib/CIR/FrontendAction/CMakeLists.txt | 17 clang/lib/Driver/ToolChains/Clang.cpp | 3 + clang/lib/FrontendTool/CMakeLists.txt | 15 .../ExecuteCompilerInvocation.cpp | 18 clang/test/CIR/hello.c| 4 + clang/test/CIR/lit.local.cfg | 2 + 16 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 clang/include/clang/CIR/CIRGenerator.h create mode 100644 clang/include/clang/CIRFrontendAction/CIRGenAction.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.cpp create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenTypeCache.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenerator.cpp create mode 100644 clang/lib/CIR/CodeGen/CMakeLists.txt create mode 100644 clang/lib/CIR/FrontendAction/CIRGenAction.cpp create mode 100644 clang/lib/CIR/FrontendAction/CMakeLists.txt create mode 100644 clang/test/CIR/hello.c create mode 100644 clang/test/CIR/lit.local.cfg diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h new file mode 100644 index 0..c9505d2473b43 --- /dev/null +++ b/clang/include/clang/CIR/CIRGenerator.h @@ -0,0 +1,59 @@ +//===- CIRGenerator.h - CIR Generation from Clang AST -===// +// +// 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 a simple interface to perform CIR generation from Clang +// AST +// +//===--===// + +#ifndef CLANG_CIRGENERATOR_H_ +#define CLANG_CIRGENERATOR_H_ + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/DeclGroup.h" +#include "clang/Basic/CodeGenOptions.h" +#include "clang/Basic/Diagnostic.h" + +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/Support/VirtualFileSystem.h" + +#include + +namespace mlir { +class MLIRContext; +} // namespace mlir +namespace cir { +class CIRGenModule; + +class CIRGenerator : public clang::ASTConsumer { + virtual void anchor(); + clang::DiagnosticsEngine &Diags; + clang::ASTContext *astCtx; + llvm::IntrusiveRefCntPtr + fs; // Only used for debug info. + + const clang::CodeGenOptions codeGenOpts; // Intentionally copied in. + + [[maybe_unused]] unsigned HandlingTopLevelDecls; + +protected: + std::unique_ptr mlirCtx; + std::unique_ptr CGM; + +public: + CIRGenerator(clang::DiagnosticsEngine &diags, + llvm::IntrusiveRefCntPtr FS, + const clang::CodeGenOptions &CGO); + ~CIRGenerator(); + void Initialize(clang::ASTContext &Context) override; + bool HandleTopLevelDecl(clang::DeclGroupRef D) override; +}; + +} // namespace cir + +#endif // CLANG_CIRGENERATOR_H_ diff --git a/clang/include/clang/CIRFrontendAction/CIRGenAction.h b/clang/include/clang/CIRFrontendAction/CIRGenAction.h new file mode 100644 index 0..aaf73ec2bffc4 --- /dev/null +++ b/clang/include/clang/CIRFrontendAction/CIRGenAction.h @@ -0,0 +1,61 @@ +//=== CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_CIR_CIRGENACTION_H +#define LLVM_CLANG_CIR_CIRGENACTION_H + +#include "clang/Frontend/FrontendAction.h" + +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/OwningOpRef.h" + +namespace mlir { +class MLIRContext; +class ModuleOp; +} // namespace mlir + +namespace cir { +class CIRGenCon
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/91007 >From 17c81f79ede403e63010a39622d61937fcf898b4 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Fri, 3 May 2024 20:19:45 + Subject: [PATCH 1/4] =?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/CIR/CIRGenerator.h| 59 + .../clang/CIRFrontendAction/CIRGenAction.h| 61 + clang/include/clang/Driver/Options.td | 2 +- clang/lib/CIR/CMakeLists.txt | 2 + clang/lib/CIR/CodeGen/CIRGenModule.cpp| 35 clang/lib/CIR/CodeGen/CIRGenModule.h | 61 + clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 27 ++ clang/lib/CIR/CodeGen/CIRGenerator.cpp| 46 ++ clang/lib/CIR/CodeGen/CMakeLists.txt | 23 + clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 88 +++ clang/lib/CIR/FrontendAction/CMakeLists.txt | 17 clang/lib/Driver/ToolChains/Clang.cpp | 3 + clang/lib/FrontendTool/CMakeLists.txt | 15 .../ExecuteCompilerInvocation.cpp | 18 clang/test/CIR/hello.c| 4 + clang/test/CIR/lit.local.cfg | 2 + 16 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 clang/include/clang/CIR/CIRGenerator.h create mode 100644 clang/include/clang/CIRFrontendAction/CIRGenAction.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.cpp create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenTypeCache.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenerator.cpp create mode 100644 clang/lib/CIR/CodeGen/CMakeLists.txt create mode 100644 clang/lib/CIR/FrontendAction/CIRGenAction.cpp create mode 100644 clang/lib/CIR/FrontendAction/CMakeLists.txt create mode 100644 clang/test/CIR/hello.c create mode 100644 clang/test/CIR/lit.local.cfg diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h new file mode 100644 index 0..c9505d2473b43 --- /dev/null +++ b/clang/include/clang/CIR/CIRGenerator.h @@ -0,0 +1,59 @@ +//===- CIRGenerator.h - CIR Generation from Clang AST -===// +// +// 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 a simple interface to perform CIR generation from Clang +// AST +// +//===--===// + +#ifndef CLANG_CIRGENERATOR_H_ +#define CLANG_CIRGENERATOR_H_ + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/DeclGroup.h" +#include "clang/Basic/CodeGenOptions.h" +#include "clang/Basic/Diagnostic.h" + +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/Support/VirtualFileSystem.h" + +#include + +namespace mlir { +class MLIRContext; +} // namespace mlir +namespace cir { +class CIRGenModule; + +class CIRGenerator : public clang::ASTConsumer { + virtual void anchor(); + clang::DiagnosticsEngine &Diags; + clang::ASTContext *astCtx; + llvm::IntrusiveRefCntPtr + fs; // Only used for debug info. + + const clang::CodeGenOptions codeGenOpts; // Intentionally copied in. + + [[maybe_unused]] unsigned HandlingTopLevelDecls; + +protected: + std::unique_ptr mlirCtx; + std::unique_ptr CGM; + +public: + CIRGenerator(clang::DiagnosticsEngine &diags, + llvm::IntrusiveRefCntPtr FS, + const clang::CodeGenOptions &CGO); + ~CIRGenerator(); + void Initialize(clang::ASTContext &Context) override; + bool HandleTopLevelDecl(clang::DeclGroupRef D) override; +}; + +} // namespace cir + +#endif // CLANG_CIRGENERATOR_H_ diff --git a/clang/include/clang/CIRFrontendAction/CIRGenAction.h b/clang/include/clang/CIRFrontendAction/CIRGenAction.h new file mode 100644 index 0..aaf73ec2bffc4 --- /dev/null +++ b/clang/include/clang/CIRFrontendAction/CIRGenAction.h @@ -0,0 +1,61 @@ +//=== CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_CIR_CIRGENACTION_H +#define LLVM_CLANG_CIR_CIRGENACTION_H + +#include "clang/Frontend/FrontendAction.h" + +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/OwningOpRef.h" + +namespace mlir { +class MLIRContext; +class ModuleOp; +} // namespace mlir + +namespace cir { +class CIRGenCon
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/91007 >From 17c81f79ede403e63010a39622d61937fcf898b4 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Fri, 3 May 2024 20:19:45 + 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/CIR/CIRGenerator.h| 59 + .../clang/CIRFrontendAction/CIRGenAction.h| 61 + clang/include/clang/Driver/Options.td | 2 +- clang/lib/CIR/CMakeLists.txt | 2 + clang/lib/CIR/CodeGen/CIRGenModule.cpp| 35 clang/lib/CIR/CodeGen/CIRGenModule.h | 61 + clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 27 ++ clang/lib/CIR/CodeGen/CIRGenerator.cpp| 46 ++ clang/lib/CIR/CodeGen/CMakeLists.txt | 23 + clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 88 +++ clang/lib/CIR/FrontendAction/CMakeLists.txt | 17 clang/lib/Driver/ToolChains/Clang.cpp | 3 + clang/lib/FrontendTool/CMakeLists.txt | 15 .../ExecuteCompilerInvocation.cpp | 18 clang/test/CIR/hello.c| 4 + clang/test/CIR/lit.local.cfg | 2 + 16 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 clang/include/clang/CIR/CIRGenerator.h create mode 100644 clang/include/clang/CIRFrontendAction/CIRGenAction.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.cpp create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenTypeCache.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenerator.cpp create mode 100644 clang/lib/CIR/CodeGen/CMakeLists.txt create mode 100644 clang/lib/CIR/FrontendAction/CIRGenAction.cpp create mode 100644 clang/lib/CIR/FrontendAction/CMakeLists.txt create mode 100644 clang/test/CIR/hello.c create mode 100644 clang/test/CIR/lit.local.cfg diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h new file mode 100644 index 0..c9505d2473b43 --- /dev/null +++ b/clang/include/clang/CIR/CIRGenerator.h @@ -0,0 +1,59 @@ +//===- CIRGenerator.h - CIR Generation from Clang AST -===// +// +// 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 a simple interface to perform CIR generation from Clang +// AST +// +//===--===// + +#ifndef CLANG_CIRGENERATOR_H_ +#define CLANG_CIRGENERATOR_H_ + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/DeclGroup.h" +#include "clang/Basic/CodeGenOptions.h" +#include "clang/Basic/Diagnostic.h" + +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/Support/VirtualFileSystem.h" + +#include + +namespace mlir { +class MLIRContext; +} // namespace mlir +namespace cir { +class CIRGenModule; + +class CIRGenerator : public clang::ASTConsumer { + virtual void anchor(); + clang::DiagnosticsEngine &Diags; + clang::ASTContext *astCtx; + llvm::IntrusiveRefCntPtr + fs; // Only used for debug info. + + const clang::CodeGenOptions codeGenOpts; // Intentionally copied in. + + [[maybe_unused]] unsigned HandlingTopLevelDecls; + +protected: + std::unique_ptr mlirCtx; + std::unique_ptr CGM; + +public: + CIRGenerator(clang::DiagnosticsEngine &diags, + llvm::IntrusiveRefCntPtr FS, + const clang::CodeGenOptions &CGO); + ~CIRGenerator(); + void Initialize(clang::ASTContext &Context) override; + bool HandleTopLevelDecl(clang::DeclGroupRef D) override; +}; + +} // namespace cir + +#endif // CLANG_CIRGENERATOR_H_ diff --git a/clang/include/clang/CIRFrontendAction/CIRGenAction.h b/clang/include/clang/CIRFrontendAction/CIRGenAction.h new file mode 100644 index 0..aaf73ec2bffc4 --- /dev/null +++ b/clang/include/clang/CIRFrontendAction/CIRGenAction.h @@ -0,0 +1,61 @@ +//=== CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_CIR_CIRGENACTION_H +#define LLVM_CLANG_CIR_CIRGENACTION_H + +#include "clang/Frontend/FrontendAction.h" + +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/OwningOpRef.h" + +namespace mlir { +class MLIRContext; +class ModuleOp; +} // namespace mlir + +namespace cir { +class CIRGenCon
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/91007 >From 17c81f79ede403e63010a39622d61937fcf898b4 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Fri, 3 May 2024 20:19:45 + 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/CIR/CIRGenerator.h| 59 + .../clang/CIRFrontendAction/CIRGenAction.h| 61 + clang/include/clang/Driver/Options.td | 2 +- clang/lib/CIR/CMakeLists.txt | 2 + clang/lib/CIR/CodeGen/CIRGenModule.cpp| 35 clang/lib/CIR/CodeGen/CIRGenModule.h | 61 + clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 27 ++ clang/lib/CIR/CodeGen/CIRGenerator.cpp| 46 ++ clang/lib/CIR/CodeGen/CMakeLists.txt | 23 + clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 88 +++ clang/lib/CIR/FrontendAction/CMakeLists.txt | 17 clang/lib/Driver/ToolChains/Clang.cpp | 3 + clang/lib/FrontendTool/CMakeLists.txt | 15 .../ExecuteCompilerInvocation.cpp | 18 clang/test/CIR/hello.c| 4 + clang/test/CIR/lit.local.cfg | 2 + 16 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 clang/include/clang/CIR/CIRGenerator.h create mode 100644 clang/include/clang/CIRFrontendAction/CIRGenAction.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.cpp create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenTypeCache.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenerator.cpp create mode 100644 clang/lib/CIR/CodeGen/CMakeLists.txt create mode 100644 clang/lib/CIR/FrontendAction/CIRGenAction.cpp create mode 100644 clang/lib/CIR/FrontendAction/CMakeLists.txt create mode 100644 clang/test/CIR/hello.c create mode 100644 clang/test/CIR/lit.local.cfg diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h new file mode 100644 index 0..c9505d2473b43 --- /dev/null +++ b/clang/include/clang/CIR/CIRGenerator.h @@ -0,0 +1,59 @@ +//===- CIRGenerator.h - CIR Generation from Clang AST -===// +// +// 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 a simple interface to perform CIR generation from Clang +// AST +// +//===--===// + +#ifndef CLANG_CIRGENERATOR_H_ +#define CLANG_CIRGENERATOR_H_ + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/DeclGroup.h" +#include "clang/Basic/CodeGenOptions.h" +#include "clang/Basic/Diagnostic.h" + +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/Support/VirtualFileSystem.h" + +#include + +namespace mlir { +class MLIRContext; +} // namespace mlir +namespace cir { +class CIRGenModule; + +class CIRGenerator : public clang::ASTConsumer { + virtual void anchor(); + clang::DiagnosticsEngine &Diags; + clang::ASTContext *astCtx; + llvm::IntrusiveRefCntPtr + fs; // Only used for debug info. + + const clang::CodeGenOptions codeGenOpts; // Intentionally copied in. + + [[maybe_unused]] unsigned HandlingTopLevelDecls; + +protected: + std::unique_ptr mlirCtx; + std::unique_ptr CGM; + +public: + CIRGenerator(clang::DiagnosticsEngine &diags, + llvm::IntrusiveRefCntPtr FS, + const clang::CodeGenOptions &CGO); + ~CIRGenerator(); + void Initialize(clang::ASTContext &Context) override; + bool HandleTopLevelDecl(clang::DeclGroupRef D) override; +}; + +} // namespace cir + +#endif // CLANG_CIRGENERATOR_H_ diff --git a/clang/include/clang/CIRFrontendAction/CIRGenAction.h b/clang/include/clang/CIRFrontendAction/CIRGenAction.h new file mode 100644 index 0..aaf73ec2bffc4 --- /dev/null +++ b/clang/include/clang/CIRFrontendAction/CIRGenAction.h @@ -0,0 +1,61 @@ +//=== CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_CIR_CIRGENACTION_H +#define LLVM_CLANG_CIR_CIRGENACTION_H + +#include "clang/Frontend/FrontendAction.h" + +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/OwningOpRef.h" + +namespace mlir { +class MLIRContext; +class ModuleOp; +} // namespace mlir + +namespace cir { +class CIRGenCon
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)
@@ -2900,7 +2900,7 @@ defm clangir : BoolFOption<"clangir", PosFlag, NegFlag LLVM pipeline to compile">, BothFlags<[], [ClangOption, CC1Option], "">>; -def emit_cir : Flag<["-"], "emit-cir">, Visibility<[CC1Option]>, +def emit_cir : Flag<["-"], "emit-cir">, Visibility<[ClangOption, CC1Option]>, lanza wrote: > Then `-c -Xclang -emit-cir` can be used to override the assumed action > passed by clangDriver to cc1. It would be incorrect to only use `-Xclang -emit-cir -c` as it would output a `.o` file for a textual `.cir` file. I've plugged in ClangIR to the action building system. `-c` requests actions through the assembler. We're stopping with ClangIR via `-emit-cir` after the `Compile` phase. > -flto modifies -c to emit a bitcode file and -S to emit a textual IR file. > -fcir can be modeled like -flto. That's an inaccurate comparison. `-fcir` is supposed to only change from using codegen to cirgen&lowering. The output shouldn't change. `-emit-cir` is supposed to emit a file with the suffix `.cir`. The *driver* has to be told the preferred output type to tell the action system to emit a `.cir` suffixed file. https://github.com/llvm/llvm-project/pull/91007 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/91007 >From 17c81f79ede403e63010a39622d61937fcf898b4 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Fri, 3 May 2024 20:19:45 + 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/CIR/CIRGenerator.h| 59 + .../clang/CIRFrontendAction/CIRGenAction.h| 61 + clang/include/clang/Driver/Options.td | 2 +- clang/lib/CIR/CMakeLists.txt | 2 + clang/lib/CIR/CodeGen/CIRGenModule.cpp| 35 clang/lib/CIR/CodeGen/CIRGenModule.h | 61 + clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 27 ++ clang/lib/CIR/CodeGen/CIRGenerator.cpp| 46 ++ clang/lib/CIR/CodeGen/CMakeLists.txt | 23 + clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 88 +++ clang/lib/CIR/FrontendAction/CMakeLists.txt | 17 clang/lib/Driver/ToolChains/Clang.cpp | 3 + clang/lib/FrontendTool/CMakeLists.txt | 15 .../ExecuteCompilerInvocation.cpp | 18 clang/test/CIR/hello.c| 4 + clang/test/CIR/lit.local.cfg | 2 + 16 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 clang/include/clang/CIR/CIRGenerator.h create mode 100644 clang/include/clang/CIRFrontendAction/CIRGenAction.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.cpp create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenTypeCache.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenerator.cpp create mode 100644 clang/lib/CIR/CodeGen/CMakeLists.txt create mode 100644 clang/lib/CIR/FrontendAction/CIRGenAction.cpp create mode 100644 clang/lib/CIR/FrontendAction/CMakeLists.txt create mode 100644 clang/test/CIR/hello.c create mode 100644 clang/test/CIR/lit.local.cfg diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h new file mode 100644 index 0..c9505d2473b43 --- /dev/null +++ b/clang/include/clang/CIR/CIRGenerator.h @@ -0,0 +1,59 @@ +//===- CIRGenerator.h - CIR Generation from Clang AST -===// +// +// 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 a simple interface to perform CIR generation from Clang +// AST +// +//===--===// + +#ifndef CLANG_CIRGENERATOR_H_ +#define CLANG_CIRGENERATOR_H_ + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/DeclGroup.h" +#include "clang/Basic/CodeGenOptions.h" +#include "clang/Basic/Diagnostic.h" + +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/Support/VirtualFileSystem.h" + +#include + +namespace mlir { +class MLIRContext; +} // namespace mlir +namespace cir { +class CIRGenModule; + +class CIRGenerator : public clang::ASTConsumer { + virtual void anchor(); + clang::DiagnosticsEngine &Diags; + clang::ASTContext *astCtx; + llvm::IntrusiveRefCntPtr + fs; // Only used for debug info. + + const clang::CodeGenOptions codeGenOpts; // Intentionally copied in. + + [[maybe_unused]] unsigned HandlingTopLevelDecls; + +protected: + std::unique_ptr mlirCtx; + std::unique_ptr CGM; + +public: + CIRGenerator(clang::DiagnosticsEngine &diags, + llvm::IntrusiveRefCntPtr FS, + const clang::CodeGenOptions &CGO); + ~CIRGenerator(); + void Initialize(clang::ASTContext &Context) override; + bool HandleTopLevelDecl(clang::DeclGroupRef D) override; +}; + +} // namespace cir + +#endif // CLANG_CIRGENERATOR_H_ diff --git a/clang/include/clang/CIRFrontendAction/CIRGenAction.h b/clang/include/clang/CIRFrontendAction/CIRGenAction.h new file mode 100644 index 0..aaf73ec2bffc4 --- /dev/null +++ b/clang/include/clang/CIRFrontendAction/CIRGenAction.h @@ -0,0 +1,61 @@ +//=== CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_CIR_CIRGENACTION_H +#define LLVM_CLANG_CIR_CIRGENACTION_H + +#include "clang/Frontend/FrontendAction.h" + +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/OwningOpRef.h" + +namespace mlir { +class MLIRContext; +class ModuleOp; +} // namespace mlir + +namespace cir { +class CIRGenConsume
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)
@@ -2900,7 +2900,7 @@ defm clangir : BoolFOption<"clangir", PosFlag, NegFlag LLVM pipeline to compile">, BothFlags<[], [ClangOption, CC1Option], "">>; -def emit_cir : Flag<["-"], "emit-cir">, Visibility<[CC1Option]>, +def emit_cir : Flag<["-"], "emit-cir">, Visibility<[ClangOption, CC1Option]>, lanza wrote: @erichkeane @AaronBallman @MaskRay I had to re-add the ClangOption here. `lib/Driver/Driver.cpp` builds the `Action` framework out based on input to the driver. So to properly orchestrate the outputs you need a driver flag to tell it that, e.g., we are emitting a `.cir` textual output. e.g. `-fsyntax-only` exists to chop off the frontend at the right point and `-emit-llvm` seems intentionally to have been made a driver flag to orchestrate `.ll` or `.bc` output. Notably, `-emit-llvm-bc` does the wrong thing in all cases. `clang -Xclang -emit-llvm-bc hello.c` does the wrong thing and emits an executable. `clang -Xclang -emit-llvm -S hello.c` also does the wrong thing and emits a file named `hello.s` that is actually llvm bitcode. https://github.com/llvm/llvm-project/pull/91007 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)
https://github.com/lanza created https://github.com/llvm/llvm-project/pull/91007 Build out the necessary infrastructure for the main entry point into ClangIR generation -- CIRGenModule. A set of boilerplate classes exist to facilitate this -- CIRGenerator, CIRGenAction, EmitCIRAction and CIRGenConsumer. These all mirror the corresponding types from LLVM generation by Clang's CodeGen. The main entry point to CIR generation is `CIRGenModule::buildTopLevelDecl`. It is currently just an empty function. We've added a test to ensure that the pipeline reaches this point and doesn't fail, but does nothing else. This will be removed in one of the subsequent patches that'll add basic `cir.func` emission. This patch also re-adds `-emit-cir` to the driver. lib/Driver/Driver.cpp requires that a driver flag exists to facilirate the selection of the right actions for the driver to create. Without a driver flag you get the standard behaviors of `-S`, `-c`, etc. If we want to emit CIR IR and, eventually, bytecode we'll need a driver flag to force this. This is why `-emit-llvm` is a driver flag. Notably, `-emit-llvm-bc` as a cc1 flag doesn't ever do the right thing. Without a driver flag it is incorrectly ignored and an executable is emitted. With `-S` a file named `something.s` is emitted which actually contains bitcode. >From 17c81f79ede403e63010a39622d61937fcf898b4 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Fri, 3 May 2024 20:19:45 + 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/CIR/CIRGenerator.h| 59 + .../clang/CIRFrontendAction/CIRGenAction.h| 61 + clang/include/clang/Driver/Options.td | 2 +- clang/lib/CIR/CMakeLists.txt | 2 + clang/lib/CIR/CodeGen/CIRGenModule.cpp| 35 clang/lib/CIR/CodeGen/CIRGenModule.h | 61 + clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 27 ++ clang/lib/CIR/CodeGen/CIRGenerator.cpp| 46 ++ clang/lib/CIR/CodeGen/CMakeLists.txt | 23 + clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 88 +++ clang/lib/CIR/FrontendAction/CMakeLists.txt | 17 clang/lib/Driver/ToolChains/Clang.cpp | 3 + clang/lib/FrontendTool/CMakeLists.txt | 15 .../ExecuteCompilerInvocation.cpp | 18 clang/test/CIR/hello.c| 4 + clang/test/CIR/lit.local.cfg | 2 + 16 files changed, 462 insertions(+), 1 deletion(-) create mode 100644 clang/include/clang/CIR/CIRGenerator.h create mode 100644 clang/include/clang/CIRFrontendAction/CIRGenAction.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.cpp create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenTypeCache.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenerator.cpp create mode 100644 clang/lib/CIR/CodeGen/CMakeLists.txt create mode 100644 clang/lib/CIR/FrontendAction/CIRGenAction.cpp create mode 100644 clang/lib/CIR/FrontendAction/CMakeLists.txt create mode 100644 clang/test/CIR/hello.c create mode 100644 clang/test/CIR/lit.local.cfg diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h new file mode 100644 index 00..c9505d2473b437 --- /dev/null +++ b/clang/include/clang/CIR/CIRGenerator.h @@ -0,0 +1,59 @@ +//===- CIRGenerator.h - CIR Generation from Clang AST -===// +// +// 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 a simple interface to perform CIR generation from Clang +// AST +// +//===--===// + +#ifndef CLANG_CIRGENERATOR_H_ +#define CLANG_CIRGENERATOR_H_ + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/DeclGroup.h" +#include "clang/Basic/CodeGenOptions.h" +#include "clang/Basic/Diagnostic.h" + +#include "llvm/ADT/IntrusiveRefCntPtr.h" +#include "llvm/Support/VirtualFileSystem.h" + +#include + +namespace mlir { +class MLIRContext; +} // namespace mlir +namespace cir { +class CIRGenModule; + +class CIRGenerator : public clang::ASTConsumer { + virtual void anchor(); + clang::DiagnosticsEngine &Diags; + clang::ASTContext *astCtx; + llvm::IntrusiveRefCntPtr + fs; // Only used for debug info. + + const clang::CodeGenOptions codeGenOpts; // Intentionally copied in. + + [[maybe_unused]] unsigned HandlingTopLevelDecls; + +protected: + std::unique_ptr mlirCtx; + std::unique_ptr CGM; + +public: + CIRGenerator(clang::DiagnosticsEngine &diags, +
[clang] [CIR] Add CIRGenerator and plug it via CIRGenAction (PR #90831)
https://github.com/lanza closed https://github.com/llvm/llvm-project/pull/90831 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Add CIRGenerator and plug it via CIRGenAction (PR #90831)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/90831 >From e57548737a72c5308e23fb442774b9bd9eca0bfa Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 2 May 2024 07:55:36 + 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/CIR/CIRGenerator.h| 28 + .../clang/CIRFrontendAction/CIRGenAction.h| 62 +++ clang/lib/CIR/CMakeLists.txt | 2 + clang/lib/CIR/CodeGen/CIRGenModule.cpp| 21 +++ clang/lib/CIR/CodeGen/CIRGenModule.h | 42 + clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 28 + clang/lib/CIR/CodeGen/CIRGenerator.cpp| 26 clang/lib/CIR/CodeGen/CMakeLists.txt | 23 +++ clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 46 ++ clang/lib/CIR/FrontendAction/CMakeLists.txt | 12 clang/lib/FrontendTool/CMakeLists.txt | 9 +++ .../ExecuteCompilerInvocation.cpp | 17 + 12 files changed, 316 insertions(+) create mode 100644 clang/include/clang/CIR/CIRGenerator.h create mode 100644 clang/include/clang/CIRFrontendAction/CIRGenAction.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.cpp create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenTypeCache.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenerator.cpp create mode 100644 clang/lib/CIR/CodeGen/CMakeLists.txt create mode 100644 clang/lib/CIR/FrontendAction/CIRGenAction.cpp create mode 100644 clang/lib/CIR/FrontendAction/CMakeLists.txt diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h new file mode 100644 index 00..c910f02698f41f --- /dev/null +++ b/clang/include/clang/CIR/CIRGenerator.h @@ -0,0 +1,28 @@ +//===- CIRGenerator.h - CIR Generation from Clang AST -===// +// +// 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 a simple interface to perform CIR generation from Clang +// AST +// +//===--===// + +#ifndef CLANG_CIRGENERATOR_H_ +#define CLANG_CIRGENERATOR_H_ + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/DeclGroup.h" + +namespace cir { +class CIRGenerator : public clang::ASTConsumer { +public: + bool HandleTopLevelDecl(clang::DeclGroupRef D) override; +}; + +} // namespace cir + +#endif // CLANG_CIRGENERATOR_H_ diff --git a/clang/include/clang/CIRFrontendAction/CIRGenAction.h b/clang/include/clang/CIRFrontendAction/CIRGenAction.h new file mode 100644 index 00..02c906b173f52b --- /dev/null +++ b/clang/include/clang/CIRFrontendAction/CIRGenAction.h @@ -0,0 +1,62 @@ +//=== CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_CIR_CIRGENACTION_H +#define LLVM_CLANG_CIR_CIRGENACTION_H + +#include "clang/Frontend/FrontendAction.h" + +namespace mlir { +class MLIRContext; +class ModuleOp; +template class OwningOpRef; +} // namespace mlir + +namespace cir { + +class CIRGenAction : public clang::ASTFrontendAction { +public: + enum class OutputType { +EmitCIR, + }; + +private: + friend class CIRGenConsumer; + + // TODO: this is redundant but just using the OwningModuleRef requires more of + // clang against MLIR. Hide this somewhere else. + std::unique_ptr> mlirModule; + + mlir::MLIRContext *mlirContext; + +protected: + CIRGenAction(OutputType action, mlir::MLIRContext *mlirContext = nullptr); + + void foo() { + + } + + std::unique_ptr + CreateASTConsumer(clang::CompilerInstance &CI, +llvm::StringRef InFile) override; + +public: + ~CIRGenAction() override; + OutputType action; +}; + +class EmitCIRAction : public CIRGenAction { + virtual void anchor(); + +public: + EmitCIRAction(mlir::MLIRContext *mlirCtx = nullptr); +}; + +} // namespace cir + +#endif diff --git a/clang/lib/CIR/CMakeLists.txt b/clang/lib/CIR/CMakeLists.txt index d2ff200e0da5f5..11cca734808dfa 100644 --- a/clang/lib/CIR/CMakeLists.txt +++ b/clang/lib/CIR/CMakeLists.txt @@ -2,3 +2,5 @@ include_directories(${LLVM_MAIN_SRC_DIR}/../mlir/include) include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include) add_subdirectory(Dialect) +add_subdirector
[clang] [CIR] Add CIRGenerator and plug it via CIRGenAction (PR #90831)
@@ -2900,7 +2900,7 @@ defm clangir : BoolFOption<"clangir", PosFlag, NegFlag LLVM pipeline to compile">, BothFlags<[], [ClangOption, CC1Option], "">>; -def emit_cir : Flag<["-"], "emit-cir">, Visibility<[CC1Option]>, +def emit_cir : Flag<["-"], "emit-cir">, Visibility<[ClangOption, CC1Option]>, lanza wrote: I had to readd this. The code in `lib/Driver/Driver.cpp:4810`ish needs to know the file output type from flags to the driver. So we need **a driver flag**. And if we need a driver flag then we might as well merge it with one that correctly feeds the emission type along as well. https://github.com/llvm/llvm-project/pull/90831 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Add CIRGenerator and plug it via CIRGenAction (PR #90831)
@@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s | FileCheck %s + +// CHECK: CIRGenModule::buildTopLevelDecl + +void foo() {} lanza wrote: Kind of a shitty test, but actually having something testable triples the size of this PR. https://github.com/llvm/llvm-project/pull/90831 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Add CIRGenerator and plug it via CIRGenAction (PR #90831)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/90831 >From e57548737a72c5308e23fb442774b9bd9eca0bfa Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 2 May 2024 07:55:36 + 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/CIR/CIRGenerator.h| 28 + .../clang/CIRFrontendAction/CIRGenAction.h| 62 +++ clang/lib/CIR/CMakeLists.txt | 2 + clang/lib/CIR/CodeGen/CIRGenModule.cpp| 21 +++ clang/lib/CIR/CodeGen/CIRGenModule.h | 42 + clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 28 + clang/lib/CIR/CodeGen/CIRGenerator.cpp| 26 clang/lib/CIR/CodeGen/CMakeLists.txt | 23 +++ clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 46 ++ clang/lib/CIR/FrontendAction/CMakeLists.txt | 12 clang/lib/FrontendTool/CMakeLists.txt | 9 +++ .../ExecuteCompilerInvocation.cpp | 17 + 12 files changed, 316 insertions(+) create mode 100644 clang/include/clang/CIR/CIRGenerator.h create mode 100644 clang/include/clang/CIRFrontendAction/CIRGenAction.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.cpp create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenTypeCache.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenerator.cpp create mode 100644 clang/lib/CIR/CodeGen/CMakeLists.txt create mode 100644 clang/lib/CIR/FrontendAction/CIRGenAction.cpp create mode 100644 clang/lib/CIR/FrontendAction/CMakeLists.txt diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h new file mode 100644 index 00..c910f02698f41f --- /dev/null +++ b/clang/include/clang/CIR/CIRGenerator.h @@ -0,0 +1,28 @@ +//===- CIRGenerator.h - CIR Generation from Clang AST -===// +// +// 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 a simple interface to perform CIR generation from Clang +// AST +// +//===--===// + +#ifndef CLANG_CIRGENERATOR_H_ +#define CLANG_CIRGENERATOR_H_ + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/DeclGroup.h" + +namespace cir { +class CIRGenerator : public clang::ASTConsumer { +public: + bool HandleTopLevelDecl(clang::DeclGroupRef D) override; +}; + +} // namespace cir + +#endif // CLANG_CIRGENERATOR_H_ diff --git a/clang/include/clang/CIRFrontendAction/CIRGenAction.h b/clang/include/clang/CIRFrontendAction/CIRGenAction.h new file mode 100644 index 00..02c906b173f52b --- /dev/null +++ b/clang/include/clang/CIRFrontendAction/CIRGenAction.h @@ -0,0 +1,62 @@ +//=== CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_CIR_CIRGENACTION_H +#define LLVM_CLANG_CIR_CIRGENACTION_H + +#include "clang/Frontend/FrontendAction.h" + +namespace mlir { +class MLIRContext; +class ModuleOp; +template class OwningOpRef; +} // namespace mlir + +namespace cir { + +class CIRGenAction : public clang::ASTFrontendAction { +public: + enum class OutputType { +EmitCIR, + }; + +private: + friend class CIRGenConsumer; + + // TODO: this is redundant but just using the OwningModuleRef requires more of + // clang against MLIR. Hide this somewhere else. + std::unique_ptr> mlirModule; + + mlir::MLIRContext *mlirContext; + +protected: + CIRGenAction(OutputType action, mlir::MLIRContext *mlirContext = nullptr); + + void foo() { + + } + + std::unique_ptr + CreateASTConsumer(clang::CompilerInstance &CI, +llvm::StringRef InFile) override; + +public: + ~CIRGenAction() override; + OutputType action; +}; + +class EmitCIRAction : public CIRGenAction { + virtual void anchor(); + +public: + EmitCIRAction(mlir::MLIRContext *mlirCtx = nullptr); +}; + +} // namespace cir + +#endif diff --git a/clang/lib/CIR/CMakeLists.txt b/clang/lib/CIR/CMakeLists.txt index d2ff200e0da5f5..11cca734808dfa 100644 --- a/clang/lib/CIR/CMakeLists.txt +++ b/clang/lib/CIR/CMakeLists.txt @@ -2,3 +2,5 @@ include_directories(${LLVM_MAIN_SRC_DIR}/../mlir/include) include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include) add_subdirectory(Dialect) +add_subdirector
[clang] [CIR] Add CIRGenerator and plug it via CIRGenAction (PR #90831)
@@ -0,0 +1,42 @@ +//===--- CIRGenModule.h - Per-Module state for CIR gen --*- C++ -*-===// +// +// 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 is the internal per-translation-unit state used for CIR translation. +// +//===--===// + +#ifndef LLVM_CLANG_LIB_CODEGEN_CIRGENMODULE_H +#define LLVM_CLANG_LIB_CODEGEN_CIRGENMODULE_H + +#include "CIRGenTypeCache.h" + +#include "clang/AST/ASTContext.h" +#include "clang/Basic/CodeGenOptions.h" +#include "clang/Basic/Diagnostic.h" +#include "mlir/IR/MLIRContext.h" + +using namespace clang; +namespace cir { +/// Implementation of a CIR/MLIR emission from Clang AST. +/// +/// This will emit operations that are specific to C(++)/ObjC(++) language, +/// preserving the semantics of the language and (hopefully) allow to perform lanza wrote: This sounds like what you wrote originally for the `CIRBuilder` class that was the original top level thing. Just going to get rid of it and use the same comment from CodeGenModule since it's less ambitious and more accurate. https://github.com/llvm/llvm-project/pull/90831 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Add CIRGenerator and plug it via CIRGenAction (PR #90831)
@@ -0,0 +1,28 @@ +//===--- CIRGenTypeCache.h - Commonly used LLVM types and info -*- C++ --*-===// +// +// 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 structure provides a set of common types useful during CIR emission. +// +//===--===// + +#ifndef LLVM_CLANG_LIB_CIR_CODEGENTYPECACHE_H +#define LLVM_CLANG_LIB_CIR_CODEGENTYPECACHE_H + +namespace cir { + +/// This structure provides a set of types that are commonly used +/// during IR emission. It's initialized once in CodeGenModule's +/// constructor and then copied around into new CIRGenFunction's. +struct CIRGenTypeCache { + CIRGenTypeCache() {} + lanza wrote: what? https://github.com/llvm/llvm-project/pull/90831 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Add CIRGenerator and plug it via CIRGenAction (PR #90831)
https://github.com/lanza updated https://github.com/llvm/llvm-project/pull/90831 >From e57548737a72c5308e23fb442774b9bd9eca0bfa Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 2 May 2024 07:55:36 + 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/CIR/CIRGenerator.h| 28 + .../clang/CIRFrontendAction/CIRGenAction.h| 62 +++ clang/lib/CIR/CMakeLists.txt | 2 + clang/lib/CIR/CodeGen/CIRGenModule.cpp| 21 +++ clang/lib/CIR/CodeGen/CIRGenModule.h | 42 + clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 28 + clang/lib/CIR/CodeGen/CIRGenerator.cpp| 26 clang/lib/CIR/CodeGen/CMakeLists.txt | 23 +++ clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 46 ++ clang/lib/CIR/FrontendAction/CMakeLists.txt | 12 clang/lib/FrontendTool/CMakeLists.txt | 9 +++ .../ExecuteCompilerInvocation.cpp | 17 + 12 files changed, 316 insertions(+) create mode 100644 clang/include/clang/CIR/CIRGenerator.h create mode 100644 clang/include/clang/CIRFrontendAction/CIRGenAction.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.cpp create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenTypeCache.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenerator.cpp create mode 100644 clang/lib/CIR/CodeGen/CMakeLists.txt create mode 100644 clang/lib/CIR/FrontendAction/CIRGenAction.cpp create mode 100644 clang/lib/CIR/FrontendAction/CMakeLists.txt diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h new file mode 100644 index 00..c910f02698f41f --- /dev/null +++ b/clang/include/clang/CIR/CIRGenerator.h @@ -0,0 +1,28 @@ +//===- CIRGenerator.h - CIR Generation from Clang AST -===// +// +// 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 a simple interface to perform CIR generation from Clang +// AST +// +//===--===// + +#ifndef CLANG_CIRGENERATOR_H_ +#define CLANG_CIRGENERATOR_H_ + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/DeclGroup.h" + +namespace cir { +class CIRGenerator : public clang::ASTConsumer { +public: + bool HandleTopLevelDecl(clang::DeclGroupRef D) override; +}; + +} // namespace cir + +#endif // CLANG_CIRGENERATOR_H_ diff --git a/clang/include/clang/CIRFrontendAction/CIRGenAction.h b/clang/include/clang/CIRFrontendAction/CIRGenAction.h new file mode 100644 index 00..02c906b173f52b --- /dev/null +++ b/clang/include/clang/CIRFrontendAction/CIRGenAction.h @@ -0,0 +1,62 @@ +//=== CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_CIR_CIRGENACTION_H +#define LLVM_CLANG_CIR_CIRGENACTION_H + +#include "clang/Frontend/FrontendAction.h" + +namespace mlir { +class MLIRContext; +class ModuleOp; +template class OwningOpRef; +} // namespace mlir + +namespace cir { + +class CIRGenAction : public clang::ASTFrontendAction { +public: + enum class OutputType { +EmitCIR, + }; + +private: + friend class CIRGenConsumer; + + // TODO: this is redundant but just using the OwningModuleRef requires more of + // clang against MLIR. Hide this somewhere else. + std::unique_ptr> mlirModule; + + mlir::MLIRContext *mlirContext; + +protected: + CIRGenAction(OutputType action, mlir::MLIRContext *mlirContext = nullptr); + + void foo() { + + } + + std::unique_ptr + CreateASTConsumer(clang::CompilerInstance &CI, +llvm::StringRef InFile) override; + +public: + ~CIRGenAction() override; + OutputType action; +}; + +class EmitCIRAction : public CIRGenAction { + virtual void anchor(); + +public: + EmitCIRAction(mlir::MLIRContext *mlirCtx = nullptr); +}; + +} // namespace cir + +#endif diff --git a/clang/lib/CIR/CMakeLists.txt b/clang/lib/CIR/CMakeLists.txt index d2ff200e0da5f5..11cca734808dfa 100644 --- a/clang/lib/CIR/CMakeLists.txt +++ b/clang/lib/CIR/CMakeLists.txt @@ -2,3 +2,5 @@ include_directories(${LLVM_MAIN_SRC_DIR}/../mlir/include) include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include) add_subdirectory(Dialect) +add_subdirector
[clang] cirgenmodule buildtopleveldecl husk (PR #90831)
https://github.com/lanza converted_to_draft https://github.com/llvm/llvm-project/pull/90831 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] cirgenmodule buildtopleveldecl husk (PR #90831)
https://github.com/lanza created https://github.com/llvm/llvm-project/pull/90831 None >From e57548737a72c5308e23fb442774b9bd9eca0bfa Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 2 May 2024 07:55:36 + 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/CIR/CIRGenerator.h| 28 + .../clang/CIRFrontendAction/CIRGenAction.h| 62 +++ clang/lib/CIR/CMakeLists.txt | 2 + clang/lib/CIR/CodeGen/CIRGenModule.cpp| 21 +++ clang/lib/CIR/CodeGen/CIRGenModule.h | 42 + clang/lib/CIR/CodeGen/CIRGenTypeCache.h | 28 + clang/lib/CIR/CodeGen/CIRGenerator.cpp| 26 clang/lib/CIR/CodeGen/CMakeLists.txt | 23 +++ clang/lib/CIR/FrontendAction/CIRGenAction.cpp | 46 ++ clang/lib/CIR/FrontendAction/CMakeLists.txt | 12 clang/lib/FrontendTool/CMakeLists.txt | 9 +++ .../ExecuteCompilerInvocation.cpp | 17 + 12 files changed, 316 insertions(+) create mode 100644 clang/include/clang/CIR/CIRGenerator.h create mode 100644 clang/include/clang/CIRFrontendAction/CIRGenAction.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.cpp create mode 100644 clang/lib/CIR/CodeGen/CIRGenModule.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenTypeCache.h create mode 100644 clang/lib/CIR/CodeGen/CIRGenerator.cpp create mode 100644 clang/lib/CIR/CodeGen/CMakeLists.txt create mode 100644 clang/lib/CIR/FrontendAction/CIRGenAction.cpp create mode 100644 clang/lib/CIR/FrontendAction/CMakeLists.txt diff --git a/clang/include/clang/CIR/CIRGenerator.h b/clang/include/clang/CIR/CIRGenerator.h new file mode 100644 index 00..c910f02698f41f --- /dev/null +++ b/clang/include/clang/CIR/CIRGenerator.h @@ -0,0 +1,28 @@ +//===- CIRGenerator.h - CIR Generation from Clang AST -===// +// +// 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 a simple interface to perform CIR generation from Clang +// AST +// +//===--===// + +#ifndef CLANG_CIRGENERATOR_H_ +#define CLANG_CIRGENERATOR_H_ + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/DeclGroup.h" + +namespace cir { +class CIRGenerator : public clang::ASTConsumer { +public: + bool HandleTopLevelDecl(clang::DeclGroupRef D) override; +}; + +} // namespace cir + +#endif // CLANG_CIRGENERATOR_H_ diff --git a/clang/include/clang/CIRFrontendAction/CIRGenAction.h b/clang/include/clang/CIRFrontendAction/CIRGenAction.h new file mode 100644 index 00..02c906b173f52b --- /dev/null +++ b/clang/include/clang/CIRFrontendAction/CIRGenAction.h @@ -0,0 +1,62 @@ +//=== CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_CIR_CIRGENACTION_H +#define LLVM_CLANG_CIR_CIRGENACTION_H + +#include "clang/Frontend/FrontendAction.h" + +namespace mlir { +class MLIRContext; +class ModuleOp; +template class OwningOpRef; +} // namespace mlir + +namespace cir { + +class CIRGenAction : public clang::ASTFrontendAction { +public: + enum class OutputType { +EmitCIR, + }; + +private: + friend class CIRGenConsumer; + + // TODO: this is redundant but just using the OwningModuleRef requires more of + // clang against MLIR. Hide this somewhere else. + std::unique_ptr> mlirModule; + + mlir::MLIRContext *mlirContext; + +protected: + CIRGenAction(OutputType action, mlir::MLIRContext *mlirContext = nullptr); + + void foo() { + + } + + std::unique_ptr + CreateASTConsumer(clang::CompilerInstance &CI, +llvm::StringRef InFile) override; + +public: + ~CIRGenAction() override; + OutputType action; +}; + +class EmitCIRAction : public CIRGenAction { + virtual void anchor(); + +public: + EmitCIRAction(mlir::MLIRContext *mlirCtx = nullptr); +}; + +} // namespace cir + +#endif diff --git a/clang/lib/CIR/CMakeLists.txt b/clang/lib/CIR/CMakeLists.txt index d2ff200e0da5f5..11cca734808dfa 100644 --- a/clang/lib/CIR/CMakeLists.txt +++ b/clang/lib/CIR/CMakeLists.txt @@ -2,3 +2,5 @@ include_directories(${LLVM_MAIN_SRC_DIR}/../mlir/include) include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include) add_subdirectory(Dialect) +add_subdirect
[clang] [CIR] Add options to emit ClangIR and enable the ClangIR pipeline (PR #89030)
https://github.com/lanza closed https://github.com/llvm/llvm-project/pull/89030 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Add options to emit ClangIR and enable the ClangIR pipeline (PR #89030)
https://github.com/lanza edited https://github.com/llvm/llvm-project/pull/89030 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CIR][NFC] Add scaffolding for the CIR dialect and CIROps.td (PR #86080)
https://github.com/lanza closed https://github.com/llvm/llvm-project/pull/86080 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [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 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)
https://github.com/lanza closed https://github.com/llvm/llvm-project/pull/86078 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CIR][cmake] Add support for cmake variable CLANG_ENABLE_CIR (PR #86078)
https://github.com/lanza edited https://github.com/llvm/llvm-project/pull/86078 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)
https://github.com/lanza closed https://github.com/llvm/llvm-project/pull/86072 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [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 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-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 &Opts, case Language::HLSL: Lang = "hlsl"; break; +case Language::CIR: + Lang = "cir"; + break; } GenerateArg(Consumer, OPT_x, @@ -2958,6 +2961,7 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, .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 "H
[clang] [llvm] Move MLIR before clang for in the list of external projects (PR #86085)
https://github.com/lanza closed https://github.com/llvm/llvm-project/pull/86085 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Move MLIR before clang for in the list of external projects (PR #86085)
https://github.com/lanza created https://github.com/llvm/llvm-project/pull/86085 clang now depends on MLIR and thus we need to include it first for it's dependencies to be added properly. >From af55dfdb1fa18413179306f42946183ba66517a1 Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Thu, 21 Mar 2024 05:22:53 + 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/test/CIR/CodeGen/basic.c | 1 + llvm/tools/CMakeLists.txt | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 clang/test/CIR/CodeGen/basic.c diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c new file mode 100644 index 00..5c103141a2 --- /dev/null +++ b/clang/test/CIR/CodeGen/basic.c @@ -0,0 +1 @@ +// RUN: true diff --git a/llvm/tools/CMakeLists.txt b/llvm/tools/CMakeLists.txt index c6116ac81d12b2..ef4ac1eff6eba0 100644 --- a/llvm/tools/CMakeLists.txt +++ b/llvm/tools/CMakeLists.txt @@ -37,11 +37,10 @@ add_llvm_tool_subdirectory(llvm-profdata) # Projects supported via LLVM_EXTERNAL_*_SOURCE_DIR need to be explicitly # specified. +add_llvm_external_project(mlir) add_llvm_external_project(clang) add_llvm_external_project(lld) add_llvm_external_project(lldb) -add_llvm_external_project(mlir) -# Flang depends on mlir, so place it afterward add_llvm_external_project(flang) add_llvm_external_project(bolt) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR][Basic][NFC] Add the CIR language to the Language enum (PR #86072)
https://github.com/lanza created https://github.com/llvm/llvm-project/pull/86072 Add the CIR language to the Language enum and the standard usages of it. commit-id:fd12b2c2 >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 &Opts, case Language::HLSL: Lang = "hlsl"; break; +case Language::CIR: + Lang = "cir"; + break; } GenerateArg(Consumer, OPT_x, @@ -2958,6 +2961,7 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, .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 I
[clang] 220e77a - [clang][CodeGenPGO] Don't use an invalid index when region counts disagree
Author: Nathan Lanza Date: 2023-05-10T22:53:53-04:00 New Revision: 220e77a83af19b3f6c47472596fdaaef8e305927 URL: https://github.com/llvm/llvm-project/commit/220e77a83af19b3f6c47472596fdaaef8e305927 DIFF: https://github.com/llvm/llvm-project/commit/220e77a83af19b3f6c47472596fdaaef8e305927.diff LOG: [clang][CodeGenPGO] Don't use an invalid index when region counts disagree If we're using an old instrprof profile and the user passes we can get Decls with children decl counts not matching the what the profile was written against. In a particular case I was debugging we have 24 decls in the AST and 22 decls in the profile. Avoid crashing in this case. Differential Revision: https://reviews.llvm.org/D149504 Added: Modified: clang/lib/CodeGen/CodeGenPGO.h Removed: diff --git a/clang/lib/CodeGen/CodeGenPGO.h b/clang/lib/CodeGen/CodeGenPGO.h index 66c93cba4bb0..392ec5a144fe 100644 --- a/clang/lib/CodeGen/CodeGenPGO.h +++ b/clang/lib/CodeGen/CodeGenPGO.h @@ -114,7 +114,12 @@ class CodeGenPGO { return 0; if (!haveRegionCounts()) return 0; -return RegionCounts[(*RegionCounterMap)[S]]; +// With profiles from a diff ering version of clang we can have mismatched +// decl counts. Don't crash in such a case. +auto Index = (*RegionCounterMap)[S]; +if (Index >= RegionCounts.size()) + return 0; +return RegionCounts[Index]; } }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 556a811 - [clang][nfc] Update some documentation referring to old clang flags
Author: Nathan Lanza Date: 2023-03-08T23:01:52-05:00 New Revision: 556a811d686ea5242d8c21b95a97b90aa1be7c56 URL: https://github.com/llvm/llvm-project/commit/556a811d686ea5242d8c21b95a97b90aa1be7c56 DIFF: https://github.com/llvm/llvm-project/commit/556a811d686ea5242d8c21b95a97b90aa1be7c56.diff LOG: [clang][nfc] Update some documentation referring to old clang flags -cfg-dump and -cfg-view were removed long ago. The rest are gone, but I'm opting not to remove these lines without finding a replacement. Added: Modified: clang/lib/StaticAnalyzer/README.txt Removed: diff --git a/clang/lib/StaticAnalyzer/README.txt b/clang/lib/StaticAnalyzer/README.txt index 75f20315a7ae8..ae622caf6ccb4 100644 --- a/clang/lib/StaticAnalyzer/README.txt +++ b/clang/lib/StaticAnalyzer/README.txt @@ -119,15 +119,17 @@ simulation results. Of course, viewing the CFG (Control-Flow Graph) is also useful: -$ clang -cc1 -help | grep cfg - -cfg-add-implicit-dtors Add C++ implicit destructors to CFGs for all analyses - -cfg-add-initializers Add C++ initializers to CFGs for all analyses - -cfg-dump Display Control-Flow Graphs - -cfg-view View Control-Flow Graphs using GraphViz - -unoptimized-cfgGenerate unoptimized CFGs for all analyses - --cfg-dump dumps a textual representation of the CFG to the console, -and -cfg-view creates a GraphViz representation. +$ clang -cc1 -analyzer-checker-help-developer + + -analyzer-checker=debug.DumpCFG Display Control-Flow Graphs + -analyzer-checker=debug.ViewCFG View Control-Flow Graphs using GraphViz +(outdated below?) + -cfg-add-implicit-dtors Add C++ implicit destructors to CFGs for all analyses + -cfg-add-initializers Add C++ initializers to CFGs for all analyses + -unoptimized-cfg Generate unoptimized CFGs for all analyses + +debug.DumpCFG dumps a textual representation of the CFG to the console, and +debug.ViewCFG creates a GraphViz representation. = References = ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] dd2f290 - Add llvm's Support lib to the psuedoCXX library
Author: Nathan Lanza Date: 2022-06-08T17:12:02-04:00 New Revision: dd2f2909188bf56716248675c58e4699c1c6b903 URL: https://github.com/llvm/llvm-project/commit/dd2f2909188bf56716248675c58e4699c1c6b903 DIFF: https://github.com/llvm/llvm-project/commit/dd2f2909188bf56716248675c58e4699c1c6b903.diff LOG: Add llvm's Support lib to the psuedoCXX library This is failing to find `EnableABIBreakingCheck` at link time. Add Support to provide it here. Reviewed By: hokein Differential Revision: https://reviews.llvm.org/D127269 Added: Modified: clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt Removed: diff --git a/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt b/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt index 9e10f2ba5388..775b3b8c9538 100644 --- a/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt +++ b/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt @@ -1,3 +1,7 @@ +set(LLVM_LINK_COMPONENTS + Support + ) + add_clang_library(clangPseudoCXX CXX.cpp ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1bd4dc4 - [hmaptool] Port to python3
Author: Nathan Lanza Date: 2021-11-19T19:25:31-05:00 New Revision: 1bd4dc4f2854edf3035732416ec7e4adbddaf982 URL: https://github.com/llvm/llvm-project/commit/1bd4dc4f2854edf3035732416ec7e4adbddaf982 DIFF: https://github.com/llvm/llvm-project/commit/1bd4dc4f2854edf3035732416ec7e4adbddaf982.diff LOG: [hmaptool] Port to python3 This is just a few trivial changes -- change the interpreter and fix a few byte-vs-string issues. Differential Revision: https://reviews.llvm.org/D107944 Added: Modified: clang/utils/hmaptool/hmaptool Removed: diff --git a/clang/utils/hmaptool/hmaptool b/clang/utils/hmaptool/hmaptool index e647cde6bc46a..7949002020489 100755 --- a/clang/utils/hmaptool/hmaptool +++ b/clang/utils/hmaptool/hmaptool @@ -1,6 +1,7 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import absolute_import, division, print_function +from ctypes import ArgumentError import json import optparse import os @@ -9,8 +10,8 @@ import sys ### -k_header_magic_LE = 'pamh' -k_header_magic_BE = 'hmap' +k_header_magic_LE = b'pamh' +k_header_magic_BE = b'hmap' def hmap_hash(str): """hash(str) -> int @@ -43,7 +44,7 @@ class HeaderMap(object): path,)) (version, reserved, strtable_offset, num_entries, - num_buckets, max_value_len) = struct.unpack(header_fmt, data) + num_buckets) = struct.unpack(header_fmt, data) if version != 1: raise SystemExit("error: %s: unknown headermap version: %r" % ( @@ -83,7 +84,7 @@ class HeaderMap(object): if len(strtable) != strtable_size: raise SystemExit("error: %s: unable to read complete string table"%( path,)) -if strtable[-1] != '\0': +if strtable[-1] != 0: raise SystemExit("error: %s: invalid string table in headermap" % ( path,)) @@ -97,8 +98,8 @@ class HeaderMap(object): def get_string(self, idx): if idx >= len(self.strtable): raise SystemExit("error: %s: invalid string index" % ( -path,)) -end_idx = self.strtable.index('\0', idx) +idx,)) +end_idx = self.strtable.index(0, idx) return self.strtable[idx:end_idx] @property @@ -220,7 +221,7 @@ def action_write(name, args): # Write out the headermap. with open(output_path, 'wb') as f: -f.write(magic.encode()) +f.write(magic) f.write(struct.pack(header_fmt, *header)) for bucket in table: f.write(struct.pack(bucket_fmt, *bucket)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fcb0ab5 - [clang][NFC] Change a mention of `objc_static_protocol` to `non_runtime`
Author: Nathan Lanza Date: 2020-10-03T14:04:14-04:00 New Revision: fcb0ab59335be185e05258c905ef57da9e7f3324 URL: https://github.com/llvm/llvm-project/commit/fcb0ab59335be185e05258c905ef57da9e7f3324 DIFF: https://github.com/llvm/llvm-project/commit/fcb0ab59335be185e05258c905ef57da9e7f3324.diff LOG: [clang][NFC] Change a mention of `objc_static_protocol` to `non_runtime` Added: Modified: clang/include/clang/AST/DeclObjC.h Removed: diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index f2c25bceed18..88cedbd91b6d 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -2178,8 +2178,8 @@ class ObjCProtocolDecl : public ObjCContainerDecl, data().ReferencedProtocols.set(List, Num, Locs, C); } - /// This is true iff the protocol is tagged with the `objc_static_protocol` - /// attribute. + /// This is true iff the protocol is tagged with the + /// `objc_non_runtime_protocol` attribute. bool isNonRuntimeProtocol() const; /// Get the set of all protocols implied by this protocols inheritance ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 14f6bfc - [clang] Implement objc_non_runtime_protocol to remove protocol metadata
Author: Nathan Lanza Date: 2020-10-02T17:35:50-04:00 New Revision: 14f6bfcb52e77867a6a84fcfd9e21bb5f1f5795c URL: https://github.com/llvm/llvm-project/commit/14f6bfcb52e77867a6a84fcfd9e21bb5f1f5795c DIFF: https://github.com/llvm/llvm-project/commit/14f6bfcb52e77867a6a84fcfd9e21bb5f1f5795c.diff LOG: [clang] Implement objc_non_runtime_protocol to remove protocol metadata Summary: Motivated by the new objc_direct attribute, this change adds a new attribute that remotes metadata from Protocols that the programmer knows isn't going to be used at runtime. We simply have the frontend skip generating any protocol metadata entries (e.g. OBJC_CLASS_NAME, _OBJC_$_PROTOCOL_INSTANCE_METHDOS, _OBJC_PROTOCOL, etc) for a protocol marked with `__attribute__((objc_non_runtime_protocol))`. There are a few APIs used to retrieve a protocol at runtime. `@protocol(SomeProtocol)` will now error out of the requested protocol is marked with attribute. `objc_getProtocol` will return `NULL` which is consistent with the behavior of a non-existing protocol. Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D75574 Added: clang/test/CodeGenObjC/non-runtime-protocol.m Modified: clang/include/clang/AST/DeclObjC.h clang/include/clang/Basic/Attr.td clang/include/clang/Basic/AttrDocs.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/AST/DeclObjC.cpp clang/lib/CodeGen/CGObjC.cpp clang/lib/CodeGen/CGObjCGNU.cpp clang/lib/CodeGen/CGObjCMac.cpp clang/lib/CodeGen/CGObjCRuntime.h clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaExprObjC.cpp clang/test/Misc/pragma-attribute-supported-attributes-list.test Removed: diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index 32e69d7fe1ed..f2c25bceed18 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -2178,6 +2178,14 @@ class ObjCProtocolDecl : public ObjCContainerDecl, data().ReferencedProtocols.set(List, Num, Locs, C); } + /// This is true iff the protocol is tagged with the `objc_static_protocol` + /// attribute. + bool isNonRuntimeProtocol() const; + + /// Get the set of all protocols implied by this protocols inheritance + /// hierarchy. + void getImpliedProtocols(llvm::DenseSet &IPs) const; + ObjCProtocolDecl *lookupProtocolNamed(IdentifierInfo *PName); // Lookup a method. First, we search locally. If a method isn't diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 4d7a65964887..60e7a9d4303b 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -2024,6 +2024,13 @@ def ObjCDirectMembers : Attr { let Documentation = [ObjCDirectMembersDocs]; } +def ObjCNonRuntimeProtocol : Attr { + let Spellings = [Clang<"objc_non_runtime_protocol">]; + let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>; + let LangOpts = [ObjC]; + let Documentation = [ObjCNonRuntimeProtocolDocs]; +} + def ObjCRuntimeName : Attr { let Spellings = [Clang<"objc_runtime_name">]; let Subjects = SubjectList<[ObjCInterface, ObjCProtocol], ErrorDiag>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 8c236796546c..bf190829381c 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -4620,6 +4620,22 @@ properties, including auto-synthesized properties. }]; } +def ObjCNonRuntimeProtocolDocs : Documentation { + let Category = DocCatDecl; + let Content = [{ +The ``objc_non_runtime_protocol`` attribute can be used to mark that an +Objective-C protocol is only used during static type-checking and doesn't need +to be represented dynamically. This avoids several small code-size and run-time +overheads associated with handling the protocol's metadata. A non-runtime +protocol cannot be used as the operand of a ``@protocol`` expression, and +dynamic attempts to find it with ``objc_getProtocol`` will fail. + +If a non-runtime protocol inherits from any ordinary protocols, classes and +derived protocols that declare conformance to the non-runtime protocol will +dynamically list their conformance to those bare protocols. + }]; +} + def SelectAnyDocs : Documentation { let Category = DocCatDecl; let Content = [{ diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index f29eec316971..b3b3bc723863 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -1034,6 +1034,8 @@ def warn_objc_boxing_invalid_utf8_string : Warning< "string is ill-formed as UTF-8 and will become a null %0 when boxed">, InGroup; +def err_objc_non_runtime_protocol_in_protocol_expr : Error< + "cannot use a protocol declared 'objc_non_runtime_protocol' i
r366159 - Allow for vendor prefixes in a list test
Author: lanza Date: Mon Jul 15 17:57:50 2019 New Revision: 366159 URL: http://llvm.org/viewvc/llvm-project?rev=366159&view=rev Log: Allow for vendor prefixes in a list test Summary: Preprocessor/init.c contains a line that explicitly checks for the string __VERSION__ "Clang{{.*}} It's valid to have a toolchain configured to emit a vendor prefix before the word Clang. e.g. __VERSION__ "Vendor Clang{{.*}} Subscribers: fedor.sergeev, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64772 Modified: cfe/trunk/test/Preprocessor/init.c Modified: cfe/trunk/test/Preprocessor/init.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=366159&r1=366158&r2=366159&view=diff == --- cfe/trunk/test/Preprocessor/init.c (original) +++ cfe/trunk/test/Preprocessor/init.c Mon Jul 15 17:57:50 2019 @@ -8169,7 +8169,7 @@ // SPARC:#define __UINT_LEAST8_MAX__ 255 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char // SPARC:#define __USER_LABEL_PREFIX__ -// SPARC:#define __VERSION__ "Clang{{.*}} +// SPARC:#define __VERSION__ "{{.*}}Clang{{.*}} // SPARC:#define __WCHAR_MAX__ 2147483647 // SPARC:#define __WCHAR_TYPE__ int // SPARC:#define __WCHAR_WIDTH__ 32 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r366166 - Change a lit test to permit vendor specific clang version
Author: lanza Date: Mon Jul 15 19:05:52 2019 New Revision: 366166 URL: http://llvm.org/viewvc/llvm-project?rev=366166&view=rev Log: Change a lit test to permit vendor specific clang version A test manually checks for the string `__VERSION__ "Clang`. This needs to permit vendor specific variants. Modified: cfe/trunk/test/Preprocessor/init.c Modified: cfe/trunk/test/Preprocessor/init.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=366166&r1=366165&r2=366166&view=diff == --- cfe/trunk/test/Preprocessor/init.c (original) +++ cfe/trunk/test/Preprocessor/init.c Mon Jul 15 19:05:52 2019 @@ -9041,7 +9041,7 @@ // X86_64-CLOUDABI:#define __UINT_LEAST8_MAX__ 255 // X86_64-CLOUDABI:#define __UINT_LEAST8_TYPE__ unsigned char // X86_64-CLOUDABI:#define __USER_LABEL_PREFIX__ -// X86_64-CLOUDABI:#define __VERSION__ "Clang{{.*}} +// X86_64-CLOUDABI:#define __VERSION__ "{{.*}}Clang{{.*}} // X86_64-CLOUDABI:#define __WCHAR_MAX__ 2147483647 // X86_64-CLOUDABI:#define __WCHAR_TYPE__ int // X86_64-CLOUDABI:#define __WCHAR_WIDTH__ 32 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits