1 // REQUIRES: x86-registered-target 2 // RUN: %clang_cc1 %s -triple i686-pc-windows-msvc -emit-llvm -o - -fasm-blocks | FileCheck %s 3 4 // Check that we take EAX or EAX:EDX and return it from these functions for MSVC 5 // compatibility. 6 7 extern "C" { 8 9 long long f_i64() { 10 __asm { 11 mov eax, 1 12 mov edx, 1 13 } 14 } 15 // CHECK-LABEL: define i64 @f_i64() 16 // CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "=A,~{eax},{{.*}}" 17 // CHECK: ret i64 %[[r]] 18 19 int f_i32() { 20 __asm { 21 mov eax, 1 22 mov edx, 1 23 } 24 } 25 // CHECK-LABEL: define i32 @f_i32() 26 // CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}" 27 // CHECK: ret i32 %[[r]] 28 29 short f_i16() { 30 __asm { 31 mov eax, 1 32 mov edx, 1 33 } 34 } 35 // CHECK-LABEL: define signext i16 @f_i16() 36 // CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}" 37 // CHECK: %[[r_i16:[^ ]*]] = trunc i32 %[[r]] to i16 38 // CHECK: ret i16 %[[r_i16]] 39 40 char f_i8() { 41 __asm { 42 mov eax, 1 43 mov edx, 1 44 } 45 } 46 // CHECK-LABEL: define signext i8 @f_i8() 47 // CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}" 48 // CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8 49 // CHECK: ret i8 %[[r_i8]] 50 51 bool f_i1() { 52 __asm { 53 mov eax, 1 54 mov edx, 1 55 } 56 } 57 // CHECK-LABEL: define zeroext i1 @f_i1() 58 // CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$1\0A\09mov edx, $$1", "={eax},~{eax},{{.*}}" 59 // CHECK: %[[r_i8:[^ ]*]] = trunc i32 %[[r]] to i8 60 // CHECK: store i8 %[[r_i8]], i8* %{{.*}} 61 // CHECK: %[[r_i1:[^ ]*]] = load i1, i1* %{{.*}} 62 // CHECK: ret i1 %[[r_i1]] 63 64 struct FourChars { 65 char a, b, c, d; 66 }; 67 FourChars f_s4() { 68 __asm { 69 mov eax, 0x01010101 70 } 71 } 72 // CHECK-LABEL: define i32 @f_s4() 73 // CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "mov eax, $$0x01010101", "={eax},~{eax},{{.*}}" 74 // CHECK: store i32 %[[r]], i32* %{{.*}} 75 // CHECK: %[[r_i32:[^ ]*]] = load i32, i32* %{{.*}} 76 // CHECK: ret i32 %[[r_i32]] 77 78 struct EightChars { 79 char a, b, c, d, e, f, g, h; 80 }; 81 EightChars f_s8() { 82 __asm { 83 mov eax, 0x01010101 84 mov edx, 0x01010101 85 } 86 } 87 // CHECK-LABEL: define i64 @f_s8() 88 // CHECK: %[[r:[^ ]*]] = call i64 asm sideeffect inteldialect "mov eax, $$0x01010101\0A\09mov edx, $$0x01010101", "=A,~{eax},{{.*}}" 89 // CHECK: store i64 %[[r]], i64* %{{.*}} 90 // CHECK: %[[r_i64:[^ ]*]] = load i64, i64* %{{.*}} 91 // CHECK: ret i64 %[[r_i64]] 92 93 } // extern "C" 94 95 int main() { 96 __asm xor eax, eax 97 } 98 // CHECK-LABEL: define i32 @main() 99 // CHECK: %[[r:[^ ]*]] = call i32 asm sideeffect inteldialect "xor eax, eax", "={eax},{{.*}}" 100 // CHECK: ret i32 %[[r]] 101