Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ea045d20
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ea045d20
编写于
1月 09, 2015
作者:
V
Valerii Hiora
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
iOS: cabi fixes
Changed alignment according to official Apple docs
上级
ac0607ac
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
75 addition
and
19 deletion
+75
-19
src/librustc_trans/trans/cabi.rs
src/librustc_trans/trans/cabi.rs
+8
-1
src/librustc_trans/trans/cabi_arm.rs
src/librustc_trans/trans/cabi_arm.rs
+67
-18
未找到文件。
src/librustc_trans/trans/cabi.rs
浏览文件 @
ea045d20
...
...
@@ -115,8 +115,15 @@ pub fn compute_abi_info(ccx: &CrateContext,
}
else
{
cabi_x86_64
::
compute_abi_info
(
ccx
,
atys
,
rty
,
ret_def
)
},
"arm"
=>
cabi_arm
::
compute_abi_info
(
ccx
,
atys
,
rty
,
ret_def
),
"aarch64"
=>
cabi_aarch64
::
compute_abi_info
(
ccx
,
atys
,
rty
,
ret_def
),
"arm"
=>
{
let
flavor
=
if
ccx
.sess
()
.target.target.target_os
==
"ios"
{
cabi_arm
::
Flavor
::
Ios
}
else
{
cabi_arm
::
Flavor
::
General
};
cabi_arm
::
compute_abi_info
(
ccx
,
atys
,
rty
,
ret_def
,
flavor
)
},
"mips"
=>
cabi_mips
::
compute_abi_info
(
ccx
,
atys
,
rty
,
ret_def
),
a
=>
ccx
.sess
()
.fatal
(
&
format!
(
"unrecognized arch
\"
{}
\"
in target specification"
,
a
)
[]),
...
...
src/librustc_trans/trans/cabi_arm.rs
浏览文件 @
ea045d20
...
...
@@ -19,16 +19,23 @@
use
std
::
cmp
;
pub
enum
Flavor
{
General
,
Ios
}
type
TyAlignFn
=
fn
(
ty
:
Type
)
->
uint
;
fn
align_up_to
(
off
:
uint
,
a
:
uint
)
->
uint
{
return
(
off
+
a
-
1u
)
/
a
*
a
;
}
fn
align
(
off
:
uint
,
ty
:
Type
)
->
uint
{
let
a
=
ty_alig
n
(
ty
);
fn
align
(
off
:
uint
,
ty
:
Type
,
align_fn
:
TyAlignFn
)
->
uint
{
let
a
=
align_f
n
(
ty
);
return
align_up_to
(
off
,
a
);
}
fn
ty_align
(
ty
:
Type
)
->
uint
{
fn
general_
ty_align
(
ty
:
Type
)
->
uint
{
match
ty
.kind
()
{
Integer
=>
{
unsafe
{
...
...
@@ -43,18 +50,51 @@ fn ty_align(ty: Type) -> uint {
1
}
else
{
let
str_tys
=
ty
.field_types
();
str_tys
.iter
()
.fold
(
1
,
|
a
,
t
|
cmp
::
max
(
a
,
ty_align
(
*
t
)))
str_tys
.iter
()
.fold
(
1
,
|
a
,
t
|
cmp
::
max
(
a
,
general_ty_align
(
*
t
)))
}
}
Array
=>
{
let
elt
=
ty
.element_type
();
general_ty_align
(
elt
)
}
_
=>
panic!
(
"ty_align: unhandled type"
)
}
}
// For more information see:
// ARMv7
// https://developer.apple.com/library/ios/documentation/Xcode/Conceptual
// /iPhoneOSABIReference/Articles/ARMv7FunctionCallingConventions.html
// ARMv6
// https://developer.apple.com/library/ios/documentation/Xcode/Conceptual
// /iPhoneOSABIReference/Articles/ARMv6FunctionCallingConventions.html
fn
ios_ty_align
(
ty
:
Type
)
->
uint
{
match
ty
.kind
()
{
Integer
=>
{
unsafe
{
cmp
::
min
(
4
,
((
llvm
::
LLVMGetIntTypeWidth
(
ty
.to_ref
())
as
uint
)
+
7
)
/
8
)
}
}
Pointer
=>
4
,
Float
=>
4
,
Double
=>
4
,
Struct
=>
{
if
ty
.is_packed
()
{
1
}
else
{
let
str_tys
=
ty
.field_types
();
str_tys
.iter
()
.fold
(
1
,
|
a
,
t
|
cmp
::
max
(
a
,
ios_ty_align
(
*
t
)))
}
}
Array
=>
{
let
elt
=
ty
.element_type
();
ty_align
(
elt
)
ios_
ty_align
(
elt
)
}
_
=>
panic!
(
"ty_align: unhandled type"
)
}
}
fn
ty_size
(
ty
:
Type
)
->
uint
{
fn
ty_size
(
ty
:
Type
,
align_fn
:
TyAlignFn
)
->
uint
{
match
ty
.kind
()
{
Integer
=>
{
unsafe
{
...
...
@@ -67,29 +107,32 @@ fn ty_size(ty: Type) -> uint {
Struct
=>
{
if
ty
.is_packed
()
{
let
str_tys
=
ty
.field_types
();
str_tys
.iter
()
.fold
(
0
,
|
s
,
t
|
s
+
ty_size
(
*
t
))
str_tys
.iter
()
.fold
(
0
,
|
s
,
t
|
s
+
ty_size
(
*
t
,
align_fn
))
}
else
{
let
str_tys
=
ty
.field_types
();
let
size
=
str_tys
.iter
()
.fold
(
0
,
|
s
,
t
|
align
(
s
,
*
t
)
+
ty_size
(
*
t
));
align
(
size
,
ty
)
let
size
=
str_tys
.iter
()
.fold
(
0
,
|
s
,
t
|
{
align
(
s
,
*
t
,
align_fn
)
+
ty_size
(
*
t
,
align_fn
)
});
align
(
size
,
ty
,
align_fn
)
}
}
Array
=>
{
let
len
=
ty
.array_length
();
let
elt
=
ty
.element_type
();
let
eltsz
=
ty_size
(
elt
);
let
eltsz
=
ty_size
(
elt
,
align_fn
);
len
*
eltsz
}
_
=>
panic!
(
"ty_size: unhandled type"
)
}
}
fn
classify_ret_ty
(
ccx
:
&
CrateContext
,
ty
:
Type
)
->
ArgType
{
fn
classify_ret_ty
(
ccx
:
&
CrateContext
,
ty
:
Type
,
align_fn
:
TyAlignFn
)
->
ArgType
{
if
is_reg_ty
(
ty
)
{
let
attr
=
if
ty
==
Type
::
i1
(
ccx
)
{
Some
(
ZExtAttribute
)
}
else
{
None
};
return
ArgType
::
direct
(
ty
,
None
,
None
,
attr
);
}
let
size
=
ty_size
(
ty
);
let
size
=
ty_size
(
ty
,
align_fn
);
if
size
<=
4
{
let
llty
=
if
size
<=
1
{
Type
::
i8
(
ccx
)
...
...
@@ -103,13 +146,13 @@ fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType {
ArgType
::
indirect
(
ty
,
Some
(
StructRetAttribute
))
}
fn
classify_arg_ty
(
ccx
:
&
CrateContext
,
ty
:
Type
)
->
ArgType
{
fn
classify_arg_ty
(
ccx
:
&
CrateContext
,
ty
:
Type
,
align_fn
:
TyAlignFn
)
->
ArgType
{
if
is_reg_ty
(
ty
)
{
let
attr
=
if
ty
==
Type
::
i1
(
ccx
)
{
Some
(
ZExtAttribute
)
}
else
{
None
};
return
ArgType
::
direct
(
ty
,
None
,
None
,
attr
);
}
let
align
=
ty_alig
n
(
ty
);
let
size
=
ty_size
(
ty
);
let
align
=
align_f
n
(
ty
);
let
size
=
ty_size
(
ty
,
align_fn
);
let
llty
=
if
align
<=
4
{
Type
::
array
(
&
Type
::
i32
(
ccx
),
((
size
+
3
)
/
4
)
as
u64
)
}
else
{
...
...
@@ -131,15 +174,21 @@ fn is_reg_ty(ty: Type) -> bool {
pub
fn
compute_abi_info
(
ccx
:
&
CrateContext
,
atys
:
&
[
Type
],
rty
:
Type
,
ret_def
:
bool
)
->
FnType
{
ret_def
:
bool
,
flavor
:
Flavor
)
->
FnType
{
let
align_fn
=
match
flavor
{
Flavor
::
General
=>
general_ty_align
as
TyAlignFn
,
Flavor
::
Ios
=>
ios_ty_align
as
TyAlignFn
,
};
let
mut
arg_tys
=
Vec
::
new
();
for
&
aty
in
atys
.iter
()
{
let
ty
=
classify_arg_ty
(
ccx
,
aty
);
let
ty
=
classify_arg_ty
(
ccx
,
aty
,
align_fn
);
arg_tys
.push
(
ty
);
}
let
ret_ty
=
if
ret_def
{
classify_ret_ty
(
ccx
,
rty
)
classify_ret_ty
(
ccx
,
rty
,
align_fn
)
}
else
{
ArgType
::
direct
(
Type
::
void
(
ccx
),
None
,
None
,
None
)
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录