123 lines · c
1// RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=i686-unknown-unknown -target-feature +xsave -emit-llvm -o - -Wall -Wno-unused-but-set-variable -Werror | FileCheck %s --check-prefix=XSAVE2// RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=i686-unknown-unknown -target-feature +xsave -fno-signed-char -emit-llvm -o - -Wall -Wno-unused-but-set-variable -Werror | FileCheck %s --check-prefix=XSAVE3 4// RUN: %clang_cc1 %s -DTEST_XGETBV -O0 -triple=i686-unknown-unknown -target-feature +xsave -emit-llvm -o - -Wall -Wno-unused-but-set-variable -Werror | FileCheck %s --check-prefix=XGETBV5// RUN: %clang_cc1 %s -DTEST_XSETBV -O0 -triple=i686-unknown-unknown -target-feature +xsave -emit-llvm -o - -Wall -Wno-unused-but-set-variable -Werror | FileCheck %s --check-prefix=XSETBV6 7// RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=i686-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -emit-llvm -o - -Wall -Wno-unused-but-set-variable -Werror | FileCheck %s --check-prefix=XSAVEOPT8// RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=i686-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -fno-signed-char -emit-llvm -o - -Wall -Wno-unused-but-set-variable -Werror | FileCheck %s --check-prefix=XSAVEOPT9 10// RUN: %clang_cc1 %s -DTEST_XSAVEC -O0 -triple=i686-unknown-unknown -target-feature +xsave -target-feature +xsavec -emit-llvm -o - -Wall -Wno-unused-but-set-variable -Werror | FileCheck %s --check-prefix=XSAVEC11// RUN: %clang_cc1 %s -DTEST_XSAVEC -O0 -triple=i686-unknown-unknown -target-feature +xsave -target-feature +xsavec -fno-signed-char -emit-llvm -o - -Wall -Wno-unused-but-set-variable -Werror | FileCheck %s --check-prefix=XSAVEC12 13// RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=i686-unknown-unknown -target-feature +xsave -target-feature +xsaves -emit-llvm -o - -Wall -Wno-unused-but-set-variable -Werror | FileCheck %s --check-prefix=XSAVES14// RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=i686-unknown-unknown -target-feature +xsave -target-feature +xsaves -fno-signed-char -emit-llvm -o - -Wall -Wno-unused-but-set-variable -Werror | FileCheck %s --check-prefix=XSAVES15 16// Don't include mm_malloc.h, it's system specific.17#define __MM_MALLOC_H18#include <x86intrin.h>19 20void test(void) {21 unsigned long long tmp_ULLi;22 unsigned int tmp_Ui;23 void* tmp_vp;24 tmp_ULLi = 0; tmp_Ui = 0; tmp_vp = 0;25 26#ifdef TEST_XSAVE27// XSAVE: [[tmp_vp_1:%[0-9a-zA-Z]+]] = load ptr, ptr %tmp_vp, align 428// XSAVE: [[tmp_ULLi_1:%[0-9a-zA-Z]+]] = load i64, ptr %tmp_ULLi, align 829// XSAVE: [[high64_1:%[0-9a-zA-Z]+]] = lshr i64 [[tmp_ULLi_1]], 3230// XSAVE: [[high32_1:%[0-9a-zA-Z]+]] = trunc i64 [[high64_1]] to i3231// XSAVE: [[low32_1:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_1]] to i3232// XSAVE: call void @llvm.x86.xsave(ptr [[tmp_vp_1]], i32 [[high32_1]], i32 [[low32_1]])33 (void)__builtin_ia32_xsave(tmp_vp, tmp_ULLi);34 35// XSAVE: [[tmp_vp_3:%[0-9a-zA-Z]+]] = load ptr, ptr %tmp_vp, align 436// XSAVE: [[tmp_ULLi_3:%[0-9a-zA-Z]+]] = load i64, ptr %tmp_ULLi, align 837// XSAVE: [[high64_3:%[0-9a-zA-Z]+]] = lshr i64 [[tmp_ULLi_3]], 3238// XSAVE: [[high32_3:%[0-9a-zA-Z]+]] = trunc i64 [[high64_3]] to i3239// XSAVE: [[low32_3:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_3]] to i3240// XSAVE: call void @llvm.x86.xrstor(ptr [[tmp_vp_3]], i32 [[high32_3]], i32 [[low32_3]])41 (void)__builtin_ia32_xrstor(tmp_vp, tmp_ULLi);42 43// XSAVE: call void @llvm.x86.xsave44 (void)_xsave(tmp_vp, tmp_ULLi);45 46// XSAVE: call void @llvm.x86.xrstor47 (void)_xrstor(tmp_vp, tmp_ULLi);48#endif49 50#ifdef TEST_XSAVEOPT51// XSAVEOPT: [[tmp_vp_1:%[0-9a-zA-Z]+]] = load ptr, ptr %tmp_vp, align 452// XSAVEOPT: [[tmp_ULLi_1:%[0-9a-zA-Z]+]] = load i64, ptr %tmp_ULLi, align 853// XSAVEOPT: [[high64_1:%[0-9a-zA-Z]+]] = lshr i64 [[tmp_ULLi_1]], 3254// XSAVEOPT: [[high32_1:%[0-9a-zA-Z]+]] = trunc i64 [[high64_1]] to i3255// XSAVEOPT: [[low32_1:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_1]] to i3256// XSAVEOPT: call void @llvm.x86.xsaveopt(ptr [[tmp_vp_1]], i32 [[high32_1]], i32 [[low32_1]])57 (void)__builtin_ia32_xsaveopt(tmp_vp, tmp_ULLi);58 59// XSAVEOPT: call void @llvm.x86.xsaveopt60 (void)_xsaveopt(tmp_vp, tmp_ULLi);61#endif62 63#ifdef TEST_XSAVEC64// XSAVEC: [[tmp_vp_1:%[0-9a-zA-Z]+]] = load ptr, ptr %tmp_vp, align 465// XSAVEC: [[tmp_ULLi_1:%[0-9a-zA-Z]+]] = load i64, ptr %tmp_ULLi, align 866// XSAVEC: [[high64_1:%[0-9a-zA-Z]+]] = lshr i64 [[tmp_ULLi_1]], 3267// XSAVEC: [[high32_1:%[0-9a-zA-Z]+]] = trunc i64 [[high64_1]] to i3268// XSAVEC: [[low32_1:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_1]] to i3269// XSAVEC: call void @llvm.x86.xsavec(ptr [[tmp_vp_1]], i32 [[high32_1]], i32 [[low32_1]])70 (void)__builtin_ia32_xsavec(tmp_vp, tmp_ULLi);71 72// XSAVEC: call void @llvm.x86.xsavec 73 (void)_xsavec(tmp_vp, tmp_ULLi);74#endif75 76#ifdef TEST_XSAVES77// XSAVES: [[tmp_vp_1:%[0-9a-zA-Z]+]] = load ptr, ptr %tmp_vp, align 478// XSAVES: [[tmp_ULLi_1:%[0-9a-zA-Z]+]] = load i64, ptr %tmp_ULLi, align 879// XSAVES: [[high64_1:%[0-9a-zA-Z]+]] = lshr i64 [[tmp_ULLi_1]], 3280// XSAVES: [[high32_1:%[0-9a-zA-Z]+]] = trunc i64 [[high64_1]] to i3281// XSAVES: [[low32_1:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_1]] to i3282// XSAVES: call void @llvm.x86.xsaves(ptr [[tmp_vp_1]], i32 [[high32_1]], i32 [[low32_1]])83 (void)__builtin_ia32_xsaves(tmp_vp, tmp_ULLi);84 85// XSAVES: [[tmp_vp_3:%[0-9a-zA-Z]+]] = load ptr, ptr %tmp_vp, align 486// XSAVES: [[tmp_ULLi_3:%[0-9a-zA-Z]+]] = load i64, ptr %tmp_ULLi, align 887// XSAVES: [[high64_3:%[0-9a-zA-Z]+]] = lshr i64 [[tmp_ULLi_3]], 3288// XSAVES: [[high32_3:%[0-9a-zA-Z]+]] = trunc i64 [[high64_3]] to i3289// XSAVES: [[low32_3:%[0-9a-zA-Z]+]] = trunc i64 [[tmp_ULLi_3]] to i3290// XSAVES: call void @llvm.x86.xrstors(ptr [[tmp_vp_3]], i32 [[high32_3]], i32 [[low32_3]])91 (void)__builtin_ia32_xrstors(tmp_vp, tmp_ULLi);92 93// XSAVES: call void @llvm.x86.xsaves94 (void)_xsaves(tmp_vp, tmp_ULLi); 95 96// XSAVES: call void @llvm.x86.xrstors97 (void)_xrstors(tmp_vp, tmp_ULLi);98#endif99 100#ifdef TEST_XGETBV101// XGETBV: [[tmp_Ui:%[0-9a-zA-z]+]] = load i32, ptr %tmp_Ui, align 4102// XGETBV: call i64 @llvm.x86.xgetbv(i32 [[tmp_Ui]])103 tmp_ULLi = __builtin_ia32_xgetbv(tmp_Ui);104 105// XGETBV: call i64 @llvm.x86.xgetbv106 tmp_ULLi = _xgetbv(tmp_Ui);107#endif108 109#ifdef TEST_XSETBV110// XSETBV: [[tmp_Ui:%[0-9a-zA-z]+]] = load i32, ptr %tmp_Ui, align 4111// XSETBV: [[tmp_ULLi_3:%[0-9a-zA-z]+]] = load i64, ptr %tmp_ULLi, align 8112// XSETBV: [[high64_3:%[0-9a-zA-z]+]] = lshr i64 [[tmp_ULLi_3]], 32113// XSETBV: [[high32_3:%[0-9a-zA-z]+]] = trunc i64 [[high64_3]] to i32114// XSETBV: [[low32_3:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_3]] to i32115// XSETBV: call void @llvm.x86.xsetbv(i32 [[tmp_Ui]], i32 [[high32_3]], i32 [[low32_3]])116 (void)__builtin_ia32_xsetbv(tmp_Ui, tmp_ULLi);117 118 // XSETBV: call void @llvm.x86.xsetbv119 (void)_xsetbv(tmp_Ui, tmp_ULLi);120#endif121 122}123