Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
78dd95f4
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
78dd95f4
编写于
9月 13, 2018
作者:
D
Denis Merigoux
提交者:
Eduard-Mihai Burtescu
11月 16, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Generalized base::unsize_thin_ptr
上级
034f6975
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
61 addition
and
41 deletion
+61
-41
src/librustc_codegen_llvm/base.rs
src/librustc_codegen_llvm/base.rs
+9
-9
src/librustc_codegen_llvm/context.rs
src/librustc_codegen_llvm/context.rs
+0
-26
src/librustc_codegen_llvm/glue.rs
src/librustc_codegen_llvm/glue.rs
+1
-1
src/librustc_codegen_llvm/interfaces/type_.rs
src/librustc_codegen_llvm/interfaces/type_.rs
+12
-1
src/librustc_codegen_llvm/mir/analyze.rs
src/librustc_codegen_llvm/mir/analyze.rs
+1
-0
src/librustc_codegen_llvm/mir/rvalue.rs
src/librustc_codegen_llvm/mir/rvalue.rs
+1
-1
src/librustc_codegen_llvm/type_.rs
src/librustc_codegen_llvm/type_.rs
+37
-3
未找到文件。
src/librustc_codegen_llvm/base.rs
浏览文件 @
78dd95f4
...
...
@@ -208,7 +208,7 @@ pub fn unsized_info<'tcx, Cx: CodegenMethods<'tcx>>(
let
vtable_ptr
=
cx
.layout_of
(
cx
.tcx
()
.mk_mut_ptr
(
target
))
.field
(
cx
,
abi
::
FAT_PTR_EXTRA
);
cx
.static_ptrcast
(
meth
::
get_vtable
(
cx
,
source
,
data
.principal
()),
cx
.backend_type
(
vtable_ptr
))
cx
.backend_type
(
&
vtable_ptr
))
}
_
=>
bug!
(
"unsized_info: invalid unsizing {:?} -> {:?}"
,
source
,
...
...
@@ -217,12 +217,12 @@ pub fn unsized_info<'tcx, Cx: CodegenMethods<'tcx>>(
}
/// Coerce `src` to `dst_ty`. `src_ty` must be a thin pointer.
pub
fn
unsize_thin_ptr
(
bx
:
&
B
uilder
<
'a
,
'll
,
'tcx
>
,
src
:
&
'll
Value
,
pub
fn
unsize_thin_ptr
<
'a
,
'tcx
:
'a
,
Bx
:
BuilderMethods
<
'a
,
'tcx
>>
(
bx
:
&
B
x
,
src
:
Bx
::
Value
,
src_ty
:
Ty
<
'tcx
>
,
dst_ty
:
Ty
<
'tcx
>
)
->
(
&
'll
Value
,
&
'll
Value
)
{
)
->
(
Bx
::
Value
,
Bx
::
Value
)
{
debug!
(
"unsize_thin_ptr: {:?} => {:?}"
,
src_ty
,
dst_ty
);
match
(
&
src_ty
.sty
,
&
dst_ty
.sty
)
{
(
&
ty
::
Ref
(
_
,
a
,
_
),
...
...
@@ -232,13 +232,13 @@ pub fn unsize_thin_ptr(
(
&
ty
::
RawPtr
(
ty
::
TypeAndMut
{
ty
:
a
,
..
}),
&
ty
::
RawPtr
(
ty
::
TypeAndMut
{
ty
:
b
,
..
}))
=>
{
assert
!
(
bx
.cx
()
.type_is_sized
(
a
));
let
ptr_ty
=
bx
.cx
()
.type_ptr_to
(
bx
.cx
()
.
layout_of
(
b
)
.llvm_type
(
bx
.cx
(
)));
let
ptr_ty
=
bx
.cx
()
.type_ptr_to
(
bx
.cx
()
.
backend_type
(
&
bx
.cx
()
.layout_of
(
b
)));
(
bx
.pointercast
(
src
,
ptr_ty
),
unsized_info
(
bx
.cx
(),
a
,
b
,
None
))
}
(
&
ty
::
Adt
(
def_a
,
_
),
&
ty
::
Adt
(
def_b
,
_
))
if
def_a
.is_box
()
&&
def_b
.is_box
()
=>
{
let
(
a
,
b
)
=
(
src_ty
.boxed_ty
(),
dst_ty
.boxed_ty
());
assert
!
(
bx
.cx
()
.type_is_sized
(
a
));
let
ptr_ty
=
bx
.cx
()
.type_ptr_to
(
bx
.cx
()
.
layout_of
(
b
)
.llvm_type
(
bx
.cx
(
)));
let
ptr_ty
=
bx
.cx
()
.type_ptr_to
(
bx
.cx
()
.
backend_type
(
&
bx
.cx
()
.layout_of
(
b
)));
(
bx
.pointercast
(
src
,
ptr_ty
),
unsized_info
(
bx
.cx
(),
a
,
b
,
None
))
}
(
&
ty
::
Adt
(
def_a
,
_
),
&
ty
::
Adt
(
def_b
,
_
))
=>
{
...
...
@@ -263,8 +263,8 @@ pub fn unsize_thin_ptr(
}
let
(
lldata
,
llextra
)
=
result
.unwrap
();
// HACK(eddyb) have to bitcast pointers until LLVM removes pointee types.
(
bx
.bitcast
(
lldata
,
dst_layout
.scalar_pair_element_llvm_type
(
bx
.cx
()
,
0
,
true
)),
bx
.bitcast
(
llextra
,
dst_layout
.scalar_pair_element_llvm_type
(
bx
.cx
()
,
1
,
true
)))
(
bx
.bitcast
(
lldata
,
bx
.cx
()
.scalar_pair_element_backend_type
(
&
dst_layout
,
0
,
true
)),
bx
.bitcast
(
llextra
,
bx
.cx
()
.scalar_pair_element_backend_type
(
&
dst_layout
,
1
,
true
)))
}
_
=>
bug!
(
"unsize_thin_ptr: called on bad types"
),
}
...
...
src/librustc_codegen_llvm/context.rs
浏览文件 @
78dd95f4
...
...
@@ -9,7 +9,6 @@
// except according to those terms.
use
attributes
;
use
common
;
use
llvm
;
use
rustc
::
dep_graph
::
DepGraphSafe
;
use
rustc
::
hir
;
...
...
@@ -746,31 +745,6 @@ pub fn eh_unwind_resume(&self) -> &'b Value {
llfn
}
pub
fn
type_needs_drop
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
common
::
type_needs_drop
(
self
.tcx
,
ty
)
}
pub
fn
type_is_sized
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
common
::
type_is_sized
(
self
.tcx
,
ty
)
}
pub
fn
type_is_freeze
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
common
::
type_is_freeze
(
self
.tcx
,
ty
)
}
pub
fn
type_has_metadata
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
use
syntax_pos
::
DUMMY_SP
;
if
ty
.is_sized
(
self
.tcx
.at
(
DUMMY_SP
),
ty
::
ParamEnv
::
reveal_all
())
{
return
false
;
}
let
tail
=
self
.tcx
.struct_tail
(
ty
);
match
tail
.sty
{
ty
::
Foreign
(
..
)
=>
false
,
ty
::
Str
|
ty
::
Slice
(
..
)
|
ty
::
Dynamic
(
..
)
=>
true
,
_
=>
bug!
(
"unexpected unsized tail: {:?}"
,
tail
.sty
),
}
}
}
impl
ty
::
layout
::
HasDataLayout
for
CodegenCx
<
'll
,
'tcx
>
{
...
...
src/librustc_codegen_llvm/glue.rs
浏览文件 @
78dd95f4
...
...
@@ -20,7 +20,7 @@
use
rustc
::
ty
::
layout
::{
LayoutOf
,
HasTyCtxt
};
use
rustc
::
ty
::{
self
,
Ty
};
use
value
::
Value
;
use
interfaces
::
{
BuilderMethods
,
ConstMethods
}
;
use
interfaces
::
*
;
pub
fn
size_and_align_of_dst
(
bx
:
&
Builder
<
'_
,
'll
,
'tcx
>
,
...
...
src/librustc_codegen_llvm/interfaces/type_.rs
浏览文件 @
78dd95f4
...
...
@@ -61,10 +61,21 @@ pub trait DerivedTypeMethods<'tcx>: Backend<'tcx> {
fn
type_from_integer
(
&
self
,
i
:
layout
::
Integer
)
->
Self
::
Type
;
fn
type_pointee_for_abi_align
(
&
self
,
align
:
Align
)
->
Self
::
Type
;
fn
type_padding_filler
(
&
self
,
size
:
Size
,
align
:
Align
)
->
Self
::
Type
;
fn
type_needs_drop
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
;
fn
type_is_sized
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
;
fn
type_is_freeze
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
;
fn
type_has_metadata
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
;
}
pub
trait
LayoutTypeMethods
<
'tcx
>
:
Backend
<
'tcx
>
{
fn
backend_type
(
&
self
,
ty
:
TyLayout
<
'tcx
>
)
->
Self
::
Type
;
fn
backend_type
(
&
self
,
ty
:
&
TyLayout
<
'tcx
>
)
->
Self
::
Type
;
fn
scalar_pair_element_backend_type
<
'a
>
(
&
self
,
ty
:
&
TyLayout
<
'tcx
>
,
index
:
usize
,
immediate
:
bool
)
->
Self
::
Type
;
}
pub
trait
TypeMethods
<
'tcx
>
:
...
...
src/librustc_codegen_llvm/mir/analyze.rs
浏览文件 @
78dd95f4
...
...
@@ -22,6 +22,7 @@
use
type_of
::
LayoutLlvmExt
;
use
super
::
FunctionCx
;
use
value
::
Value
;
use
interfaces
::
*
;
pub
fn
non_ssa_locals
(
fx
:
&
FunctionCx
<
'a
,
'll
,
'tcx
,
&
'll
Value
>
)
->
BitSet
<
mir
::
Local
>
{
let
mir
=
fx
.mir
;
...
...
src/librustc_codegen_llvm/mir/rvalue.rs
浏览文件 @
78dd95f4
...
...
@@ -25,7 +25,7 @@
use
type_of
::
LayoutLlvmExt
;
use
value
::
Value
;
use
interfaces
::
{
BuilderMethods
,
ConstMethods
,
BaseTypeMethods
,
IntrinsicDeclarationMethods
}
;
use
interfaces
::
*
;
use
super
::{
FunctionCx
,
LocalRef
};
use
super
::
operand
::{
OperandRef
,
OperandValue
};
...
...
src/librustc_codegen_llvm/type_.rs
浏览文件 @
78dd95f4
...
...
@@ -20,9 +20,9 @@
use
syntax
::
ast
;
use
rustc
::
ty
::
layout
::{
self
,
Align
,
Size
};
use
rustc
::
ty
::
layout
::{
self
,
Align
,
Size
,
HasTyCtxt
};
use
rustc
::
util
::
nodemap
::
FxHashMap
;
use
rustc
::
ty
::
Ty
;
use
rustc
::
ty
::
{
self
,
Ty
}
;
use
rustc
::
ty
::
layout
::
TyLayout
;
use
rustc_data_structures
::
small_c_str
::
SmallCStr
;
use
common
::{
self
,
TypeKind
};
...
...
@@ -365,10 +365,44 @@ fn type_padding_filler(
assert_eq!
(
size
%
unit_size
,
0
);
self
.type_array
(
self
.type_from_integer
(
unit
),
size
/
unit_size
)
}
fn
type_needs_drop
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
common
::
type_needs_drop
(
self
.tcx
(),
ty
)
}
fn
type_is_sized
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
common
::
type_is_sized
(
self
.tcx
(),
ty
)
}
fn
type_is_freeze
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
common
::
type_is_freeze
(
self
.tcx
(),
ty
)
}
fn
type_has_metadata
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
use
syntax_pos
::
DUMMY_SP
;
if
ty
.is_sized
(
self
.tcx
()
.at
(
DUMMY_SP
),
ty
::
ParamEnv
::
reveal_all
())
{
return
false
;
}
let
tail
=
self
.tcx
()
.struct_tail
(
ty
);
match
tail
.sty
{
ty
::
Foreign
(
..
)
=>
false
,
ty
::
Str
|
ty
::
Slice
(
..
)
|
ty
::
Dynamic
(
..
)
=>
true
,
_
=>
bug!
(
"unexpected unsized tail: {:?}"
,
tail
.sty
),
}
}
}
impl
LayoutTypeMethods
<
'tcx
>
for
CodegenCx
<
'll
,
'tcx
>
{
fn
backend_type
(
&
self
,
ty
:
TyLayout
<
'tcx
>
)
->
&
'll
Type
{
fn
backend_type
(
&
self
,
ty
:
&
TyLayout
<
'tcx
>
)
->
&
'll
Type
{
ty
.llvm_type
(
&
self
)
}
fn
scalar_pair_element_backend_type
<
'a
>
(
&
self
,
ty
:
&
TyLayout
<
'tcx
>
,
index
:
usize
,
immediate
:
bool
)
->
&
'll
Type
{
ty
.scalar_pair_element_llvm_type
(
&
self
,
index
,
immediate
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录