-
Notifications
You must be signed in to change notification settings - Fork 758
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'a51798e3d68b9e04660757ff6e645c8ba46baaa9' into llvmspir…
…v_pulldown
- Loading branch information
Showing
217 changed files
with
8,006 additions
and
5,726 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//====- LowerToLLVM.h- Lowering from CIR to LLVM --------------------------===// | ||
// | ||
// 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 an interface for converting CIR modules to LLVM IR. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#ifndef CLANG_CIR_LOWERTOLLVM_H | ||
#define CLANG_CIR_LOWERTOLLVM_H | ||
|
||
#include "mlir/Pass/Pass.h" | ||
|
||
#include <memory> | ||
|
||
namespace llvm { | ||
class LLVMContext; | ||
class Module; | ||
} // namespace llvm | ||
|
||
namespace mlir { | ||
class ModuleOp; | ||
} // namespace mlir | ||
|
||
namespace cir { | ||
|
||
namespace direct { | ||
std::unique_ptr<llvm::Module> | ||
lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp M, llvm::LLVMContext &Ctx); | ||
} // namespace direct | ||
} // namespace cir | ||
|
||
#endif // CLANG_CIR_LOWERTOLLVM_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(DirectToLLVM) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
set(LLVM_LINK_COMPONENTS | ||
Core | ||
Support | ||
) | ||
|
||
add_clang_library(clangCIRLoweringDirectToLLVM | ||
LowerToLLVM.cpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//====- LowerToLLVM.cpp - Lowering from CIR to LLVMIR ---------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file implements lowering of CIR operations to LLVMIR. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "clang/CIR/LowerToLLVM.h" | ||
|
||
#include "mlir/IR/BuiltinOps.h" | ||
#include "llvm/IR/Module.h" | ||
#include "llvm/Support/TimeProfiler.h" | ||
|
||
using namespace cir; | ||
using namespace llvm; | ||
|
||
namespace cir { | ||
namespace direct { | ||
|
||
std::unique_ptr<llvm::Module> | ||
lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp MOp, LLVMContext &LLVMCtx) { | ||
llvm::TimeTraceScope scope("lower from CIR to LLVM directly"); | ||
|
||
std::optional<StringRef> ModuleName = MOp.getName(); | ||
auto M = std::make_unique<llvm::Module>( | ||
ModuleName ? *ModuleName : "CIRToLLVMModule", LLVMCtx); | ||
|
||
if (!M) | ||
report_fatal_error("Lowering from LLVMIR dialect to llvm IR failed!"); | ||
|
||
return M; | ||
} | ||
} // namespace direct | ||
} // namespace cir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Smoke test for ClangIR-to-LLVM IR code generation | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o - | FileCheck %s | ||
|
||
// TODO: Add checks when proper lowering is implemented. | ||
// For now, we're just creating an empty module. | ||
// CHECK: ModuleID | ||
|
||
void foo() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.