Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
de5f8244
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
de5f8244
编写于
2月 25, 2016
作者:
E
Eduard Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
trans: Use llvm::Attributes directly in ArgTy.
上级
c7172a99
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
80 addition
and
78 deletion
+80
-78
src/librustc_llvm/lib.rs
src/librustc_llvm/lib.rs
+1
-1
src/librustc_trans/trans/abi.rs
src/librustc_trans/trans/abi.rs
+43
-43
src/librustc_trans/trans/cabi_aarch64.rs
src/librustc_trans/trans/cabi_aarch64.rs
+3
-3
src/librustc_trans/trans/cabi_arm.rs
src/librustc_trans/trans/cabi_arm.rs
+2
-2
src/librustc_trans/trans/cabi_asmjs.rs
src/librustc_trans/trans/cabi_asmjs.rs
+9
-9
src/librustc_trans/trans/cabi_mips.rs
src/librustc_trans/trans/cabi_mips.rs
+2
-2
src/librustc_trans/trans/cabi_powerpc.rs
src/librustc_trans/trans/cabi_powerpc.rs
+2
-2
src/librustc_trans/trans/cabi_powerpc64.rs
src/librustc_trans/trans/cabi_powerpc64.rs
+3
-3
src/librustc_trans/trans/cabi_x86.rs
src/librustc_trans/trans/cabi_x86.rs
+6
-6
src/librustc_trans/trans/cabi_x86_64.rs
src/librustc_trans/trans/cabi_x86_64.rs
+5
-3
src/librustc_trans/trans/cabi_x86_win64.rs
src/librustc_trans/trans/cabi_x86_win64.rs
+2
-2
src/librustc_trans/trans/declare.rs
src/librustc_trans/trans/declare.rs
+1
-1
src/librustc_trans/trans/foreign.rs
src/librustc_trans/trans/foreign.rs
+1
-1
未找到文件。
src/librustc_llvm/lib.rs
浏览文件 @
de5f8244
...
...
@@ -185,7 +185,7 @@ pub enum DLLStorageClassTypes {
}
}
#[derive(Copy,
Clone,
Default)]
#[derive(Copy,
Clone,
Default
,
Debug
)]
pub
struct
Attributes
{
regular
:
Attribute
,
dereferenceable_bytes
:
u64
...
...
src/librustc_trans/trans/abi.rs
浏览文件 @
de5f8244
...
...
@@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub
use
self
::
ArgKind
::
*
;
use
llvm
;
use
trans
::
common
::{
return_type_is_void
,
type_is_fat_ptr
};
use
trans
::
context
::
CrateContext
;
...
...
@@ -43,7 +41,7 @@
pub
const
FAT_PTR_EXTRA
:
usize
=
1
;
#[derive(Clone,
Copy,
PartialEq,
Debug)]
pub
enum
ArgKind
{
enum
ArgKind
{
/// Pass the argument directly using the normal converted
/// LLVM type or by coercing to another specified type
Direct
,
...
...
@@ -59,7 +57,7 @@ pub enum ArgKind {
/// This is borrowed from clang's ABIInfo.h
#[derive(Clone,
Copy,
Debug)]
pub
struct
ArgType
{
pub
kind
:
ArgKind
,
kind
:
ArgKind
,
/// Original LLVM type
pub
original_ty
:
Type
,
/// Sizing LLVM type (pointers are opaque).
...
...
@@ -81,28 +79,48 @@ pub struct ArgType {
pub
cast
:
Option
<
Type
>
,
/// Dummy argument, which is emitted before the real argument
pub
pad
:
Option
<
Type
>
,
/// LLVM attribute of argument
pub
attr
:
Option
<
llvm
::
Attribute
>
/// LLVM attribute
s
of argument
pub
attr
s
:
llvm
::
Attributes
}
impl
ArgType
{
fn
new
(
original_ty
:
Type
,
ty
:
Type
)
->
ArgType
{
ArgType
{
kind
:
Direct
,
kind
:
ArgKind
::
Direct
,
original_ty
:
original_ty
,
ty
:
ty
,
cast
:
None
,
pad
:
None
,
attr
:
None
attr
s
:
llvm
::
Attributes
::
default
()
}
}
pub
fn
make_indirect
(
&
mut
self
,
ccx
:
&
CrateContext
)
{
// Wipe old attributes, likely not valid through indirection.
self
.attrs
=
llvm
::
Attributes
::
default
();
let
llarg_sz
=
llsize_of_real
(
ccx
,
self
.ty
);
// For non-immediate arguments the callee gets its own copy of
// the value on the stack, so there are no aliases. It's also
// program-invisible so can't possibly capture
self
.attrs
.set
(
llvm
::
Attribute
::
NoAlias
)
.set
(
llvm
::
Attribute
::
NoCapture
)
.set_dereferenceable
(
llarg_sz
);
self
.kind
=
ArgKind
::
Indirect
;
}
pub
fn
ignore
(
&
mut
self
)
{
self
.kind
=
ArgKind
::
Ignore
;
}
pub
fn
is_indirect
(
&
self
)
->
bool
{
self
.kind
==
Indirect
self
.kind
==
ArgKind
::
Indirect
}
pub
fn
is_ignore
(
&
self
)
->
bool
{
self
.kind
==
Ignore
self
.kind
==
ArgKind
::
Ignore
}
}
...
...
@@ -178,7 +196,7 @@ pub fn new<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
if
ty
.is_bool
()
{
let
llty
=
Type
::
i1
(
ccx
);
let
mut
arg
=
ArgType
::
new
(
llty
,
llty
);
arg
.attr
=
Some
(
llvm
::
Attribute
::
ZExt
);
arg
.attr
s
.set
(
llvm
::
Attribute
::
ZExt
);
arg
}
else
{
ArgType
::
new
(
type_of
::
type_of
(
ccx
,
ty
),
...
...
@@ -221,7 +239,7 @@ pub fn new<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
let
size
=
llsize_of_alloc
(
ccx
,
arg
.ty
);
if
size
>
llsize_of_alloc
(
ccx
,
ccx
.int_type
())
{
arg
.
kind
=
Indirect
;
arg
.
make_indirect
(
ccx
)
;
}
else
if
size
>
0
{
// We want to pass small aggregates as immediates, but using
// a LLVM aggregate type for this leads to bad optimizations,
...
...
@@ -238,6 +256,9 @@ pub fn new<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
for
arg
in
&
mut
fty
.args
{
fixup
(
arg
);
}
if
fty
.ret
.is_indirect
()
{
fty
.ret.attrs
.set
(
llvm
::
Attribute
::
StructRet
);
}
return
fty
;
}
...
...
@@ -264,6 +285,10 @@ pub fn new<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
a
=>
ccx
.sess
()
.fatal
(
&
format!
(
"unrecognized arch
\"
{}
\"
in target specification"
,
a
))
}
if
fty
.ret
.is_indirect
()
{
fty
.ret.attrs
.set
(
llvm
::
Attribute
::
StructRet
);
}
fty
}
...
...
@@ -302,43 +327,18 @@ pub fn llvm_type(&self, ccx: &CrateContext) -> Type {
}
}
pub
fn
llvm_attrs
(
&
self
,
ccx
:
&
CrateContext
)
->
llvm
::
AttrBuilder
{
pub
fn
llvm_attrs
(
&
self
)
->
llvm
::
AttrBuilder
{
let
mut
attrs
=
llvm
::
AttrBuilder
::
new
();
let
mut
i
=
if
self
.ret
.is_indirect
()
{
1
}
else
{
0
};
// Add attributes that are always applicable, independent of the concrete foreign ABI
if
self
.ret
.is_indirect
()
{
let
llret_sz
=
llsize_of_real
(
ccx
,
self
.ret.ty
);
// The outptr can be noalias and nocapture because it's entirely
// invisible to the program. We also know it's nonnull as well
// as how many bytes we can dereference
attrs
.arg
(
i
)
.set
(
llvm
::
Attribute
::
StructRet
)
.set
(
llvm
::
Attribute
::
NoAlias
)
.set
(
llvm
::
Attribute
::
NoCapture
)
.set_dereferenceable
(
llret_sz
);
};
// Add attributes that depend on the concrete foreign ABI
if
let
Some
(
attr
)
=
self
.ret.attr
{
attrs
.arg
(
i
)
.set
(
attr
);
}
*
attrs
.arg
(
i
)
=
self
.ret.attrs
;
i
+=
1
;
for
arg
in
&
self
.args
{
if
arg
.is_ignore
()
{
continue
;
}
// skip padding
if
arg
.pad
.is_some
()
{
i
+=
1
;
}
if
let
Some
(
attr
)
=
arg
.attr
{
attrs
.arg
(
i
)
.set
(
attr
);
if
!
arg
.is_ignore
()
{
if
arg
.pad
.is_some
()
{
i
+=
1
;
}
*
attrs
.arg
(
i
)
=
arg
.attrs
;
i
+=
1
;
}
i
+=
1
;
}
attrs
}
}
src/librustc_trans/trans/cabi_aarch64.rs
浏览文件 @
de5f8244
...
...
@@ -11,7 +11,7 @@
#![allow(non_upper_case_globals)]
use
llvm
::{
Integer
,
Pointer
,
Float
,
Double
,
Struct
,
Array
,
Vector
};
use
trans
::
abi
::{
FnType
,
ArgType
,
Indirect
};
use
trans
::
abi
::{
FnType
,
ArgType
};
use
trans
::
context
::
CrateContext
;
use
trans
::
type_
::
Type
;
...
...
@@ -185,7 +185,7 @@ fn classify_ret_ty(ccx: &CrateContext, ret: &mut ArgType) {
ret
.cast
=
Some
(
llty
);
return
;
}
ret
.
kind
=
Indirect
;
ret
.
make_indirect
(
ccx
)
;
}
fn
classify_arg_ty
(
ccx
:
&
CrateContext
,
arg
:
&
mut
ArgType
)
{
...
...
@@ -214,7 +214,7 @@ fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType) {
arg
.cast
=
Some
(
llty
);
return
;
}
arg
.
kind
=
Indirect
;
arg
.
make_indirect
(
ccx
)
;
}
fn
is_reg_ty
(
ty
:
Type
)
->
bool
{
...
...
src/librustc_trans/trans/cabi_arm.rs
浏览文件 @
de5f8244
...
...
@@ -11,7 +11,7 @@
#![allow(non_upper_case_globals)]
use
llvm
::{
Integer
,
Pointer
,
Float
,
Double
,
Struct
,
Array
,
Vector
};
use
trans
::
abi
::{
FnType
,
ArgType
,
Indirect
};
use
trans
::
abi
::{
FnType
,
ArgType
};
use
trans
::
context
::
CrateContext
;
use
trans
::
type_
::
Type
;
...
...
@@ -145,7 +145,7 @@ fn classify_ret_ty(ccx: &CrateContext, ret: &mut ArgType, align_fn: TyAlignFn) {
ret
.cast
=
Some
(
llty
);
return
;
}
ret
.
kind
=
Indirect
;
ret
.
make_indirect
(
ccx
)
;
}
fn
classify_arg_ty
(
ccx
:
&
CrateContext
,
arg
:
&
mut
ArgType
,
align_fn
:
TyAlignFn
)
{
...
...
src/librustc_trans/trans/cabi_asmjs.rs
浏览文件 @
de5f8244
...
...
@@ -11,7 +11,7 @@
#![allow(non_upper_case_globals)]
use
llvm
::{
Struct
,
Array
,
Attribute
};
use
trans
::
abi
::{
FnType
,
ArgType
,
Indirect
};
use
trans
::
abi
::{
FnType
,
ArgType
};
use
trans
::
context
::
CrateContext
;
use
trans
::
type_
::
Type
;
...
...
@@ -20,36 +20,36 @@
// See the https://github.com/kripken/emscripten-fastcomp-clang repository.
// The class `EmscriptenABIInfo` in `/lib/CodeGen/TargetInfo.cpp` contains the ABI definitions.
fn
classify_ret_ty
(
ret
:
&
mut
ArgType
)
{
fn
classify_ret_ty
(
ccx
:
&
CrateContext
,
ret
:
&
mut
ArgType
)
{
match
ret
.ty
.kind
()
{
Struct
=>
{
let
field_types
=
ret
.ty
.field_types
();
if
field_types
.len
()
==
1
{
ret
.cast
=
Some
(
field_types
[
0
]);
}
else
{
ret
.
kind
=
Indirect
;
ret
.
make_indirect
(
ccx
)
;
}
}
Array
=>
{
ret
.
kind
=
Indirect
;
ret
.
make_indirect
(
ccx
)
;
}
_
=>
{}
}
}
fn
classify_arg_ty
(
arg
:
&
mut
ArgType
)
{
fn
classify_arg_ty
(
ccx
:
&
CrateContext
,
arg
:
&
mut
ArgType
)
{
if
arg
.ty
.is_aggregate
()
{
arg
.
kind
=
Indirect
;
arg
.attr
=
Some
(
Attribute
::
ByVal
);
arg
.
make_indirect
(
ccx
)
;
arg
.attr
s
.set
(
Attribute
::
ByVal
);
}
}
pub
fn
compute_abi_info
(
ccx
:
&
CrateContext
,
fty
:
&
mut
FnType
)
{
if
fty
.ret.ty
!=
Type
::
void
(
ccx
)
{
classify_ret_ty
(
&
mut
fty
.ret
);
classify_ret_ty
(
ccx
,
&
mut
fty
.ret
);
}
for
arg
in
&
mut
fty
.args
{
classify_arg_ty
(
arg
);
classify_arg_ty
(
ccx
,
arg
);
}
}
src/librustc_trans/trans/cabi_mips.rs
浏览文件 @
de5f8244
...
...
@@ -14,7 +14,7 @@
use
std
::
cmp
;
use
llvm
;
use
llvm
::{
Integer
,
Pointer
,
Float
,
Double
,
Struct
,
Array
,
Vector
};
use
trans
::
abi
::{
ArgType
,
FnType
,
Indirect
};
use
trans
::
abi
::{
ArgType
,
FnType
};
use
trans
::
context
::
CrateContext
;
use
trans
::
type_
::
Type
;
...
...
@@ -148,7 +148,7 @@ fn struct_ty(ccx: &CrateContext, ty: Type) -> Type {
pub
fn
compute_abi_info
(
ccx
:
&
CrateContext
,
fty
:
&
mut
FnType
)
{
if
fty
.ret.ty
!=
Type
::
void
(
ccx
)
{
if
!
is_reg_ty
(
fty
.ret.ty
)
{
fty
.ret.
kind
=
Indirect
;
fty
.ret
.
make_indirect
(
ccx
)
;
}
}
...
...
src/librustc_trans/trans/cabi_powerpc.rs
浏览文件 @
de5f8244
...
...
@@ -11,7 +11,7 @@
use
libc
::
c_uint
;
use
llvm
;
use
llvm
::{
Integer
,
Pointer
,
Float
,
Double
,
Struct
,
Array
};
use
trans
::
abi
::{
FnType
,
ArgType
,
Indirect
};
use
trans
::
abi
::{
FnType
,
ArgType
};
use
trans
::
context
::
CrateContext
;
use
trans
::
type_
::
Type
;
...
...
@@ -143,7 +143,7 @@ fn struct_ty(ccx: &CrateContext, ty: Type) -> Type {
pub
fn
compute_abi_info
(
ccx
:
&
CrateContext
,
fty
:
&
mut
FnType
)
{
if
fty
.ret.ty
!=
Type
::
void
(
ccx
)
{
if
!
is_reg_ty
(
fty
.ret.ty
)
{
fty
.ret.
kind
=
Indirect
;
fty
.ret
.
make_indirect
(
ccx
)
;
}
}
...
...
src/librustc_trans/trans/cabi_powerpc64.rs
浏览文件 @
de5f8244
...
...
@@ -16,7 +16,7 @@
// need to be fixed when PowerPC vector support is added.
use
llvm
::{
Integer
,
Pointer
,
Float
,
Double
,
Struct
,
Array
};
use
trans
::
abi
::{
FnType
,
ArgType
,
Indirect
};
use
trans
::
abi
::{
FnType
,
ArgType
};
use
trans
::
context
::
CrateContext
;
use
trans
::
type_
::
Type
;
...
...
@@ -158,7 +158,7 @@ fn classify_ret_ty(ccx: &CrateContext, ret: &mut ArgType) {
// The PowerPC64 big endian ABI doesn't return aggregates in registers
if
ccx
.sess
()
.target.target.target_endian
==
"big"
{
ret
.
kind
=
Indirect
;
ret
.
make_indirect
(
ccx
)
;
}
if
let
Some
((
base_ty
,
members
))
=
is_homogenous_aggregate_ty
(
ret
.ty
)
{
...
...
@@ -182,7 +182,7 @@ fn classify_ret_ty(ccx: &CrateContext, ret: &mut ArgType) {
return
;
}
ret
.
kind
=
Indirect
;
ret
.
make_indirect
(
ccx
)
;
}
fn
classify_arg_ty
(
ccx
:
&
CrateContext
,
arg
:
&
mut
ArgType
)
{
...
...
src/librustc_trans/trans/cabi_x86.rs
浏览文件 @
de5f8244
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
use
llvm
::
*
;
use
trans
::
abi
::
{
FnType
,
Indirect
,
Ignore
}
;
use
trans
::
abi
::
FnType
;
use
trans
::
type_
::
Type
;
use
super
::
common
::
*
;
use
super
::
machine
::
*
;
...
...
@@ -30,20 +30,20 @@ pub fn compute_abi_info(ccx: &CrateContext, fty: &mut FnType) {
2
=>
fty
.ret.cast
=
Some
(
Type
::
i16
(
ccx
)),
4
=>
fty
.ret.cast
=
Some
(
Type
::
i32
(
ccx
)),
8
=>
fty
.ret.cast
=
Some
(
Type
::
i64
(
ccx
)),
_
=>
fty
.ret.
kind
=
Indirect
_
=>
fty
.ret
.
make_indirect
(
ccx
)
}
}
else
{
fty
.ret.
kind
=
Indirect
;
fty
.ret
.
make_indirect
(
ccx
)
;
}
}
for
arg
in
&
mut
fty
.args
{
if
arg
.ty
.kind
()
==
Struct
{
if
llsize_of_alloc
(
ccx
,
arg
.ty
)
==
0
{
arg
.
kind
=
Ignore
;
arg
.
ignore
()
;
}
else
{
arg
.
kind
=
Indirect
;
arg
.attr
=
Some
(
Attribute
::
ByVal
);
arg
.
make_indirect
(
ccx
)
;
arg
.attr
s
.set
(
Attribute
::
ByVal
);
}
}
}
...
...
src/librustc_trans/trans/cabi_x86_64.rs
浏览文件 @
de5f8244
...
...
@@ -16,7 +16,7 @@
use
llvm
::{
Integer
,
Pointer
,
Float
,
Double
};
use
llvm
::{
Struct
,
Array
,
Attribute
,
Vector
};
use
trans
::
abi
::{
ArgType
,
FnType
,
Indirect
};
use
trans
::
abi
::{
ArgType
,
FnType
};
use
trans
::
context
::
CrateContext
;
use
trans
::
type_
::
Type
;
...
...
@@ -393,8 +393,10 @@ fn x86_64_ty<F>(ccx: &CrateContext,
if
!
arg
.ty
.is_reg_ty
()
{
let
cls
=
classify_ty
(
arg
.ty
);
if
is_mem_cls
(
&
cls
)
{
arg
.kind
=
Indirect
;
arg
.attr
=
ind_attr
;
arg
.make_indirect
(
ccx
);
if
let
Some
(
attr
)
=
ind_attr
{
arg
.attrs
.set
(
attr
);
}
}
else
{
arg
.cast
=
Some
(
llreg_ty
(
ccx
,
&
cls
));
}
...
...
src/librustc_trans/trans/cabi_x86_win64.rs
浏览文件 @
de5f8244
...
...
@@ -11,7 +11,7 @@
use
llvm
::
*
;
use
super
::
common
::
*
;
use
super
::
machine
::
*
;
use
trans
::
abi
::{
ArgType
,
FnType
,
Indirect
};
use
trans
::
abi
::{
ArgType
,
FnType
};
use
trans
::
type_
::
Type
;
// Win64 ABI: http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx
...
...
@@ -24,7 +24,7 @@ pub fn compute_abi_info(ccx: &CrateContext, fty: &mut FnType) {
2
=>
a
.cast
=
Some
(
Type
::
i16
(
ccx
)),
4
=>
a
.cast
=
Some
(
Type
::
i32
(
ccx
)),
8
=>
a
.cast
=
Some
(
Type
::
i64
(
ccx
)),
_
=>
a
.
kind
=
Indirect
_
=>
a
.
make_indirect
(
ccx
)
}
}
};
...
...
src/librustc_trans/trans/declare.rs
浏览文件 @
de5f8244
...
...
@@ -113,7 +113,7 @@ pub fn declare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
attributes
::
from_fn_type
(
ccx
,
fn_type
)
}
else
{
attributes
::
unwind
(
llfn
,
false
);
fty
.llvm_attrs
(
ccx
)
fty
.llvm_attrs
()
};
attrs
.apply_llfn
(
llfn
);
...
...
src/librustc_trans/trans/foreign.rs
浏览文件 @
de5f8244
...
...
@@ -253,7 +253,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
llfn
,
&
llargs_foreign
[
..
],
fn_type
.cconv
,
Some
(
fn_type
.llvm_attrs
(
ccx
)),
Some
(
fn_type
.llvm_attrs
()),
call_debug_loc
);
// If the function we just called does not use an outpointer,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录