Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
755850f3
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,发现更多精彩内容 >>
提交
755850f3
编写于
12月 16, 2016
作者:
M
Mark-Simulacrum
提交者:
Mark Simulacrum
12月 20, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge OwnedBuilder and Builder
上级
8ed11209
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
38 deletion
+23
-38
src/librustc_trans/builder.rs
src/librustc_trans/builder.rs
+14
-2
src/librustc_trans/common.rs
src/librustc_trans/common.rs
+9
-36
未找到文件。
src/librustc_trans/builder.rs
浏览文件 @
755850f3
...
...
@@ -32,6 +32,14 @@ pub struct Builder<'a, 'tcx: 'a> {
pub
ccx
:
&
'a
CrateContext
<
'a
,
'tcx
>
,
}
impl
<
'blk
,
'tcx
>
Drop
for
Builder
<
'blk
,
'tcx
>
{
fn
drop
(
&
mut
self
)
{
unsafe
{
llvm
::
LLVMDisposeBuilder
(
self
.llbuilder
);
}
}
}
// This is a really awful way to get a zero-length c-string, but better (and a
// lot more efficient) than doing str::as_c_str("", ...) every time.
pub
fn
noname
()
->
*
const
c_char
{
...
...
@@ -40,9 +48,13 @@ pub fn noname() -> *const c_char {
}
impl
<
'a
,
'tcx
>
Builder
<
'a
,
'tcx
>
{
pub
fn
new
(
ccx
:
&
'a
CrateContext
<
'a
,
'tcx
>
)
->
Builder
<
'a
,
'tcx
>
{
pub
fn
with_ccx
(
ccx
:
&
'a
CrateContext
<
'a
,
'tcx
>
)
->
Self
{
// Create a fresh builder from the crate context.
let
llbuilder
=
unsafe
{
llvm
::
LLVMCreateBuilderInContext
(
ccx
.llcx
())
};
Builder
{
llbuilder
:
ccx
.raw_builder
()
,
llbuilder
:
llbuilder
,
ccx
:
ccx
,
}
}
...
...
src/librustc_trans/common.rs
浏览文件 @
755850f3
...
...
@@ -306,7 +306,7 @@ pub struct FunctionContext<'a, 'tcx: 'a> {
// Used and maintained by the debuginfo module.
pub
debug_context
:
debuginfo
::
FunctionDebugContext
,
alloca_builder
:
Owned
Builder
<
'a
,
'tcx
>
,
alloca_builder
:
Builder
<
'a
,
'tcx
>
,
}
impl
<
'a
,
'tcx
>
FunctionContext
<
'a
,
'tcx
>
{
...
...
@@ -359,13 +359,13 @@ pub fn new(
param_substs
:
param_substs
,
ccx
:
ccx
,
debug_context
:
debug_context
,
alloca_builder
:
OwnedBuilder
::
new_
with_ccx
(
ccx
),
alloca_builder
:
Builder
::
with_ccx
(
ccx
),
};
let
val
=
{
let
entry_bcx
=
fcx
.build_new_block
(
"entry-block"
);
let
val
=
entry_bcx
.load
(
C_null
(
Type
::
i8p
(
ccx
)));
fcx
.alloca_builder.
builder
.
position_at_start
(
entry_bcx
.llbb
());
fcx
.alloca_builder
.position_at_start
(
entry_bcx
.llbb
());
val
};
...
...
@@ -509,7 +509,7 @@ pub fn eh_unwind_resume(&self) -> Callee<'tcx> {
}
pub
fn
alloca
(
&
self
,
ty
:
Type
,
name
:
&
str
)
->
ValueRef
{
self
.alloca_builder.
builder
.
dynamic_alloca
(
ty
,
name
)
self
.alloca_builder
.dynamic_alloca
(
ty
,
name
)
}
}
...
...
@@ -521,33 +521,6 @@ fn drop(&mut self) {
}
}
pub
struct
OwnedBuilder
<
'blk
,
'tcx
:
'blk
>
{
builder
:
Builder
<
'blk
,
'tcx
>
}
impl
<
'blk
,
'tcx
>
OwnedBuilder
<
'blk
,
'tcx
>
{
pub
fn
new_with_ccx
(
ccx
:
&
'blk
CrateContext
<
'blk
,
'tcx
>
)
->
Self
{
// Create a fresh builder from the crate context.
let
llbuilder
=
unsafe
{
llvm
::
LLVMCreateBuilderInContext
(
ccx
.llcx
())
};
OwnedBuilder
{
builder
:
Builder
{
llbuilder
:
llbuilder
,
ccx
:
ccx
,
}
}
}
}
impl
<
'blk
,
'tcx
>
Drop
for
OwnedBuilder
<
'blk
,
'tcx
>
{
fn
drop
(
&
mut
self
)
{
unsafe
{
llvm
::
LLVMDisposeBuilder
(
self
.builder.llbuilder
);
}
}
}
#[must_use]
pub
struct
BlockAndBuilder
<
'blk
,
'tcx
:
'blk
>
{
// The BasicBlockRef returned from a call to
...
...
@@ -561,18 +534,18 @@ pub struct BlockAndBuilder<'blk, 'tcx: 'blk> {
// attached.
fcx
:
&
'blk
FunctionContext
<
'blk
,
'tcx
>
,
owned_builder
:
Owned
Builder
<
'blk
,
'tcx
>
,
builder
:
Builder
<
'blk
,
'tcx
>
,
}
impl
<
'blk
,
'tcx
>
BlockAndBuilder
<
'blk
,
'tcx
>
{
pub
fn
new
(
llbb
:
BasicBlockRef
,
fcx
:
&
'blk
FunctionContext
<
'blk
,
'tcx
>
)
->
Self
{
let
owned_builder
=
OwnedBuilder
::
new_
with_ccx
(
fcx
.ccx
);
let
builder
=
Builder
::
with_ccx
(
fcx
.ccx
);
// Set the builder's position to this block's end.
owned_builder
.
builder
.position_at_end
(
llbb
);
builder
.position_at_end
(
llbb
);
BlockAndBuilder
{
llbb
:
llbb
,
fcx
:
fcx
,
owned_builder
:
owned_
builder
,
builder
:
builder
,
}
}
...
...
@@ -610,7 +583,7 @@ pub fn llbb(&self) -> BasicBlockRef {
impl
<
'blk
,
'tcx
>
Deref
for
BlockAndBuilder
<
'blk
,
'tcx
>
{
type
Target
=
Builder
<
'blk
,
'tcx
>
;
fn
deref
(
&
self
)
->
&
Self
::
Target
{
&
self
.
owned_builder.
builder
&
self
.builder
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录