Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
44cebe59
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
44cebe59
编写于
11月 18, 2019
作者:
M
Mazdak Farrokhzad
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reduce size of hir::ExprKind
上级
f1b882b5
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
74 addition
and
59 deletion
+74
-59
src/librustc/hir/intravisit.rs
src/librustc/hir/intravisit.rs
+3
-4
src/librustc/hir/lowering/expr.rs
src/librustc/hir/lowering/expr.rs
+13
-13
src/librustc/hir/mod.rs
src/librustc/hir/mod.rs
+10
-3
src/librustc/hir/print.rs
src/librustc/hir/print.rs
+11
-10
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/expr_use_visitor.rs
+3
-3
src/librustc/mir/mod.rs
src/librustc/mir/mod.rs
+2
-2
src/librustc/ty/structural_impls.rs
src/librustc/ty/structural_impls.rs
+1
-1
src/librustc_codegen_llvm/asm.rs
src/librustc_codegen_llvm/asm.rs
+1
-1
src/librustc_codegen_ssa/traits/asm.rs
src/librustc_codegen_ssa/traits/asm.rs
+2
-2
src/librustc_mir/hair/cx/expr.rs
src/librustc_mir/hair/cx/expr.rs
+4
-4
src/librustc_mir/hair/mod.rs
src/librustc_mir/hair/mod.rs
+5
-1
src/librustc_passes/liveness.rs
src/librustc_passes/liveness.rs
+17
-13
src/librustc_typeck/check/expr.rs
src/librustc_typeck/check/expr.rs
+2
-2
未找到文件。
src/librustc/hir/intravisit.rs
浏览文件 @
44cebe59
...
...
@@ -1086,10 +1086,9 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
ExprKind
::
Ret
(
ref
optional_expression
)
=>
{
walk_list!
(
visitor
,
visit_expr
,
optional_expression
);
}
ExprKind
::
InlineAsm
(
_
,
ref
outputs
,
ref
inputs
)
=>
{
for
expr
in
outputs
.iter
()
.chain
(
inputs
.iter
())
{
visitor
.visit_expr
(
expr
)
}
ExprKind
::
InlineAsm
(
ref
asm
)
=>
{
walk_list!
(
visitor
,
visit_expr
,
&
asm
.outputs_exprs
);
walk_list!
(
visitor
,
visit_expr
,
&
asm
.inputs_exprs
);
}
ExprKind
::
Yield
(
ref
subexpression
,
_
)
=>
{
visitor
.visit_expr
(
subexpression
);
...
...
src/librustc/hir/lowering/expr.rs
浏览文件 @
44cebe59
...
...
@@ -966,7 +966,7 @@ fn with_loop_condition_scope<T, F>(&mut self, f: F) -> T
}
fn
lower_expr_asm
(
&
mut
self
,
asm
:
&
InlineAsm
)
->
hir
::
ExprKind
{
let
hir_asm
=
hir
::
InlineAsm
{
let
inner
=
hir
::
InlineAsmInner
{
inputs
:
asm
.inputs
.iter
()
.map
(|
&
(
ref
c
,
_
)|
c
.clone
())
.collect
(),
outputs
:
asm
.outputs
.iter
()
...
...
@@ -984,18 +984,18 @@ fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind {
alignstack
:
asm
.alignstack
,
dialect
:
asm
.dialect
,
};
let
outputs
=
asm
.outputs
.iter
()
.map
(|
out
|
self
.lower_expr
(
&
out
.expr
)
)
.collect
();
let
inputs
=
asm
.in
puts
.iter
()
.map
(|
&
(
_
,
ref
input
)|
self
.lower_expr
(
input
))
.collect
();
hir
::
ExprKind
::
InlineAsm
(
P
(
hir_asm
)
,
outputs
,
inputs
)
let
hir_asm
=
hir
::
InlineAsm
{
inner
,
inputs_exprs
:
asm
.inputs
.iter
(
)
.map
(|
&
(
_
,
ref
input
)|
self
.lower_expr
(
input
))
.collect
(),
outputs_exprs
:
asm
.out
puts
.iter
()
.map
(|
out
|
self
.lower_expr
(
&
out
.expr
))
.collect
(),
};
hir
::
ExprKind
::
InlineAsm
(
P
(
hir_asm
))
}
fn
lower_field
(
&
mut
self
,
f
:
&
Field
)
->
hir
::
Field
{
...
...
src/librustc/hir/mod.rs
浏览文件 @
44cebe59
...
...
@@ -1457,7 +1457,7 @@ pub struct Expr {
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch
=
"x86_64"
)]
static_assert_size!
(
Expr
,
72
);
static_assert_size!
(
Expr
,
64
);
impl
Expr
{
pub
fn
precedence
(
&
self
)
->
ExprPrecedence
{
...
...
@@ -1656,7 +1656,7 @@ pub enum ExprKind {
Ret
(
Option
<
P
<
Expr
>>
),
/// Inline assembly (from `asm!`), with its outputs and inputs.
InlineAsm
(
P
<
InlineAsm
>
,
HirVec
<
Expr
>
,
HirVec
<
Expr
>
),
InlineAsm
(
P
<
InlineAsm
>
),
/// A struct or struct-like variant literal expression.
///
...
...
@@ -2063,7 +2063,7 @@ pub struct InlineAsmOutput {
// NOTE(eddyb) This is used within MIR as well, so unlike the rest of the HIR,
// it needs to be `Clone` and use plain `Vec<T>` instead of `HirVec<T>`.
#[derive(Clone,
RustcEncodable,
RustcDecodable,
Debug,
HashStable)]
pub
struct
InlineAsm
{
pub
struct
InlineAsm
Inner
{
pub
asm
:
Symbol
,
pub
asm_str_style
:
StrStyle
,
pub
outputs
:
Vec
<
InlineAsmOutput
>
,
...
...
@@ -2074,6 +2074,13 @@ pub struct InlineAsm {
pub
dialect
:
AsmDialect
,
}
#[derive(RustcEncodable,
RustcDecodable,
Debug,
HashStable)]
pub
struct
InlineAsm
{
pub
inner
:
InlineAsmInner
,
pub
outputs_exprs
:
HirVec
<
Expr
>
,
pub
inputs_exprs
:
HirVec
<
Expr
>
,
}
/// Represents a parameter in a function header.
#[derive(RustcEncodable,
RustcDecodable,
Debug,
HashStable)]
pub
struct
Param
{
...
...
src/librustc/hir/print.rs
浏览文件 @
44cebe59
...
...
@@ -1365,14 +1365,15 @@ pub fn print_expr(&mut self, expr: &hir::Expr) {
self
.print_expr_maybe_paren
(
&
expr
,
parser
::
PREC_JUMP
);
}
}
hir
::
ExprKind
::
InlineAsm
(
ref
a
,
ref
outputs
,
ref
inputs
)
=>
{
hir
::
ExprKind
::
InlineAsm
(
ref
a
)
=>
{
let
i
=
&
a
.inner
;
self
.s
.word
(
"asm!"
);
self
.popen
();
self
.print_string
(
&
a
.asm
.as_str
(),
a
.asm_str_style
);
self
.print_string
(
&
i
.asm
.as_str
(),
i
.asm_str_style
);
self
.word_space
(
":"
);
let
mut
out_idx
=
0
;
self
.commasep
(
Inconsistent
,
&
a
.outputs
,
|
s
,
out
|
{
self
.commasep
(
Inconsistent
,
&
i
.outputs
,
|
s
,
out
|
{
let
constraint
=
out
.constraint
.as_str
();
let
mut
ch
=
constraint
.chars
();
match
ch
.next
()
{
...
...
@@ -1383,7 +1384,7 @@ pub fn print_expr(&mut self, expr: &hir::Expr) {
_
=>
s
.print_string
(
&
constraint
,
ast
::
StrStyle
::
Cooked
),
}
s
.popen
();
s
.print_expr
(
&
output
s
[
out_idx
]);
s
.print_expr
(
&
a
.outputs_expr
s
[
out_idx
]);
s
.pclose
();
out_idx
+=
1
;
});
...
...
@@ -1391,28 +1392,28 @@ pub fn print_expr(&mut self, expr: &hir::Expr) {
self
.word_space
(
":"
);
let
mut
in_idx
=
0
;
self
.commasep
(
Inconsistent
,
&
a
.inputs
,
|
s
,
co
|
{
self
.commasep
(
Inconsistent
,
&
i
.inputs
,
|
s
,
co
|
{
s
.print_string
(
&
co
.as_str
(),
ast
::
StrStyle
::
Cooked
);
s
.popen
();
s
.print_expr
(
&
input
s
[
in_idx
]);
s
.print_expr
(
&
a
.inputs_expr
s
[
in_idx
]);
s
.pclose
();
in_idx
+=
1
;
});
self
.s
.space
();
self
.word_space
(
":"
);
self
.commasep
(
Inconsistent
,
&
a
.clobbers
,
|
s
,
co
|
{
self
.commasep
(
Inconsistent
,
&
i
.clobbers
,
|
s
,
co
|
{
s
.print_string
(
&
co
.as_str
(),
ast
::
StrStyle
::
Cooked
);
});
let
mut
options
=
vec!
[];
if
a
.volatile
{
if
i
.volatile
{
options
.push
(
"volatile"
);
}
if
a
.alignstack
{
if
i
.alignstack
{
options
.push
(
"alignstack"
);
}
if
a
.dialect
==
ast
::
AsmDialect
::
Intel
{
if
i
.dialect
==
ast
::
AsmDialect
::
Intel
{
options
.push
(
"intel"
);
}
...
...
src/librustc/middle/expr_use_visitor.rs
浏览文件 @
44cebe59
...
...
@@ -283,15 +283,15 @@ pub fn walk_expr(&mut self, expr: &hir::Expr) {
self
.borrow_expr
(
&
base
,
bk
);
}
hir
::
ExprKind
::
InlineAsm
(
ref
ia
,
ref
outputs
,
ref
inputs
)
=>
{
for
(
o
,
output
)
in
ia
.
outputs
.iter
()
.zip
(
output
s
)
{
hir
::
ExprKind
::
InlineAsm
(
ref
ia
)
=>
{
for
(
o
,
output
)
in
ia
.
inner.outputs
.iter
()
.zip
(
&
ia
.outputs_expr
s
)
{
if
o
.is_indirect
{
self
.consume_expr
(
output
);
}
else
{
self
.mutate_expr
(
output
);
}
}
self
.consume_exprs
(
input
s
);
self
.consume_exprs
(
&
ia
.inputs_expr
s
);
}
hir
::
ExprKind
::
Continue
(
..
)
|
...
...
src/librustc/mir/mod.rs
浏览文件 @
44cebe59
...
...
@@ -6,7 +6,7 @@
use
crate
::
hir
::
def
::{
CtorKind
,
Namespace
};
use
crate
::
hir
::
def_id
::
DefId
;
use
crate
::
hir
::{
self
,
InlineAsm
as
HirInlineAsm
}
;
use
crate
::
hir
;
use
crate
::
mir
::
interpret
::{
PanicInfo
,
Scalar
};
use
crate
::
mir
::
visit
::
MirVisitable
;
use
crate
::
ty
::
adjustment
::
PointerCast
;
...
...
@@ -1638,7 +1638,7 @@ pub enum FakeReadCause {
#[derive(Clone,
Debug,
RustcEncodable,
RustcDecodable,
HashStable,
TypeFoldable)]
pub
struct
InlineAsm
<
'tcx
>
{
pub
asm
:
HirInlineAsm
,
pub
asm
:
hir
::
InlineAsmInner
,
pub
outputs
:
Box
<
[
Place
<
'tcx
>
]
>
,
pub
inputs
:
Box
<
[(
Span
,
Operand
<
'tcx
>
)]
>
,
}
...
...
src/librustc/ty/structural_impls.rs
浏览文件 @
44cebe59
...
...
@@ -301,7 +301,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
::
syntax_pos
::
symbol
::
Symbol
,
crate
::
hir
::
def
::
Res
,
crate
::
hir
::
def_id
::
DefId
,
crate
::
hir
::
InlineAsm
,
crate
::
hir
::
InlineAsm
Inner
,
crate
::
hir
::
MatchSource
,
crate
::
hir
::
Mutability
,
crate
::
hir
::
Unsafety
,
...
...
src/librustc_codegen_llvm/asm.rs
浏览文件 @
44cebe59
...
...
@@ -17,7 +17,7 @@
impl
AsmBuilderMethods
<
'tcx
>
for
Builder
<
'a
,
'll
,
'tcx
>
{
fn
codegen_inline_asm
(
&
mut
self
,
ia
:
&
hir
::
InlineAsm
,
ia
:
&
hir
::
InlineAsm
Inner
,
outputs
:
Vec
<
PlaceRef
<
'tcx
,
&
'll
Value
>>
,
mut
inputs
:
Vec
<&
'll
Value
>
,
span
:
Span
,
...
...
src/librustc_codegen_ssa/traits/asm.rs
浏览文件 @
44cebe59
use
super
::
BackendTypes
;
use
crate
::
mir
::
place
::
PlaceRef
;
use
rustc
::
hir
::{
GlobalAsm
,
InlineAsm
};
use
rustc
::
hir
::{
GlobalAsm
,
InlineAsm
Inner
};
use
syntax_pos
::
Span
;
pub
trait
AsmBuilderMethods
<
'tcx
>
:
BackendTypes
{
/// Take an inline assembly expression and splat it out via LLVM
fn
codegen_inline_asm
(
&
mut
self
,
ia
:
&
InlineAsm
,
ia
:
&
InlineAsm
Inner
,
outputs
:
Vec
<
PlaceRef
<
'tcx
,
Self
::
Value
>>
,
inputs
:
Vec
<
Self
::
Value
>
,
span
:
Span
,
...
...
src/librustc_mir/hair/cx/expr.rs
浏览文件 @
44cebe59
...
...
@@ -533,11 +533,11 @@ fn make_mirror_unadjusted<'a, 'tcx>(
convert_path_expr
(
cx
,
expr
,
res
)
}
hir
::
ExprKind
::
InlineAsm
(
ref
asm
,
ref
outputs
,
ref
inputs
)
=>
{
hir
::
ExprKind
::
InlineAsm
(
ref
asm
)
=>
{
ExprKind
::
InlineAsm
{
asm
,
outputs
:
output
s
.to_ref
(),
inputs
:
input
s
.to_ref
(),
asm
:
&
asm
.inner
,
outputs
:
asm
.outputs_expr
s
.to_ref
(),
inputs
:
asm
.inputs_expr
s
.to_ref
(),
}
}
...
...
src/librustc_mir/hair/mod.rs
浏览文件 @
44cebe59
...
...
@@ -93,6 +93,10 @@ pub enum StmtKind<'tcx> {
},
}
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch
=
"x86_64"
)]
rustc_data_structures
::
static_assert_size!
(
Expr
<
'_
>
,
168
);
/// The Hair trait implementor lowers their expressions (`&'tcx H::Expr`)
/// into instances of this `Expr` enum. This lowering can be done
/// basically as lazily or as eagerly as desired: every recursive
...
...
@@ -264,7 +268,7 @@ pub enum ExprKind<'tcx> {
user_ty
:
Option
<
Canonical
<
'tcx
,
UserType
<
'tcx
>>>
,
},
InlineAsm
{
asm
:
&
'tcx
hir
::
InlineAsm
,
asm
:
&
'tcx
hir
::
InlineAsm
Inner
,
outputs
:
Vec
<
ExprRef
<
'tcx
>>
,
inputs
:
Vec
<
ExprRef
<
'tcx
>>
},
...
...
src/librustc_passes/liveness.rs
浏览文件 @
44cebe59
...
...
@@ -1184,17 +1184,21 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode) -> LiveNode {
self
.propagate_through_expr
(
&
e
,
succ
)
}
hir
::
ExprKind
::
InlineAsm
(
ref
ia
,
ref
outputs
,
ref
inputs
)
=>
{
hir
::
ExprKind
::
InlineAsm
(
ref
asm
)
=>
{
let
ia
=
&
asm
.inner
;
let
outputs
=
&
asm
.outputs_exprs
;
let
inputs
=
&
asm
.inputs_exprs
;
let
succ
=
ia
.outputs
.iter
()
.zip
(
outputs
)
.rev
()
.fold
(
succ
,
|
succ
,
(
o
,
output
)|
{
// see comment on places
// in propagate_through_place_components()
if
o
.is_indirect
{
self
.propagate_through_expr
(
output
,
succ
)
}
else
{
let
acc
=
if
o
.is_rw
{
ACC_WRITE
|
ACC_READ
}
else
{
ACC_WRITE
};
let
succ
=
self
.write_place
(
output
,
succ
,
acc
);
self
.propagate_through_place_components
(
output
,
succ
)
}});
// see comment on places
// in propagate_through_place_components()
if
o
.is_indirect
{
self
.propagate_through_expr
(
output
,
succ
)
}
else
{
let
acc
=
if
o
.is_rw
{
ACC_WRITE
|
ACC_READ
}
else
{
ACC_WRITE
};
let
succ
=
self
.write_place
(
output
,
succ
,
acc
);
self
.propagate_through_place_components
(
output
,
succ
)
}
});
// Inputs are executed first. Propagate last because of rev order
self
.propagate_through_exprs
(
inputs
,
succ
)
...
...
@@ -1395,13 +1399,13 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr) {
}
}
hir
::
ExprKind
::
InlineAsm
(
ref
ia
,
ref
outputs
,
ref
inputs
)
=>
{
for
input
in
input
s
{
hir
::
ExprKind
::
InlineAsm
(
ref
asm
)
=>
{
for
input
in
&
asm
.inputs_expr
s
{
this
.visit_expr
(
input
);
}
// Output operands must be places
for
(
o
,
output
)
in
ia
.outputs
.iter
()
.zip
(
output
s
)
{
for
(
o
,
output
)
in
asm
.inner.outputs
.iter
()
.zip
(
&
asm
.outputs_expr
s
)
{
if
!
o
.is_indirect
{
this
.check_place
(
output
);
}
...
...
src/librustc_typeck/check/expr.rs
浏览文件 @
44cebe59
...
...
@@ -244,8 +244,8 @@ fn check_expr_kind(
ExprKind
::
Path
(
ref
qpath
)
=>
{
self
.check_expr_path
(
qpath
,
expr
)
}
ExprKind
::
InlineAsm
(
_
,
ref
outputs
,
ref
inputs
)
=>
{
for
expr
in
outputs
.iter
()
.chain
(
input
s
.iter
())
{
ExprKind
::
InlineAsm
(
ref
asm
)
=>
{
for
expr
in
asm
.outputs_exprs
.iter
()
.chain
(
asm
.inputs_expr
s
.iter
())
{
self
.check_expr
(
expr
);
}
tcx
.mk_unit
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录