Files
TheRock/compiler/amd-llvm/clang/test/CodeGen/ms-intrinsics-cpuid.c
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

81 lines
5.3 KiB
C

// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
// RUN: -Werror -triple i686-windows-msvc -emit-llvm %s -o - | FileCheck %s --check-prefix=X86
// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
// RUN: -Werror -triple x86_64-windows-msvc -emit-llvm %s -o - | FileCheck %s --check-prefix=X64
// intrin.h needs size_t, but -ffreestanding prevents us from getting it from
// stddef.h. Work around it with this typedef.
typedef __SIZE_TYPE__ size_t;
#include <intrin.h>
#pragma intrinsic(__cpuid)
void test__cpuid(int cpuInfo[4], int function_id) {
__cpuid(cpuInfo, function_id);
}
// X86-LABEL: define {{.*}} @test__cpuid(ptr noundef %{{.*}}, i32 noundef %{{.*}})
// X86-DAG: [[ASMRESULTS:%[0-9]+]] = call { i32, i32, i32, i32 } asm "cpuid", "={ax},={bx},={cx},={dx},{ax},{cx}"
// X86-DAG: [[ADDRPTR0:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 0
// X86-DAG: [[ADDRPTR1:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 1
// X86-DAG: [[ADDRPTR2:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 2
// X86-DAG: [[ADDRPTR3:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 3
// X86-DAG: [[RESULT0:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 0
// X86-DAG: [[RESULT1:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 1
// X86-DAG: [[RESULT2:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 2
// X86-DAG: [[RESULT3:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 3
// X86-DAG: store i32 [[RESULT0]], ptr [[ADDRPTR0]], align 4
// X86-DAG: store i32 [[RESULT1]], ptr [[ADDRPTR1]], align 4
// X86-DAG: store i32 [[RESULT2]], ptr [[ADDRPTR2]], align 4
// X86-DAG: store i32 [[RESULT3]], ptr [[ADDRPTR3]], align 4
// X64-LABEL: define {{.*}} @test__cpuid(ptr noundef %{{.*}}, i32 noundef %{{.*}})
// X64-DAG: [[ASMRESULTS:%[0-9]+]] = call { i32, i32, i32, i32 } asm "xchgq %rbx, ${1:q}\0Acpuid\0Axchgq %rbx, ${1:q}", "={ax},=r,={cx},={dx},0,2"
// X64-DAG: [[ADDRPTR0:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 0
// X64-DAG: [[ADDRPTR1:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 1
// X64-DAG: [[ADDRPTR2:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 2
// X64-DAG: [[ADDRPTR3:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 3
// X64-DAG: [[RESULT0:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 0
// X64-DAG: [[RESULT1:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 1
// X64-DAG: [[RESULT2:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 2
// X64-DAG: [[RESULT3:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 3
// X64-DAG: store i32 [[RESULT0]], ptr [[ADDRPTR0]], align 4
// X64-DAG: store i32 [[RESULT1]], ptr [[ADDRPTR1]], align 4
// X64-DAG: store i32 [[RESULT2]], ptr [[ADDRPTR2]], align 4
// X64-DAG: store i32 [[RESULT3]], ptr [[ADDRPTR3]], align 4
#pragma intrinsic(__cpuidex)
void test__cpuidex(int cpuInfo[4], int function_id, int subfunction_id) {
__cpuidex(cpuInfo, function_id, subfunction_id);
}
// X86-LABEL: define {{.*}} @test__cpuidex(ptr noundef %{{.*}}, i32 noundef %{{.*}}, i32 noundef %{{.*}})
// X86-DAG: [[ASMRESULTS:%[0-9]+]] = call { i32, i32, i32, i32 } asm "cpuid", "={ax},={bx},={cx},={dx},{ax},{cx}"
// X86-DAG: [[ADDRPTR0:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 0
// X86-DAG: [[ADDRPTR1:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 1
// X86-DAG: [[ADDRPTR2:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 2
// X86-DAG: [[ADDRPTR3:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 3
// X86-DAG: [[RESULT0:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 0
// X86-DAG: [[RESULT1:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 1
// X86-DAG: [[RESULT2:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 2
// X86-DAG: [[RESULT3:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 3
// X86-DAG: store i32 [[RESULT0]], ptr [[ADDRPTR0]], align 4
// X86-DAG: store i32 [[RESULT1]], ptr [[ADDRPTR1]], align 4
// X86-DAG: store i32 [[RESULT2]], ptr [[ADDRPTR2]], align 4
// X86-DAG: store i32 [[RESULT3]], ptr [[ADDRPTR3]], align 4
// X64-LABEL: define {{.*}} @test__cpuidex(ptr noundef %{{.*}}, i32 noundef %{{.*}}, i32 noundef %{{.*}})
// X64-DAG: [[ASMRESULTS:%[0-9]+]] = call { i32, i32, i32, i32 } asm "xchgq %rbx, ${1:q}\0Acpuid\0Axchgq %rbx, ${1:q}", "={ax},=r,={cx},={dx},0,2"
// X64-DAG: [[ADDRPTR0:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 0
// X64-DAG: [[ADDRPTR1:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 1
// X64-DAG: [[ADDRPTR2:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 2
// X64-DAG: [[ADDRPTR3:%[0-9]+]] = getelementptr inbounds i32, ptr %{{.*}}, i32 3
// X64-DAG: [[RESULT0:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 0
// X64-DAG: [[RESULT1:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 1
// X64-DAG: [[RESULT2:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 2
// X64-DAG: [[RESULT3:%[0-9]+]] = extractvalue { i32, i32, i32, i32 } [[ASMRESULTS]], 3
// X64-DAG: store i32 [[RESULT0]], ptr [[ADDRPTR0]], align 4
// X64-DAG: store i32 [[RESULT1]], ptr [[ADDRPTR1]], align 4
// X64-DAG: store i32 [[RESULT2]], ptr [[ADDRPTR2]], align 4
// X64-DAG: store i32 [[RESULT3]], ptr [[ADDRPTR3]], align 4