Skip to content

Commit fbcfabb

Browse files
authored
[CIR][CIRGen][builtin][X86] handle _mm_lfence (#1474)
I realized I committed a new file with CRLF before. Really sorry about that >_< Related: #1404
1 parent 6b68a48 commit fbcfabb

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,13 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned BuiltinID,
105105
voidTy, Ops[0])
106106
.getResult();
107107
}
108+
case X86::BI_mm_lfence: {
109+
mlir::Type voidTy = cir::VoidType::get(&getMLIRContext());
110+
return builder
111+
.create<cir::LLVMIntrinsicCallOp>(
112+
getLoc(E->getExprLoc()), builder.getStringAttr("x86.sse2.lfence"),
113+
voidTy)
114+
.getResult();
115+
}
108116
}
109117
}

clang/test/CIR/CodeGen/AArch64/neon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
// REQUIRES: aarch64-registered-target || arm-registered-target
1313

14-
// This test mimics clang/test/CodeGen/aarch64-neon-intrinsics.c, which eventually
14+
// This test mimics clang/test/CodeGen/AArch64/neon-intrinsics.c, which eventually
1515
// CIR shall be able to support fully. Since this is going to take some time to converge,
1616
// the unsupported/NYI code is commented out, so that we can incrementally improve this.
1717
// The NYI filecheck used contains the LLVM output from OG codegen that should guide the
Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
// Global variables of intergal types
2-
// RUN: %clang_cc1 -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-cir -o %t.cir %s
3-
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
4-
// RUN: %clang_cc1 -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-llvm -o %t.ll %s
5-
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
6-
7-
void test_mm_clflush(const void* tmp_vCp) {
8-
// CIR-LABEL: test_mm_clflush
9-
// LLVM-LABEL: test_mm_clflush
10-
_mm_clflush(tmp_vCp);
11-
// CIR: {{%.*}} = cir.llvm.intrinsic "x86.sse2.clflush" {{%.*}} : (!cir.ptr<!void>) -> !void
12-
// LLVM: call void @llvm.x86.sse2.clflush(ptr {{%.*}})
13-
}
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-cir -o %t.cir %s
2+
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3+
// RUN: %clang_cc1 -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-llvm -o %t.ll %s
4+
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
5+
6+
// This test mimics clang/test/CodeGen/builtins-x86.c, which eventually
7+
// CIR shall be able to support fully.
8+
9+
void test_mm_clflush(const void* tmp_vCp) {
10+
// CIR-LABEL: test_mm_clflush
11+
// LLVM-LABEL: test_mm_clflush
12+
_mm_clflush(tmp_vCp);
13+
// CIR: {{%.*}} = cir.llvm.intrinsic "x86.sse2.clflush" {{%.*}} : (!cir.ptr<!void>) -> !void
14+
// LLVM: call void @llvm.x86.sse2.clflush(ptr {{%.*}})
15+
}
16+
17+
void test_mm_lfence() {
18+
// CIR-LABEL: test_mm_lfence
19+
// LLVM-LABEL: test_mm_lfence
20+
_mm_lfence();
21+
// CIR: {{%.*}} = cir.llvm.intrinsic "x86.sse2.lfence" : () -> !void
22+
// LLVM: call void @llvm.x86.sse2.lfence()
23+
}

0 commit comments

Comments
 (0)