Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2de2fb1c
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,发现更多精彩内容 >>
提交
2de2fb1c
编写于
9月 15, 2013
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
auto merge of #9219 : thestinger/rust/function-split, r=alexcrichton
上级
72f62abe
6d0a847c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
44 addition
and
55 deletion
+44
-55
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/base.rs
+9
-8
src/librustc/middle/trans/build.rs
src/librustc/middle/trans/build.rs
+6
-10
src/librustc/middle/trans/builder.rs
src/librustc/middle/trans/builder.rs
+11
-25
src/librustc/middle/trans/callee.rs
src/librustc/middle/trans/callee.rs
+1
-1
src/librustc/middle/trans/foreign.rs
src/librustc/middle/trans/foreign.rs
+8
-2
src/librustc/middle/trans/glue.rs
src/librustc/middle/trans/glue.rs
+3
-3
src/librustc/middle/trans/intrinsic.rs
src/librustc/middle/trans/intrinsic.rs
+6
-6
未找到文件。
src/librustc/middle/trans/base.rs
浏览文件 @
2de2fb1c
...
...
@@ -825,7 +825,8 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t)
};
}
pub
fn
invoke
(
bcx
:
@
mut
Block
,
llfn
:
ValueRef
,
llargs
:
~
[
ValueRef
])
pub
fn
invoke
(
bcx
:
@
mut
Block
,
llfn
:
ValueRef
,
llargs
:
~
[
ValueRef
],
attributes
:
&
[(
uint
,
lib
::
llvm
::
Attribute
)])
->
(
ValueRef
,
@
mut
Block
)
{
let
_
icx
=
push_ctxt
(
"invoke_"
);
if
bcx
.unreachable
{
...
...
@@ -865,7 +866,7 @@ pub fn invoke(bcx: @mut Block, llfn: ValueRef, llargs: ~[ValueRef])
debug!
(
"arg: %x"
,
::
std
::
cast
::
transmute
(
llarg
));
}
}
let
llresult
=
Call
(
bcx
,
llfn
,
llargs
);
let
llresult
=
Call
(
bcx
,
llfn
,
llargs
,
attributes
);
return
(
llresult
,
bcx
);
}
}
...
...
@@ -976,7 +977,7 @@ pub fn get_landing_pad(bcx: @mut Block) -> BasicBlockRef {
// Because we may have unwound across a stack boundary, we must call into
// the runtime to figure out which stack segment we are on and place the
// stack limit back into the TLS.
Call
(
pad_bcx
,
bcx
.ccx
()
.upcalls.reset_stack_limit
,
[]);
Call
(
pad_bcx
,
bcx
.ccx
()
.upcalls.reset_stack_limit
,
[]
,
[]
);
// We store the retval in a function-central alloca, so that calls to
// Resume can find it.
...
...
@@ -1071,7 +1072,7 @@ pub fn trans_trace(bcx: @mut Block, sp_opt: Option<Span>, trace_str: @str) {
let
V_trace_str
=
PointerCast
(
bcx
,
V_trace_str
,
Type
::
i8p
());
let
V_filename
=
PointerCast
(
bcx
,
V_filename
,
Type
::
i8p
());
let
args
=
~
[
V_trace_str
,
V_filename
,
C_int
(
ccx
,
V_line
)];
Call
(
bcx
,
ccx
.upcalls.trace
,
args
);
Call
(
bcx
,
ccx
.upcalls.trace
,
args
,
[]
);
}
pub
fn
ignore_lhs
(
_
bcx
:
@
mut
Block
,
local
:
&
ast
::
Local
)
->
bool
{
...
...
@@ -1465,7 +1466,7 @@ pub fn call_memcpy(cx: @mut Block, dst: ValueRef, src: ValueRef, n_bytes: ValueR
let
size
=
IntCast
(
cx
,
n_bytes
,
ccx
.int_type
);
let
align
=
C_i32
(
align
as
i32
);
let
volatile
=
C_i1
(
false
);
Call
(
cx
,
memcpy
,
[
dst_ptr
,
src_ptr
,
size
,
align
,
volatile
]);
Call
(
cx
,
memcpy
,
[
dst_ptr
,
src_ptr
,
size
,
align
,
volatile
]
,
[]
);
}
pub
fn
memcpy_ty
(
bcx
:
@
mut
Block
,
dst
:
ValueRef
,
src
:
ValueRef
,
t
:
ty
::
t
)
{
...
...
@@ -1510,7 +1511,7 @@ pub fn memzero(b: &Builder, llptr: ValueRef, ty: Type) {
let
size
=
machine
::
llsize_of
(
ccx
,
ty
);
let
align
=
C_i32
(
llalign_of_min
(
ccx
,
ty
)
as
i32
);
let
volatile
=
C_i1
(
false
);
b
.call
(
llintrinsicfn
,
[
llptr
,
llzeroval
,
size
,
align
,
volatile
]);
b
.call
(
llintrinsicfn
,
[
llptr
,
llzeroval
,
size
,
align
,
volatile
]
,
[]
);
}
pub
fn
alloc_ty
(
bcx
:
@
mut
Block
,
t
:
ty
::
t
,
name
:
&
str
)
->
ValueRef
{
...
...
@@ -2353,7 +2354,7 @@ fn create_main(ccx: @mut CrateContext, main_llfn: ValueRef) -> ValueRef {
llvm
::
LLVMGetParam
(
llfdecl
,
env_arg
as
c_uint
)
};
let
args
=
~
[
llenvarg
];
Call
(
bcx
,
main_llfn
,
args
);
Call
(
bcx
,
main_llfn
,
args
,
[]
);
finish_fn
(
fcx
,
bcx
);
return
llfdecl
;
...
...
@@ -2808,7 +2809,7 @@ pub fn declare_dbg_intrinsics(llmod: ModuleRef, intrinsics: &mut HashMap<&'stati
pub
fn
trap
(
bcx
:
@
mut
Block
)
{
match
bcx
.ccx
()
.intrinsics
.find_equiv
(
&
&
"llvm.trap"
)
{
Some
(
&
x
)
=>
{
Call
(
bcx
,
x
,
[]);
},
Some
(
&
x
)
=>
{
Call
(
bcx
,
x
,
[]
,
[]
);
},
_
=>
bcx
.sess
()
.bug
(
"unbound llvm.trap in trap"
)
}
}
...
...
src/librustc/middle/trans/build.rs
浏览文件 @
2de2fb1c
...
...
@@ -644,20 +644,16 @@ pub fn InlineAsmCall(cx: @mut Block, asm: *c_char, cons: *c_char,
B
(
cx
)
.inline_asm_call
(
asm
,
cons
,
inputs
,
output
,
volatile
,
alignstack
,
dia
)
}
pub
fn
Call
(
cx
:
@
mut
Block
,
Fn
:
ValueRef
,
Args
:
&
[
ValueRef
])
->
ValueRef
{
pub
fn
Call
(
cx
:
@
mut
Block
,
Fn
:
ValueRef
,
Args
:
&
[
ValueRef
],
attributes
:
&
[(
uint
,
lib
::
llvm
::
Attribute
)])
->
ValueRef
{
if
cx
.unreachable
{
return
_
UndefReturn
(
cx
,
Fn
);
}
B
(
cx
)
.call
(
Fn
,
Args
)
B
(
cx
)
.call
(
Fn
,
Args
,
attributes
)
}
pub
fn
FastCall
(
cx
:
@
mut
Block
,
Fn
:
ValueRef
,
Args
:
&
[
ValueRef
])
->
ValueRef
{
pub
fn
CallWithConv
(
cx
:
@
mut
Block
,
Fn
:
ValueRef
,
Args
:
&
[
ValueRef
],
Conv
:
CallConv
,
attributes
:
&
[(
uint
,
lib
::
llvm
::
Attribute
)])
->
ValueRef
{
if
cx
.unreachable
{
return
_
UndefReturn
(
cx
,
Fn
);
}
B
(
cx
)
.call
(
Fn
,
Args
)
}
pub
fn
CallWithConv
(
cx
:
@
mut
Block
,
Fn
:
ValueRef
,
Args
:
&
[
ValueRef
],
Conv
:
CallConv
,
sret
:
bool
)
->
ValueRef
{
if
cx
.unreachable
{
return
_
UndefReturn
(
cx
,
Fn
);
}
B
(
cx
)
.call_with_conv
(
Fn
,
Args
,
Conv
,
sret
)
B
(
cx
)
.call_with_conv
(
Fn
,
Args
,
Conv
,
attributes
)
}
pub
fn
AtomicFence
(
cx
:
@
mut
Block
,
order
:
AtomicOrdering
)
{
...
...
src/librustc/middle/trans/builder.rs
浏览文件 @
2de2fb1c
...
...
@@ -13,7 +13,6 @@
use
lib
::
llvm
::{
CallConv
,
AtomicBinOp
,
AtomicOrdering
,
AsmDialect
};
use
lib
::
llvm
::{
Opcode
,
IntPredicate
,
RealPredicate
,
False
};
use
lib
::
llvm
::{
ValueRef
,
BasicBlockRef
,
BuilderRef
,
ModuleRef
};
use
lib
::
llvm
::{
StructRetAttribute
};
use
middle
::
trans
::
base
;
use
middle
::
trans
::
common
::
*
;
use
middle
::
trans
::
machine
::
llalign_of_min
;
...
...
@@ -748,7 +747,7 @@ pub fn add_comment(&self, text: &str) {
c
,
noname
(),
False
,
False
)
}
};
self
.call
(
asm
,
[]);
self
.call
(
asm
,
[]
,
[]
);
}
}
...
...
@@ -773,42 +772,29 @@ pub fn inline_asm_call(&self, asm: *c_char, cons: *c_char,
unsafe
{
let
v
=
llvm
::
LLVMInlineAsm
(
fty
.to_ref
(),
asm
,
cons
,
volatile
,
alignstack
,
dia
as
c_uint
);
self
.call
(
v
,
inputs
)
self
.call
(
v
,
inputs
,
[]
)
}
}
pub
fn
call
(
&
self
,
llfn
:
ValueRef
,
args
:
&
[
ValueRef
])
->
ValueRef
{
pub
fn
call
(
&
self
,
llfn
:
ValueRef
,
args
:
&
[
ValueRef
],
attributes
:
&
[(
uint
,
lib
::
llvm
::
Attribute
)])
->
ValueRef
{
self
.count_insn
(
"call"
);
do
args
.as_imm_buf
|
ptr
,
len
|
{
unsafe
{
llvm
::
LLVMBuildCall
(
self
.llbuilder
,
llfn
,
ptr
,
len
as
c_uint
,
noname
())
}
}
}
pub
fn
fastcall
(
&
self
,
llfn
:
ValueRef
,
args
:
&
[
ValueRef
])
->
ValueRef
{
self
.count_insn
(
"fastcall"
);
unsafe
{
let
v
=
llvm
::
LLVMBuildCall
(
self
.llbuilder
,
llfn
,
vec
::
raw
::
to_ptr
(
args
),
args
.len
()
as
c_uint
,
noname
());
lib
::
llvm
::
SetInstructionCallConv
(
v
,
lib
::
llvm
::
FastCallConv
);
for
&
(
idx
,
attr
)
in
attributes
.iter
()
{
llvm
::
LLVMAddInstrAttribute
(
v
,
idx
as
c_uint
,
attr
as
c_uint
);
}
v
}
}
pub
fn
call_with_conv
(
&
self
,
llfn
:
ValueRef
,
args
:
&
[
ValueRef
],
conv
:
CallConv
,
sret
:
bool
)
->
ValueRef
{
conv
:
CallConv
,
attributes
:
&
[(
uint
,
lib
::
llvm
::
Attribute
)]
)
->
ValueRef
{
self
.count_insn
(
"callwithconv"
);
unsafe
{
let
v
=
llvm
::
LLVMBuildCall
(
self
.llbuilder
,
llfn
,
vec
::
raw
::
to_ptr
(
args
),
args
.len
()
as
c_uint
,
noname
());
lib
::
llvm
::
SetInstructionCallConv
(
v
,
conv
);
if
sret
{
let
return_slot
=
1
;
llvm
::
LLVMAddInstrAttribute
(
v
,
return_slot
,
StructRetAttribute
as
c_uint
);
}
v
}
let
v
=
self
.call
(
llfn
,
args
,
attributes
);
lib
::
llvm
::
SetInstructionCallConv
(
v
,
conv
);
v
}
pub
fn
select
(
&
self
,
cond
:
ValueRef
,
then_val
:
ValueRef
,
else_val
:
ValueRef
)
->
ValueRef
{
...
...
src/librustc/middle/trans/callee.rs
浏览文件 @
2de2fb1c
...
...
@@ -707,7 +707,7 @@ pub fn trans_call_inner(in_cx: @mut Block,
}
// Invoke the actual rust fn and update bcx/llresult.
let
(
llret
,
b
)
=
base
::
invoke
(
bcx
,
llfn
,
llargs
);
let
(
llret
,
b
)
=
base
::
invoke
(
bcx
,
llfn
,
llargs
,
[]
);
bcx
=
b
;
llresult
=
llret
;
...
...
src/librustc/middle/trans/foreign.rs
浏览文件 @
2de2fb1c
...
...
@@ -11,7 +11,7 @@
use
back
::{
link
};
use
std
::
libc
::
c_uint
;
use
lib
::
llvm
::{
ValueRef
,
Attribute
,
CallConv
};
use
lib
::
llvm
::{
ValueRef
,
Attribute
,
CallConv
,
StructRetAttribute
};
use
lib
::
llvm
::
llvm
;
use
lib
;
use
middle
::
trans
::
machine
;
...
...
@@ -266,7 +266,13 @@ pub fn trans_native_call(bcx: @mut Block,
}
};
let
llforeign_retval
=
CallWithConv
(
bcx
,
llfn
,
llargs_foreign
,
cc
,
fn_type
.sret
);
let
attrs
;
if
fn_type
.sret
{
attrs
=
&
[(
1
,
StructRetAttribute
)];
}
else
{
attrs
=
&
[];
}
let
llforeign_retval
=
CallWithConv
(
bcx
,
llfn
,
llargs_foreign
,
cc
,
attrs
);
// If the function we just called does not use an outpointer,
// store the result into the rust outpointer. Cast the outpointer
...
...
src/librustc/middle/trans/glue.rs
浏览文件 @
2de2fb1c
...
...
@@ -332,7 +332,7 @@ pub fn call_tydesc_glue_full(bcx: @mut Block,
}
};
Call
(
bcx
,
llfn
,
[
C_null
(
Type
::
nil
()
.ptr_to
()),
llrawptr
]);
Call
(
bcx
,
llfn
,
[
C_null
(
Type
::
nil
()
.ptr_to
()),
llrawptr
]
,
[]
);
}
// See [Note-arg-mode]
...
...
@@ -424,7 +424,7 @@ pub fn trans_struct_drop_flag(bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did:
let
self_arg
=
PointerCast
(
bcx
,
v0
,
params
[
0
]);
let
args
=
~
[
self_arg
];
Call
(
bcx
,
dtor_addr
,
args
);
Call
(
bcx
,
dtor_addr
,
args
,
[]
);
// Drop the fields
let
field_tys
=
ty
::
struct_fields
(
bcx
.tcx
(),
class_did
,
substs
);
...
...
@@ -459,7 +459,7 @@ pub fn trans_struct_drop(mut bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did:
let
self_arg
=
PointerCast
(
bcx
,
v0
,
params
[
0
]);
let
args
=
~
[
self_arg
];
Call
(
bcx
,
dtor_addr
,
args
);
Call
(
bcx
,
dtor_addr
,
args
,
[]
);
// Drop the fields
let
field_tys
=
ty
::
struct_fields
(
bcx
.tcx
(),
class_did
,
substs
);
...
...
src/librustc/middle/trans/intrinsic.rs
浏览文件 @
2de2fb1c
...
...
@@ -49,7 +49,7 @@ fn simple_llvm_intrinsic(bcx: @mut Block, name: &'static str, num_args: uint) {
args
[
i
]
=
get_param
(
bcx
.fcx.llfn
,
first_real_arg
+
i
);
}
let
llfn
=
bcx
.ccx
()
.intrinsics
.get_copy
(
&
name
);
Ret
(
bcx
,
Call
(
bcx
,
llfn
,
args
.slice
(
0
,
num_args
)));
Ret
(
bcx
,
Call
(
bcx
,
llfn
,
args
.slice
(
0
,
num_args
)
,
[]
));
}
fn
with_overflow_instrinsic
(
bcx
:
@
mut
Block
,
name
:
&
'static
str
)
{
...
...
@@ -59,7 +59,7 @@ fn with_overflow_instrinsic(bcx: @mut Block, name: &'static str) {
let
llfn
=
bcx
.ccx
()
.intrinsics
.get_copy
(
&
name
);
// convert `i1` to a `bool`, and write to the out parameter
let
val
=
Call
(
bcx
,
llfn
,
[
a
,
b
]);
let
val
=
Call
(
bcx
,
llfn
,
[
a
,
b
]
,
[]
);
let
result
=
ExtractValue
(
bcx
,
val
,
0
);
let
overflow
=
ZExt
(
bcx
,
ExtractValue
(
bcx
,
val
,
1
),
Type
::
bool
());
let
retptr
=
get_param
(
bcx
.fcx.llfn
,
bcx
.fcx
.out_arg_pos
());
...
...
@@ -87,7 +87,7 @@ fn memcpy_intrinsic(bcx: @mut Block, name: &'static str, tp_ty: ty::t, sizebits:
let
count
=
get_param
(
decl
,
first_real_arg
+
2
);
let
volatile
=
C_i1
(
false
);
let
llfn
=
bcx
.ccx
()
.intrinsics
.get_copy
(
&
name
);
Call
(
bcx
,
llfn
,
[
dst_ptr
,
src_ptr
,
Mul
(
bcx
,
size
,
count
),
align
,
volatile
]);
Call
(
bcx
,
llfn
,
[
dst_ptr
,
src_ptr
,
Mul
(
bcx
,
size
,
count
),
align
,
volatile
]
,
[]
);
RetVoid
(
bcx
);
}
...
...
@@ -108,7 +108,7 @@ fn memset_intrinsic(bcx: @mut Block, name: &'static str, tp_ty: ty::t, sizebits:
let
count
=
get_param
(
decl
,
first_real_arg
+
2
);
let
volatile
=
C_i1
(
false
);
let
llfn
=
bcx
.ccx
()
.intrinsics
.get_copy
(
&
name
);
Call
(
bcx
,
llfn
,
[
dst_ptr
,
val
,
Mul
(
bcx
,
size
,
count
),
align
,
volatile
]);
Call
(
bcx
,
llfn
,
[
dst_ptr
,
val
,
Mul
(
bcx
,
size
,
count
),
align
,
volatile
]
,
[]
);
RetVoid
(
bcx
);
}
...
...
@@ -116,7 +116,7 @@ fn count_zeros_intrinsic(bcx: @mut Block, name: &'static str) {
let
x
=
get_param
(
bcx
.fcx.llfn
,
bcx
.fcx
.arg_pos
(
0u
));
let
y
=
C_i1
(
false
);
let
llfn
=
bcx
.ccx
()
.intrinsics
.get_copy
(
&
name
);
Ret
(
bcx
,
Call
(
bcx
,
llfn
,
[
x
,
y
]));
Ret
(
bcx
,
Call
(
bcx
,
llfn
,
[
x
,
y
]
,
[]
));
}
let
output_type
=
ty
::
ty_fn_ret
(
ty
::
node_id_to_type
(
ccx
.tcx
,
item
.id
));
...
...
@@ -366,7 +366,7 @@ fn count_zeros_intrinsic(bcx: @mut Block, name: &'static str) {
}
"frame_address"
=>
{
let
frameaddress
=
ccx
.intrinsics
.get_copy
(
&
&
"llvm.frameaddress"
);
let
frameaddress_val
=
Call
(
bcx
,
frameaddress
,
[
C_i32
(
0i32
)]);
let
frameaddress_val
=
Call
(
bcx
,
frameaddress
,
[
C_i32
(
0i32
)]
,
[]
);
let
star_u8
=
ty
::
mk_imm_ptr
(
bcx
.tcx
(),
ty
::
mk_mach_uint
(
ast
::
ty_u8
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录