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

Side by Side Diff: crosstest/test_calling_conv.cpp

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: Fix comments and style in the 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.cpp - 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 <cstring>
18
19 #include "test_calling_conv.h"
20
21 #define CALL_AS_TYPE(Ty) (reinterpret_cast<Ty *>(Callee))
Jim Stichnoth 2014/08/06 18:26:15 Here and below, it would be nice to minimize the u
wala 2014/08/07 18:09:21 Done.
22
23 void caller_i(void) {
24 int arg1 = 0x12345678;
25 CALL_AS_TYPE(callee_i_Ty)(arg1);
26 }
27
28 void caller_vvvvv(void) {
29 v4si32 arg1 = {0, 1, 2, 3};
30 v4si32 arg2 = {4, 5, 6, 7};
31 v4si32 arg3 = {8, 9, 10, 11};
32 v4si32 arg4 = {12, 13, 14, 15};
33 v4si32 arg5 = {16, 17, 18, 19};
34
35 CALL_AS_TYPE(callee_vvvvv_Ty)(arg1, arg2, arg3, arg4, arg5);
36 }
37
38 void caller_vlvlvfvdviv(void) {
39 v4f32 arg1 = {0, 1, 2, 3};
40 int64_t arg2 = 4;
41 v4f32 arg3 = {5, 6, 7, 8};
42 int64_t arg4 = 9;
43 v4f32 arg5 = {10, 11, 12, 13};
44 float arg6 = 14;
45 v4f32 arg7 = {15, 16, 17, 18};
46 double arg8 = 19;
47 v4f32 arg9 = {20, 21, 22, 23};
48 int arg10 = 24;
49 v4f32 arg11 = {25, 26, 27, 28};
50
51 CALL_AS_TYPE(callee_vlvlvfvdviv_Ty)(arg1, arg2, arg3, arg4, arg5, arg6, arg7,
52 arg8, arg9, arg10, arg11);
53 }
54
55 #define HANDLE_ARG(ARGNUM) \
56 case ARGNUM: \
57 memcpy(&Buf[0], &arg##ARGNUM, sizeof(arg##ARGNUM)); \
58 break;
59
60 void __attribute__((noinline)) callee_i(int arg1) {
61 switch (ArgNum) { HANDLE_ARG(1); }
62 }
63
64 void __attribute__((noinline))
65 callee_vvvvv(v4si32 arg1, v4si32 arg2, v4si32 arg3, v4si32 arg4, v4si32 arg5) {
66 switch (ArgNum) {
67 HANDLE_ARG(1);
68 HANDLE_ARG(2);
69 HANDLE_ARG(3);
70 HANDLE_ARG(4);
71 HANDLE_ARG(5);
72 }
73 }
74
75 void __attribute__((noinline))
76 callee_vlvlvfvdviv(v4f32 arg1, int64_t arg2, v4f32 arg3, int64_t arg4,
77 v4f32 arg5, float arg6, v4f32 arg7, double arg8, v4f32 arg9,
78 int arg10, v4f32 arg11) {
79 switch (ArgNum) {
80 HANDLE_ARG(1);
81 HANDLE_ARG(2);
82 HANDLE_ARG(3);
83 HANDLE_ARG(4);
84 HANDLE_ARG(5);
85 HANDLE_ARG(6);
86 HANDLE_ARG(7);
87 HANDLE_ARG(8);
88 HANDLE_ARG(9);
89 HANDLE_ARG(10);
90 HANDLE_ARG(11);
91 }
92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698