Skip to content

Commit ef4d5a7

Browse files
committed
Revert "[CIR] Add framework for CIR to LLVM IR lowering (llvm#124650)"
This reverts commit 38ddcb7.
1 parent 5d94d87 commit ef4d5a7

File tree

10 files changed

+19
-160
lines changed

10 files changed

+19
-160
lines changed

clang/include/clang/CIR/FrontendAction/CIRGenAction.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class CIRGenAction : public clang::ASTFrontendAction {
2626
public:
2727
enum class OutputType {
2828
EmitCIR,
29-
EmitLLVM,
3029
};
3130

3231
private:
@@ -56,13 +55,6 @@ class EmitCIRAction : public CIRGenAction {
5655
EmitCIRAction(mlir::MLIRContext *MLIRCtx = nullptr);
5756
};
5857

59-
class EmitLLVMAction : public CIRGenAction {
60-
virtual void anchor();
61-
62-
public:
63-
EmitLLVMAction(mlir::MLIRContext *MLIRCtx = nullptr);
64-
};
65-
6658
} // namespace cir
6759

6860
#endif

clang/include/clang/CIR/LowerToLLVM.h

Lines changed: 0 additions & 36 deletions
This file was deleted.

clang/lib/CIR/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ add_subdirectory(Dialect)
55
add_subdirectory(CodeGen)
66
add_subdirectory(FrontendAction)
77
add_subdirectory(Interfaces)
8-
add_subdirectory(Lowering)

clang/lib/CIR/FrontendAction/CIRGenAction.cpp

Lines changed: 18 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,42 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "clang/CIR/FrontendAction/CIRGenAction.h"
10-
#include "mlir/IR/MLIRContext.h"
11-
#include "mlir/IR/OwningOpRef.h"
1210
#include "clang/CIR/CIRGenerator.h"
13-
#include "clang/CIR/LowerToLLVM.h"
14-
#include "clang/CodeGen/BackendUtil.h"
1511
#include "clang/Frontend/CompilerInstance.h"
16-
#include "llvm/IR/Module.h"
12+
13+
#include "mlir/IR/MLIRContext.h"
14+
#include "mlir/IR/OwningOpRef.h"
1715

1816
using namespace cir;
1917
using namespace clang;
2018

2119
namespace cir {
2220

23-
static BackendAction
24-
getBackendActionFromOutputType(CIRGenAction::OutputType Action) {
25-
switch (Action) {
26-
case CIRGenAction::OutputType::EmitCIR:
27-
assert(false &&
28-
"Unsupported output type for getBackendActionFromOutputType!");
29-
break; // Unreachable, but fall through to report that
30-
case CIRGenAction::OutputType::EmitLLVM:
31-
return BackendAction::Backend_EmitLL;
32-
}
33-
// We should only get here if a non-enum value is passed in or we went through
34-
// the assert(false) case above
35-
llvm_unreachable("Unsupported output type!");
36-
}
37-
38-
static std::unique_ptr<llvm::Module>
39-
lowerFromCIRToLLVMIR(mlir::ModuleOp MLIRModule, llvm::LLVMContext &LLVMCtx) {
40-
return direct::lowerDirectlyFromCIRToLLVMIR(MLIRModule, LLVMCtx);
41-
}
42-
4321
class CIRGenConsumer : public clang::ASTConsumer {
4422

4523
virtual void anchor();
4624

4725
CIRGenAction::OutputType Action;
4826

49-
CompilerInstance &CI;
50-
5127
std::unique_ptr<raw_pwrite_stream> OutputStream;
5228

5329
ASTContext *Context{nullptr};
5430
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS;
5531
std::unique_ptr<CIRGenerator> Gen;
5632

5733
public:
58-
CIRGenConsumer(CIRGenAction::OutputType Action, CompilerInstance &CI,
34+
CIRGenConsumer(CIRGenAction::OutputType Action,
35+
DiagnosticsEngine &DiagnosticsEngine,
36+
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
37+
const HeaderSearchOptions &HeaderSearchOptions,
38+
const CodeGenOptions &CodeGenOptions,
39+
const TargetOptions &TargetOptions,
40+
const LangOptions &LangOptions,
41+
const FrontendOptions &FEOptions,
5942
std::unique_ptr<raw_pwrite_stream> OS)
60-
: Action(Action), CI(CI), OutputStream(std::move(OS)),
61-
FS(&CI.getVirtualFileSystem()),
62-
Gen(std::make_unique<CIRGenerator>(CI.getDiagnostics(), std::move(FS),
63-
CI.getCodeGenOpts())) {}
43+
: Action(Action), OutputStream(std::move(OS)), FS(VFS),
44+
Gen(std::make_unique<CIRGenerator>(DiagnosticsEngine, std::move(VFS),
45+
CodeGenOptions)) {}
6446

6547
void Initialize(ASTContext &Ctx) override {
6648
assert(!Context && "initialized multiple times");
@@ -84,17 +66,6 @@ class CIRGenConsumer : public clang::ASTConsumer {
8466
MlirModule->print(*OutputStream, Flags);
8567
}
8668
break;
87-
case CIRGenAction::OutputType::EmitLLVM: {
88-
llvm::LLVMContext LLVMCtx;
89-
std::unique_ptr<llvm::Module> LLVMModule =
90-
lowerFromCIRToLLVMIR(MlirModule, LLVMCtx);
91-
92-
BackendAction BEAction = getBackendActionFromOutputType(Action);
93-
emitBackendOutput(
94-
CI, CI.getCodeGenOpts(), C.getTargetInfo().getDataLayoutString(),
95-
LLVMModule.get(), BEAction, FS, std::move(OutputStream));
96-
break;
97-
}
9869
}
9970
}
10071
};
@@ -113,8 +84,6 @@ getOutputStream(CompilerInstance &CI, StringRef InFile,
11384
switch (Action) {
11485
case CIRGenAction::OutputType::EmitCIR:
11586
return CI.createDefaultOutputFile(false, InFile, "cir");
116-
case CIRGenAction::OutputType::EmitLLVM:
117-
return CI.createDefaultOutputFile(false, InFile, "ll");
11887
}
11988
llvm_unreachable("Invalid CIRGenAction::OutputType");
12089
}
@@ -126,16 +95,14 @@ CIRGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
12695
if (!Out)
12796
Out = getOutputStream(CI, InFile, Action);
12897

129-
auto Result =
130-
std::make_unique<cir::CIRGenConsumer>(Action, CI, std::move(Out));
98+
auto Result = std::make_unique<cir::CIRGenConsumer>(
99+
Action, CI.getDiagnostics(), &CI.getVirtualFileSystem(),
100+
CI.getHeaderSearchOpts(), CI.getCodeGenOpts(), CI.getTargetOpts(),
101+
CI.getLangOpts(), CI.getFrontendOpts(), std::move(Out));
131102

132103
return Result;
133104
}
134105

135106
void EmitCIRAction::anchor() {}
136107
EmitCIRAction::EmitCIRAction(mlir::MLIRContext *MLIRCtx)
137108
: CIRGenAction(OutputType::EmitCIR, MLIRCtx) {}
138-
139-
void EmitLLVMAction::anchor() {}
140-
EmitLLVMAction::EmitLLVMAction(mlir::MLIRContext *MLIRCtx)
141-
: CIRGenAction(OutputType::EmitLLVM, MLIRCtx) {}

clang/lib/CIR/FrontendAction/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ add_clang_library(clangCIRFrontendAction
1212
clangAST
1313
clangFrontend
1414
clangCIR
15-
clangCIRLoweringDirectToLLVM
1615
MLIRCIR
1716
MLIRIR
1817
)

clang/lib/CIR/Lowering/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

clang/lib/CIR/Lowering/DirectToLLVM/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 0 additions & 39 deletions
This file was deleted.

clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,7 @@ CreateFrontendBaseAction(CompilerInstance &CI) {
7171
llvm_unreachable("CIR suppport not built into clang");
7272
#endif
7373
case EmitHTML: return std::make_unique<HTMLPrintAction>();
74-
case EmitLLVM: {
75-
#if CLANG_ENABLE_CIR
76-
if (UseCIR)
77-
return std::make_unique<cir::EmitLLVMAction>();
78-
#endif
79-
return std::make_unique<EmitLLVMAction>();
80-
}
74+
case EmitLLVM: return std::make_unique<EmitLLVMAction>();
8175
case EmitLLVMOnly: return std::make_unique<EmitLLVMOnlyAction>();
8276
case EmitCodeGenOnly: return std::make_unique<EmitCodeGenOnlyAction>();
8377
case EmitObj: return std::make_unique<EmitObjAction>();

clang/test/CIR/Lowering/hello.c

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)