summaryrefslogtreecommitdiffstats
path: root/tests/codegen/some-abis-do-extend-params-to-32-bits.rs
blob: 9f2d9d06524f0d65a30dd56432a01216570aa34a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
// compile-flags: -Cno-prepopulate-passes -Copt-level=0

// revisions:x86_64 i686 aarch64-apple aarch64-windows aarch64-linux arm riscv

//[x86_64] compile-flags: --target x86_64-unknown-uefi
//[x86_64] needs-llvm-components: x86
//[i686] compile-flags: --target i686-unknown-linux-musl
//[i686] needs-llvm-components: x86
//[aarch64-windows] compile-flags: --target aarch64-pc-windows-msvc
//[aarch64-windows] needs-llvm-components: aarch64
//[aarch64-linux] compile-flags: --target aarch64-unknown-linux-gnu
//[aarch64-linux] needs-llvm-components: aarch64
//[aarch64-apple] compile-flags: --target aarch64-apple-darwin
//[aarch64-apple] needs-llvm-components: aarch64
//[arm] compile-flags: --target armv7r-none-eabi
//[arm] needs-llvm-components: arm
//[riscv] compile-flags: --target riscv64gc-unknown-none-elf
//[riscv] needs-llvm-components: riscv

// See bottom of file for a corresponding C source file that is meant to yield
// equivalent declarations.
#![feature(no_core, lang_items)]
#![crate_type = "lib"]
#![no_std]
#![no_core]

#[lang="sized"] trait Sized { }
#[lang="freeze"] trait Freeze { }
#[lang="copy"] trait Copy { }

// The patterns in this file are written in the style of a table to make the
// uniformities and distinctions more apparent.
//
//                  ZERO/SIGN-EXTENDING TO 32 BITS            NON-EXTENDING
//                  ==============================  =======================
// x86_64:          void @c_arg_u8(i8 zeroext %_a)
// i686:            void @c_arg_u8(i8 zeroext %_a)
// aarch64-apple:   void @c_arg_u8(i8 zeroext %_a)
// aarch64-windows:                                  void @c_arg_u8(i8 %_a)
// aarch64-linux:                                    void @c_arg_u8(i8 %_a)
// arm:             void @c_arg_u8(i8 zeroext %_a)
// riscv:           void @c_arg_u8(i8 zeroext %_a)
#[no_mangle] pub extern "C" fn c_arg_u8(_a: u8) { }

// x86_64:          void @c_arg_u16(i16 zeroext %_a)
// i686:            void @c_arg_u16(i16 zeroext %_a)
// aarch64-apple:   void @c_arg_u16(i16 zeroext %_a)
// aarch64-windows:                                 void @c_arg_u16(i16 %_a)
// aarch64-linux:                                   void @c_arg_u16(i16 %_a)
// arm:             void @c_arg_u16(i16 zeroext %_a)
// riscv:           void @c_arg_u16(i16 zeroext %_a)
#[no_mangle] pub extern "C" fn c_arg_u16(_a: u16) { }

// x86_64:          void @c_arg_u32(i32 %_a)
// i686:            void @c_arg_u32(i32 %_a)
// aarch64-apple:   void @c_arg_u32(i32 %_a)
// aarch64-windows:                                 void @c_arg_u32(i32 %_a)
// aarch64-linux:                                   void @c_arg_u32(i32 %_a)
// arm:             void @c_arg_u32(i32 %_a)
// riscv:           void @c_arg_u32(i32 signext %_a)
#[no_mangle] pub extern "C" fn c_arg_u32(_a: u32) { }

// x86_64:          void @c_arg_u64(i64 %_a)
// i686:            void @c_arg_u64(i64 %_a)
// aarch64-apple:   void @c_arg_u64(i64 %_a)
// aarch64-windows:                                 void @c_arg_u64(i64 %_a)
// aarch64-linux:                                   void @c_arg_u64(i64 %_a)
// arm:             void @c_arg_u64(i64 %_a)
// riscv:           void @c_arg_u64(i64 %_a)
#[no_mangle] pub extern "C" fn c_arg_u64(_a: u64) { }

// x86_64:          void @c_arg_i8(i8 signext %_a)
// i686:            void @c_arg_i8(i8 signext %_a)
// aarch64-apple:   void @c_arg_i8(i8 signext %_a)
// aarch64-windows:                                  void @c_arg_i8(i8 %_a)
// aarch64-linux:                                    void @c_arg_i8(i8 %_a)
// arm:             void @c_arg_i8(i8 signext %_a)
// riscv:           void @c_arg_i8(i8 signext %_a)
#[no_mangle] pub extern "C" fn c_arg_i8(_a: i8) { }

// x86_64:          void @c_arg_i16(i16 signext %_a)
// i686:            void @c_arg_i16(i16 signext %_a)
// aarch64-apple:   void @c_arg_i16(i16 signext %_a)
// aarch64-windows:                                 void @c_arg_i16(i16 %_a)
// aarch64-linux:                                   void @c_arg_i16(i16 %_a)
// arm:             void @c_arg_i16(i16 signext %_a)
// riscv:           void @c_arg_i16(i16 signext %_a)
#[no_mangle] pub extern "C" fn c_arg_i16(_a: i16) { }

// x86_64:          void @c_arg_i32(i32 %_a)
// i686:            void @c_arg_i32(i32 %_a)
// aarch64-apple:   void @c_arg_i32(i32 %_a)
// aarch64-windows:                                 void @c_arg_i32(i32 %_a)
// aarch64-linux:                                   void @c_arg_i32(i32 %_a)
// arm:             void @c_arg_i32(i32 %_a)
// riscv:           void @c_arg_i32(i32 signext %_a)
#[no_mangle] pub extern "C" fn c_arg_i32(_a: i32) { }

// x86_64:          void @c_arg_i64(i64 %_a)
// i686:            void @c_arg_i64(i64 %_a)
// aarch64-apple:   void @c_arg_i64(i64 %_a)
// aarch64-windows:                                 void @c_arg_i64(i64 %_a)
// aarch64-linux:                                   void @c_arg_i64(i64 %_a)
// arm:             void @c_arg_i64(i64 %_a)
// riscv:           void @c_arg_i64(i64 %_a)
#[no_mangle] pub extern "C" fn c_arg_i64(_a: i64) { }

// x86_64:          zeroext i8 @c_ret_u8()
// i686:            zeroext i8 @c_ret_u8()
// aarch64-apple:   zeroext i8 @c_ret_u8()
// aarch64-windows:                                 i8 @c_ret_u8()
// aarch64-linux:                                   i8 @c_ret_u8()
// arm:             zeroext i8 @c_ret_u8()
// riscv:           zeroext i8 @c_ret_u8()
#[no_mangle] pub extern "C" fn c_ret_u8() -> u8 { 0 }

// x86_64:          zeroext i16 @c_ret_u16()
// i686:            zeroext i16 @c_ret_u16()
// aarch64-apple:   zeroext i16 @c_ret_u16()
// aarch64-windows:                                 i16 @c_ret_u16()
// aarch64-linux:                                   i16 @c_ret_u16()
// arm:             zeroext i16 @c_ret_u16()
// riscv:           zeroext i16 @c_ret_u16()
#[no_mangle] pub extern "C" fn c_ret_u16() -> u16 { 0 }

// x86_64:          i32 @c_ret_u32()
// i686:            i32 @c_ret_u32()
// aarch64-apple:   i32 @c_ret_u32()
// aarch64-windows:                                 i32 @c_ret_u32()
// aarch64-linux:                                   i32 @c_ret_u32()
// arm:             i32 @c_ret_u32()
// riscv:           signext i32 @c_ret_u32()
#[no_mangle] pub extern "C" fn c_ret_u32() -> u32 { 0 }

// x86_64:          i64 @c_ret_u64()
// i686:            i64 @c_ret_u64()
// aarch64-apple:   i64 @c_ret_u64()
// aarch64-windows:                                 i64 @c_ret_u64()
// aarch64-linux:                                   i64 @c_ret_u64()
// arm:             i64 @c_ret_u64()
// riscv:           i64 @c_ret_u64()
#[no_mangle] pub extern "C" fn c_ret_u64() -> u64 { 0 }

// x86_64:          signext i8 @c_ret_i8()
// i686:            signext i8 @c_ret_i8()
// aarch64-apple:   signext i8 @c_ret_i8()
// aarch64-windows:                                 i8 @c_ret_i8()
// aarch64-linux:                                   i8 @c_ret_i8()
// arm:             signext i8 @c_ret_i8()
// riscv:           signext i8 @c_ret_i8()
#[no_mangle] pub extern "C" fn c_ret_i8() -> i8 { 0 }

// x86_64:          signext i16 @c_ret_i16()
// i686:            signext i16 @c_ret_i16()
// aarch64-apple:   signext i16 @c_ret_i16()
// aarch64-windows:                                 i16 @c_ret_i16()
// aarch64-linux:                                   i16 @c_ret_i16()
// arm:             signext i16 @c_ret_i16()
// riscv:           signext i16 @c_ret_i16()
#[no_mangle] pub extern "C" fn c_ret_i16() -> i16 { 0 }

// x86_64:          i32 @c_ret_i32()
// i686:            i32 @c_ret_i32()
// aarch64-apple:   i32 @c_ret_i32()
// aarch64-windows:                                 i32 @c_ret_i32()
// aarch64-linux:                                   i32 @c_ret_i32()
// arm:             i32 @c_ret_i32()
// riscv:           signext i32 @c_ret_i32()
#[no_mangle] pub extern "C" fn c_ret_i32() -> i32 { 0 }

// x86_64:          i64 @c_ret_i64()
// i686:            i64 @c_ret_i64()
// aarch64-apple:   i64 @c_ret_i64()
// aarch64-windows:                                 i64 @c_ret_i64()
// aarch64-linux:                                   i64 @c_ret_i64()
// arm:             i64 @c_ret_i64()
// riscv:           i64 @c_ret_i64()
#[no_mangle] pub extern "C" fn c_ret_i64() -> i64 { 0 }

const C_SOURCE_FILE: &'static str = r##"
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>

void c_arg_u8(uint8_t _a) { }
void c_arg_u16(uint16_t _a) { }
void c_arg_u32(uint32_t _a) { }
void c_arg_u64(uint64_t _a) { }

void c_arg_i8(int8_t _a) { }
void c_arg_i16(int16_t _a) { }
void c_arg_i32(int32_t _a) { }
void c_arg_i64(int64_t _a) { }

uint8_t  c_ret_u8()  { return 0; }
uint16_t c_ret_u16() { return 0; }
uint32_t c_ret_u32() { return 0; }
uint64_t c_ret_u64() { return 0; }

int8_t   c_ret_i8()  { return 0; }
int16_t  c_ret_i16() { return 0; }
int32_t  c_ret_i32() { return 0; }
int64_t  c_ret_i64() { return 0; }
"##;