Ivan Krasin | ef05abd | 2011-08-24 20:22:22 +0000 | [diff] [blame^] | 1 | // RUN: %clang -ccc-host-triple le32-unknown-nacl -ccc-echo %s -emit-llvm -c -o /tmp/OUTPUTNAME 2> %t.log |
| 2 | |
| 3 | // Make sure we used clang. |
| 4 | // RUN: grep 'clang\(-[0-9.]\+\)\?\(\.[Ee][Xx][Ee]\)\?" -cc1 .*le32-unknown-nacl.c' %t.log |
| 5 | |
| 6 | // RUN: llvm-dis < /tmp/OUTPUTNAME | FileCheck %s |
| 7 | |
| 8 | // Check platform defines |
| 9 | #include <stddef.h> |
| 10 | |
| 11 | extern "C" { |
| 12 | |
| 13 | #ifdef __native_client__ |
| 14 | void __native_client__defined() { |
| 15 | // CHECK: __native_client__defined |
| 16 | } |
| 17 | #endif |
| 18 | |
| 19 | #ifdef __le32__ |
| 20 | void __le32__defined() { |
| 21 | // CHECK: __le32__defined |
| 22 | } |
| 23 | #endif |
| 24 | |
| 25 | #ifdef __pnacl__ |
| 26 | void __pnacl__defined() { |
| 27 | // CHECK: __pnacl__defined |
| 28 | } |
| 29 | #endif |
| 30 | |
| 31 | // Check types |
| 32 | |
| 33 | // CHECK: signext i8 @check_char() |
| 34 | char check_char() { return 0; } |
| 35 | |
| 36 | // CHECK: signext i16 @check_short() |
| 37 | short check_short() { return 0; } |
| 38 | |
| 39 | // CHECK: i32 @check_int() |
| 40 | int check_int() { return 0; } |
| 41 | |
| 42 | // CHECK: i32 @check_long() |
| 43 | long check_long() { return 0; } |
| 44 | |
| 45 | // CHECK: i64 @check_longlong() |
| 46 | long long check_longlong() { return 0; } |
| 47 | |
| 48 | // CHECK: zeroext i8 @check_uchar() |
| 49 | unsigned char check_uchar() { return 0; } |
| 50 | |
| 51 | // CHECK: zeroext i16 @check_ushort() |
| 52 | unsigned short check_ushort() { return 0; } |
| 53 | |
| 54 | // CHECK: i32 @check_uint() |
| 55 | unsigned int check_uint() { return 0; } |
| 56 | |
| 57 | // CHECK: i32 @check_ulong() |
| 58 | unsigned long check_ulong() { return 0; } |
| 59 | |
| 60 | // CHECK: i64 @check_ulonglong() |
| 61 | unsigned long long check_ulonglong() { return 0; } |
| 62 | |
| 63 | // CHECK: i32 @check_size_t() |
| 64 | size_t check_size_t() { return 0; } |
| 65 | |
| 66 | // CHECK: float @check_float() |
| 67 | float check_float() { return 0; } |
| 68 | |
| 69 | // CHECK: double @check_double() |
| 70 | double check_double() { return 0; } |
| 71 | |
| 72 | } |
| 73 | |
| 74 | // Check that pointers are 32-bit. |
| 75 | |
| 76 | template<int> void Switch(); |
| 77 | template<> void Switch<4>(); |
| 78 | template<> void Switch<8>(); |
| 79 | |
| 80 | void check_pointer_size() { |
| 81 | // CHECK: SwitchILi4 |
| 82 | Switch<sizeof(void*)>(); |
| 83 | |
| 84 | // CHECK: SwitchILi8 |
| 85 | Switch<sizeof(long long)>(); |
| 86 | } |