1 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
2 // RUN:         -triple i686--windows -emit-llvm %s -o - \
3 // RUN:         | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
4 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
5 // RUN:         -triple thumbv7--windows -emit-llvm %s -o - \
6 // RUN:         | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
7 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
8 // RUN:         -triple x86_64--windows -emit-llvm %s -o - \
9 // RUN:         | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
10 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
11 // RUN:         -triple i686--linux -emit-llvm %s -o - \
12 // RUN:         | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
13 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
14 // RUN:         -triple x86_64--linux -emit-llvm %s -o - \
15 // RUN:         | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
16 // RUN: %clang_cc1 -ffreestanding -fms-extensions \
17 // RUN:         -triple x86_64--darwin -emit-llvm %s -o - \
18 // RUN:         | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
19 
20 // rotate left
21 
test_rotl8(unsigned char value,unsigned char shift)22 unsigned char test_rotl8(unsigned char value, unsigned char shift) {
23   return _rotl8(value, shift);
24 }
25 // CHECK: i8 @test_rotl8
26 // CHECK:   [[R:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
27 // CHECK:   ret i8 [[R]]
28 
test_rotl16(unsigned short value,unsigned char shift)29 unsigned short test_rotl16(unsigned short value, unsigned char shift) {
30   return _rotl16(value, shift);
31 }
32 // CHECK: i16 @test_rotl16
33 // CHECK:   [[R:%.*]] = call i16 @llvm.fshl.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
34 // CHECK:   ret i16 [[R]]
35 
test_rotl(unsigned int value,int shift)36 unsigned int test_rotl(unsigned int value, int shift) {
37   return _rotl(value, shift);
38 }
39 // CHECK: i32 @test_rotl
40 // CHECK:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
41 // CHECK:   ret i32 [[R]]
42 
test_lrotl(unsigned long value,int shift)43 unsigned long test_lrotl(unsigned long value, int shift) {
44   return _lrotl(value, shift);
45 }
46 // CHECK-32BIT-LONG: i32 @test_lrotl
47 // CHECK-32BIT-LONG:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
48 // CHECK-32BIT-LONG:   ret i32 [[R]]
49 // CHECK-64BIT-LONG: i64 @test_lrotl
50 // CHECK-64BIT-LONG:   [[R:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
51 // CHECK-64BIT-LONG:   ret i64 [[R]]
52 
test_rotl64(unsigned __int64 value,int shift)53 unsigned __int64 test_rotl64(unsigned __int64 value, int shift) {
54   return _rotl64(value, shift);
55 }
56 // CHECK: i64 @test_rotl64
57 // CHECK:   [[R:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
58 // CHECK:   ret i64 [[R]]
59 
60 // rotate right
61 
test_rotr8(unsigned char value,unsigned char shift)62 unsigned char test_rotr8(unsigned char value, unsigned char shift) {
63   return _rotr8(value, shift);
64 }
65 // CHECK: i8 @test_rotr8
66 // CHECK:   [[R:%.*]] = call i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
67 // CHECK:   ret i8 [[R]]
68 
test_rotr16(unsigned short value,unsigned char shift)69 unsigned short test_rotr16(unsigned short value, unsigned char shift) {
70   return _rotr16(value, shift);
71 }
72 // CHECK: i16 @test_rotr16
73 // CHECK:   [[R:%.*]] = call i16 @llvm.fshr.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
74 // CHECK:   ret i16 [[R]]
75 
test_rotr(unsigned int value,int shift)76 unsigned int test_rotr(unsigned int value, int shift) {
77   return _rotr(value, shift);
78 }
79 // CHECK: i32 @test_rotr
80 // CHECK:   [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
81 // CHECK:   ret i32 [[R]]
82 
test_lrotr(unsigned long value,int shift)83 unsigned long test_lrotr(unsigned long value, int shift) {
84   return _lrotr(value, shift);
85 }
86 // CHECK-32BIT-LONG: i32 @test_lrotr
87 // CHECK-32BIT-LONG:   [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
88 // CHECK-32BIT-LONG:   ret i32 [[R]]
89 // CHECK-64BIT-LONG: i64 @test_lrotr
90 // CHECK-64BIT-LONG:   [[R:%.*]] = call i64 @llvm.fshr.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
91 // CHECK-64BIT-LONG:   ret i64 [[R]]
92 
test_rotr64(unsigned __int64 value,int shift)93 unsigned __int64 test_rotr64(unsigned __int64 value, int shift) {
94   return _rotr64(value, shift);
95 }
96 // CHECK: i64 @test_rotr64
97 // CHECK:   [[R:%.*]] = call i64 @llvm.fshr.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
98 // CHECK:   ret i64 [[R]]
99 
100