Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6c5b990c
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
6c5b990c
编写于
8月 30, 2018
作者:
D
Denis Merigoux
提交者:
Eduard-Mihai Burtescu
11月 16, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
All CommonMethods now real methods (not static)
上级
33eee837
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
31 addition
and
32 deletion
+31
-32
src/librustc_codegen_llvm/base.rs
src/librustc_codegen_llvm/base.rs
+1
-1
src/librustc_codegen_llvm/common.rs
src/librustc_codegen_llvm/common.rs
+10
-10
src/librustc_codegen_llvm/glue.rs
src/librustc_codegen_llvm/glue.rs
+6
-6
src/librustc_codegen_llvm/interfaces/common.rs
src/librustc_codegen_llvm/interfaces/common.rs
+8
-8
src/librustc_codegen_llvm/intrinsic.rs
src/librustc_codegen_llvm/intrinsic.rs
+4
-4
src/librustc_codegen_llvm/mir/block.rs
src/librustc_codegen_llvm/mir/block.rs
+1
-1
src/librustc_codegen_llvm/mir/rvalue.rs
src/librustc_codegen_llvm/mir/rvalue.rs
+1
-2
未找到文件。
src/librustc_codegen_llvm/base.rs
浏览文件 @
6c5b990c
...
...
@@ -1151,7 +1151,7 @@ fn module_codegen<'a, 'tcx>(
if
!
cx
.used_statics
.borrow
()
.is_empty
()
{
let
name
=
const_cstr!
(
"llvm.used"
);
let
section
=
const_cstr!
(
"llvm.metadata"
);
let
array
=
CodegenCx
::
c_array
(
Type
::
i8
(
&
cx
)
.ptr_to
(),
&*
cx
.used_statics
.borrow
());
let
array
=
cx
.
c_array
(
Type
::
i8
(
&
cx
)
.ptr_to
(),
&*
cx
.used_statics
.borrow
());
unsafe
{
let
g
=
llvm
::
LLVMAddGlobal
(
cx
.llmod
,
...
...
src/librustc_codegen_llvm/common.rs
浏览文件 @
6c5b990c
...
...
@@ -321,13 +321,13 @@ fn c_struct(
&
self
.c_struct_in_context
(
&
self
.llcx
,
elts
,
packed
)
}
fn
c_array
(
ty
:
&
'll
Type
,
elts
:
&
[
&
'll
Value
])
->
&
'll
Value
{
fn
c_array
(
&
self
,
ty
:
&
'll
Type
,
elts
:
&
[
&
'll
Value
])
->
&
'll
Value
{
unsafe
{
return
llvm
::
LLVMConstArray
(
ty
,
elts
.as_ptr
(),
elts
.len
()
as
c_uint
);
}
}
fn
c_vector
(
elts
:
&
[
&
'll
Value
])
->
&
'll
Value
{
fn
c_vector
(
&
self
,
elts
:
&
[
&
'll
Value
])
->
&
'll
Value
{
unsafe
{
return
llvm
::
LLVMConstVector
(
elts
.as_ptr
(),
elts
.len
()
as
c_uint
);
}
...
...
@@ -337,7 +337,7 @@ fn c_bytes(&self, bytes: &[u8]) -> &'ll Value {
&
self
.c_bytes_in_context
(
&
self
.llcx
,
bytes
)
}
fn
const_get_elt
(
v
:
&
'll
Value
,
idx
:
u64
)
->
&
'll
Value
{
fn
const_get_elt
(
&
self
,
v
:
&
'll
Value
,
idx
:
u64
)
->
&
'll
Value
{
unsafe
{
assert_eq!
(
idx
as
c_uint
as
u64
,
idx
);
let
us
=
&
[
idx
as
c_uint
];
...
...
@@ -350,9 +350,9 @@ fn const_get_elt(v: &'ll Value, idx: u64) -> &'ll Value {
}
}
fn
const_get_real
(
v
:
&
'll
Value
)
->
Option
<
(
f64
,
bool
)
>
{
fn
const_get_real
(
&
self
,
v
:
&
'll
Value
)
->
Option
<
(
f64
,
bool
)
>
{
unsafe
{
if
Self
::
is_const_real
(
v
)
{
if
self
.
is_const_real
(
v
)
{
let
mut
loses_info
:
llvm
::
Bool
=
::
std
::
mem
::
uninitialized
();
let
r
=
llvm
::
LLVMConstRealGetDouble
(
v
,
&
mut
loses_info
);
let
loses_info
=
if
loses_info
==
1
{
true
}
else
{
false
};
...
...
@@ -363,27 +363,27 @@ fn const_get_real(v: &'ll Value) -> Option<(f64, bool)> {
}
}
fn
const_to_uint
(
v
:
&
'll
Value
)
->
u64
{
fn
const_to_uint
(
&
self
,
v
:
&
'll
Value
)
->
u64
{
unsafe
{
llvm
::
LLVMConstIntGetZExtValue
(
v
)
}
}
fn
is_const_integral
(
v
:
&
'll
Value
)
->
bool
{
fn
is_const_integral
(
&
self
,
v
:
&
'll
Value
)
->
bool
{
unsafe
{
llvm
::
LLVMIsAConstantInt
(
v
)
.is_some
()
}
}
fn
is_const_real
(
v
:
&
'll
Value
)
->
bool
{
fn
is_const_real
(
&
self
,
v
:
&
'll
Value
)
->
bool
{
unsafe
{
llvm
::
LLVMIsAConstantFP
(
v
)
.is_some
()
}
}
fn
const_to_opt_u128
(
v
:
&
'll
Value
,
sign_ext
:
bool
)
->
Option
<
u128
>
{
fn
const_to_opt_u128
(
&
self
,
v
:
&
'll
Value
,
sign_ext
:
bool
)
->
Option
<
u128
>
{
unsafe
{
if
Self
::
is_const_integral
(
v
)
{
if
self
.
is_const_integral
(
v
)
{
let
(
mut
lo
,
mut
hi
)
=
(
0u64
,
0u64
);
let
success
=
llvm
::
LLVMRustConstInt128Get
(
v
,
sign_ext
,
&
mut
hi
,
&
mut
lo
);
...
...
src/librustc_codegen_llvm/glue.rs
浏览文件 @
6c5b990c
...
...
@@ -34,8 +34,8 @@ pub fn size_and_align_of_dst(
let
(
size
,
align
)
=
bx
.cx
()
.size_and_align_of
(
t
);
debug!
(
"size_and_align_of_dst t={} info={:?} size: {:?} align: {:?}"
,
t
,
info
,
size
,
align
);
let
size
=
CodegenCx
::
c_usize
(
bx
.cx
(),
size
.bytes
());
let
align
=
CodegenCx
::
c_usize
(
bx
.cx
(),
align
.abi
());
let
size
=
bx
.cx
()
.c_usize
(
size
.bytes
());
let
align
=
bx
.cx
()
.c_usize
(
align
.abi
());
return
(
size
,
align
);
}
match
t
.sty
{
...
...
@@ -49,8 +49,8 @@ pub fn size_and_align_of_dst(
// The info in this case is the length of the str, so the size is that
// times the unit size.
let
(
size
,
align
)
=
bx
.cx
()
.size_and_align_of
(
unit
);
(
bx
.mul
(
info
.unwrap
(),
CodegenCx
::
c_usize
(
bx
.cx
(),
size
.bytes
())),
CodegenCx
::
c_usize
(
bx
.cx
(),
align
.abi
()))
(
bx
.mul
(
info
.unwrap
(),
bx
.cx
()
.c_usize
(
size
.bytes
())),
bx
.cx
()
.c_usize
(
align
.abi
()))
}
_
=>
{
let
cx
=
bx
.cx
();
...
...
@@ -93,8 +93,8 @@ pub fn size_and_align_of_dst(
// Choose max of two known alignments (combined value must
// be aligned according to more restrictive of the two).
let
align
=
match
(
CodegenCx
::
const_to_opt_u128
(
sized_align
,
false
),
CodegenCx
::
const_to_opt_u128
(
unsized_align
,
false
))
{
let
align
=
match
(
bx
.cx
()
.
const_to_opt_u128
(
sized_align
,
false
),
bx
.cx
()
.
const_to_opt_u128
(
unsized_align
,
false
))
{
(
Some
(
sized_align
),
Some
(
unsized_align
))
=>
{
// If both alignments are constant, (the sized_align should always be), then
// pick the correct alignment statically.
...
...
src/librustc_codegen_llvm/interfaces/common.rs
浏览文件 @
6c5b990c
...
...
@@ -40,16 +40,16 @@ fn c_struct(
elts
:
&
[
Self
::
Value
],
packed
:
bool
)
->
Self
::
Value
;
fn
c_array
(
ty
:
Self
::
Type
,
elts
:
&
[
Self
::
Value
])
->
Self
::
Value
;
fn
c_vector
(
elts
:
&
[
Self
::
Value
])
->
Self
::
Value
;
fn
c_array
(
&
self
,
ty
:
Self
::
Type
,
elts
:
&
[
Self
::
Value
])
->
Self
::
Value
;
fn
c_vector
(
&
self
,
elts
:
&
[
Self
::
Value
])
->
Self
::
Value
;
fn
c_bytes
(
&
self
,
bytes
:
&
[
u8
])
->
Self
::
Value
;
fn
const_get_elt
(
v
:
Self
::
Value
,
idx
:
u64
)
->
Self
::
Value
;
fn
const_get_real
(
v
:
Self
::
Value
)
->
Option
<
(
f64
,
bool
)
>
;
fn
const_to_uint
(
v
:
Self
::
Value
)
->
u64
;
fn
is_const_integral
(
v
:
Self
::
Value
)
->
bool
;
fn
is_const_real
(
v
:
Self
::
Value
)
->
bool
;
fn
const_to_opt_u128
(
v
:
Self
::
Value
,
sign_ext
:
bool
)
->
Option
<
u128
>
;
fn
const_get_elt
(
&
self
,
v
:
Self
::
Value
,
idx
:
u64
)
->
Self
::
Value
;
fn
const_get_real
(
&
self
,
v
:
Self
::
Value
)
->
Option
<
(
f64
,
bool
)
>
;
fn
const_to_uint
(
&
self
,
v
:
Self
::
Value
)
->
u64
;
fn
is_const_integral
(
&
self
,
v
:
Self
::
Value
)
->
bool
;
fn
is_const_real
(
&
self
,
v
:
Self
::
Value
)
->
bool
;
fn
const_to_opt_u128
(
&
self
,
v
:
Self
::
Value
,
sign_ext
:
bool
)
->
Option
<
u128
>
;
}
pub
trait
CommonWriteMethods
:
Backend
{
...
...
src/librustc_codegen_llvm/intrinsic.rs
浏览文件 @
6c5b990c
...
...
@@ -1114,8 +1114,8 @@ fn generic_simd_intrinsic(
let
indices
:
Option
<
Vec
<
_
>>
=
(
0
..
n
)
.map
(|
i
|
{
let
arg_idx
=
i
;
let
val
=
CodegenCx
::
const_get_elt
(
vector
,
i
as
u64
);
match
CodegenCx
::
const_to_opt_u128
(
val
,
true
)
{
let
val
=
bx
.cx
()
.
const_get_elt
(
vector
,
i
as
u64
);
match
bx
.cx
()
.
const_to_opt_u128
(
val
,
true
)
{
None
=>
{
emit_error!
(
"shuffle index #{} is not a constant"
,
arg_idx
);
None
...
...
@@ -1136,7 +1136,7 @@ fn generic_simd_intrinsic(
return
Ok
(
bx
.shuffle_vector
(
args
[
0
]
.immediate
(),
args
[
1
]
.immediate
(),
CodegenCx
::
c_vector
(
&
indices
)))
bx
.cx
()
.
c_vector
(
&
indices
)))
}
if
name
==
"simd_insert"
{
...
...
@@ -1549,7 +1549,7 @@ fn non_ptr(t: ty::Ty) -> ty::Ty {
// code is generated
// * if the accumulator of the fmul isn't 1, incorrect
// code is generated
match
CodegenCx
::
const_get_real
(
acc
)
{
match
bx
.cx
()
.
const_get_real
(
acc
)
{
None
=>
return_error!
(
"accumulator of {} is not a constant"
,
$name
),
Some
((
v
,
loses_info
))
=>
{
if
$name
.contains
(
"mul"
)
&&
v
!=
1.0_f64
{
...
...
src/librustc_codegen_llvm/mir/block.rs
浏览文件 @
6c5b990c
...
...
@@ -324,7 +324,7 @@ fn codegen_terminator(&mut self,
mir
::
TerminatorKind
::
Assert
{
ref
cond
,
expected
,
ref
msg
,
target
,
cleanup
}
=>
{
let
cond
=
self
.codegen_operand
(
&
bx
,
cond
)
.immediate
();
let
mut
const_cond
=
CodegenCx
::
const_to_opt_u128
(
cond
,
false
)
.map
(|
c
|
c
==
1
);
let
mut
const_cond
=
bx
.cx
()
.
const_to_opt_u128
(
cond
,
false
)
.map
(|
c
|
c
==
1
);
// This case can currently arise only from functions marked
// with #[rustc_inherit_overflow_checks] and inlined from
...
...
src/librustc_codegen_llvm/mir/rvalue.rs
浏览文件 @
6c5b990c
...
...
@@ -20,7 +20,6 @@
use
builder
::
Builder
;
use
callee
;
use
common
::{
self
,
IntPredicate
,
RealPredicate
};
use
context
::
CodegenCx
;
use
consts
;
use
monomorphize
;
use
type_
::
Type
;
...
...
@@ -110,7 +109,7 @@ pub fn codegen_rvalue(&mut self,
let
size
=
bx
.cx
()
.c_usize
(
dest
.layout.size
.bytes
());
// Use llvm.memset.p0i8.* to initialize all zero arrays
if
CodegenCx
::
is_const_integral
(
v
)
&&
CodegenCx
::
const_to_uint
(
v
)
==
0
{
if
bx
.cx
()
.is_const_integral
(
v
)
&&
bx
.cx
()
.
const_to_uint
(
v
)
==
0
{
let
fill
=
bx
.cx
()
.c_u8
(
0
);
base
::
call_memset
(
&
bx
,
start
,
fill
,
size
,
align
,
false
);
return
bx
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录