Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
fb7de6a0
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,发现更多精彩内容 >>
提交
fb7de6a0
编写于
1月 05, 2018
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc_trans: rename CrateContext to CodegenCx.
上级
2931af62
变更
39
隐藏空白更改
内联
并排
Showing
39 changed file
with
273 addition
and
273 deletion
+273
-273
src/librustc_trans/abi.rs
src/librustc_trans/abi.rs
+17
-17
src/librustc_trans/asm.rs
src/librustc_trans/asm.rs
+1
-1
src/librustc_trans/attributes.rs
src/librustc_trans/attributes.rs
+4
-4
src/librustc_trans/base.rs
src/librustc_trans/base.rs
+9
-9
src/librustc_trans/builder.rs
src/librustc_trans/builder.rs
+3
-3
src/librustc_trans/cabi_aarch64.rs
src/librustc_trans/cabi_aarch64.rs
+5
-5
src/librustc_trans/cabi_arm.rs
src/librustc_trans/cabi_arm.rs
+5
-5
src/librustc_trans/cabi_asmjs.rs
src/librustc_trans/cabi_asmjs.rs
+3
-3
src/librustc_trans/cabi_mips.rs
src/librustc_trans/cabi_mips.rs
+4
-4
src/librustc_trans/cabi_mips64.rs
src/librustc_trans/cabi_mips64.rs
+4
-4
src/librustc_trans/cabi_powerpc.rs
src/librustc_trans/cabi_powerpc.rs
+4
-4
src/librustc_trans/cabi_powerpc64.rs
src/librustc_trans/cabi_powerpc64.rs
+5
-5
src/librustc_trans/cabi_s390x.rs
src/librustc_trans/cabi_s390x.rs
+4
-4
src/librustc_trans/cabi_sparc.rs
src/librustc_trans/cabi_sparc.rs
+4
-4
src/librustc_trans/cabi_sparc64.rs
src/librustc_trans/cabi_sparc64.rs
+5
-5
src/librustc_trans/cabi_x86.rs
src/librustc_trans/cabi_x86.rs
+3
-3
src/librustc_trans/cabi_x86_64.rs
src/librustc_trans/cabi_x86_64.rs
+4
-4
src/librustc_trans/callee.rs
src/librustc_trans/callee.rs
+3
-3
src/librustc_trans/common.rs
src/librustc_trans/common.rs
+13
-13
src/librustc_trans/consts.rs
src/librustc_trans/consts.rs
+6
-6
src/librustc_trans/context.rs
src/librustc_trans/context.rs
+12
-12
src/librustc_trans/debuginfo/create_scope_map.rs
src/librustc_trans/debuginfo/create_scope_map.rs
+3
-3
src/librustc_trans/debuginfo/doc.rs
src/librustc_trans/debuginfo/doc.rs
+1
-1
src/librustc_trans/debuginfo/gdb.rs
src/librustc_trans/debuginfo/gdb.rs
+4
-4
src/librustc_trans/debuginfo/metadata.rs
src/librustc_trans/debuginfo/metadata.rs
+36
-36
src/librustc_trans/debuginfo/mod.rs
src/librustc_trans/debuginfo/mod.rs
+7
-7
src/librustc_trans/debuginfo/namespace.rs
src/librustc_trans/debuginfo/namespace.rs
+4
-4
src/librustc_trans/debuginfo/type_names.rs
src/librustc_trans/debuginfo/type_names.rs
+5
-5
src/librustc_trans/debuginfo/utils.rs
src/librustc_trans/debuginfo/utils.rs
+6
-6
src/librustc_trans/declare.rs
src/librustc_trans/declare.rs
+10
-10
src/librustc_trans/intrinsic.rs
src/librustc_trans/intrinsic.rs
+8
-8
src/librustc_trans/meth.rs
src/librustc_trans/meth.rs
+1
-1
src/librustc_trans/mir/constant.rs
src/librustc_trans/mir/constant.rs
+17
-17
src/librustc_trans/mir/mod.rs
src/librustc_trans/mir/mod.rs
+4
-4
src/librustc_trans/mir/operand.rs
src/librustc_trans/mir/operand.rs
+3
-3
src/librustc_trans/mir/place.rs
src/librustc_trans/mir/place.rs
+2
-2
src/librustc_trans/trans_item.rs
src/librustc_trans/trans_item.rs
+5
-5
src/librustc_trans/type_.rs
src/librustc_trans/type_.rs
+26
-26
src/librustc_trans/type_of.rs
src/librustc_trans/type_of.rs
+13
-13
未找到文件。
src/librustc_trans/abi.rs
浏览文件 @
fb7de6a0
...
...
@@ -12,7 +12,7 @@
use
base
;
use
builder
::
Builder
;
use
common
::{
ty_fn_sig
,
C_usize
};
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
use
cabi_x86
;
use
cabi_x86_64
;
use
cabi_x86_win64
;
...
...
@@ -209,7 +209,7 @@ impl Reg {
}
impl
Reg
{
pub
fn
align
(
&
self
,
ccx
:
&
C
rateContext
)
->
Align
{
pub
fn
align
(
&
self
,
ccx
:
&
C
odegenCx
)
->
Align
{
let
dl
=
ccx
.data_layout
();
match
self
.kind
{
RegKind
::
Integer
=>
{
...
...
@@ -234,7 +234,7 @@ pub fn align(&self, ccx: &CrateContext) -> Align {
}
}
pub
fn
llvm_type
(
&
self
,
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
llvm_type
(
&
self
,
ccx
:
&
C
odegenCx
)
->
Type
{
match
self
.kind
{
RegKind
::
Integer
=>
Type
::
ix
(
ccx
,
self
.size
.bits
()),
RegKind
::
Float
=>
{
...
...
@@ -276,11 +276,11 @@ fn from(unit: Reg) -> Uniform {
}
impl
Uniform
{
pub
fn
align
(
&
self
,
ccx
:
&
C
rateContext
)
->
Align
{
pub
fn
align
(
&
self
,
ccx
:
&
C
odegenCx
)
->
Align
{
self
.unit
.align
(
ccx
)
}
pub
fn
llvm_type
(
&
self
,
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
llvm_type
(
&
self
,
ccx
:
&
C
odegenCx
)
->
Type
{
let
llunit
=
self
.unit
.llvm_type
(
ccx
);
if
self
.total
<=
self
.unit.size
{
...
...
@@ -307,7 +307,7 @@ pub fn llvm_type(&self, ccx: &CrateContext) -> Type {
pub
trait
LayoutExt
<
'tcx
>
{
fn
is_aggregate
(
&
self
)
->
bool
;
fn
homogeneous_aggregate
<
'a
>
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
Option
<
Reg
>
;
fn
homogeneous_aggregate
<
'a
>
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Option
<
Reg
>
;
}
impl
<
'tcx
>
LayoutExt
<
'tcx
>
for
TyLayout
<
'tcx
>
{
...
...
@@ -321,7 +321,7 @@ fn is_aggregate(&self) -> bool {
}
}
fn
homogeneous_aggregate
<
'a
>
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
Option
<
Reg
>
{
fn
homogeneous_aggregate
<
'a
>
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Option
<
Reg
>
{
match
self
.abi
{
layout
::
Abi
::
Uninhabited
=>
None
,
...
...
@@ -423,7 +423,7 @@ fn from(uniform: Uniform) -> CastTarget {
}
impl
CastTarget
{
pub
fn
size
(
&
self
,
ccx
:
&
C
rateContext
)
->
Size
{
pub
fn
size
(
&
self
,
ccx
:
&
C
odegenCx
)
->
Size
{
match
*
self
{
CastTarget
::
Uniform
(
u
)
=>
u
.total
,
CastTarget
::
Pair
(
a
,
b
)
=>
{
...
...
@@ -433,7 +433,7 @@ pub fn size(&self, ccx: &CrateContext) -> Size {
}
}
pub
fn
align
(
&
self
,
ccx
:
&
C
rateContext
)
->
Align
{
pub
fn
align
(
&
self
,
ccx
:
&
C
odegenCx
)
->
Align
{
match
*
self
{
CastTarget
::
Uniform
(
u
)
=>
u
.align
(
ccx
),
CastTarget
::
Pair
(
a
,
b
)
=>
{
...
...
@@ -444,7 +444,7 @@ pub fn align(&self, ccx: &CrateContext) -> Align {
}
}
pub
fn
llvm_type
(
&
self
,
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
llvm_type
(
&
self
,
ccx
:
&
C
odegenCx
)
->
Type
{
match
*
self
{
CastTarget
::
Uniform
(
u
)
=>
u
.llvm_type
(
ccx
),
CastTarget
::
Pair
(
a
,
b
)
=>
{
...
...
@@ -547,7 +547,7 @@ pub fn is_ignore(&self) -> bool {
/// Get the LLVM type for an place of the original Rust type of
/// this argument/return, i.e. the result of `type_of::type_of`.
pub
fn
memory_ty
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
Type
{
pub
fn
memory_ty
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Type
{
self
.layout
.llvm_type
(
ccx
)
}
...
...
@@ -647,7 +647,7 @@ pub struct FnType<'tcx> {
}
impl
<
'a
,
'tcx
>
FnType
<
'tcx
>
{
pub
fn
of_instance
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
instance
:
&
ty
::
Instance
<
'tcx
>
)
pub
fn
of_instance
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
instance
:
&
ty
::
Instance
<
'tcx
>
)
->
Self
{
let
fn_ty
=
instance
.ty
(
ccx
.tcx
);
let
sig
=
ty_fn_sig
(
ccx
,
fn_ty
);
...
...
@@ -655,7 +655,7 @@ pub fn of_instance(ccx: &CrateContext<'a, 'tcx>, instance: &ty::Instance<'tcx>)
FnType
::
new
(
ccx
,
sig
,
&
[])
}
pub
fn
new
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
new
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
sig
:
ty
::
FnSig
<
'tcx
>
,
extra_args
:
&
[
Ty
<
'tcx
>
])
->
FnType
<
'tcx
>
{
let
mut
fn_ty
=
FnType
::
unadjusted
(
ccx
,
sig
,
extra_args
);
...
...
@@ -663,7 +663,7 @@ pub fn new(ccx: &CrateContext<'a, 'tcx>,
fn_ty
}
pub
fn
new_vtable
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
new_vtable
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
sig
:
ty
::
FnSig
<
'tcx
>
,
extra_args
:
&
[
Ty
<
'tcx
>
])
->
FnType
<
'tcx
>
{
let
mut
fn_ty
=
FnType
::
unadjusted
(
ccx
,
sig
,
extra_args
);
...
...
@@ -688,7 +688,7 @@ pub fn new_vtable(ccx: &CrateContext<'a, 'tcx>,
fn_ty
}
pub
fn
unadjusted
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
unadjusted
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
sig
:
ty
::
FnSig
<
'tcx
>
,
extra_args
:
&
[
Ty
<
'tcx
>
])
->
FnType
<
'tcx
>
{
debug!
(
"FnType::unadjusted({:?}, {:?})"
,
sig
,
extra_args
);
...
...
@@ -863,7 +863,7 @@ pub fn unadjusted(ccx: &CrateContext<'a, 'tcx>,
}
fn
adjust_for_abi
(
&
mut
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
abi
:
Abi
)
{
if
abi
==
Abi
::
Unadjusted
{
return
}
...
...
@@ -939,7 +939,7 @@ fn adjust_for_abi(&mut self,
}
}
pub
fn
llvm_type
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
Type
{
pub
fn
llvm_type
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Type
{
let
mut
llargument_tys
=
Vec
::
new
();
let
llreturn_ty
=
match
self
.ret.mode
{
...
...
src/librustc_trans/asm.rs
浏览文件 @
fb7de6a0
...
...
@@ -119,7 +119,7 @@ pub fn trans_inline_asm<'a, 'tcx>(
}
}
pub
fn
trans_global_asm
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
trans_global_asm
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ga
:
&
hir
::
GlobalAsm
)
{
let
asm
=
CString
::
new
(
ga
.asm
.as_str
()
.as_bytes
())
.unwrap
();
unsafe
{
...
...
src/librustc_trans/attributes.rs
浏览文件 @
fb7de6a0
...
...
@@ -24,7 +24,7 @@
use
llvm_util
;
pub
use
syntax
::
attr
::{
self
,
InlineAttr
};
use
syntax
::
ast
;
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
/// Mark LLVM function to use provided inline heuristic.
#[inline]
...
...
@@ -67,7 +67,7 @@ pub fn naked(val: ValueRef, is_naked: bool) {
Attribute
::
Naked
.toggle_llfn
(
Function
,
val
,
is_naked
);
}
pub
fn
set_frame_pointer_elimination
(
ccx
:
&
C
rateContext
,
llfn
:
ValueRef
)
{
pub
fn
set_frame_pointer_elimination
(
ccx
:
&
C
odegenCx
,
llfn
:
ValueRef
)
{
// FIXME: #11906: Omitting frame pointers breaks retrieving the value of a
// parameter.
if
ccx
.sess
()
.must_not_eliminate_frame_pointers
()
{
...
...
@@ -77,7 +77,7 @@ pub fn set_frame_pointer_elimination(ccx: &CrateContext, llfn: ValueRef) {
}
}
pub
fn
set_probestack
(
ccx
:
&
C
rateContext
,
llfn
:
ValueRef
)
{
pub
fn
set_probestack
(
ccx
:
&
C
odegenCx
,
llfn
:
ValueRef
)
{
// Only use stack probes if the target specification indicates that we
// should be using stack probes
if
!
ccx
.sess
()
.target.target.options.stack_probes
{
...
...
@@ -101,7 +101,7 @@ pub fn set_probestack(ccx: &CrateContext, llfn: ValueRef) {
/// Composite function which sets LLVM attributes for function depending on its AST (#[attribute])
/// attributes.
pub
fn
from_fn_attrs
(
ccx
:
&
C
rateContext
,
llfn
:
ValueRef
,
id
:
DefId
)
{
pub
fn
from_fn_attrs
(
ccx
:
&
C
odegenCx
,
llfn
:
ValueRef
,
id
:
DefId
)
{
use
syntax
::
attr
::
*
;
let
attrs
=
ccx
.tcx
.get_attrs
(
id
);
inline
(
llfn
,
find_inline_attr
(
Some
(
ccx
.sess
()
.diagnostic
()),
&
attrs
));
...
...
src/librustc_trans/base.rs
浏览文件 @
fb7de6a0
...
...
@@ -59,7 +59,7 @@
use
rustc_mir
::
monomorphize
::
collector
::{
self
,
MonoItemCollectionMode
};
use
common
::{
self
,
C_struct_in_context
,
C_array
,
val_ty
};
use
consts
;
use
context
::{
self
,
C
rateContext
};
use
context
::{
self
,
C
odegenCx
};
use
debuginfo
;
use
declare
;
use
meth
;
...
...
@@ -94,13 +94,13 @@
pub
use
rustc_mir
::
monomorphize
::
item
::
linkage_by_name
;
pub
struct
StatRecorder
<
'a
,
'tcx
:
'a
>
{
ccx
:
&
'a
C
rateContext
<
'a
,
'tcx
>
,
ccx
:
&
'a
C
odegenCx
<
'a
,
'tcx
>
,
name
:
Option
<
String
>
,
istart
:
usize
,
}
impl
<
'a
,
'tcx
>
StatRecorder
<
'a
,
'tcx
>
{
pub
fn
new
(
ccx
:
&
'a
C
rateContext
<
'a
,
'tcx
>
,
name
:
String
)
->
StatRecorder
<
'a
,
'tcx
>
{
pub
fn
new
(
ccx
:
&
'a
C
odegenCx
<
'a
,
'tcx
>
,
name
:
String
)
->
StatRecorder
<
'a
,
'tcx
>
{
let
istart
=
ccx
.stats
.borrow
()
.n_llvm_insns
;
StatRecorder
{
ccx
,
...
...
@@ -189,7 +189,7 @@ pub fn compare_simd_types<'a, 'tcx>(
/// The `old_info` argument is a bit funny. It is intended for use
/// in an upcast, where the new vtable for an object will be derived
/// from the old one.
pub
fn
unsized_info
<
'ccx
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'ccx
,
'tcx
>
,
pub
fn
unsized_info
<
'ccx
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'ccx
,
'tcx
>
,
source
:
Ty
<
'tcx
>
,
target
:
Ty
<
'tcx
>
,
old_info
:
Option
<
ValueRef
>
)
...
...
@@ -455,7 +455,7 @@ pub fn call_memset<'a, 'tcx>(b: &Builder<'a, 'tcx>,
b
.call
(
llintrinsicfn
,
&
[
ptr
,
fill_byte
,
size
,
align
,
volatile
],
None
)
}
pub
fn
trans_instance
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
instance
:
Instance
<
'tcx
>
)
{
pub
fn
trans_instance
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
instance
:
Instance
<
'tcx
>
)
{
let
_
s
=
if
ccx
.sess
()
.trans_stats
()
{
let
mut
instance_name
=
String
::
new
();
DefPathBasedNames
::
new
(
ccx
.tcx
,
true
,
true
)
...
...
@@ -506,7 +506,7 @@ pub fn trans_instance<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, instance: Instance
mir
::
trans_mir
(
ccx
,
lldecl
,
&
mir
,
instance
,
sig
);
}
pub
fn
set_link_section
(
ccx
:
&
C
rateContext
,
pub
fn
set_link_section
(
ccx
:
&
C
odegenCx
,
llval
:
ValueRef
,
attrs
:
&
[
ast
::
Attribute
])
{
if
let
Some
(
sect
)
=
attr
::
first_attr_value_str_by_name
(
attrs
,
"link_section"
)
{
...
...
@@ -522,7 +522,7 @@ pub fn set_link_section(ccx: &CrateContext,
/// Create the `main` function which will initialize the rust runtime and call
/// users main function.
fn
maybe_create_entry_wrapper
(
ccx
:
&
C
rateContext
)
{
fn
maybe_create_entry_wrapper
(
ccx
:
&
C
odegenCx
)
{
let
(
main_def_id
,
span
)
=
match
*
ccx
.sess
()
.entry_fn
.borrow
()
{
Some
((
id
,
span
))
=>
{
(
ccx
.tcx.hir
.local_def_id
(
id
),
span
)
...
...
@@ -547,7 +547,7 @@ fn maybe_create_entry_wrapper(ccx: &CrateContext) {
config
::
EntryNone
=>
{}
// Do nothing.
}
fn
create_entry_fn
<
'ccx
>
(
ccx
:
&
'ccx
C
rateContext
,
fn
create_entry_fn
<
'ccx
>
(
ccx
:
&
'ccx
C
odegenCx
,
sp
:
Span
,
rust_main
:
ValueRef
,
rust_main_def_id
:
DefId
,
...
...
@@ -1203,7 +1203,7 @@ fn module_translation<'a, 'tcx>(
.to_fingerprint
()
.to_hex
());
// Instantiate translation items without filling out definitions yet...
let
ccx
=
C
rateContext
::
new
(
tcx
,
cgu
,
&
llmod_id
);
let
ccx
=
C
odegenCx
::
new
(
tcx
,
cgu
,
&
llmod_id
);
let
module
=
{
let
trans_items
=
ccx
.codegen_unit
.items_in_deterministic_order
(
ccx
.tcx
);
...
...
src/librustc_trans/builder.rs
浏览文件 @
fb7de6a0
...
...
@@ -32,7 +32,7 @@
#[must_use]
pub
struct
Builder
<
'a
,
'tcx
:
'a
>
{
pub
llbuilder
:
BuilderRef
,
pub
ccx
:
&
'a
C
rateContext
<
'a
,
'tcx
>
,
pub
ccx
:
&
'a
C
odegenCx
<
'a
,
'tcx
>
,
}
impl
<
'a
,
'tcx
>
Drop
for
Builder
<
'a
,
'tcx
>
{
...
...
@@ -51,7 +51,7 @@ fn noname() -> *const c_char {
}
impl
<
'a
,
'tcx
>
Builder
<
'a
,
'tcx
>
{
pub
fn
new_block
<
'b
>
(
ccx
:
&
'a
C
rateContext
<
'a
,
'tcx
>
,
llfn
:
ValueRef
,
name
:
&
'b
str
)
->
Self
{
pub
fn
new_block
<
'b
>
(
ccx
:
&
'a
C
odegenCx
<
'a
,
'tcx
>
,
llfn
:
ValueRef
,
name
:
&
'b
str
)
->
Self
{
let
builder
=
Builder
::
with_ccx
(
ccx
);
let
llbb
=
unsafe
{
let
name
=
CString
::
new
(
name
)
.unwrap
();
...
...
@@ -65,7 +65,7 @@ pub fn new_block<'b>(ccx: &'a CrateContext<'a, 'tcx>, llfn: ValueRef, name: &'b
builder
}
pub
fn
with_ccx
(
ccx
:
&
'a
C
rateContext
<
'a
,
'tcx
>
)
->
Self
{
pub
fn
with_ccx
(
ccx
:
&
'a
C
odegenCx
<
'a
,
'tcx
>
)
->
Self
{
// Create a fresh builder from the crate context.
let
llbuilder
=
unsafe
{
llvm
::
LLVMCreateBuilderInContext
(
ccx
.llcx
)
...
...
src/librustc_trans/cabi_aarch64.rs
浏览文件 @
fb7de6a0
...
...
@@ -9,9 +9,9 @@
// except according to those terms.
use
abi
::{
FnType
,
ArgType
,
LayoutExt
,
Reg
,
RegKind
,
Uniform
};
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
fn
is_homogeneous_aggregate
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
)
fn
is_homogeneous_aggregate
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
)
->
Option
<
Uniform
>
{
arg
.layout
.homogeneous_aggregate
(
ccx
)
.and_then
(|
unit
|
{
let
size
=
arg
.layout.size
;
...
...
@@ -38,7 +38,7 @@ fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut Ar
})
}
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
)
{
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
)
{
if
!
ret
.layout
.is_aggregate
()
{
ret
.extend_integer_width_to
(
32
);
return
;
...
...
@@ -69,7 +69,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tc
ret
.make_indirect
();
}
fn
classify_arg_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
)
{
fn
classify_arg_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
)
{
if
!
arg
.layout
.is_aggregate
()
{
arg
.extend_integer_width_to
(
32
);
return
;
...
...
@@ -100,7 +100,7 @@ fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tc
arg
.make_indirect
();
}
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
if
!
fty
.ret
.is_ignore
()
{
classify_ret_ty
(
ccx
,
&
mut
fty
.ret
);
}
...
...
src/librustc_trans/cabi_arm.rs
浏览文件 @
fb7de6a0
...
...
@@ -9,10 +9,10 @@
// except according to those terms.
use
abi
::{
FnType
,
ArgType
,
LayoutExt
,
Reg
,
RegKind
,
Uniform
};
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
use
llvm
::
CallConv
;
fn
is_homogeneous_aggregate
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
)
fn
is_homogeneous_aggregate
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
)
->
Option
<
Uniform
>
{
arg
.layout
.homogeneous_aggregate
(
ccx
)
.and_then
(|
unit
|
{
let
size
=
arg
.layout.size
;
...
...
@@ -39,7 +39,7 @@ fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut Ar
})
}
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
,
vfp
:
bool
)
{
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
,
vfp
:
bool
)
{
if
!
ret
.layout
.is_aggregate
()
{
ret
.extend_integer_width_to
(
32
);
return
;
...
...
@@ -71,7 +71,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tc
ret
.make_indirect
();
}
fn
classify_arg_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
,
vfp
:
bool
)
{
fn
classify_arg_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
,
vfp
:
bool
)
{
if
!
arg
.layout
.is_aggregate
()
{
arg
.extend_integer_width_to
(
32
);
return
;
...
...
@@ -92,7 +92,7 @@ fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tc
});
}
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
// If this is a target with a hard-float ABI, and the function is not explicitly
// `extern "aapcs"`, then we must use the VFP registers for homogeneous aggregates.
let
vfp
=
ccx
.sess
()
.target.target.llvm_target
.ends_with
(
"hf"
)
...
...
src/librustc_trans/cabi_asmjs.rs
浏览文件 @
fb7de6a0
...
...
@@ -9,14 +9,14 @@
// except according to those terms.
use
abi
::{
FnType
,
ArgType
,
LayoutExt
,
Uniform
};
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
// Data layout: e-p:32:32-i64:64-v128:32:128-n32-S128
// 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
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
)
{
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
)
{
if
ret
.layout
.is_aggregate
()
{
if
let
Some
(
unit
)
=
ret
.layout
.homogeneous_aggregate
(
ccx
)
{
let
size
=
ret
.layout.size
;
...
...
@@ -39,7 +39,7 @@ fn classify_arg_ty(arg: &mut ArgType) {
}
}
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
if
!
fty
.ret
.is_ignore
()
{
classify_ret_ty
(
ccx
,
&
mut
fty
.ret
);
}
...
...
src/librustc_trans/cabi_mips.rs
浏览文件 @
fb7de6a0
...
...
@@ -9,11 +9,11 @@
// except according to those terms.
use
abi
::{
ArgType
,
FnType
,
LayoutExt
,
Reg
,
Uniform
};
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
use
rustc
::
ty
::
layout
::
Size
;
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
,
offset
:
&
mut
Size
)
{
if
!
ret
.layout
.is_aggregate
()
{
...
...
@@ -24,7 +24,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
fn
classify_arg_ty
(
ccx
:
&
C
rateContext
,
arg
:
&
mut
ArgType
,
offset
:
&
mut
Size
)
{
fn
classify_arg_ty
(
ccx
:
&
C
odegenCx
,
arg
:
&
mut
ArgType
,
offset
:
&
mut
Size
)
{
let
dl
=
&
ccx
.tcx.data_layout
;
let
size
=
arg
.layout.size
;
let
align
=
arg
.layout.align
.max
(
dl
.i32_align
)
.min
(
dl
.i64_align
);
...
...
@@ -44,7 +44,7 @@ fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, offset: &mut Size) {
*
offset
=
offset
.abi_align
(
align
)
+
size
.abi_align
(
align
);
}
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
let
mut
offset
=
Size
::
from_bytes
(
0
);
if
!
fty
.ret
.is_ignore
()
{
classify_ret_ty
(
ccx
,
&
mut
fty
.ret
,
&
mut
offset
);
...
...
src/librustc_trans/cabi_mips64.rs
浏览文件 @
fb7de6a0
...
...
@@ -9,11 +9,11 @@
// except according to those terms.
use
abi
::{
ArgType
,
FnType
,
LayoutExt
,
Reg
,
Uniform
};
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
use
rustc
::
ty
::
layout
::
Size
;
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
,
offset
:
&
mut
Size
)
{
if
!
ret
.layout
.is_aggregate
()
{
...
...
@@ -24,7 +24,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
fn
classify_arg_ty
(
ccx
:
&
C
rateContext
,
arg
:
&
mut
ArgType
,
offset
:
&
mut
Size
)
{
fn
classify_arg_ty
(
ccx
:
&
C
odegenCx
,
arg
:
&
mut
ArgType
,
offset
:
&
mut
Size
)
{
let
dl
=
&
ccx
.tcx.data_layout
;
let
size
=
arg
.layout.size
;
let
align
=
arg
.layout.align
.max
(
dl
.i32_align
)
.min
(
dl
.i64_align
);
...
...
@@ -44,7 +44,7 @@ fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, offset: &mut Size) {
*
offset
=
offset
.abi_align
(
align
)
+
size
.abi_align
(
align
);
}
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
let
mut
offset
=
Size
::
from_bytes
(
0
);
if
!
fty
.ret
.is_ignore
()
{
classify_ret_ty
(
ccx
,
&
mut
fty
.ret
,
&
mut
offset
);
...
...
src/librustc_trans/cabi_powerpc.rs
浏览文件 @
fb7de6a0
...
...
@@ -9,11 +9,11 @@
// except according to those terms.
use
abi
::{
ArgType
,
FnType
,
LayoutExt
,
Reg
,
Uniform
};
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
use
rustc
::
ty
::
layout
::
Size
;
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
,
offset
:
&
mut
Size
)
{
if
!
ret
.layout
.is_aggregate
()
{
...
...
@@ -24,7 +24,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
fn
classify_arg_ty
(
ccx
:
&
C
rateContext
,
arg
:
&
mut
ArgType
,
offset
:
&
mut
Size
)
{
fn
classify_arg_ty
(
ccx
:
&
C
odegenCx
,
arg
:
&
mut
ArgType
,
offset
:
&
mut
Size
)
{
let
dl
=
&
ccx
.tcx.data_layout
;
let
size
=
arg
.layout.size
;
let
align
=
arg
.layout.align
.max
(
dl
.i32_align
)
.min
(
dl
.i64_align
);
...
...
@@ -44,7 +44,7 @@ fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, offset: &mut Size) {
*
offset
=
offset
.abi_align
(
align
)
+
size
.abi_align
(
align
);
}
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
let
mut
offset
=
Size
::
from_bytes
(
0
);
if
!
fty
.ret
.is_ignore
()
{
classify_ret_ty
(
ccx
,
&
mut
fty
.ret
,
&
mut
offset
);
...
...
src/librustc_trans/cabi_powerpc64.rs
浏览文件 @
fb7de6a0
...
...
@@ -13,7 +13,7 @@
// need to be fixed when PowerPC vector support is added.
use
abi
::{
FnType
,
ArgType
,
LayoutExt
,
Reg
,
RegKind
,
Uniform
};
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
use
rustc
::
ty
::
layout
;
#[derive(Debug,
Clone,
Copy,
PartialEq)]
...
...
@@ -23,7 +23,7 @@ enum ABI {
}
use
self
::
ABI
::
*
;
fn
is_homogeneous_aggregate
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
is_homogeneous_aggregate
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
,
abi
:
ABI
)
->
Option
<
Uniform
>
{
...
...
@@ -52,7 +52,7 @@ fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
})
}
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
,
abi
:
ABI
)
{
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
,
abi
:
ABI
)
{
if
!
ret
.layout
.is_aggregate
()
{
ret
.extend_integer_width_to
(
64
);
return
;
...
...
@@ -92,7 +92,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tc
ret
.make_indirect
();
}
fn
classify_arg_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
,
abi
:
ABI
)
{
fn
classify_arg_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
,
abi
:
ABI
)
{
if
!
arg
.layout
.is_aggregate
()
{
arg
.extend_integer_width_to
(
64
);
return
;
...
...
@@ -128,7 +128,7 @@ fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tc
});
}
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
let
abi
=
match
ccx
.sess
()
.target.target.target_endian
.as_str
()
{
"big"
=>
ELFv1
,
"little"
=>
ELFv2
,
...
...
src/librustc_trans/cabi_s390x.rs
浏览文件 @
fb7de6a0
...
...
@@ -12,7 +12,7 @@
// for a pre-z13 machine or using -mno-vx.
use
abi
::{
FnType
,
ArgType
,
LayoutExt
,
Reg
};
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
use
rustc
::
ty
::
layout
::{
self
,
TyLayout
};
...
...
@@ -24,7 +24,7 @@ fn classify_ret_ty(ret: &mut ArgType) {
}
}
fn
is_single_fp_element
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
is_single_fp_element
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
layout
:
TyLayout
<
'tcx
>
)
->
bool
{
match
layout
.abi
{
layout
::
Abi
::
Scalar
(
ref
scalar
)
=>
{
...
...
@@ -44,7 +44,7 @@ fn is_single_fp_element<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
fn
classify_arg_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
)
{
fn
classify_arg_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
)
{
if
!
arg
.layout
.is_aggregate
()
&&
arg
.layout.size
.bits
()
<=
64
{
arg
.extend_integer_width_to
(
64
);
return
;
...
...
@@ -67,7 +67,7 @@ fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tc
}
}
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
if
!
fty
.ret
.is_ignore
()
{
classify_ret_ty
(
&
mut
fty
.ret
);
}
...
...
src/librustc_trans/cabi_sparc.rs
浏览文件 @
fb7de6a0
...
...
@@ -9,11 +9,11 @@
// except according to those terms.
use
abi
::{
ArgType
,
FnType
,
LayoutExt
,
Reg
,
Uniform
};
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
use
rustc
::
ty
::
layout
::
Size
;
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
,
offset
:
&
mut
Size
)
{
if
!
ret
.layout
.is_aggregate
()
{
...
...
@@ -24,7 +24,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
fn
classify_arg_ty
(
ccx
:
&
C
rateContext
,
arg
:
&
mut
ArgType
,
offset
:
&
mut
Size
)
{
fn
classify_arg_ty
(
ccx
:
&
C
odegenCx
,
arg
:
&
mut
ArgType
,
offset
:
&
mut
Size
)
{
let
dl
=
&
ccx
.tcx.data_layout
;
let
size
=
arg
.layout.size
;
let
align
=
arg
.layout.align
.max
(
dl
.i32_align
)
.min
(
dl
.i64_align
);
...
...
@@ -44,7 +44,7 @@ fn classify_arg_ty(ccx: &CrateContext, arg: &mut ArgType, offset: &mut Size) {
*
offset
=
offset
.abi_align
(
align
)
+
size
.abi_align
(
align
);
}
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
let
mut
offset
=
Size
::
from_bytes
(
0
);
if
!
fty
.ret
.is_ignore
()
{
classify_ret_ty
(
ccx
,
&
mut
fty
.ret
,
&
mut
offset
);
...
...
src/librustc_trans/cabi_sparc64.rs
浏览文件 @
fb7de6a0
...
...
@@ -11,9 +11,9 @@
// FIXME: This needs an audit for correctness and completeness.
use
abi
::{
FnType
,
ArgType
,
LayoutExt
,
Reg
,
RegKind
,
Uniform
};
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
fn
is_homogeneous_aggregate
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
)
fn
is_homogeneous_aggregate
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
)
->
Option
<
Uniform
>
{
arg
.layout
.homogeneous_aggregate
(
ccx
)
.and_then
(|
unit
|
{
// Ensure we have at most eight uniquely addressable members.
...
...
@@ -38,7 +38,7 @@ fn is_homogeneous_aggregate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut Ar
})
}
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
)
{
fn
classify_ret_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ret
:
&
mut
ArgType
<
'tcx
>
)
{
if
!
ret
.layout
.is_aggregate
()
{
ret
.extend_integer_width_to
(
64
);
return
;
...
...
@@ -72,7 +72,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tc
ret
.make_indirect
();
}
fn
classify_arg_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
)
{
fn
classify_arg_ty
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
arg
:
&
mut
ArgType
<
'tcx
>
)
{
if
!
arg
.layout
.is_aggregate
()
{
arg
.extend_integer_width_to
(
64
);
return
;
...
...
@@ -90,7 +90,7 @@ fn classify_arg_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &mut ArgType<'tc
});
}
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
if
!
fty
.ret
.is_ignore
()
{
classify_ret_ty
(
ccx
,
&
mut
fty
.ret
);
}
...
...
src/librustc_trans/cabi_x86.rs
浏览文件 @
fb7de6a0
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
use
abi
::{
ArgAttribute
,
FnType
,
LayoutExt
,
PassMode
,
Reg
,
RegKind
};
use
common
::
C
rateContext
;
use
common
::
C
odegenCx
;
use
rustc
::
ty
::
layout
::{
self
,
TyLayout
};
...
...
@@ -19,7 +19,7 @@ pub enum Flavor {
Fastcall
}
fn
is_single_fp_element
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
is_single_fp_element
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
layout
:
TyLayout
<
'tcx
>
)
->
bool
{
match
layout
.abi
{
layout
::
Abi
::
Scalar
(
ref
scalar
)
=>
{
...
...
@@ -39,7 +39,7 @@ fn is_single_fp_element<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
,
flavor
:
Flavor
)
{
if
!
fty
.ret
.is_ignore
()
{
...
...
src/librustc_trans/cabi_x86_64.rs
浏览文件 @
fb7de6a0
...
...
@@ -12,7 +12,7 @@
// https://github.com/jckarter/clay/blob/master/compiler/src/externals.cpp
use
abi
::{
ArgType
,
CastTarget
,
FnType
,
LayoutExt
,
Reg
,
RegKind
};
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
use
rustc
::
ty
::
layout
::{
self
,
TyLayout
,
Size
};
...
...
@@ -31,7 +31,7 @@ enum Class {
const
LARGEST_VECTOR_SIZE
:
usize
=
512
;
const
MAX_EIGHTBYTES
:
usize
=
LARGEST_VECTOR_SIZE
/
64
;
fn
classify_arg
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
arg
:
&
ArgType
<
'tcx
>
)
fn
classify_arg
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
arg
:
&
ArgType
<
'tcx
>
)
->
Result
<
[
Class
;
MAX_EIGHTBYTES
],
Memory
>
{
fn
unify
(
cls
:
&
mut
[
Class
],
off
:
Size
,
...
...
@@ -52,7 +52,7 @@ fn unify(cls: &mut [Class],
cls
[
i
]
=
to_write
;
}
fn
classify
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
classify
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
layout
:
TyLayout
<
'tcx
>
,
cls
:
&
mut
[
Class
],
off
:
Size
)
...
...
@@ -189,7 +189,7 @@ fn cast_target(cls: &[Class], size: Size) -> CastTarget {
target
}
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
pub
fn
compute_abi_info
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
fty
:
&
mut
FnType
<
'tcx
>
)
{
let
mut
int_regs
=
6
;
// RDI, RSI, RDX, RCX, R8, R9
let
mut
sse_regs
=
8
;
// XMM0-7
...
...
src/librustc_trans/callee.rs
浏览文件 @
fb7de6a0
...
...
@@ -15,7 +15,7 @@
//! closure.
use
attributes
;
use
common
::{
self
,
C
rateContext
};
use
common
::{
self
,
C
odegenCx
};
use
consts
;
use
declare
;
use
llvm
::{
self
,
ValueRef
};
...
...
@@ -36,7 +36,7 @@
///
/// - `ccx`: the crate context
/// - `instance`: the instance to be instantiated
pub
fn
get_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
get_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
instance
:
Instance
<
'tcx
>
)
->
ValueRef
{
...
...
@@ -176,7 +176,7 @@ pub fn get_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
llfn
}
pub
fn
resolve_and_get_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
resolve_and_get_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
def_id
:
DefId
,
substs
:
&
'tcx
Substs
<
'tcx
>
)
->
ValueRef
...
...
src/librustc_trans/common.rs
浏览文件 @
fb7de6a0
...
...
@@ -38,7 +38,7 @@
use
syntax
::
symbol
::
InternedString
;
use
syntax_pos
::{
Span
,
DUMMY_SP
};
pub
use
context
::
C
rateContext
;
pub
use
context
::
C
odegenCx
;
pub
fn
type_needs_drop
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
ty
.needs_drop
(
tcx
,
ty
::
ParamEnv
::
empty
(
traits
::
Reveal
::
All
))
...
...
@@ -152,23 +152,23 @@ pub fn C_uint_big(t: Type, u: u128) -> ValueRef {
}
}
pub
fn
C_bool
(
ccx
:
&
C
rateContext
,
val
:
bool
)
->
ValueRef
{
pub
fn
C_bool
(
ccx
:
&
C
odegenCx
,
val
:
bool
)
->
ValueRef
{
C_uint
(
Type
::
i1
(
ccx
),
val
as
u64
)
}
pub
fn
C_i32
(
ccx
:
&
C
rateContext
,
i
:
i32
)
->
ValueRef
{
pub
fn
C_i32
(
ccx
:
&
C
odegenCx
,
i
:
i32
)
->
ValueRef
{
C_int
(
Type
::
i32
(
ccx
),
i
as
i64
)
}
pub
fn
C_u32
(
ccx
:
&
C
rateContext
,
i
:
u32
)
->
ValueRef
{
pub
fn
C_u32
(
ccx
:
&
C
odegenCx
,
i
:
u32
)
->
ValueRef
{
C_uint
(
Type
::
i32
(
ccx
),
i
as
u64
)
}
pub
fn
C_u64
(
ccx
:
&
C
rateContext
,
i
:
u64
)
->
ValueRef
{
pub
fn
C_u64
(
ccx
:
&
C
odegenCx
,
i
:
u64
)
->
ValueRef
{
C_uint
(
Type
::
i64
(
ccx
),
i
)
}
pub
fn
C_usize
(
ccx
:
&
C
rateContext
,
i
:
u64
)
->
ValueRef
{
pub
fn
C_usize
(
ccx
:
&
C
odegenCx
,
i
:
u64
)
->
ValueRef
{
let
bit_size
=
ccx
.data_layout
()
.pointer_size
.bits
();
if
bit_size
<
64
{
// make sure it doesn't overflow
...
...
@@ -178,14 +178,14 @@ pub fn C_usize(ccx: &CrateContext, i: u64) -> ValueRef {
C_uint
(
ccx
.isize_ty
,
i
)
}
pub
fn
C_u8
(
ccx
:
&
C
rateContext
,
i
:
u8
)
->
ValueRef
{
pub
fn
C_u8
(
ccx
:
&
C
odegenCx
,
i
:
u8
)
->
ValueRef
{
C_uint
(
Type
::
i8
(
ccx
),
i
as
u64
)
}
// This is a 'c-like' raw string, which differs from
// our boxed-and-length-annotated strings.
pub
fn
C_cstr
(
cx
:
&
C
rateContext
,
s
:
InternedString
,
null_terminated
:
bool
)
->
ValueRef
{
pub
fn
C_cstr
(
cx
:
&
C
odegenCx
,
s
:
InternedString
,
null_terminated
:
bool
)
->
ValueRef
{
unsafe
{
if
let
Some
(
&
llval
)
=
cx
.const_cstr_cache
.borrow
()
.get
(
&
s
)
{
return
llval
;
...
...
@@ -210,20 +210,20 @@ pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> Va
// NB: Do not use `do_spill_noroot` to make this into a constant string, or
// you will be kicked off fast isel. See issue #4352 for an example of this.
pub
fn
C_str_slice
(
cx
:
&
C
rateContext
,
s
:
InternedString
)
->
ValueRef
{
pub
fn
C_str_slice
(
cx
:
&
C
odegenCx
,
s
:
InternedString
)
->
ValueRef
{
let
len
=
s
.len
();
let
cs
=
consts
::
ptrcast
(
C_cstr
(
cx
,
s
,
false
),
cx
.layout_of
(
cx
.tcx
.mk_str
())
.llvm_type
(
cx
)
.ptr_to
());
C_fat_ptr
(
cx
,
cs
,
C_usize
(
cx
,
len
as
u64
))
}
pub
fn
C_fat_ptr
(
cx
:
&
C
rateContext
,
ptr
:
ValueRef
,
meta
:
ValueRef
)
->
ValueRef
{
pub
fn
C_fat_ptr
(
cx
:
&
C
odegenCx
,
ptr
:
ValueRef
,
meta
:
ValueRef
)
->
ValueRef
{
assert_eq!
(
abi
::
FAT_PTR_ADDR
,
0
);
assert_eq!
(
abi
::
FAT_PTR_EXTRA
,
1
);
C_struct
(
cx
,
&
[
ptr
,
meta
],
false
)
}
pub
fn
C_struct
(
cx
:
&
C
rateContext
,
elts
:
&
[
ValueRef
],
packed
:
bool
)
->
ValueRef
{
pub
fn
C_struct
(
cx
:
&
C
odegenCx
,
elts
:
&
[
ValueRef
],
packed
:
bool
)
->
ValueRef
{
C_struct_in_context
(
cx
.llcx
,
elts
,
packed
)
}
...
...
@@ -247,7 +247,7 @@ pub fn C_vector(elts: &[ValueRef]) -> ValueRef {
}
}
pub
fn
C_bytes
(
cx
:
&
C
rateContext
,
bytes
:
&
[
u8
])
->
ValueRef
{
pub
fn
C_bytes
(
cx
:
&
C
odegenCx
,
bytes
:
&
[
u8
])
->
ValueRef
{
C_bytes_in_context
(
cx
.llcx
,
bytes
)
}
...
...
@@ -382,7 +382,7 @@ pub fn shift_mask_val<'a, 'tcx>(
}
}
pub
fn
ty_fn_sig
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
ty_fn_sig
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ty
:
Ty
<
'tcx
>
)
->
ty
::
PolyFnSig
<
'tcx
>
{
...
...
src/librustc_trans/consts.rs
浏览文件 @
fb7de6a0
...
...
@@ -17,7 +17,7 @@
use
debuginfo
;
use
base
;
use
monomorphize
::{
MonoItem
,
MonoItemExt
};
use
common
::{
C
rateContext
,
val_ty
};
use
common
::{
C
odegenCx
,
val_ty
};
use
declare
;
use
monomorphize
::
Instance
;
use
type_
::
Type
;
...
...
@@ -43,7 +43,7 @@ pub fn bitcast(val: ValueRef, ty: Type) -> ValueRef {
}
}
fn
set_global_alignment
(
ccx
:
&
C
rateContext
,
fn
set_global_alignment
(
ccx
:
&
C
odegenCx
,
gv
:
ValueRef
,
mut
align
:
Align
)
{
// The target may require greater alignment for globals than the type does.
...
...
@@ -62,7 +62,7 @@ fn set_global_alignment(ccx: &CrateContext,
}
}
pub
fn
addr_of_mut
(
ccx
:
&
C
rateContext
,
pub
fn
addr_of_mut
(
ccx
:
&
C
odegenCx
,
cv
:
ValueRef
,
align
:
Align
,
kind
:
&
str
)
...
...
@@ -80,7 +80,7 @@ pub fn addr_of_mut(ccx: &CrateContext,
}
}
pub
fn
addr_of
(
ccx
:
&
C
rateContext
,
pub
fn
addr_of
(
ccx
:
&
C
odegenCx
,
cv
:
ValueRef
,
align
:
Align
,
kind
:
&
str
)
...
...
@@ -104,7 +104,7 @@ pub fn addr_of(ccx: &CrateContext,
gv
}
pub
fn
get_static
(
ccx
:
&
C
rateContext
,
def_id
:
DefId
)
->
ValueRef
{
pub
fn
get_static
(
ccx
:
&
C
odegenCx
,
def_id
:
DefId
)
->
ValueRef
{
let
instance
=
Instance
::
mono
(
ccx
.tcx
,
def_id
);
if
let
Some
(
&
g
)
=
ccx
.instances
.borrow
()
.get
(
&
instance
)
{
return
g
;
...
...
@@ -244,7 +244,7 @@ pub fn get_static(ccx: &CrateContext, def_id: DefId) -> ValueRef {
g
}
pub
fn
trans_static
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
trans_static
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
m
:
hir
::
Mutability
,
id
:
ast
::
NodeId
,
attrs
:
&
[
ast
::
Attribute
])
...
...
src/librustc_trans/context.rs
浏览文件 @
fb7de6a0
...
...
@@ -42,10 +42,10 @@
use
syntax
::
symbol
::
InternedString
;
use
abi
::
Abi
;
/// There is one `C
rateContext
` per compilation unit. Each one has its own LLVM
/// There is one `C
odegenCx
` per compilation unit. Each one has its own LLVM
/// `ContextRef` so that several compilation units may be optimized in parallel.
/// All other LLVM data structures in the `C
rateContext
` are tied to that `ContextRef`.
pub
struct
C
rateContext
<
'a
,
'tcx
:
'a
>
{
/// All other LLVM data structures in the `C
odegenCx
` are tied to that `ContextRef`.
pub
struct
C
odegenCx
<
'a
,
'tcx
:
'a
>
{
pub
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
pub
check_overflow
:
bool
,
pub
use_dll_storage_attrs
:
bool
,
...
...
@@ -107,7 +107,7 @@ pub struct CrateContext<'a, 'tcx: 'a> {
local_gen_sym_counter
:
Cell
<
usize
>
,
}
impl
<
'a
,
'tcx
>
DepGraphSafe
for
C
rateContext
<
'a
,
'tcx
>
{
impl
<
'a
,
'tcx
>
DepGraphSafe
for
C
odegenCx
<
'a
,
'tcx
>
{
}
pub
fn
get_reloc_model
(
sess
:
&
Session
)
->
llvm
::
RelocMode
{
...
...
@@ -212,11 +212,11 @@ pub unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (Cont
(
llcx
,
llmod
)
}
impl
<
'a
,
'tcx
>
C
rateContext
<
'a
,
'tcx
>
{
impl
<
'a
,
'tcx
>
C
odegenCx
<
'a
,
'tcx
>
{
pub
fn
new
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
codegen_unit
:
Arc
<
CodegenUnit
<
'tcx
>>
,
llmod_id
:
&
str
)
->
C
rateContext
<
'a
,
'tcx
>
{
->
C
odegenCx
<
'a
,
'tcx
>
{
// An interesting part of Windows which MSVC forces our hand on (and
// apparently MinGW didn't) is the usage of `dllimport` and `dllexport`
// attributes in LLVM IR as well as native dependencies (in C these
...
...
@@ -280,7 +280,7 @@ pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
None
};
let
mut
ccx
=
C
rateContext
{
let
mut
ccx
=
C
odegenCx
{
tcx
,
check_overflow
,
use_dll_storage_attrs
,
...
...
@@ -318,7 +318,7 @@ pub fn into_stats(self) -> Stats {
}
}
impl
<
'b
,
'tcx
>
C
rateContext
<
'b
,
'tcx
>
{
impl
<
'b
,
'tcx
>
C
odegenCx
<
'b
,
'tcx
>
{
pub
fn
sess
<
'a
>
(
&
'a
self
)
->
&
'a
Session
{
&
self
.tcx.sess
}
...
...
@@ -448,19 +448,19 @@ pub fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool {
}
}
impl
<
'a
,
'tcx
>
ty
::
layout
::
HasDataLayout
for
&
'a
C
rateContext
<
'a
,
'tcx
>
{
impl
<
'a
,
'tcx
>
ty
::
layout
::
HasDataLayout
for
&
'a
C
odegenCx
<
'a
,
'tcx
>
{
fn
data_layout
(
&
self
)
->
&
ty
::
layout
::
TargetDataLayout
{
&
self
.tcx.data_layout
}
}
impl
<
'a
,
'tcx
>
ty
::
layout
::
HasTyCtxt
<
'tcx
>
for
&
'a
C
rateContext
<
'a
,
'tcx
>
{
impl
<
'a
,
'tcx
>
ty
::
layout
::
HasTyCtxt
<
'tcx
>
for
&
'a
C
odegenCx
<
'a
,
'tcx
>
{
fn
tcx
<
'b
>
(
&
'b
self
)
->
TyCtxt
<
'b
,
'tcx
,
'tcx
>
{
self
.tcx
}
}
impl
<
'a
,
'tcx
>
LayoutOf
<
Ty
<
'tcx
>>
for
&
'a
C
rateContext
<
'a
,
'tcx
>
{
impl
<
'a
,
'tcx
>
LayoutOf
<
Ty
<
'tcx
>>
for
&
'a
C
odegenCx
<
'a
,
'tcx
>
{
type
TyLayout
=
TyLayout
<
'tcx
>
;
fn
layout_of
(
self
,
ty
:
Ty
<
'tcx
>
)
->
Self
::
TyLayout
{
...
...
@@ -474,7 +474,7 @@ fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {
}
/// Declare any llvm intrinsics that you might need
fn
declare_intrinsic
(
ccx
:
&
C
rateContext
,
key
:
&
str
)
->
Option
<
ValueRef
>
{
fn
declare_intrinsic
(
ccx
:
&
C
odegenCx
,
key
:
&
str
)
->
Option
<
ValueRef
>
{
macro_rules!
ifn
{
(
$name:expr
,
fn
()
->
$ret:expr
)
=>
(
if
key
==
$name
{
...
...
src/librustc_trans/debuginfo/create_scope_map.rs
浏览文件 @
fb7de6a0
...
...
@@ -14,7 +14,7 @@
use
llvm
;
use
llvm
::
debuginfo
::
DIScope
;
use
common
::
C
rateContext
;
use
common
::
C
odegenCx
;
use
rustc
::
mir
::{
Mir
,
VisibilityScope
};
use
libc
::
c_uint
;
...
...
@@ -44,7 +44,7 @@ pub fn is_valid(&self) -> bool {
/// Produce DIScope DIEs for each MIR Scope which has variables defined in it.
/// If debuginfo is disabled, the returned vector is empty.
pub
fn
create_mir_scopes
(
ccx
:
&
C
rateContext
,
mir
:
&
Mir
,
debug_context
:
&
FunctionDebugContext
)
pub
fn
create_mir_scopes
(
ccx
:
&
C
odegenCx
,
mir
:
&
Mir
,
debug_context
:
&
FunctionDebugContext
)
->
IndexVec
<
VisibilityScope
,
MirDebugScope
>
{
let
null_scope
=
MirDebugScope
{
scope_metadata
:
ptr
::
null_mut
(),
...
...
@@ -77,7 +77,7 @@ pub fn create_mir_scopes(ccx: &CrateContext, mir: &Mir, debug_context: &Function
scopes
}
fn
make_mir_scope
(
ccx
:
&
C
rateContext
,
fn
make_mir_scope
(
ccx
:
&
C
odegenCx
,
mir
:
&
Mir
,
has_variables
:
&
BitVector
,
debug_context
:
&
FunctionDebugContextData
,
...
...
src/librustc_trans/debuginfo/doc.rs
浏览文件 @
fb7de6a0
...
...
@@ -44,7 +44,7 @@
//! that exact file path.
//!
//! All private state used by the module is stored within either the
//! CrateDebugContext struct (owned by the C
rateContext
) or the
//! CrateDebugContext struct (owned by the C
odegenCx
) or the
//! FunctionDebugContext (owned by the MirContext).
//!
//! This file consists of three conceptual sections:
...
...
src/librustc_trans/debuginfo/gdb.rs
浏览文件 @
fb7de6a0
...
...
@@ -12,7 +12,7 @@
use
llvm
;
use
common
::{
C_bytes
,
C
rateContext
,
C_i32
};
use
common
::{
C_bytes
,
C
odegenCx
,
C_i32
};
use
builder
::
Builder
;
use
declare
;
use
type_
::
Type
;
...
...
@@ -24,7 +24,7 @@
/// Inserts a side-effect free instruction sequence that makes sure that the
/// .debug_gdb_scripts global is referenced, so it isn't removed by the linker.
pub
fn
insert_reference_to_gdb_debug_scripts_section_global
(
ccx
:
&
C
rateContext
,
builder
:
&
Builder
)
{
pub
fn
insert_reference_to_gdb_debug_scripts_section_global
(
ccx
:
&
C
odegenCx
,
builder
:
&
Builder
)
{
if
needs_gdb_debug_scripts_section
(
ccx
)
{
let
gdb_debug_scripts_section_global
=
get_or_insert_gdb_debug_scripts_section_global
(
ccx
);
// Load just the first byte as that's all that's necessary to force
...
...
@@ -40,7 +40,7 @@ pub fn insert_reference_to_gdb_debug_scripts_section_global(ccx: &CrateContext,
/// Allocates the global variable responsible for the .debug_gdb_scripts binary
/// section.
pub
fn
get_or_insert_gdb_debug_scripts_section_global
(
ccx
:
&
C
rateContext
)
pub
fn
get_or_insert_gdb_debug_scripts_section_global
(
ccx
:
&
C
odegenCx
)
->
llvm
::
ValueRef
{
let
c_section_var_name
=
"__rustc_debug_gdb_scripts_section__
\0
"
;
let
section_var_name
=
&
c_section_var_name
[
..
c_section_var_name
.len
()
-
1
];
...
...
@@ -77,7 +77,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(ccx: &CrateContext)
}
}
pub
fn
needs_gdb_debug_scripts_section
(
ccx
:
&
C
rateContext
)
->
bool
{
pub
fn
needs_gdb_debug_scripts_section
(
ccx
:
&
C
odegenCx
)
->
bool
{
let
omit_gdb_pretty_printer_section
=
attr
::
contains_name
(
&
ccx
.tcx.hir
.krate_attrs
(),
"omit_gdb_pretty_printer_section"
);
...
...
src/librustc_trans/debuginfo/metadata.rs
浏览文件 @
fb7de6a0
...
...
@@ -29,7 +29,7 @@
use
rustc
::
ty
::
util
::
TypeIdHasher
;
use
rustc
::
ich
::
Fingerprint
;
use
rustc
::
ty
::
Instance
;
use
common
::
C
rateContext
;
use
common
::
C
odegenCx
;
use
rustc
::
ty
::{
self
,
AdtKind
,
Ty
,
TyCtxt
};
use
rustc
::
ty
::
layout
::{
self
,
Align
,
LayoutOf
,
Size
,
TyLayout
};
use
rustc
::
session
::
config
;
...
...
@@ -133,7 +133,7 @@ fn get_unique_type_id_as_string(&self, unique_type_id: UniqueTypeId) -> &str {
// Get the UniqueTypeId for the given type. If the UniqueTypeId for the given
// type has been requested before, this is just a table lookup. Otherwise an
// ID will be generated and stored for later lookup.
fn
get_unique_type_id_of_type
<
'a
>
(
&
mut
self
,
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
get_unique_type_id_of_type
<
'a
>
(
&
mut
self
,
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
type_
:
Ty
<
'tcx
>
)
->
UniqueTypeId
{
// Let's see if we already have something in the cache
match
self
.type_to_unique_id
.get
(
&
type_
)
.cloned
()
{
...
...
@@ -157,7 +157,7 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
// types of their own, so they need special handling. We still need a
// UniqueTypeId for them, since to debuginfo they *are* real types.
fn
get_unique_type_id_of_enum_variant
<
'a
>
(
&
mut
self
,
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
enum_type
:
Ty
<
'tcx
>
,
variant_name
:
&
str
)
->
UniqueTypeId
{
...
...
@@ -186,7 +186,7 @@ enum RecursiveTypeDescription<'tcx> {
}
fn
create_and_register_recursive_type_forward_declaration
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
unfinished_type
:
Ty
<
'tcx
>
,
unique_type_id
:
UniqueTypeId
,
metadata_stub
:
DICompositeType
,
...
...
@@ -210,7 +210,7 @@ impl<'tcx> RecursiveTypeDescription<'tcx> {
// Finishes up the description of the type in question (mostly by providing
// descriptions of the fields of the given type) and returns the final type
// metadata.
fn
finalize
<
'a
>
(
&
self
,
cx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
MetadataCreationResult
{
fn
finalize
<
'a
>
(
&
self
,
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
MetadataCreationResult
{
match
*
self
{
FinalMetadata
(
metadata
)
=>
MetadataCreationResult
::
new
(
metadata
,
false
),
UnfinishedMetadata
{
...
...
@@ -262,7 +262,7 @@ fn finalize<'a>(&self, cx: &CrateContext<'a, 'tcx>) -> MetadataCreationResult {
)
}
fn
fixed_vec_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
fixed_vec_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
unique_type_id
:
UniqueTypeId
,
array_or_slice_type
:
Ty
<
'tcx
>
,
element_type
:
Ty
<
'tcx
>
,
...
...
@@ -298,7 +298,7 @@ fn fixed_vec_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return
MetadataCreationResult
::
new
(
metadata
,
false
);
}
fn
vec_slice_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
vec_slice_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
slice_ptr_type
:
Ty
<
'tcx
>
,
element_type
:
Ty
<
'tcx
>
,
unique_type_id
:
UniqueTypeId
,
...
...
@@ -347,7 +347,7 @@ fn vec_slice_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
MetadataCreationResult
::
new
(
metadata
,
false
)
}
fn
subroutine_type_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
subroutine_type_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
unique_type_id
:
UniqueTypeId
,
signature
:
ty
::
PolyFnSig
<
'tcx
>
,
span
:
Span
)
...
...
@@ -386,7 +386,7 @@ fn subroutine_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// trait_type should be the actual trait (e.g., Trait). Where the trait is part
// of a DST struct, there is no trait_object_type and the results of this
// function will be a little bit weird.
fn
trait_pointer_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
trait_pointer_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
trait_type
:
Ty
<
'tcx
>
,
trait_object_type
:
Option
<
Ty
<
'tcx
>>
,
unique_type_id
:
UniqueTypeId
)
...
...
@@ -453,7 +453,7 @@ fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
syntax_pos
::
DUMMY_SP
)
}
pub
fn
type_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
type_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
t
:
Ty
<
'tcx
>
,
usage_site_span
:
Span
)
->
DIType
{
...
...
@@ -673,7 +673,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
metadata
}
pub
fn
file_metadata
(
cx
:
&
C
rateContext
,
pub
fn
file_metadata
(
cx
:
&
C
odegenCx
,
file_name
:
&
FileName
,
defining_crate
:
CrateNum
)
->
DIFile
{
debug!
(
"file_metadata: file_name: {}, defining_crate: {}"
,
...
...
@@ -691,11 +691,11 @@ pub fn file_metadata(cx: &CrateContext,
file_metadata_raw
(
cx
,
&
file_name
.to_string
(),
&
directory
.to_string_lossy
())
}
pub
fn
unknown_file_metadata
(
cx
:
&
C
rateContext
)
->
DIFile
{
pub
fn
unknown_file_metadata
(
cx
:
&
C
odegenCx
)
->
DIFile
{
file_metadata_raw
(
cx
,
"<unknown>"
,
""
)
}
fn
file_metadata_raw
(
cx
:
&
C
rateContext
,
fn
file_metadata_raw
(
cx
:
&
C
odegenCx
,
file_name
:
&
str
,
directory
:
&
str
)
->
DIFile
{
...
...
@@ -721,7 +721,7 @@ fn file_metadata_raw(cx: &CrateContext,
file_metadata
}
fn
basic_type_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
basic_type_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
t
:
Ty
<
'tcx
>
)
->
DIType
{
debug!
(
"basic_type_metadata: {:?}"
,
t
);
...
...
@@ -758,7 +758,7 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return
ty_metadata
;
}
fn
foreign_type_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
foreign_type_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
t
:
Ty
<
'tcx
>
,
unique_type_id
:
UniqueTypeId
)
->
DIType
{
debug!
(
"foreign_type_metadata: {:?}"
,
t
);
...
...
@@ -767,7 +767,7 @@ fn foreign_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
create_struct_stub
(
cx
,
t
,
&
name
,
unique_type_id
,
NO_SCOPE_METADATA
)
}
fn
pointer_type_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
pointer_type_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
pointer_type
:
Ty
<
'tcx
>
,
pointee_type_metadata
:
DIType
)
->
DIType
{
...
...
@@ -901,7 +901,7 @@ enum MemberDescriptionFactory<'tcx> {
}
impl
<
'tcx
>
MemberDescriptionFactory
<
'tcx
>
{
fn
create_member_descriptions
<
'a
>
(
&
self
,
cx
:
&
C
rateContext
<
'a
,
'tcx
>
)
fn
create_member_descriptions
<
'a
>
(
&
self
,
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Vec
<
MemberDescription
>
{
match
*
self
{
StructMDF
(
ref
this
)
=>
{
...
...
@@ -935,7 +935,7 @@ struct StructMemberDescriptionFactory<'tcx> {
}
impl
<
'tcx
>
StructMemberDescriptionFactory
<
'tcx
>
{
fn
create_member_descriptions
<
'a
>
(
&
self
,
cx
:
&
C
rateContext
<
'a
,
'tcx
>
)
fn
create_member_descriptions
<
'a
>
(
&
self
,
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Vec
<
MemberDescription
>
{
let
layout
=
cx
.layout_of
(
self
.ty
);
self
.variant.fields
.iter
()
.enumerate
()
.map
(|(
i
,
f
)|
{
...
...
@@ -959,7 +959,7 @@ fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
}
fn
prepare_struct_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
prepare_struct_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
struct_type
:
Ty
<
'tcx
>
,
unique_type_id
:
UniqueTypeId
,
span
:
Span
)
...
...
@@ -1004,7 +1004,7 @@ struct TupleMemberDescriptionFactory<'tcx> {
}
impl
<
'tcx
>
TupleMemberDescriptionFactory
<
'tcx
>
{
fn
create_member_descriptions
<
'a
>
(
&
self
,
cx
:
&
C
rateContext
<
'a
,
'tcx
>
)
fn
create_member_descriptions
<
'a
>
(
&
self
,
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Vec
<
MemberDescription
>
{
let
layout
=
cx
.layout_of
(
self
.ty
);
self
.component_types
.iter
()
.enumerate
()
.map
(|(
i
,
&
component_type
)|
{
...
...
@@ -1021,7 +1021,7 @@ fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
}
}
fn
prepare_tuple_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
prepare_tuple_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
tuple_type
:
Ty
<
'tcx
>
,
component_types
:
&
[
Ty
<
'tcx
>
],
unique_type_id
:
UniqueTypeId
,
...
...
@@ -1057,7 +1057,7 @@ struct UnionMemberDescriptionFactory<'tcx> {
}
impl
<
'tcx
>
UnionMemberDescriptionFactory
<
'tcx
>
{
fn
create_member_descriptions
<
'a
>
(
&
self
,
cx
:
&
C
rateContext
<
'a
,
'tcx
>
)
fn
create_member_descriptions
<
'a
>
(
&
self
,
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Vec
<
MemberDescription
>
{
self
.variant.fields
.iter
()
.enumerate
()
.map
(|(
i
,
f
)|
{
let
field
=
self
.layout
.field
(
cx
,
i
);
...
...
@@ -1074,7 +1074,7 @@ fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
}
}
fn
prepare_union_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
prepare_union_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
union_type
:
Ty
<
'tcx
>
,
unique_type_id
:
UniqueTypeId
,
span
:
Span
)
...
...
@@ -1125,7 +1125,7 @@ struct EnumMemberDescriptionFactory<'tcx> {
}
impl
<
'tcx
>
EnumMemberDescriptionFactory
<
'tcx
>
{
fn
create_member_descriptions
<
'a
>
(
&
self
,
cx
:
&
C
rateContext
<
'a
,
'tcx
>
)
fn
create_member_descriptions
<
'a
>
(
&
self
,
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Vec
<
MemberDescription
>
{
let
adt
=
&
self
.enum_type
.ty_adt_def
()
.unwrap
();
match
self
.layout.variants
{
...
...
@@ -1210,7 +1210,7 @@ fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
// of discriminant instead of us having to recover its path.
// Right now it's not even going to work for `niche_start > 0`,
// and for multiple niche variants it only supports the first.
fn
compute_field_path
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
compute_field_path
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
name
:
&
mut
String
,
layout
:
TyLayout
<
'tcx
>
,
offset
:
Size
,
...
...
@@ -1260,7 +1260,7 @@ struct VariantMemberDescriptionFactory<'tcx> {
}
impl
<
'tcx
>
VariantMemberDescriptionFactory
<
'tcx
>
{
fn
create_member_descriptions
<
'a
>
(
&
self
,
cx
:
&
C
rateContext
<
'a
,
'tcx
>
)
fn
create_member_descriptions
<
'a
>
(
&
self
,
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Vec
<
MemberDescription
>
{
self
.args
.iter
()
.enumerate
()
.map
(|(
i
,
&
(
ref
name
,
ty
))|
{
let
(
size
,
align
)
=
cx
.size_and_align_of
(
ty
);
...
...
@@ -1290,7 +1290,7 @@ enum EnumDiscriminantInfo {
// of the variant, and (3) a MemberDescriptionFactory for producing the
// descriptions of the fields of the variant. This is a rudimentary version of a
// full RecursiveTypeDescription.
fn
describe_enum_variant
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
describe_enum_variant
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
layout
:
layout
::
TyLayout
<
'tcx
>
,
variant
:
&
'tcx
ty
::
VariantDef
,
discriminant_info
:
EnumDiscriminantInfo
,
...
...
@@ -1350,7 +1350,7 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
(
metadata_stub
,
member_description_factory
)
}
fn
prepare_enum_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
prepare_enum_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
enum_type
:
Ty
<
'tcx
>
,
enum_def_id
:
DefId
,
unique_type_id
:
UniqueTypeId
,
...
...
@@ -1470,7 +1470,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}),
);
fn
get_enum_discriminant_name
(
cx
:
&
C
rateContext
,
fn
get_enum_discriminant_name
(
cx
:
&
C
odegenCx
,
def_id
:
DefId
)
->
InternedString
{
cx
.tcx
.item_name
(
def_id
)
...
...
@@ -1481,7 +1481,7 @@ fn get_enum_discriminant_name(cx: &CrateContext,
/// results in a LLVM struct.
///
/// Examples of Rust types to use this are: structs, tuples, boxes, vecs, and enums.
fn
composite_type_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
composite_type_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
composite_type
:
Ty
<
'tcx
>
,
composite_type_name
:
&
str
,
composite_type_unique_id
:
UniqueTypeId
,
...
...
@@ -1507,7 +1507,7 @@ fn composite_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return
composite_type_metadata
;
}
fn
set_members_of_composite_type
(
cx
:
&
C
rateContext
,
fn
set_members_of_composite_type
(
cx
:
&
C
odegenCx
,
composite_type_metadata
:
DICompositeType
,
member_descriptions
:
&
[
MemberDescription
])
{
// In some rare cases LLVM metadata uniquing would lead to an existing type
...
...
@@ -1558,7 +1558,7 @@ fn set_members_of_composite_type(cx: &CrateContext,
// A convenience wrapper around LLVMRustDIBuilderCreateStructType(). Does not do
// any caching, does not add any fields to the struct. This can be done later
// with set_members_of_composite_type().
fn
create_struct_stub
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
create_struct_stub
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
struct_type
:
Ty
<
'tcx
>
,
struct_type_name
:
&
str
,
unique_type_id
:
UniqueTypeId
,
...
...
@@ -1595,7 +1595,7 @@ fn create_struct_stub<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return
metadata_stub
;
}
fn
create_union_stub
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
create_union_stub
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
union_type
:
Ty
<
'tcx
>
,
union_type_name
:
&
str
,
unique_type_id
:
UniqueTypeId
,
...
...
@@ -1633,7 +1633,7 @@ fn create_union_stub<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
/// Creates debug information for the given global variable.
///
/// Adds the created metadata nodes directly to the crate's IR.
pub
fn
create_global_var_metadata
(
cx
:
&
C
rateContext
,
pub
fn
create_global_var_metadata
(
cx
:
&
C
odegenCx
,
node_id
:
ast
::
NodeId
,
global
:
ValueRef
)
{
if
cx
.dbg_cx
.is_none
()
{
...
...
@@ -1689,7 +1689,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
}
// Creates an "extension" of an existing DIScope into another file.
pub
fn
extend_scope_to_file
(
ccx
:
&
C
rateContext
,
pub
fn
extend_scope_to_file
(
ccx
:
&
C
odegenCx
,
scope_metadata
:
DIScope
,
file
:
&
syntax_pos
::
FileMap
,
defining_crate
:
CrateNum
)
...
...
@@ -1707,7 +1707,7 @@ pub fn extend_scope_to_file(ccx: &CrateContext,
/// given type.
///
/// Adds the created metadata nodes directly to the crate's IR.
pub
fn
create_vtable_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
create_vtable_metadata
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ty
:
ty
::
Ty
<
'tcx
>
,
vtable
:
ValueRef
)
{
if
cx
.dbg_cx
.is_none
()
{
...
...
src/librustc_trans/debuginfo/mod.rs
浏览文件 @
fb7de6a0
...
...
@@ -27,7 +27,7 @@
use
rustc
::
ty
::
subst
::
Substs
;
use
abi
::
Abi
;
use
common
::
C
rateContext
;
use
common
::
C
odegenCx
;
use
builder
::
Builder
;
use
monomorphize
::
Instance
;
use
rustc
::
ty
::{
self
,
Ty
};
...
...
@@ -150,7 +150,7 @@ pub enum VariableKind {
}
/// Create any deferred debug metadata nodes
pub
fn
finalize
(
cx
:
&
C
rateContext
)
{
pub
fn
finalize
(
cx
:
&
C
odegenCx
)
{
if
cx
.dbg_cx
.is_none
()
{
return
;
}
...
...
@@ -201,7 +201,7 @@ pub fn finalize(cx: &CrateContext) {
/// for debug info creation. The function may also return another variant of the
/// FunctionDebugContext enum which indicates why no debuginfo should be created
/// for the function.
pub
fn
create_function_debug_context
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
create_function_debug_context
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
instance
:
Instance
<
'tcx
>
,
sig
:
ty
::
FnSig
<
'tcx
>
,
llfn
:
ValueRef
,
...
...
@@ -299,7 +299,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return
FunctionDebugContext
::
RegularContext
(
fn_debug_context
);
fn
get_function_signature
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
get_function_signature
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
sig
:
ty
::
FnSig
<
'tcx
>
)
->
DIArray
{
if
cx
.sess
()
.opts.debuginfo
==
LimitedDebugInfo
{
return
create_DIArray
(
DIB
(
cx
),
&
[]);
...
...
@@ -358,7 +358,7 @@ fn get_function_signature<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return
create_DIArray
(
DIB
(
cx
),
&
signature
[
..
]);
}
fn
get_template_parameters
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
get_template_parameters
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
generics
:
&
ty
::
Generics
,
substs
:
&
Substs
<
'tcx
>
,
file_metadata
:
DIFile
,
...
...
@@ -409,7 +409,7 @@ fn get_template_parameters<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
return
create_DIArray
(
DIB
(
cx
),
&
template_params
[
..
]);
}
fn
get_type_parameter_names
(
cx
:
&
C
rateContext
,
generics
:
&
ty
::
Generics
)
->
Vec
<
ast
::
Name
>
{
fn
get_type_parameter_names
(
cx
:
&
C
odegenCx
,
generics
:
&
ty
::
Generics
)
->
Vec
<
ast
::
Name
>
{
let
mut
names
=
generics
.parent
.map_or
(
vec!
[],
|
def_id
|
{
get_type_parameter_names
(
cx
,
cx
.tcx
.generics_of
(
def_id
))
});
...
...
@@ -417,7 +417,7 @@ fn get_type_parameter_names(cx: &CrateContext, generics: &ty::Generics) -> Vec<a
names
}
fn
get_containing_scope
<
'ccx
,
'tcx
>
(
cx
:
&
C
rateContext
<
'ccx
,
'tcx
>
,
fn
get_containing_scope
<
'ccx
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'ccx
,
'tcx
>
,
instance
:
Instance
<
'tcx
>
)
->
DIScope
{
// First, let's see if this is a method within an inherent impl. Because
...
...
src/librustc_trans/debuginfo/namespace.rs
浏览文件 @
fb7de6a0
...
...
@@ -20,13 +20,13 @@
use
llvm
::
debuginfo
::
DIScope
;
use
rustc
::
hir
::
def_id
::
DefId
;
use
rustc
::
hir
::
map
::
DefPathData
;
use
common
::
C
rateContext
;
use
common
::
C
odegenCx
;
use
std
::
ffi
::
CString
;
use
std
::
ptr
;
pub
fn
mangled_name_of_instance
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
instance
:
Instance
<
'tcx
>
,
)
->
ty
::
SymbolName
{
let
tcx
=
ccx
.tcx
;
...
...
@@ -34,7 +34,7 @@ pub fn mangled_name_of_instance<'a, 'tcx>(
}
pub
fn
mangled_name_of_item
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
node_id
:
ast
::
NodeId
,
)
->
ty
::
SymbolName
{
let
tcx
=
ccx
.tcx
;
...
...
@@ -43,7 +43,7 @@ pub fn mangled_name_of_item<'a, 'tcx>(
tcx
.symbol_name
(
instance
)
}
pub
fn
item_namespace
(
ccx
:
&
C
rateContext
,
def_id
:
DefId
)
->
DIScope
{
pub
fn
item_namespace
(
ccx
:
&
C
odegenCx
,
def_id
:
DefId
)
->
DIScope
{
if
let
Some
(
&
scope
)
=
debug_context
(
ccx
)
.namespace_map
.borrow
()
.get
(
&
def_id
)
{
return
scope
;
}
...
...
src/librustc_trans/debuginfo/type_names.rs
浏览文件 @
fb7de6a0
...
...
@@ -10,7 +10,7 @@
// Type Names for Debug Info.
use
common
::
C
rateContext
;
use
common
::
C
odegenCx
;
use
rustc
::
hir
::
def_id
::
DefId
;
use
rustc
::
ty
::
subst
::
Substs
;
use
rustc
::
ty
::{
self
,
Ty
};
...
...
@@ -21,7 +21,7 @@
// any caching, i.e. calling the function twice with the same type will also do
// the work twice. The `qualified` parameter only affects the first level of the
// type name, further levels (i.e. type parameters) are always fully qualified.
pub
fn
compute_debuginfo_type_name
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
compute_debuginfo_type_name
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
t
:
Ty
<
'tcx
>
,
qualified
:
bool
)
->
String
{
...
...
@@ -32,7 +32,7 @@ pub fn compute_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// Pushes the name of the type as it should be stored in debuginfo on the
// `output` String. See also compute_debuginfo_type_name().
pub
fn
push_debuginfo_type_name
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
push_debuginfo_type_name
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
t
:
Ty
<
'tcx
>
,
qualified
:
bool
,
output
:
&
mut
String
)
{
...
...
@@ -179,7 +179,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
}
fn
push_item_name
(
cx
:
&
C
rateContext
,
fn
push_item_name
(
cx
:
&
C
odegenCx
,
def_id
:
DefId
,
qualified
:
bool
,
output
:
&
mut
String
)
{
...
...
@@ -199,7 +199,7 @@ fn push_item_name(cx: &CrateContext,
// reconstructed for items from non-local crates. For local crates, this
// would be possible but with inlining and LTO we have to use the least
// common denominator - otherwise we would run into conflicts.
fn
push_type_params
<
'a
,
'tcx
>
(
cx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
push_type_params
<
'a
,
'tcx
>
(
cx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
substs
:
&
Substs
<
'tcx
>
,
output
:
&
mut
String
)
{
if
substs
.types
()
.next
()
.is_none
()
{
...
...
src/librustc_trans/debuginfo/utils.rs
浏览文件 @
fb7de6a0
...
...
@@ -18,12 +18,12 @@
use
llvm
;
use
llvm
::
debuginfo
::{
DIScope
,
DIBuilderRef
,
DIDescriptor
,
DIArray
};
use
common
::{
C
rateContext
};
use
common
::{
C
odegenCx
};
use
syntax_pos
::{
self
,
Span
};
use
syntax
::
ast
;
pub
fn
is_node_local_to_unit
(
cx
:
&
C
rateContext
,
node_id
:
ast
::
NodeId
)
->
bool
pub
fn
is_node_local_to_unit
(
cx
:
&
C
odegenCx
,
node_id
:
ast
::
NodeId
)
->
bool
{
// The is_local_to_unit flag indicates whether a function is local to the
// current compilation unit (i.e. if it is *static* in the C-sense). The
...
...
@@ -45,23 +45,23 @@ pub fn create_DIArray(builder: DIBuilderRef, arr: &[DIDescriptor]) -> DIArray {
}
/// Return syntax_pos::Loc corresponding to the beginning of the span
pub
fn
span_start
(
cx
:
&
C
rateContext
,
span
:
Span
)
->
syntax_pos
::
Loc
{
pub
fn
span_start
(
cx
:
&
C
odegenCx
,
span
:
Span
)
->
syntax_pos
::
Loc
{
cx
.sess
()
.codemap
()
.lookup_char_pos
(
span
.lo
())
}
#[inline]
pub
fn
debug_context
<
'a
,
'tcx
>
(
cx
:
&
'a
C
rateContext
<
'a
,
'tcx
>
)
pub
fn
debug_context
<
'a
,
'tcx
>
(
cx
:
&
'a
C
odegenCx
<
'a
,
'tcx
>
)
->
&
'a
CrateDebugContext
<
'tcx
>
{
cx
.dbg_cx
.as_ref
()
.unwrap
()
}
#[inline]
#[allow(non_snake_case)]
pub
fn
DIB
(
cx
:
&
C
rateContext
)
->
DIBuilderRef
{
pub
fn
DIB
(
cx
:
&
C
odegenCx
)
->
DIBuilderRef
{
cx
.dbg_cx
.as_ref
()
.unwrap
()
.builder
}
pub
fn
get_namespace_for_item
(
cx
:
&
C
rateContext
,
def_id
:
DefId
)
->
DIScope
{
pub
fn
get_namespace_for_item
(
cx
:
&
C
odegenCx
,
def_id
:
DefId
)
->
DIScope
{
item_namespace
(
cx
,
cx
.tcx
.parent
(
def_id
)
.expect
(
"get_namespace_for_item: missing parent?"
))
}
src/librustc_trans/declare.rs
浏览文件 @
fb7de6a0
...
...
@@ -27,7 +27,7 @@
use
rustc_back
::
PanicStrategy
;
use
abi
::{
Abi
,
FnType
};
use
attributes
;
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
use
common
;
use
type_
::
Type
;
use
value
::
Value
;
...
...
@@ -39,7 +39,7 @@
///
/// If there’s a value with the same name already declared, the function will
/// return its ValueRef instead.
pub
fn
declare_global
(
ccx
:
&
C
rateContext
,
name
:
&
str
,
ty
:
Type
)
->
llvm
::
ValueRef
{
pub
fn
declare_global
(
ccx
:
&
C
odegenCx
,
name
:
&
str
,
ty
:
Type
)
->
llvm
::
ValueRef
{
debug!
(
"declare_global(name={:?})"
,
name
);
let
namebuf
=
CString
::
new
(
name
)
.unwrap_or_else
(|
_
|{
bug!
(
"name {:?} contains an interior null byte"
,
name
)
...
...
@@ -54,7 +54,7 @@ pub fn declare_global(ccx: &CrateContext, name: &str, ty: Type) -> llvm::ValueRe
///
/// If there’s a value with the same name already declared, the function will
/// update the declaration and return existing ValueRef instead.
fn
declare_raw_fn
(
ccx
:
&
C
rateContext
,
name
:
&
str
,
callconv
:
llvm
::
CallConv
,
ty
:
Type
)
->
ValueRef
{
fn
declare_raw_fn
(
ccx
:
&
C
odegenCx
,
name
:
&
str
,
callconv
:
llvm
::
CallConv
,
ty
:
Type
)
->
ValueRef
{
debug!
(
"declare_raw_fn(name={:?}, ty={:?})"
,
name
,
ty
);
let
namebuf
=
CString
::
new
(
name
)
.unwrap_or_else
(|
_
|{
bug!
(
"name {:?} contains an interior null byte"
,
name
)
...
...
@@ -114,7 +114,7 @@ fn declare_raw_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty:
///
/// If there’s a value with the same name already declared, the function will
/// update the declaration and return existing ValueRef instead.
pub
fn
declare_cfn
(
ccx
:
&
C
rateContext
,
name
:
&
str
,
fn_type
:
Type
)
->
ValueRef
{
pub
fn
declare_cfn
(
ccx
:
&
C
odegenCx
,
name
:
&
str
,
fn_type
:
Type
)
->
ValueRef
{
declare_raw_fn
(
ccx
,
name
,
llvm
::
CCallConv
,
fn_type
)
}
...
...
@@ -123,7 +123,7 @@ pub fn declare_cfn(ccx: &CrateContext, name: &str, fn_type: Type) -> ValueRef {
///
/// If there’s a value with the same name already declared, the function will
/// update the declaration and return existing ValueRef instead.
pub
fn
declare_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
name
:
&
str
,
pub
fn
declare_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
name
:
&
str
,
fn_type
:
Ty
<
'tcx
>
)
->
ValueRef
{
debug!
(
"declare_rust_fn(name={:?}, fn_type={:?})"
,
name
,
fn_type
);
let
sig
=
common
::
ty_fn_sig
(
ccx
,
fn_type
);
...
...
@@ -154,7 +154,7 @@ pub fn declare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str,
/// return None if the name already has a definition associated with it. In that
/// case an error should be reported to the user, because it usually happens due
/// to user’s fault (e.g. misuse of #[no_mangle] or #[export_name] attributes).
pub
fn
define_global
(
ccx
:
&
C
rateContext
,
name
:
&
str
,
ty
:
Type
)
->
Option
<
ValueRef
>
{
pub
fn
define_global
(
ccx
:
&
C
odegenCx
,
name
:
&
str
,
ty
:
Type
)
->
Option
<
ValueRef
>
{
if
get_defined_value
(
ccx
,
name
)
.is_some
()
{
None
}
else
{
...
...
@@ -167,7 +167,7 @@ pub fn define_global(ccx: &CrateContext, name: &str, ty: Type) -> Option<ValueRe
/// Use this function when you intend to define a function. This function will
/// return panic if the name already has a definition associated with it. This
/// can happen with #[no_mangle] or #[export_name], for example.
pub
fn
define_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
define_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
name
:
&
str
,
fn_type
:
Ty
<
'tcx
>
)
->
ValueRef
{
if
get_defined_value
(
ccx
,
name
)
.is_some
()
{
...
...
@@ -182,7 +182,7 @@ pub fn define_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
/// Use this function when you intend to define a function. This function will
/// return panic if the name already has a definition associated with it. This
/// can happen with #[no_mangle] or #[export_name], for example.
pub
fn
define_internal_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
define_internal_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
name
:
&
str
,
fn_type
:
Ty
<
'tcx
>
)
->
ValueRef
{
let
llfn
=
define_fn
(
ccx
,
name
,
fn_type
);
...
...
@@ -192,7 +192,7 @@ pub fn define_internal_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
/// Get declared value by name.
pub
fn
get_declared_value
(
ccx
:
&
C
rateContext
,
name
:
&
str
)
->
Option
<
ValueRef
>
{
pub
fn
get_declared_value
(
ccx
:
&
C
odegenCx
,
name
:
&
str
)
->
Option
<
ValueRef
>
{
debug!
(
"get_declared_value(name={:?})"
,
name
);
let
namebuf
=
CString
::
new
(
name
)
.unwrap_or_else
(|
_
|{
bug!
(
"name {:?} contains an interior null byte"
,
name
)
...
...
@@ -209,7 +209,7 @@ pub fn get_declared_value(ccx: &CrateContext, name: &str) -> Option<ValueRef> {
/// Get defined or externally defined (AvailableExternally linkage) value by
/// name.
pub
fn
get_defined_value
(
ccx
:
&
C
rateContext
,
name
:
&
str
)
->
Option
<
ValueRef
>
{
pub
fn
get_defined_value
(
ccx
:
&
C
odegenCx
,
name
:
&
str
)
->
Option
<
ValueRef
>
{
get_declared_value
(
ccx
,
name
)
.and_then
(|
val
|{
let
declaration
=
unsafe
{
llvm
::
LLVMIsDeclaration
(
val
)
!=
0
...
...
src/librustc_trans/intrinsic.rs
浏览文件 @
fb7de6a0
...
...
@@ -35,7 +35,7 @@
use
std
::
cmp
::
Ordering
;
use
std
::
iter
;
fn
get_simple_intrinsic
(
ccx
:
&
C
rateContext
,
name
:
&
str
)
->
Option
<
ValueRef
>
{
fn
get_simple_intrinsic
(
ccx
:
&
C
odegenCx
,
name
:
&
str
)
->
Option
<
ValueRef
>
{
let
llvm_name
=
match
name
{
"sqrtf32"
=>
"llvm.sqrt.f32"
,
"sqrtf64"
=>
"llvm.sqrt.f64"
,
...
...
@@ -565,7 +565,7 @@ fn one<T>(x: Vec<T>) -> T {
assert_eq!
(
x
.len
(),
1
);
x
.into_iter
()
.next
()
.unwrap
()
}
fn
ty_to_type
(
ccx
:
&
C
rateContext
,
t
:
&
intrinsics
::
Type
)
->
Vec
<
Type
>
{
fn
ty_to_type
(
ccx
:
&
C
odegenCx
,
t
:
&
intrinsics
::
Type
)
->
Vec
<
Type
>
{
use
intrinsics
::
Type
::
*
;
match
*
t
{
Void
=>
vec!
[
Type
::
void
(
ccx
)],
...
...
@@ -750,7 +750,7 @@ fn memset_intrinsic<'a, 'tcx>(
fn
try_intrinsic
<
'a
,
'tcx
>
(
bcx
:
&
Builder
<
'a
,
'tcx
>
,
ccx
:
&
C
rateContext
,
ccx
:
&
C
odegenCx
,
func
:
ValueRef
,
data
:
ValueRef
,
local_ptr
:
ValueRef
,
...
...
@@ -775,7 +775,7 @@ fn try_intrinsic<'a, 'tcx>(
// writing, however, LLVM does not recommend the usage of these new instructions
// as the old ones are still more optimized.
fn
trans_msvc_try
<
'a
,
'tcx
>
(
bcx
:
&
Builder
<
'a
,
'tcx
>
,
ccx
:
&
C
rateContext
,
ccx
:
&
C
odegenCx
,
func
:
ValueRef
,
data
:
ValueRef
,
local_ptr
:
ValueRef
,
...
...
@@ -883,7 +883,7 @@ fn trans_msvc_try<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
// functions in play. By calling a shim we're guaranteed that our shim will have
// the right personality function.
fn
trans_gnu_try
<
'a
,
'tcx
>
(
bcx
:
&
Builder
<
'a
,
'tcx
>
,
ccx
:
&
C
rateContext
,
ccx
:
&
C
odegenCx
,
func
:
ValueRef
,
data
:
ValueRef
,
local_ptr
:
ValueRef
,
...
...
@@ -942,7 +942,7 @@ fn trans_gnu_try<'a, 'tcx>(bcx: &Builder<'a, 'tcx>,
// Helper function to give a Block to a closure to translate a shim function.
// This is currently primarily used for the `try` intrinsic functions above.
fn
gen_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
gen_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
name
:
&
str
,
inputs
:
Vec
<
Ty
<
'tcx
>>
,
output
:
Ty
<
'tcx
>
,
...
...
@@ -965,7 +965,7 @@ fn gen_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
// catch exceptions.
//
// This function is only generated once and is then cached.
fn
get_rust_try_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
get_rust_try_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
trans
:
&
mut
for
<
'b
>
FnMut
(
Builder
<
'b
,
'tcx
>
))
->
ValueRef
{
if
let
Some
(
llfn
)
=
ccx
.rust_try_fn
.get
()
{
...
...
@@ -1243,7 +1243,7 @@ enum Style { Float, Int(/* is signed? */ bool), Unsupported }
// Returns None if the type is not an integer
// FIXME: there’s multiple of this functions, investigate using some of the already existing
// stuffs.
fn
int_type_width_signed
(
ty
:
Ty
,
ccx
:
&
C
rateContext
)
->
Option
<
(
u64
,
bool
)
>
{
fn
int_type_width_signed
(
ty
:
Ty
,
ccx
:
&
C
odegenCx
)
->
Option
<
(
u64
,
bool
)
>
{
match
ty
.sty
{
ty
::
TyInt
(
t
)
=>
Some
((
match
t
{
ast
::
IntTy
::
Isize
=>
{
...
...
src/librustc_trans/meth.rs
浏览文件 @
fb7de6a0
...
...
@@ -69,7 +69,7 @@ pub fn get_usize(self, bcx: &Builder<'a, 'tcx>, llvtable: ValueRef) -> ValueRef
/// The `trait_ref` encodes the erased self type. Hence if we are
/// making an object `Foo<Trait>` from a value of type `Foo<T>`, then
/// `trait_ref` would map `T:Trait`.
pub
fn
get_vtable
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
get_vtable
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ty
:
Ty
<
'tcx
>
,
trait_ref
:
Option
<
ty
::
PolyExistentialTraitRef
<
'tcx
>>
)
->
ValueRef
...
...
src/librustc_trans/mir/constant.rs
浏览文件 @
fb7de6a0
...
...
@@ -27,7 +27,7 @@
use
abi
::{
self
,
Abi
};
use
callee
;
use
builder
::
Builder
;
use
common
::{
self
,
C
rateContext
,
const_get_elt
,
val_ty
};
use
common
::{
self
,
C
odegenCx
,
const_get_elt
,
val_ty
};
use
common
::{
C_array
,
C_bool
,
C_bytes
,
C_int
,
C_uint
,
C_uint_big
,
C_u32
,
C_u64
};
use
common
::{
C_null
,
C_struct
,
C_str_slice
,
C_undef
,
C_usize
,
C_vector
,
C_fat_ptr
};
use
common
::
const_to_opt_u128
;
...
...
@@ -62,7 +62,7 @@ pub fn new(llval: ValueRef, ty: Ty<'tcx>) -> Const<'tcx> {
}
}
pub
fn
from_constint
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
ci
:
&
ConstInt
)
->
Const
<
'tcx
>
{
pub
fn
from_constint
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
ci
:
&
ConstInt
)
->
Const
<
'tcx
>
{
let
tcx
=
ccx
.tcx
;
let
(
llval
,
ty
)
=
match
*
ci
{
I8
(
v
)
=>
(
C_int
(
Type
::
i8
(
ccx
),
v
as
i64
),
tcx
.types.i8
),
...
...
@@ -82,7 +82,7 @@ pub fn from_constint(ccx: &CrateContext<'a, 'tcx>, ci: &ConstInt) -> Const<'tcx>
}
/// Translate ConstVal into a LLVM constant value.
pub
fn
from_constval
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
from_constval
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
cv
:
&
ConstVal
,
ty
:
Ty
<
'tcx
>
)
->
Const
<
'tcx
>
{
...
...
@@ -115,7 +115,7 @@ pub fn from_constval(ccx: &CrateContext<'a, 'tcx>,
Const
::
new
(
val
,
ty
)
}
fn
get_field
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
i
:
usize
)
->
ValueRef
{
fn
get_field
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
i
:
usize
)
->
ValueRef
{
let
layout
=
ccx
.layout_of
(
self
.ty
);
let
field
=
layout
.field
(
ccx
,
i
);
if
field
.is_zst
()
{
...
...
@@ -145,11 +145,11 @@ fn get_field(&self, ccx: &CrateContext<'a, 'tcx>, i: usize) -> ValueRef {
}
}
fn
get_pair
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
(
ValueRef
,
ValueRef
)
{
fn
get_pair
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
(
ValueRef
,
ValueRef
)
{
(
self
.get_field
(
ccx
,
0
),
self
.get_field
(
ccx
,
1
))
}
fn
get_fat_ptr
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
(
ValueRef
,
ValueRef
)
{
fn
get_fat_ptr
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
(
ValueRef
,
ValueRef
)
{
assert_eq!
(
abi
::
FAT_PTR_ADDR
,
0
);
assert_eq!
(
abi
::
FAT_PTR_EXTRA
,
1
);
self
.get_pair
(
ccx
)
...
...
@@ -163,7 +163,7 @@ fn as_place(&self) -> ConstPlace<'tcx> {
}
}
pub
fn
to_operand
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
OperandRef
<
'tcx
>
{
pub
fn
to_operand
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
OperandRef
<
'tcx
>
{
let
layout
=
ccx
.layout_of
(
self
.ty
);
let
llty
=
layout
.immediate_llvm_type
(
ccx
);
let
llvalty
=
val_ty
(
self
.llval
);
...
...
@@ -232,7 +232,7 @@ fn to_const(&self, span: Span) -> Const<'tcx> {
}
}
pub
fn
len
<
'a
>
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
ValueRef
{
pub
fn
len
<
'a
>
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
ValueRef
{
match
self
.ty.sty
{
ty
::
TyArray
(
_
,
n
)
=>
{
C_usize
(
ccx
,
n
.val
.to_const_int
()
.unwrap
()
.to_u64
()
.unwrap
())
...
...
@@ -249,7 +249,7 @@ pub fn len<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> ValueRef {
/// Machinery for translating a constant's MIR to LLVM values.
/// FIXME(eddyb) use miri and lower its allocations to LLVM.
struct
MirConstContext
<
'a
,
'tcx
:
'a
>
{
ccx
:
&
'a
C
rateContext
<
'a
,
'tcx
>
,
ccx
:
&
'a
C
odegenCx
<
'a
,
'tcx
>
,
mir
:
&
'a
mir
::
Mir
<
'tcx
>
,
/// Type parameters for const fn and associated constants.
...
...
@@ -270,7 +270,7 @@ fn add_err<'tcx, U, V>(failure: &mut Result<U, ConstEvalErr<'tcx>>,
}
impl
<
'a
,
'tcx
>
MirConstContext
<
'a
,
'tcx
>
{
fn
new
(
ccx
:
&
'a
C
rateContext
<
'a
,
'tcx
>
,
fn
new
(
ccx
:
&
'a
C
odegenCx
<
'a
,
'tcx
>
,
mir
:
&
'a
mir
::
Mir
<
'tcx
>
,
substs
:
&
'tcx
Substs
<
'tcx
>
,
args
:
IndexVec
<
mir
::
Local
,
Result
<
Const
<
'tcx
>
,
ConstEvalErr
<
'tcx
>>>
)
...
...
@@ -289,7 +289,7 @@ fn new(ccx: &'a CrateContext<'a, 'tcx>,
context
}
fn
trans_def
(
ccx
:
&
'a
C
rateContext
<
'a
,
'tcx
>
,
fn
trans_def
(
ccx
:
&
'a
C
odegenCx
<
'a
,
'tcx
>
,
def_id
:
DefId
,
substs
:
&
'tcx
Substs
<
'tcx
>
,
args
:
IndexVec
<
mir
::
Local
,
Result
<
Const
<
'tcx
>
,
ConstEvalErr
<
'tcx
>>>
)
...
...
@@ -1060,7 +1060,7 @@ pub fn const_scalar_checked_binop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
}
unsafe
fn
cast_const_float_to_int
(
ccx
:
&
C
rateContext
,
unsafe
fn
cast_const_float_to_int
(
ccx
:
&
C
odegenCx
,
operand
:
&
Const
,
signed
:
bool
,
int_ty
:
Type
,
...
...
@@ -1095,7 +1095,7 @@ unsafe fn cast_const_float_to_int(ccx: &CrateContext,
C_uint_big
(
int_ty
,
cast_result
.value
)
}
unsafe
fn
cast_const_int_to_float
(
ccx
:
&
C
rateContext
,
unsafe
fn
cast_const_int_to_float
(
ccx
:
&
C
odegenCx
,
llval
:
ValueRef
,
signed
:
bool
,
float_ty
:
Type
)
->
ValueRef
{
...
...
@@ -1154,7 +1154,7 @@ pub fn trans_constant(&mut self,
pub
fn
trans_static_initializer
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
def_id
:
DefId
)
->
Result
<
ValueRef
,
ConstEvalErr
<
'tcx
>>
{
...
...
@@ -1182,7 +1182,7 @@ pub fn trans_static_initializer<'a, 'tcx>(
/// this could be changed in the future to avoid allocating unnecessary
/// space after values of shorter-than-maximum cases.
fn
trans_const_adt
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
t
:
Ty
<
'tcx
>
,
kind
:
&
mir
::
AggregateKind
,
vals
:
&
[
Const
<
'tcx
>
]
...
...
@@ -1272,7 +1272,7 @@ fn trans_const_adt<'a, 'tcx>(
/// initializer is 4-byte aligned then simply translating the tuple as
/// a two-element struct will locate it at offset 4, and accesses to it
/// will read the wrong memory.
fn
build_const_struct
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
build_const_struct
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
layout
:
layout
::
TyLayout
<
'tcx
>
,
vals
:
&
[
Const
<
'tcx
>
],
discr
:
Option
<
Const
<
'tcx
>>
)
...
...
@@ -1332,6 +1332,6 @@ fn build_const_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
Const
::
new
(
C_struct
(
ccx
,
&
cfields
,
packed
),
layout
.ty
)
}
fn
padding
(
ccx
:
&
C
rateContext
,
size
:
Size
)
->
ValueRef
{
fn
padding
(
ccx
:
&
C
odegenCx
,
size
:
Size
)
->
ValueRef
{
C_undef
(
Type
::
array
(
&
Type
::
i8
(
ccx
),
size
.bytes
()))
}
src/librustc_trans/mir/mod.rs
浏览文件 @
fb7de6a0
...
...
@@ -19,7 +19,7 @@
use
rustc
::
session
::
config
::
FullDebugInfo
;
use
base
;
use
builder
::
Builder
;
use
common
::{
C
rateContext
,
Funclet
};
use
common
::{
C
odegenCx
,
Funclet
};
use
debuginfo
::{
self
,
declare_local
,
VariableAccess
,
VariableKind
,
FunctionDebugContext
};
use
monomorphize
::
Instance
;
use
abi
::{
ArgAttribute
,
FnType
,
PassMode
};
...
...
@@ -48,7 +48,7 @@ pub struct MirContext<'a, 'tcx:'a> {
llfn
:
ValueRef
,
ccx
:
&
'a
C
rateContext
<
'a
,
'tcx
>
,
ccx
:
&
'a
C
odegenCx
<
'a
,
'tcx
>
,
fn_ty
:
FnType
<
'tcx
>
,
...
...
@@ -176,7 +176,7 @@ enum LocalRef<'tcx> {
}
impl
<
'a
,
'tcx
>
LocalRef
<
'tcx
>
{
fn
new_operand
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
layout
:
TyLayout
<
'tcx
>
)
->
LocalRef
<
'tcx
>
{
fn
new_operand
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
layout
:
TyLayout
<
'tcx
>
)
->
LocalRef
<
'tcx
>
{
if
layout
.is_zst
()
{
// Zero-size temporaries aren't always initialized, which
// doesn't matter because they don't contain data, but
...
...
@@ -191,7 +191,7 @@ fn new_operand(ccx: &CrateContext<'a, 'tcx>, layout: TyLayout<'tcx>) -> LocalRef
///////////////////////////////////////////////////////////////////////////
pub
fn
trans_mir
<
'a
,
'tcx
:
'a
>
(
ccx
:
&
'a
C
rateContext
<
'a
,
'tcx
>
,
ccx
:
&
'a
C
odegenCx
<
'a
,
'tcx
>
,
llfn
:
ValueRef
,
mir
:
&
'a
Mir
<
'tcx
>
,
instance
:
Instance
<
'tcx
>
,
...
...
src/librustc_trans/mir/operand.rs
浏览文件 @
fb7de6a0
...
...
@@ -15,7 +15,7 @@
use
rustc_data_structures
::
indexed_vec
::
Idx
;
use
base
;
use
common
::{
self
,
C
rateContext
,
C_undef
,
C_usize
};
use
common
::{
self
,
C
odegenCx
,
C_undef
,
C_usize
};
use
builder
::
Builder
;
use
value
::
Value
;
use
type_of
::
LayoutLlvmExt
;
...
...
@@ -81,7 +81,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
impl
<
'a
,
'tcx
>
OperandRef
<
'tcx
>
{
pub
fn
new_zst
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
pub
fn
new_zst
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
layout
:
TyLayout
<
'tcx
>
)
->
OperandRef
<
'tcx
>
{
assert
!
(
layout
.is_zst
());
OperandRef
{
...
...
@@ -99,7 +99,7 @@ pub fn immediate(self) -> ValueRef {
}
}
pub
fn
deref
(
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
PlaceRef
<
'tcx
>
{
pub
fn
deref
(
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
PlaceRef
<
'tcx
>
{
let
projected_ty
=
self
.layout.ty
.builtin_deref
(
true
,
ty
::
NoPreference
)
.unwrap_or_else
(||
bug!
(
"deref of non-pointer {:?}"
,
self
))
.ty
;
let
(
llptr
,
llextra
)
=
match
self
.val
{
...
...
src/librustc_trans/mir/place.rs
浏览文件 @
fb7de6a0
...
...
@@ -16,7 +16,7 @@
use
rustc_data_structures
::
indexed_vec
::
Idx
;
use
base
;
use
builder
::
Builder
;
use
common
::{
C
rateContext
,
C_usize
,
C_u8
,
C_u32
,
C_uint
,
C_int
,
C_null
,
C_uint_big
};
use
common
::{
C
odegenCx
,
C_usize
,
C_u8
,
C_u32
,
C_uint
,
C_int
,
C_null
,
C_uint_big
};
use
consts
;
use
type_of
::
LayoutLlvmExt
;
use
type_
::
Type
;
...
...
@@ -63,7 +63,7 @@ pub fn alloca(bcx: &Builder<'a, 'tcx>, layout: TyLayout<'tcx>, name: &str)
Self
::
new_sized
(
tmp
,
layout
,
layout
.align
)
}
pub
fn
len
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
ValueRef
{
pub
fn
len
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
ValueRef
{
if
let
layout
::
FieldPlacement
::
Array
{
count
,
..
}
=
self
.layout.fields
{
if
self
.layout
.is_unsized
()
{
assert
!
(
self
.has_extra
());
...
...
src/librustc_trans/trans_item.rs
浏览文件 @
fb7de6a0
...
...
@@ -18,7 +18,7 @@
use
attributes
;
use
base
;
use
consts
;
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
use
declare
;
use
llvm
;
use
monomorphize
::
Instance
;
...
...
@@ -38,7 +38,7 @@
pub
use
rustc_mir
::
monomorphize
::
item
::
MonoItemExt
as
BaseMonoItemExt
;
pub
trait
MonoItemExt
<
'a
,
'tcx
>
:
fmt
::
Debug
+
BaseMonoItemExt
<
'a
,
'tcx
>
{
fn
define
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
{
fn
define
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
{
debug!
(
"BEGIN IMPLEMENTING '{} ({})' in cgu {}"
,
self
.to_string
(
ccx
.tcx
),
self
.to_raw_string
(),
...
...
@@ -79,7 +79,7 @@ fn define(&self, ccx: &CrateContext<'a, 'tcx>) {
}
fn
predefine
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
linkage
:
Linkage
,
visibility
:
Visibility
)
{
debug!
(
"BEGIN PREDEFINING '{} ({})' in cgu {}"
,
...
...
@@ -138,7 +138,7 @@ fn to_raw_string(&self) -> String {
impl
<
'a
,
'tcx
>
MonoItemExt
<
'a
,
'tcx
>
for
MonoItem
<
'tcx
>
{}
fn
predefine_static
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
predefine_static
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
node_id
:
ast
::
NodeId
,
linkage
:
Linkage
,
visibility
:
Visibility
,
...
...
@@ -162,7 +162,7 @@ fn predefine_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ccx
.statics
.borrow_mut
()
.insert
(
g
,
def_id
);
}
fn
predefine_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
predefine_fn
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
instance
:
Instance
<
'tcx
>
,
linkage
:
Linkage
,
visibility
:
Visibility
,
...
...
src/librustc_trans/type_.rs
浏览文件 @
fb7de6a0
...
...
@@ -14,7 +14,7 @@
use
llvm
::{
ContextRef
,
TypeRef
,
Bool
,
False
,
True
,
TypeKind
};
use
llvm
::{
Float
,
Double
,
X86_FP80
,
PPC_FP128
,
FP128
};
use
context
::
C
rateContext
;
use
context
::
C
odegenCx
;
use
syntax
::
ast
;
use
rustc
::
ty
::
layout
::{
self
,
Align
,
Size
};
...
...
@@ -62,19 +62,19 @@ pub fn to_ref_slice(slice: &[Type]) -> &[TypeRef] {
unsafe
{
mem
::
transmute
(
slice
)
}
}
pub
fn
void
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
void
(
ccx
:
&
C
odegenCx
)
->
Type
{
ty!
(
llvm
::
LLVMVoidTypeInContext
(
ccx
.llcx
))
}
pub
fn
metadata
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
metadata
(
ccx
:
&
C
odegenCx
)
->
Type
{
ty!
(
llvm
::
LLVMRustMetadataTypeInContext
(
ccx
.llcx
))
}
pub
fn
i1
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
i1
(
ccx
:
&
C
odegenCx
)
->
Type
{
ty!
(
llvm
::
LLVMInt1TypeInContext
(
ccx
.llcx
))
}
pub
fn
i8
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
i8
(
ccx
:
&
C
odegenCx
)
->
Type
{
ty!
(
llvm
::
LLVMInt8TypeInContext
(
ccx
.llcx
))
}
...
...
@@ -82,44 +82,44 @@ pub fn i8_llcx(llcx: ContextRef) -> Type {
ty!
(
llvm
::
LLVMInt8TypeInContext
(
llcx
))
}
pub
fn
i16
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
i16
(
ccx
:
&
C
odegenCx
)
->
Type
{
ty!
(
llvm
::
LLVMInt16TypeInContext
(
ccx
.llcx
))
}
pub
fn
i32
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
i32
(
ccx
:
&
C
odegenCx
)
->
Type
{
ty!
(
llvm
::
LLVMInt32TypeInContext
(
ccx
.llcx
))
}
pub
fn
i64
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
i64
(
ccx
:
&
C
odegenCx
)
->
Type
{
ty!
(
llvm
::
LLVMInt64TypeInContext
(
ccx
.llcx
))
}
pub
fn
i128
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
i128
(
ccx
:
&
C
odegenCx
)
->
Type
{
ty!
(
llvm
::
LLVMIntTypeInContext
(
ccx
.llcx
,
128
))
}
// Creates an integer type with the given number of bits, e.g. i24
pub
fn
ix
(
ccx
:
&
C
rateContext
,
num_bits
:
u64
)
->
Type
{
pub
fn
ix
(
ccx
:
&
C
odegenCx
,
num_bits
:
u64
)
->
Type
{
ty!
(
llvm
::
LLVMIntTypeInContext
(
ccx
.llcx
,
num_bits
as
c_uint
))
}
pub
fn
f32
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
f32
(
ccx
:
&
C
odegenCx
)
->
Type
{
ty!
(
llvm
::
LLVMFloatTypeInContext
(
ccx
.llcx
))
}
pub
fn
f64
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
f64
(
ccx
:
&
C
odegenCx
)
->
Type
{
ty!
(
llvm
::
LLVMDoubleTypeInContext
(
ccx
.llcx
))
}
pub
fn
bool
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
bool
(
ccx
:
&
C
odegenCx
)
->
Type
{
Type
::
i8
(
ccx
)
}
pub
fn
char
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
char
(
ccx
:
&
C
odegenCx
)
->
Type
{
Type
::
i32
(
ccx
)
}
pub
fn
i8p
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
i8p
(
ccx
:
&
C
odegenCx
)
->
Type
{
Type
::
i8
(
ccx
)
.ptr_to
()
}
...
...
@@ -127,7 +127,7 @@ pub fn i8p_llcx(llcx: ContextRef) -> Type {
Type
::
i8_llcx
(
llcx
)
.ptr_to
()
}
pub
fn
isize
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
isize
(
ccx
:
&
C
odegenCx
)
->
Type
{
match
&
ccx
.tcx.sess.target.target.target_pointer_width
[
..
]
{
"16"
=>
Type
::
i16
(
ccx
),
"32"
=>
Type
::
i32
(
ccx
),
...
...
@@ -136,7 +136,7 @@ pub fn isize(ccx: &CrateContext) -> Type {
}
}
pub
fn
c_int
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
c_int
(
ccx
:
&
C
odegenCx
)
->
Type
{
match
&
ccx
.tcx.sess.target.target.target_c_int_width
[
..
]
{
"16"
=>
Type
::
i16
(
ccx
),
"32"
=>
Type
::
i32
(
ccx
),
...
...
@@ -145,7 +145,7 @@ pub fn c_int(ccx: &CrateContext) -> Type {
}
}
pub
fn
int_from_ty
(
ccx
:
&
C
rateContext
,
t
:
ast
::
IntTy
)
->
Type
{
pub
fn
int_from_ty
(
ccx
:
&
C
odegenCx
,
t
:
ast
::
IntTy
)
->
Type
{
match
t
{
ast
::
IntTy
::
Isize
=>
ccx
.isize_ty
,
ast
::
IntTy
::
I8
=>
Type
::
i8
(
ccx
),
...
...
@@ -156,7 +156,7 @@ pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type {
}
}
pub
fn
uint_from_ty
(
ccx
:
&
C
rateContext
,
t
:
ast
::
UintTy
)
->
Type
{
pub
fn
uint_from_ty
(
ccx
:
&
C
odegenCx
,
t
:
ast
::
UintTy
)
->
Type
{
match
t
{
ast
::
UintTy
::
Usize
=>
ccx
.isize_ty
,
ast
::
UintTy
::
U8
=>
Type
::
i8
(
ccx
),
...
...
@@ -167,7 +167,7 @@ pub fn uint_from_ty(ccx: &CrateContext, t: ast::UintTy) -> Type {
}
}
pub
fn
float_from_ty
(
ccx
:
&
C
rateContext
,
t
:
ast
::
FloatTy
)
->
Type
{
pub
fn
float_from_ty
(
ccx
:
&
C
odegenCx
,
t
:
ast
::
FloatTy
)
->
Type
{
match
t
{
ast
::
FloatTy
::
F32
=>
Type
::
f32
(
ccx
),
ast
::
FloatTy
::
F64
=>
Type
::
f64
(
ccx
),
...
...
@@ -186,14 +186,14 @@ pub fn variadic_func(args: &[Type], ret: &Type) -> Type {
args
.len
()
as
c_uint
,
True
))
}
pub
fn
struct_
(
ccx
:
&
C
rateContext
,
els
:
&
[
Type
],
packed
:
bool
)
->
Type
{
pub
fn
struct_
(
ccx
:
&
C
odegenCx
,
els
:
&
[
Type
],
packed
:
bool
)
->
Type
{
let
els
:
&
[
TypeRef
]
=
Type
::
to_ref_slice
(
els
);
ty!
(
llvm
::
LLVMStructTypeInContext
(
ccx
.llcx
,
els
.as_ptr
(),
els
.len
()
as
c_uint
,
packed
as
Bool
))
}
pub
fn
named_struct
(
ccx
:
&
C
rateContext
,
name
:
&
str
)
->
Type
{
pub
fn
named_struct
(
ccx
:
&
C
odegenCx
,
name
:
&
str
)
->
Type
{
let
name
=
CString
::
new
(
name
)
.unwrap
();
ty!
(
llvm
::
LLVMStructCreateNamed
(
ccx
.llcx
,
name
.as_ptr
()))
}
...
...
@@ -265,7 +265,7 @@ pub fn int_width(&self) -> u64 {
}
}
pub
fn
from_integer
(
cx
:
&
C
rateContext
,
i
:
layout
::
Integer
)
->
Type
{
pub
fn
from_integer
(
cx
:
&
C
odegenCx
,
i
:
layout
::
Integer
)
->
Type
{
use
rustc
::
ty
::
layout
::
Integer
::
*
;
match
i
{
I8
=>
Type
::
i8
(
cx
),
...
...
@@ -278,7 +278,7 @@ pub fn from_integer(cx: &CrateContext, i: layout::Integer) -> Type {
/// Return a LLVM type that has at most the required alignment,
/// as a conservative approximation for unknown pointee types.
pub
fn
pointee_for_abi_align
(
ccx
:
&
C
rateContext
,
align
:
Align
)
->
Type
{
pub
fn
pointee_for_abi_align
(
ccx
:
&
C
odegenCx
,
align
:
Align
)
->
Type
{
// FIXME(eddyb) We could find a better approximation if ity.align < align.
let
ity
=
layout
::
Integer
::
approximate_abi_align
(
ccx
,
align
);
Type
::
from_integer
(
ccx
,
ity
)
...
...
@@ -286,7 +286,7 @@ pub fn pointee_for_abi_align(ccx: &CrateContext, align: Align) -> Type {
/// Return a LLVM type that has at most the required alignment,
/// and exactly the required size, as a best-effort padding array.
pub
fn
padding_filler
(
ccx
:
&
C
rateContext
,
size
:
Size
,
align
:
Align
)
->
Type
{
pub
fn
padding_filler
(
ccx
:
&
C
odegenCx
,
size
:
Size
,
align
:
Align
)
->
Type
{
let
unit
=
layout
::
Integer
::
approximate_abi_align
(
ccx
,
align
);
let
size
=
size
.bytes
();
let
unit_size
=
unit
.size
()
.bytes
();
...
...
@@ -294,7 +294,7 @@ pub fn padding_filler(ccx: &CrateContext, size: Size, align: Align) -> Type {
Type
::
array
(
&
Type
::
from_integer
(
ccx
,
unit
),
size
/
unit_size
)
}
pub
fn
x86_mmx
(
ccx
:
&
C
rateContext
)
->
Type
{
pub
fn
x86_mmx
(
ccx
:
&
C
odegenCx
)
->
Type
{
ty!
(
llvm
::
LLVMX86MMXTypeInContext
(
ccx
.llcx
))
}
}
src/librustc_trans/type_of.rs
浏览文件 @
fb7de6a0
...
...
@@ -19,7 +19,7 @@
use
std
::
fmt
::
Write
;
fn
uncached_llvm_type
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
uncached_llvm_type
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
layout
:
TyLayout
<
'tcx
>
,
defer
:
&
mut
Option
<
(
Type
,
TyLayout
<
'tcx
>
)
>
)
->
Type
{
...
...
@@ -110,7 +110,7 @@ fn uncached_llvm_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
fn
struct_llfields
<
'a
,
'tcx
>
(
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
struct_llfields
<
'a
,
'tcx
>
(
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
layout
:
TyLayout
<
'tcx
>
)
->
(
Vec
<
Type
>
,
bool
)
{
debug!
(
"struct_llfields: {:#?}"
,
layout
);
...
...
@@ -158,7 +158,7 @@ fn struct_llfields<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
(
result
,
packed
)
}
impl
<
'a
,
'tcx
>
C
rateContext
<
'a
,
'tcx
>
{
impl
<
'a
,
'tcx
>
C
odegenCx
<
'a
,
'tcx
>
{
pub
fn
align_of
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
Align
{
self
.layout_of
(
ty
)
.align
}
...
...
@@ -197,14 +197,14 @@ pub struct PointeeInfo {
pub
trait
LayoutLlvmExt
<
'tcx
>
{
fn
is_llvm_immediate
(
&
self
)
->
bool
;
fn
is_llvm_scalar_pair
<
'a
>
(
&
self
)
->
bool
;
fn
llvm_type
<
'a
>
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
Type
;
fn
immediate_llvm_type
<
'a
>
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
Type
;
fn
scalar_llvm_type_at
<
'a
>
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
llvm_type
<
'a
>
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Type
;
fn
immediate_llvm_type
<
'a
>
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Type
;
fn
scalar_llvm_type_at
<
'a
>
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
scalar
:
&
layout
::
Scalar
,
offset
:
Size
)
->
Type
;
fn
scalar_pair_element_llvm_type
<
'a
>
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
scalar_pair_element_llvm_type
<
'a
>
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
index
:
usize
)
->
Type
;
fn
llvm_field_index
(
&
self
,
index
:
usize
)
->
u64
;
fn
pointee_info_at
<
'a
>
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
offset
:
Size
)
fn
pointee_info_at
<
'a
>
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
offset
:
Size
)
->
Option
<
PointeeInfo
>
;
}
...
...
@@ -240,7 +240,7 @@ fn is_llvm_scalar_pair<'a>(&self) -> bool {
/// with the inner-most trailing unsized field using the "minimal unit"
/// of that field's type - this is useful for taking the address of
/// that field and ensuring the struct has the right alignment.
fn
llvm_type
<
'a
>
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
Type
{
fn
llvm_type
<
'a
>
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Type
{
if
let
layout
::
Abi
::
Scalar
(
ref
scalar
)
=
self
.abi
{
// Use a different cache for scalars because pointers to DSTs
// can be either fat or thin (data pointers of fat pointers).
...
...
@@ -305,7 +305,7 @@ fn llvm_type<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> Type {
llty
}
fn
immediate_llvm_type
<
'a
>
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
)
->
Type
{
fn
immediate_llvm_type
<
'a
>
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
)
->
Type
{
if
let
layout
::
Abi
::
Scalar
(
ref
scalar
)
=
self
.abi
{
if
scalar
.is_bool
()
{
return
Type
::
i1
(
ccx
);
...
...
@@ -314,7 +314,7 @@ fn immediate_llvm_type<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> Type {
self
.llvm_type
(
ccx
)
}
fn
scalar_llvm_type_at
<
'a
>
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
scalar_llvm_type_at
<
'a
>
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
scalar
:
&
layout
::
Scalar
,
offset
:
Size
)
->
Type
{
match
scalar
.value
{
layout
::
Int
(
i
,
_
)
=>
Type
::
from_integer
(
ccx
,
i
),
...
...
@@ -332,7 +332,7 @@ fn scalar_llvm_type_at<'a>(&self, ccx: &CrateContext<'a, 'tcx>,
}
}
fn
scalar_pair_element_llvm_type
<
'a
>
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
fn
scalar_pair_element_llvm_type
<
'a
>
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
index
:
usize
)
->
Type
{
// HACK(eddyb) special-case fat pointers until LLVM removes
// pointee types, to avoid bitcasting every `OperandRef::deref`.
...
...
@@ -396,7 +396,7 @@ fn llvm_field_index(&self, index: usize) -> u64 {
}
}
fn
pointee_info_at
<
'a
>
(
&
self
,
ccx
:
&
C
rateContext
<
'a
,
'tcx
>
,
offset
:
Size
)
fn
pointee_info_at
<
'a
>
(
&
self
,
ccx
:
&
C
odegenCx
<
'a
,
'tcx
>
,
offset
:
Size
)
->
Option
<
PointeeInfo
>
{
if
let
Some
(
&
pointee
)
=
ccx
.pointee_infos
.borrow
()
.get
(
&
(
self
.ty
,
offset
))
{
return
pointee
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录