Skip to content

Commit bc95e0b

Browse files
fangyi-zhoulanza
andauthored
[CIR] Add back ability to process cir files in cc1 (#1628)
Reapplying e66b670 which was reverted during rebase (after fixing some conflicts). Un-xfails the test `cc1.cir` (#1497). --------- Co-authored-by: Nathan Lanza <nathanlanza@gmail.com>
1 parent 88d7931 commit bc95e0b

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

clang/include/clang/Basic/LangStandard.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ enum class Language : uint8_t {
2626
/// Assembly: we accept this only so that we can preprocess it.
2727
Asm,
2828

29-
/// LLVM IR: we accept this so that we can run the optimizer on it,
30-
/// and compile it to assembly or object code.
29+
/// LLVM IR & CIR: we accept these so that we can run the optimizer on them,
30+
/// and compile them to assembly or object code (or LLVM for CIR).
3131
CIR,
3232
LLVM_IR,
3333

clang/include/clang/Driver/Types.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ TYPE("lto-ir", LTO_IR, INVALID, "s", phases
100100
TYPE("lto-bc", LTO_BC, INVALID, "o", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
101101

102102
TYPE("mlir", MLIR, INVALID, "mlir", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
103+
TYPE("cir", CIR, INVALID, "cir", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
103104

104105
// Misc.
105106
TYPE("ast", AST, INVALID, "ast", phases::Compile, phases::Backend, phases::Assemble, phases::Link)

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3239,6 +3239,7 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
32393239
.Cases("ast", "pcm", "precompiled-header",
32403240
InputKind(Language::Unknown, InputKind::Precompiled))
32413241
.Case("ir", Language::LLVM_IR)
3242+
.Case("cir", Language::CIR)
32423243
.Default(Language::Unknown);
32433244

32443245
if (DashX.isUnknown())
@@ -3708,7 +3709,8 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
37083709
const llvm::Triple &T,
37093710
InputKind IK) {
37103711
if (IK.getFormat() == InputKind::Precompiled ||
3711-
IK.getLanguage() == Language::LLVM_IR) {
3712+
IK.getLanguage() == Language::LLVM_IR ||
3713+
IK.getLanguage() == Language::CIR) {
37123714
if (Opts.ObjCAutoRefCount)
37133715
GenerateArg(Consumer, OPT_fobjc_arc);
37143716
if (Opts.PICLevel != 0)
@@ -4011,7 +4013,8 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
40114013
unsigned NumErrorsBefore = Diags.getNumErrors();
40124014

40134015
if (IK.getFormat() == InputKind::Precompiled ||
4014-
IK.getLanguage() == Language::LLVM_IR) {
4016+
IK.getLanguage() == Language::LLVM_IR ||
4017+
IK.getLanguage() == Language::CIR) {
40154018
// ObjCAAutoRefCount and Sanitize LangOpts are used to setup the
40164019
// PassManager in BackendUtil.cpp. They need to be initialized no matter
40174020
// what the input type is.

clang/lib/Frontend/FrontendOptions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ InputKind FrontendOptions::getInputKindForExtension(StringRef Extension) {
3434
.Case("hip", Language::HIP)
3535
.Cases("ll", "bc", Language::LLVM_IR)
3636
.Case("hlsl", Language::HLSL)
37+
.Case("cir", Language::CIR)
3738
.Default(Language::Unknown);
3839
}

clang/test/CIR/cc1.cir

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.cir
22
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=LLVM
3-
// XFAIL: *
43

54
module {
65
cir.func @foo() {

0 commit comments

Comments
 (0)