Clang Project

clang_source_code/test/CodeGen/attr-mode-vector-types.c
1// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -o - | FileCheck %s
2
3typedef int __attribute__((mode(byte))) __attribute__((vector_size(4))) vec_t1;
4typedef int __attribute__((mode(QI))) __attribute__((vector_size(8))) vec_t2;
5typedef int __attribute__((mode(SI))) __attribute__((vector_size(16))) vec_t3;
6typedef int __attribute__((mode(DI))) __attribute__((vector_size(64)))vec_t4;
7typedef float __attribute__((mode(SF))) __attribute__((vector_size(128))) vec_t5;
8typedef float __attribute__((mode(DF))) __attribute__((vector_size(256))) vec_t6;
9
10void check() {
11  // CHECK: alloca <4 x i8>
12  vec_t1 v1;
13  // CHECK: alloca <8 x i8>
14  vec_t2 v2;
15  // CHECK: alloca <4 x i32>
16  vec_t3 v3;
17  // CHECK: alloca <8 x i64>
18  vec_t4 v4;
19  // CHECK: alloca <32 x float>
20  vec_t5 v5;
21  // CHECK: alloca <32 x double>
22  vec_t6 v6;
23}
24
25// CHECK: ret i32 4
26int check_size1() { return sizeof(vec_t1); }
27
28// CHECK: ret i32 8
29int check_size2() { return sizeof(vec_t2); }
30
31// CHECK: ret i32 16
32int check_size3() { return sizeof(vec_t3); }
33
34// CHECK: ret i32 64
35int check_size4() { return sizeof(vec_t4); }
36
37// CHECK: ret i32 128
38int check_size5() { return sizeof(vec_t5); }
39
40// CHECK: ret i32 256
41int check_size6() { return sizeof(vec_t6); }
42