Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: crosstest/test_calling_conv.c

Issue 444443002: Subzero: Align the stack at the point of function calls. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Improve wording of a comment and reorder function in crosstest Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 //===- subzero/crosstest/test_calling_conv.c - Implementation for tests ---===//
2 //
3 // The Subzero Code Generator
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the test functions used to check that Subzero
11 // generates code compatible with the calling convention used by
12 // llc. "Caller" functions test the handling of out-args, and "callee"
13 // functions test the handling of in-args.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #include <string.h>
18
19 #include "test_calling_conv.h"
20
21 #define CALL_AS_TYPE(Ty) ((Ty *)Callee)
22
23 void caller_i(void) {
24 int arg1 = 0x12345678;
25 CALL_AS_TYPE(callee_i_Ty)(arg1);
26 }
27
28 void caller_alloca_16_i(void) {
29 char Array[16];
30 fakeUse(Array);
31 int arg1 = 0x12345678;
32 CALL_AS_TYPE(callee_i_Ty)(arg1);
33 }
34
35 void caller_alloca_17_i(void) {
36 char Array[17];
37 fakeUse(Array);
38 int arg1 = 0x12345678;
39 CALL_AS_TYPE(callee_i_Ty)(arg1);
40 }
41
42 void caller_alloca_vla_i(void) {
43 char Array[DynAllocaSize];
44 fakeUse(Array);
45 int arg1 = 0x12345678;
46 CALL_AS_TYPE(callee_i_Ty)(arg1);
47 }
48
49 void caller_vvvvv(void) {
50 v4si32 arg1 = {0, 1, 2, 3};
51 v4si32 arg2 = {4, 5, 6, 7};
52 v4si32 arg3 = {8, 9, 10, 11};
53 v4si32 arg4 = {12, 13, 14, 15};
54 v4si32 arg5 = {16, 17, 18, 19};
55
56 CALL_AS_TYPE(callee_vvvvv_Ty)(arg1, arg2, arg3, arg4, arg5);
57 }
58
59 void caller_vlvlvfvdviv(void) {
60 v4f32 arg1 = {0, 1, 2, 3};
61 int64_t arg2 = 4;
62 v4f32 arg3 = {5, 6, 7, 8};
63 int64_t arg4 = 9;
64 v4f32 arg5 = {10, 11, 12, 13};
65 float arg6 = 14;
66 v4f32 arg7 = {15, 16, 17, 18};
67 double arg8 = 19;
68 v4f32 arg9 = {20, 21, 22, 23};
69 int arg10 = 24;
70 v4f32 arg11 = {25, 26, 27, 28};
71
72 CALL_AS_TYPE(callee_vlvlvfvdviv_Ty)(arg1, arg2, arg3, arg4, arg5, arg6, arg7,
73 arg8, arg9, arg10, arg11);
74 }
75
76 #define HANDLE_ARG(ARGNUM) \
77 case ARGNUM: \
78 memcpy(&Buf[0], &arg##ARGNUM, sizeof(arg##ARGNUM)); \
79 break;
80
81 void __attribute__((noinline)) callee_i(int arg1) {
82 switch (ArgNum) { HANDLE_ARG(1); }
83 }
84
85 void __attribute__((noinline)) callee_alloca_16_i(int arg1) {
86 char Array[16];
87 fakeUse(Array);
88 switch (ArgNum) { HANDLE_ARG(1); }
89 }
90
91 void __attribute__((noinline)) callee_alloca_17_i(int arg1) {
92 char Array[17];
93 fakeUse(Array);
94 switch (ArgNum) { HANDLE_ARG(1); }
95 }
96
97 void __attribute__((noinline)) callee_alloca_vla_i(int arg1) {
98 char Array[DynAllocaSize];
99 fakeUse(Array);
100 switch (ArgNum) { HANDLE_ARG(1); }
101 }
102
103 void __attribute__((noinline))
104 callee_vvvvv(v4si32 arg1, v4si32 arg2, v4si32 arg3, v4si32 arg4, v4si32 arg5) {
105 switch (ArgNum) {
106 HANDLE_ARG(1);
107 HANDLE_ARG(2);
108 HANDLE_ARG(3);
109 HANDLE_ARG(4);
110 HANDLE_ARG(5);
111 }
112 }
113
114 void __attribute__((noinline))
115 callee_vlvlvfvdviv(v4f32 arg1, int64_t arg2, v4f32 arg3, int64_t arg4,
116 v4f32 arg5, float arg6, v4f32 arg7, double arg8, v4f32 arg9,
117 int arg10, v4f32 arg11) {
118 switch (ArgNum) {
119 HANDLE_ARG(1);
120 HANDLE_ARG(2);
121 HANDLE_ARG(3);
122 HANDLE_ARG(4);
123 HANDLE_ARG(5);
124 HANDLE_ARG(6);
125 HANDLE_ARG(7);
126 HANDLE_ARG(8);
127 HANDLE_ARG(9);
128 HANDLE_ARG(10);
129 HANDLE_ARG(11);
130 }
131 }
132
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698