15e52fa90SGabor Buella // RUN: %clang_cc1 %s -ffreestanding -triple x86_64-unknown-unknown -target-feature +sgx -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-64
25e52fa90SGabor Buella // RUN: %clang_cc1 %s -ffreestanding -triple i386 -target-feature +sgx -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-32
35e52fa90SGabor Buella
4*5219ed89SGabor Buella #include <immintrin.h>
55e52fa90SGabor Buella #include <stdint.h>
65e52fa90SGabor Buella #include <stddef.h>
75e52fa90SGabor Buella
test_encls(uint32_t leaf,size_t data[3])85e52fa90SGabor Buella uint32_t test_encls(uint32_t leaf, size_t data[3]) {
95e52fa90SGabor Buella // CHECK-64: call { i32, i64, i64, i64 } asm "encls", "={ax},={bx},={cx},={dx},{ax},{bx},{cx},{dx},~{cc},~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i64 %{{.*}})
105e52fa90SGabor Buella // CHECK-32: call { i32, i32, i32, i32 } asm "encls", "={ax},={bx},={cx},={dx},{ax},{bx},{cx},{dx},~{cc},~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}})
115e52fa90SGabor Buella
125e52fa90SGabor Buella return _encls_u32(leaf, data);
135e52fa90SGabor Buella }
145e52fa90SGabor Buella
test_enclu(uint32_t leaf,size_t data[3])155e52fa90SGabor Buella uint32_t test_enclu(uint32_t leaf, size_t data[3]) {
165e52fa90SGabor Buella // CHECK-64: call { i32, i64, i64, i64 } asm "enclu", "={ax},={bx},={cx},={dx},{ax},{bx},{cx},{dx},~{cc},~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i64 %{{.*}})
175e52fa90SGabor Buella // CHECK-32: call { i32, i32, i32, i32 } asm "enclu", "={ax},={bx},={cx},={dx},{ax},{bx},{cx},{dx},~{cc},~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}})
185e52fa90SGabor Buella
195e52fa90SGabor Buella return _enclu_u32(leaf, data);
205e52fa90SGabor Buella }
215e52fa90SGabor Buella
test_enclv(uint32_t leaf,size_t data[3])225e52fa90SGabor Buella uint32_t test_enclv(uint32_t leaf, size_t data[3]) {
235e52fa90SGabor Buella // CHECK-64: call { i32, i64, i64, i64 } asm "enclv", "={ax},={bx},={cx},={dx},{ax},{bx},{cx},{dx},~{cc},~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i64 %{{.*}})
245e52fa90SGabor Buella // CHECK-32: call { i32, i32, i32, i32 } asm "enclv", "={ax},={bx},={cx},={dx},{ax},{bx},{cx},{dx},~{cc},~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}})
255e52fa90SGabor Buella
265e52fa90SGabor Buella return _enclv_u32(leaf, data);
275e52fa90SGabor Buella }
28