[clang] [CIR][X86] Implement xsave/xrstor builtins Fixes part of #167752 (PR #170877)

Medha Tiwari via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 6 01:54:51 PST 2025


================
@@ -0,0 +1,175 @@
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +xsave -target-feature +xsaveopt -target-feature +xsavec -target-feature +xsaves -fclangir -emit-cir -o %t.cir -Wall -Werror
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +xsave -target-feature +xsaveopt -target-feature +xsavec -target-feature +xsaves -fclangir -emit-llvm -o %t.ll -Wall -Werror
+// RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s
+
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +xsave -target-feature +xsaveopt -target-feature +xsavec -target-feature +xsaves -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG
+
+void test_xsave(void *p, unsigned long long m) {
+  // CIR-LABEL: test_xsave
+  // CIR: cir.call_llvm_intrinsic "x86.xsave"
----------------
medhatiwari wrote:

Added detailed CIR and LLVM checks for test_xsave showing the shift, casts, and intrinsic call with parameters. The pattern is the same for all other xsave variants, so I kept just the intrinsic name check for the rest to avoid redundancy.

https://github.com/llvm/llvm-project/pull/170877


More information about the cfe-commits mailing list