[clang] [CIR][X86] Implement xsave/xrstor builtins Fixes part of #167752 (PR #170877)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 9 11:11:42 PST 2025
================
@@ -7,23 +7,35 @@
void test_xsave(void *p, unsigned long long m) {
// CIR-LABEL: test_xsave
- // CIR: cir.const #cir.int<32> : !s64i
- // CIR: cir.shift(right, {{.*}} : !u64i, {{.*}} : !s64i) -> !u64i
- // CIR: cir.cast integral %{{.*}} : !u64i -> !s32i
- // CIR: cir.cast integral %{{.*}} : !u64i -> !s32i
- // CIR: cir.call_llvm_intrinsic "x86.xsave"
+ // CIR: [[P:%.*]] = cir.load {{.*}} : !cir.ptr<!cir.ptr<!void>>, !cir.ptr<!void>
+ // CIR: [[M:%.*]] = cir.load {{.*}} : !cir.ptr<!u64i>, !u64i
+ // CIR: [[CONST:%.*]] = cir.const #cir.int<32> : !s64i
+ // CIR: [[SHIFT:%.*]] = cir.shift(right, [[M]] : !u64i, [[CONST]] : !s64i) -> !u64i
+ // CIR: [[CAST1:%.*]] = cir.cast integral [[SHIFT]] : !u64i -> !s32i
+ // CIR: [[CAST2:%.*]] = cir.cast integral [[M]] : !u64i -> !s32i
+ // CIR: cir.call_llvm_intrinsic "x86.xsave" [[P]], [[CAST1]], [[CAST2]]
// LLVM-LABEL: test_xsave
- // LLVM: lshr i64 {{.*}}, 32
- // LLVM: trunc i64 {{.*}} to i32
- // LLVM: trunc i64 {{.*}} to i32
- // LLVM: call void @llvm.x86.xsave(ptr {{.*}}, i32 {{.*}}, i32 {{.*}})
+ // LLVM: [[LP:%.*]] = load ptr, ptr
+ // LLVM: [[LM:%.*]] = load i64, ptr
+ // LLVM: [[LSHIFT:%.*]] = lshr i64 [[LM]], 32
+ // LLVM: [[LCAST1:%.*]] = trunc i64 [[LSHIFT]] to i32
+ // LLVM: [[LCAST2:%.*]] = trunc i64 [[LM]] to i32
+ // LLVM: call void @llvm.x86.xsave(ptr [[LP]], i32 [[LCAST1]], i32 [[LCAST2]])
// OGCG-LABEL: test_xsave
- // OGCG: call void @llvm.x86.xsave
+ // OGCG: [[OP:%.*]] = load ptr, ptr
----------------
andykaylor wrote:
This is fine, but it isn't necessary to use different identifiers between LLVM checks and OGCG checks. We often even reuse identifiers between different test cases with the same output type.
https://github.com/llvm/llvm-project/pull/170877
More information about the cfe-commits
mailing list