Skip to content

Commit

Permalink
[CIR] Introduce cir-translate to replace mlir-translate (llvm#177)
Browse files Browse the repository at this point in the history
This change introduces `cir-translate` as a replacement of
`mlir-translate` to convert CIR directly to LLVM IR. The main benefit of
this is to utilize the CIR attribute interface to handle CIR-specific
attributes such as `cir.extra`. Other advantages at this time, besides
the cir attribute support, could be that we can go directly from CIR to
LLVMIR without exposing the intermediate MLIR LLVM dialect form.
Previously `cir-tool` emit the LLVM dialect form and `milr-translate`
took it from there. Now `cir-translate` can directly take CIR and yield
LLVMIR.

I'm also renaming `cir-tool` to `cir-opt` which eventually would be just
a CIR-to-CIR transformer, but for now I'm keeping the functionality of
CIR to LLVM dialect.

So,
`cir-opt` will do all CIR-to-CIR transforms, just like LLVM `opt` or
`mlir-opt`, and
`cir-translate` will handle CIR to LLVMIR translation, and
LLVMIR-to-LLVMIR transforms, like the LLVM `llc` or the `mlir-translate`
  • Loading branch information
htyu authored and lanza committed Jan 29, 2024
1 parent cebe37d commit 601aef7
Show file tree
Hide file tree
Showing 65 changed files with 196 additions and 104 deletions.
1 change: 0 additions & 1 deletion clang/include/clang/CIR/LowerToLLVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace cir {
namespace direct {
std::unique_ptr<llvm::Module>
lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp theModule,
std::unique_ptr<mlir::MLIRContext> mlirCtx,
llvm::LLVMContext &llvmCtx);
}

Expand Down
3 changes: 1 addition & 2 deletions clang/lib/CIR/FrontendAction/CIRGenAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ static std::unique_ptr<llvm::Module> lowerFromCIRToLLVMIR(
const clang::FrontendOptions &feOptions, mlir::ModuleOp mlirMod,
std::unique_ptr<mlir::MLIRContext> mlirCtx, llvm::LLVMContext &llvmCtx) {
if (feOptions.ClangIRDirectLowering)
return direct::lowerDirectlyFromCIRToLLVMIR(mlirMod, std::move(mlirCtx),
llvmCtx);
return direct::lowerDirectlyFromCIRToLLVMIR(mlirMod, llvmCtx);
else
return lowerFromCIRToMLIRToLLVMIR(mlirMod, std::move(mlirCtx), llvmCtx);
}
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1416,9 +1416,9 @@ extern void registerCIRDialectTranslation(mlir::MLIRContext &context);

std::unique_ptr<llvm::Module>
lowerDirectlyFromCIRToLLVMIR(mlir::ModuleOp theModule,
std::unique_ptr<mlir::MLIRContext> mlirCtx,
LLVMContext &llvmCtx) {
mlir::PassManager pm(mlirCtx.get());
mlir::MLIRContext *mlirCtx = theModule.getContext();
mlir::PassManager pm(mlirCtx);

pm.addPass(createConvertCIRToLLVMPass());

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/IR/array.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s | cir-tool | FileCheck %s
// RUN: cir-opt %s | cir-opt | FileCheck %s

!u32i = !cir.int<u, 32>

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/IR/branch.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s | FileCheck %s
// RUN: cir-opt %s | FileCheck %s

#false = #cir.bool<false> : !cir.bool
#true = #cir.bool<true> : !cir.bool
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/IR/call.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s | FileCheck %s
// RUN: cir-opt %s | FileCheck %s

!s32i = !cir.int<s, 32>
!fnptr = !cir.ptr<!cir.func<!s32i (!cir.ptr<!s32i>)>>
Expand All @@ -10,4 +10,4 @@ module {
}
}

// CHECK: %0 = cir.call %arg0(%arg1) : (!cir.ptr<!cir.func<!s32i (!cir.ptr<!s32i>)>>, !s32i) -> !s32i
// CHECK: %0 = cir.call %arg0(%arg1) : (!cir.ptr<!cir.func<!s32i (!cir.ptr<!s32i>)>>, !s32i) -> !s32i
2 changes: 1 addition & 1 deletion clang/test/CIR/IR/cast.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s | cir-tool | FileCheck %s
// RUN: cir-opt %s | cir-opt | FileCheck %s
!s32i = !cir.int<s, 32>

module {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/IR/cir-ops.cir
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Test the CIR operations can parse and print correctly (roundtrip)

// RUN: cir-tool %s | cir-tool | FileCheck %s
// RUN: cir-opt %s | cir-opt | FileCheck %s
!s32i = !cir.int<s, 32>
!s8i = !cir.int<s, 8>
!u64i = !cir.int<u, 64>
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/IR/func.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s | FileCheck %s
// RUN: cir-opt %s | FileCheck %s
!s32i = !cir.int<s, 32>
!u8i = !cir.int<u, 8>
module {
Expand Down Expand Up @@ -42,4 +42,4 @@ module {
cir.func no_proto private @no_proto(...) -> !s32i
}

// CHECK: cir.func @l0()
// CHECK: cir.func @l0()
2 changes: 1 addition & 1 deletion clang/test/CIR/IR/global.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s | FileCheck %s
// RUN: cir-opt %s | FileCheck %s
!s8i = !cir.int<s, 8>
!s32i = !cir.int<s, 32>
!s64i = !cir.int<s, 64>
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/IR/inlineAttr.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s | FileCheck %s -check-prefix=CIR
// RUN: cir-tool %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-opt %s | FileCheck %s -check-prefix=CIR
// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR

module {
cir.func @l0() extra( {cir.inline = #cir.inline<no>} ) {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/IR/int.cir
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// cir.global external @a = #cir.int<255> : !cir.int<u, 8>
// }

// RUN: cir-tool %s | FileCheck %s
// RUN: cir-opt %s | FileCheck %s
!s8i = !cir.int<s, 8>
!s16i = !cir.int<s, 16>
!s32i = !cir.int<s, 32>
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/IR/invalid.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Test attempts to build bogus CIR
// RUN: cir-tool %s -verify-diagnostics -split-input-file
// RUN: cir-opt %s -verify-diagnostics -split-input-file

!u32i = !cir.int<u, 32>

Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/IR/loop.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s | FileCheck %s
// RUN: cir-opt %s | FileCheck %s
#false = #cir.bool<false> : !cir.bool
#true = #cir.bool<true> : !cir.bool
!u32i = !cir.int<u, 32>
Expand Down Expand Up @@ -212,4 +212,4 @@ cir.func @l2() {
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK-NEXT: cir.return
// CHECK-NEXT: }
// CHECK-NEXT: }
2 changes: 1 addition & 1 deletion clang/test/CIR/IR/module.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s -split-input-file -o %t.cir
// RUN: cir-opt %s -split-input-file -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s

// Should parse and print C source language attribute.
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/IR/ptr_stride.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s | cir-tool | FileCheck %s
// RUN: cir-opt %s | cir-opt | FileCheck %s
!s32i = !cir.int<s, 32>

module {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/IR/struct.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s | cir-tool | FileCheck %s
// RUN: cir-opt %s | cir-opt | FileCheck %s

!u8i = !cir.int<u, 8>
!u16i = !cir.int<u, 16>
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/IR/switch.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s | FileCheck %s
// RUN: cir-opt %s | FileCheck %s
!s32i = !cir.int<s, 32>

cir.func @s0() {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/IR/ternary.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s | cir-tool | FileCheck %s
// RUN: cir-opt %s | cir-opt | FileCheck %s
!u32i = !cir.int<u, 32>

module {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/IR/types.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s | cir-tool | FileCheck %s
// RUN: cir-opt %s | cir-opt | FileCheck %s

!u32i = !cir.int<u, 32>

Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/ThroughMLIR/array.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-mlir -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-opt %s -cir-to-mlir -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM

module {
cir.func @foo() {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/ThroughMLIR/binop-fp.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-opt %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM

module {
cir.func @foo() {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/ThroughMLIR/binop-unsigned-int.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-opt %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM

module {
cir.func @foo() {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/ThroughMLIR/bool.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-opt %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM

#false = #cir.bool<false> : !cir.bool
#true = #cir.bool<true> : !cir.bool
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/ThroughMLIR/cmp.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-opt %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM

module {
cir.func @foo() {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/Lowering/ThroughMLIR/dot.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s -cir-to-mlir -o %t.mlir
// RUN: cir-opt %s -cir-to-mlir -o %t.mlir
// RUN: FileCheck --input-file=%t.mlir %s
// XFAIL: *

Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/ThroughMLIR/goto.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -canonicalize -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -canonicalize -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -canonicalize -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-opt %s -canonicalize -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM

module {
cir.func @foo() {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/ThroughMLIR/memref.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-opt %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM

module {
cir.func @foo() -> i32 {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/ThroughMLIR/unary-inc-dec.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-opt %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM

module {
cir.func @foo() {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/ThroughMLIR/unary-plus-minus.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-mlir -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-opt %s -cir-to-mlir -cir-mlir-to-llvm -o - | mlir-translate -mlir-to-llvmir | FileCheck %s -check-prefix=LLVM

module {
cir.func @foo() {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/array.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-llvm -o - | mlir-translate -mlir-to-llvmir -allow-unregistered-dialect | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-translate %s -cir-to-llvmir -o - | FileCheck %s -check-prefix=LLVM

module {
cir.func @foo() {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/binop-fp.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-llvm -o - | mlir-translate -mlir-to-llvmir -allow-unregistered-dialect | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-translate %s -cir-to-llvmir | FileCheck %s -check-prefix=LLVM

module {
cir.func @foo() {
Expand Down
3 changes: 1 addition & 2 deletions clang/test/CIR/Lowering/binop-signed-int.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s -cir-to-llvm -o %t.mlir
// RUN: cir-opt %s -cir-to-llvm -o %t.mlir
// RUN: FileCheck --input-file=%t.mlir %s

!s32i = !cir.int<s, 32>
Expand Down Expand Up @@ -62,4 +62,3 @@ module {
cir.return
}
}

4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/binop-unsigned-int.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-llvm -o - | mlir-translate -mlir-to-llvmir -allow-unregistered-dialect | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-translate %s -cir-to-llvmir | FileCheck %s -check-prefix=LLVM
!u32i = !cir.int<u, 32>

module {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/bool.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-llvm -o - | mlir-translate -mlir-to-llvmir -allow-unregistered-dialect | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-translate %s -cir-to-llvmir | FileCheck %s -check-prefix=LLVM

#false = #cir.bool<false> : !cir.bool
#true = #cir.bool<true> : !cir.bool
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CIR/Lowering/branch.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-llvm -o - | mlir-translate -mlir-to-llvmir -allow-unregistered-dialect | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-translate %s -cir-to-llvmir | FileCheck %s -check-prefix=LLVM

!s32i = !cir.int<s, 32>
cir.func @foo(%arg0: !cir.bool) -> !s32i {
Expand All @@ -25,7 +25,7 @@ cir.func @foo(%arg0: !cir.bool) -> !s32i {
// MLIR-NEXT: }
// MLIR-NEXT: }

// LLVM: define i32 @foo(i8 %0) {
// LLVM: define i32 @foo(i8 %0)
// LLVM-NEXT: %2 = trunc i8 %0 to i1
// LLVM-NEXT: br i1 %2, label %3, label %4
// LLVM-EMPTY:
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/call.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-llvm -o - | mlir-translate -mlir-to-llvmir -allow-unregistered-dialect | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-translate %s -cir-to-llvmir | FileCheck %s -check-prefix=LLVM

module {
cir.func @a() {
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CIR/Lowering/cast.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-llvm -o - | mlir-translate -mlir-to-llvmir -allow-unregistered-dialect | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-translate %s -cir-to-llvmir | FileCheck %s -check-prefix=LLVM
!s16i = !cir.int<s, 16>
!s32i = !cir.int<s, 32>
!s64i = !cir.int<s, 64>
Expand All @@ -22,7 +22,7 @@ module {
// MLIR-NEXT: }


// LLVM: define i32 @foo(i32 %0) {
// LLVM: define i32 @foo(i32 %0)
// LLVM-NEXT: %2 = icmp ne i32 %0, 0
// LLVM-NEXT: %3 = zext i1 %2 to i8
// LLVM-NEXT: ret i32 %0
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/cmp.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-llvm -o - | mlir-translate -mlir-to-llvmir -allow-unregistered-dialect | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-translate %s -cir-to-llvmir | FileCheck %s -check-prefix=LLVM
!s32i = !cir.int<s, 32>
module {
cir.func @foo() {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/Lowering/dot.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s -cir-to-llvm -o %t.mlir
// RUN: cir-opt %s -cir-to-llvm -o %t.mlir
// RUN: FileCheck --input-file=%t.mlir %s -check-prefix=MLIR

!s32i = !cir.int<s, 32>
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/Lowering/func.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s -cir-to-llvm -o %t.mlir
// RUN: cir-opt %s -cir-to-llvm -o %t.mlir
// RUN: FileCheck %s -check-prefix=MLIR --input-file=%t.mlir
// XFAIL: *

Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/globals.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-llvm -o - | mlir-translate -mlir-to-llvmir -allow-unregistered-dialect | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-translate %s -cir-to-llvmir | FileCheck %s -check-prefix=LLVM

!s16i = !cir.int<s, 16>
!s32i = !cir.int<s, 32>
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/goto.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -canonicalize -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -canonicalize -cir-to-llvm -o - | mlir-translate -mlir-to-llvmir -allow-unregistered-dialect | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -canonicalize -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-opt %s -canonicalize -o - | cir-translate -cir-to-llvmir | FileCheck %s -check-prefix=LLVM

!u32i = !cir.int<u, 32>

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/Lowering/hello.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s -cir-to-llvm -o %t.mlir
// RUN: cir-opt %s -cir-to-llvm -o %t.mlir
// RUN: FileCheck --input-file=%t.mlir %s

!s32i = !cir.int<s, 32>
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CIR/Lowering/if.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-llvm -o - | mlir-translate -mlir-to-llvmir -allow-unregistered-dialect | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-translate %s -cir-to-llvmir | FileCheck %s -check-prefix=LLVM
!s32i = !cir.int<s, 32>

module {
Expand Down Expand Up @@ -31,7 +31,7 @@ module {
// MLIR-NEXT: llvm.return %arg0 : i32
// MLIR-NEXT: }

// LLVM: define i32 @foo(i32 %0) {
// LLVM: define i32 @foo(i32 %0)
// LLVM-NEXT: %2 = icmp ne i32 %0, 0
// LLVM-NEXT: %3 = zext i1 %2 to i8
// LLVM-NEXT: %4 = trunc i8 %3 to i1
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/loadstorealloca.cir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: cir-tool %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-tool %s -cir-to-llvm -o - | mlir-translate -mlir-to-llvmir -allow-unregistered-dialect | FileCheck %s -check-prefix=LLVM
// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
// RUN: cir-translate %s -cir-to-llvmir | FileCheck %s -check-prefix=LLVM
!u32i = !cir.int<u, 32>

module {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CIR/Lowering/loop.cir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: cir-tool %s -cir-to-llvm -o %t.mlir
// RUN: cir-opt %s -cir-to-llvm -o %t.mlir
// RUN: FileCheck --input-file=%t.mlir %s -check-prefix=MLIR

!s32i = !cir.int<s, 32>
Expand Down
Loading

0 comments on commit 601aef7

Please sign in to comment.