Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
0514c7b1
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,发现更多精彩内容 >>
提交
0514c7b1
编写于
9月 07, 2018
作者:
D
Denis Merigoux
提交者:
Eduard-Mihai Burtescu
11月 16, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Generalized some base.rs methods
上级
c487b825
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
99 addition
and
50 deletion
+99
-50
src/librustc_codegen_llvm/base.rs
src/librustc_codegen_llvm/base.rs
+40
-31
src/librustc_codegen_llvm/builder.rs
src/librustc_codegen_llvm/builder.rs
+3
-4
src/librustc_codegen_llvm/common.rs
src/librustc_codegen_llvm/common.rs
+22
-3
src/librustc_codegen_llvm/interfaces/backend.rs
src/librustc_codegen_llvm/interfaces/backend.rs
+2
-3
src/librustc_codegen_llvm/interfaces/builder.rs
src/librustc_codegen_llvm/interfaces/builder.rs
+1
-3
src/librustc_codegen_llvm/interfaces/type_.rs
src/librustc_codegen_llvm/interfaces/type_.rs
+2
-1
src/librustc_codegen_llvm/intrinsic.rs
src/librustc_codegen_llvm/intrinsic.rs
+1
-1
src/librustc_codegen_llvm/llvm/ffi.rs
src/librustc_codegen_llvm/llvm/ffi.rs
+24
-0
src/librustc_codegen_llvm/type_.rs
src/librustc_codegen_llvm/type_.rs
+4
-4
未找到文件。
src/librustc_codegen_llvm/base.rs
浏览文件 @
0514c7b1
...
...
@@ -30,7 +30,7 @@
use
abi
;
use
back
::
write
::{
self
,
OngoingCodegen
};
use
llvm
::{
self
,
TypeKind
,
get_param
};
use
llvm
::{
self
,
get_param
};
use
metadata
;
use
rustc
::
dep_graph
::
cgu_reuse_tracker
::
CguReuse
;
use
rustc
::
hir
::
def_id
::{
CrateNum
,
DefId
,
LOCAL_CRATE
};
...
...
@@ -54,7 +54,7 @@
use
builder
::{
Builder
,
MemFlags
};
use
callee
;
use
rustc_mir
::
monomorphize
::
item
::
DefPathBasedNames
;
use
common
::{
self
,
IntPredicate
,
RealPredicate
};
use
common
::{
self
,
IntPredicate
,
RealPredicate
,
TypeKind
};
use
consts
;
use
context
::
CodegenCx
;
use
debuginfo
;
...
...
@@ -66,7 +66,6 @@
use
rustc_codegen_utils
::
symbol_names_test
;
use
time_graph
;
use
mono_item
::{
MonoItem
,
MonoItemExt
};
use
type_
::
Type
;
use
type_of
::
LayoutLlvmExt
;
use
rustc
::
util
::
nodemap
::
FxHashMap
;
use
CrateInfo
;
...
...
@@ -333,21 +332,31 @@ pub fn coerce_unsized_into(
}
}
pub
fn
cast_shift_expr_rhs
(
bx
:
&
Builder
<
'_
,
'll
,
'_
>
,
op
:
hir
::
BinOpKind
,
lhs
:
&
'll
Value
,
rhs
:
&
'll
Value
)
->
&
'll
Value
{
pub
fn
cast_shift_expr_rhs
<
'a
,
'tcx
:
'a
,
Builder
:
BuilderMethods
<
'a
,
'tcx
>>
(
bx
:
&
Builder
,
op
:
hir
::
BinOpKind
,
lhs
:
Builder
::
Value
,
rhs
:
Builder
::
Value
)
->
Builder
::
Value
{
cast_shift_rhs
(
bx
,
op
,
lhs
,
rhs
,
|
a
,
b
|
bx
.trunc
(
a
,
b
),
|
a
,
b
|
bx
.zext
(
a
,
b
))
}
fn
cast_shift_rhs
<
'll
,
F
,
G
>
(
bx
:
&
Builder
<
'_
,
'll
,
'_
>
,
op
:
hir
::
BinOpKind
,
lhs
:
&
'll
Value
,
rhs
:
&
'll
Value
,
trunc
:
F
,
zext
:
G
)
->
&
'll
Value
where
F
:
FnOnce
(
&
'll
Value
,
&
'll
Type
)
->
&
'll
Value
,
G
:
FnOnce
(
&
'll
Value
,
&
'll
Type
)
->
&
'll
Value
fn
cast_shift_rhs
<
'a
,
'tcx
:
'a
,
F
,
G
,
Builder
:
BuilderMethods
<
'a
,
'tcx
>>
(
bx
:
&
Builder
,
op
:
hir
::
BinOpKind
,
lhs
:
Builder
::
Value
,
rhs
:
Builder
::
Value
,
trunc
:
F
,
zext
:
G
)
->
Builder
::
Value
where
F
:
FnOnce
(
Builder
::
Value
,
Builder
::
Type
)
->
Builder
::
Value
,
G
:
FnOnce
(
Builder
::
Value
,
Builder
::
Type
)
->
Builder
::
Value
{
// Shifts may have any size int on the rhs
if
op
.is_shift
()
{
...
...
@@ -389,10 +398,10 @@ pub fn call_assume(bx: &Builder<'_, 'll, '_>, val: &'ll Value) {
bx
.call
(
assume_intrinsic
,
&
[
val
],
None
);
}
pub
fn
from_immediate
<
'a
,
'
ll
:
'a
,
'tcx
:
'll
>
(
bx
:
&
Builder
<
'_
,
'll
,
'_
,
&
'll
Value
>
,
val
:
&
'll
Value
)
->
&
'll
Value
{
pub
fn
from_immediate
<
'a
,
'
tcx
:
'a
,
Builder
:
BuilderMethods
<
'a
,
'tcx
>
>
(
bx
:
&
Builder
,
val
:
Builder
::
Value
)
->
Builder
::
Value
{
if
bx
.cx
()
.val_ty
(
val
)
==
bx
.cx
()
.type_i1
()
{
bx
.zext
(
val
,
bx
.cx
()
.type_i8
())
}
else
{
...
...
@@ -400,30 +409,30 @@ pub fn from_immediate<'a, 'll: 'a, 'tcx: 'll>(
}
}
pub
fn
to_immediate
(
bx
:
&
Builder
<
'_
,
'll
,
'_
>
,
val
:
&
'll
Value
,
pub
fn
to_immediate
<
'a
,
'tcx
:
'a
,
Builder
:
BuilderMethods
<
'a
,
'tcx
>>
(
bx
:
&
Builder
,
val
:
Builder
::
Value
,
layout
:
layout
::
TyLayout
,
)
->
&
'll
Value
{
)
->
Builder
::
Value
{
if
let
layout
::
Abi
::
Scalar
(
ref
scalar
)
=
layout
.abi
{
return
to_immediate_scalar
(
bx
,
val
,
scalar
);
}
val
}
pub
fn
to_immediate_scalar
(
bx
:
&
Builder
<
'_
,
'll
,
'_
>
,
val
:
&
'll
Value
,
pub
fn
to_immediate_scalar
<
'a
,
'tcx
:
'a
,
Builder
:
BuilderMethods
<
'a
,
'tcx
>>
(
bx
:
&
Builder
,
val
:
Builder
::
Value
,
scalar
:
&
layout
::
Scalar
,
)
->
&
'll
Value
{
)
->
Builder
::
Value
{
if
scalar
.is_bool
()
{
return
bx
.trunc
(
val
,
bx
.cx
()
.type_i1
());
}
val
}
pub
fn
call_memcpy
<
'a
,
'll
:
'a
,
'tcx
:
'll
>
(
bx
:
&
Builder
<
'_
,
'll
,
'_
,
&
'll
Value
>
,
pub
fn
call_memcpy
(
bx
:
&
Builder
<
'_
,
'll
,
'_
>
,
dst
:
&
'll
Value
,
dst_align
:
Align
,
src
:
&
'll
Value
,
...
...
@@ -446,8 +455,8 @@ pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll>(
bx
.memcpy
(
dst_ptr
,
dst_align
.abi
(),
src_ptr
,
src_align
.abi
(),
size
,
volatile
);
}
pub
fn
memcpy_ty
<
'a
,
'll
:
'a
,
'tcx
:
'll
>
(
bx
:
&
Builder
<
'_
,
'll
,
'_
,
&
'll
Value
>
,
pub
fn
memcpy_ty
(
bx
:
&
Builder
<
'_
,
'll
,
'_
>
,
dst
:
&
'll
Value
,
dst_align
:
Align
,
src
:
&
'll
Value
,
...
...
src/librustc_codegen_llvm/builder.rs
浏览文件 @
0514c7b1
...
...
@@ -60,7 +60,6 @@ impl Backend for Builder<'a, 'll, 'tcx> {
type
Value
=
&
'll
Value
;
type
BasicBlock
=
&
'll
BasicBlock
;
type
Type
=
&
'll
Type
;
type
TypeKind
=
llvm
::
TypeKind
;
type
Context
=
&
'll
llvm
::
Context
;
}
...
...
@@ -1146,7 +1145,7 @@ fn check_store<'b>(&self,
let
stored_ty
=
self
.cx
.val_ty
(
val
);
let
stored_ptr_ty
=
self
.cx
.type_ptr_to
(
stored_ty
);
assert_eq!
(
self
.cx
.type_kind
(
dest_ptr_ty
),
llvm
::
TypeKind
::
Pointer
);
assert_eq!
(
self
.cx
.type_kind
(
dest_ptr_ty
),
TypeKind
::
Pointer
);
if
dest_ptr_ty
==
stored_ptr_ty
{
ptr
...
...
@@ -1165,11 +1164,11 @@ fn check_call<'b>(&self,
args
:
&
'b
[
&
'll
Value
])
->
Cow
<
'b
,
[
&
'll
Value
]
>
{
let
mut
fn_ty
=
self
.cx
.val_ty
(
llfn
);
// Strip off pointers
while
self
.cx
.type_kind
(
fn_ty
)
==
llvm
::
TypeKind
::
Pointer
{
while
self
.cx
.type_kind
(
fn_ty
)
==
TypeKind
::
Pointer
{
fn_ty
=
self
.cx
.element_type
(
fn_ty
);
}
assert
!
(
self
.cx
.type_kind
(
fn_ty
)
==
llvm
::
TypeKind
::
Function
,
assert
!
(
self
.cx
.type_kind
(
fn_ty
)
==
TypeKind
::
Function
,
"builder::{} not passed a function, but {:?}"
,
typ
,
fn_ty
);
let
param_tys
=
self
.cx
.func_params_types
(
fn_ty
);
...
...
src/librustc_codegen_llvm/common.rs
浏览文件 @
0514c7b1
...
...
@@ -12,8 +12,7 @@
//! Code that is useful in various codegen modules.
use
llvm
::{
self
,
TypeKind
};
use
llvm
::{
True
,
False
,
Bool
,
BasicBlock
};
use
llvm
::{
self
,
True
,
False
,
Bool
,
BasicBlock
};
use
rustc
::
hir
::
def_id
::
DefId
;
use
rustc
::
middle
::
lang_items
::
LangItem
;
use
abi
;
...
...
@@ -131,6 +130,27 @@ pub enum SynchronizationScope {
CrossThread
,
}
#[derive(Copy,
Clone,
PartialEq,
Debug)]
pub
enum
TypeKind
{
Void
,
Half
,
Float
,
Double
,
X86_FP80
,
FP128
,
PPc_FP128
,
Label
,
Integer
,
Function
,
Struct
,
Array
,
Pointer
,
Vector
,
Metadata
,
X86_MMX
,
Token
,
}
/*
* A note on nomenclature of linking: "extern", "foreign", and "upcall".
*
...
...
@@ -197,7 +217,6 @@ impl Backend for CodegenCx<'ll, 'tcx> {
type
Value
=
&
'll
Value
;
type
BasicBlock
=
&
'll
BasicBlock
;
type
Type
=
&
'll
Type
;
type
TypeKind
=
llvm
::
TypeKind
;
type
Context
=
&
'll
llvm
::
Context
;
}
...
...
src/librustc_codegen_llvm/interfaces/backend.rs
浏览文件 @
0514c7b1
...
...
@@ -11,9 +11,8 @@
use
std
::
fmt
::
Debug
;
pub
trait
Backend
{
type
Value
:
Debug
+
PartialEq
;
type
Value
:
Debug
+
PartialEq
+
Copy
;
type
BasicBlock
;
type
Type
:
Debug
+
PartialEq
;
type
TypeKind
;
type
Type
:
Debug
+
PartialEq
+
Copy
;
type
Context
;
}
src/librustc_codegen_llvm/interfaces/builder.rs
浏览文件 @
0514c7b1
...
...
@@ -23,13 +23,11 @@
use
syntax
::
ast
::
AsmDialect
;
pub
trait
BuilderMethods
<
'a
,
'tcx
:
'a
>
:
Backend
{
type
CodegenCx
:
TypeMethods
+
ConstMethods
+
Backend
<
type
CodegenCx
:
'a
+
TypeMethods
+
ConstMethods
+
Backend
<
Value
=
Self
::
Value
,
BasicBlock
=
Self
::
BasicBlock
,
Type
=
Self
::
Type
,
TypeKind
=
Self
::
TypeKind
,
Context
=
Self
::
Context
,
>
;
...
...
src/librustc_codegen_llvm/interfaces/type_.rs
浏览文件 @
0514c7b1
...
...
@@ -9,6 +9,7 @@
// except according to those terms.
use
super
::
backend
::
Backend
;
use
common
::
TypeKind
;
pub
trait
TypeMethods
:
Backend
{
fn
type_void
(
&
self
)
->
Self
::
Type
;
...
...
@@ -30,7 +31,7 @@ pub trait TypeMethods: Backend {
fn
type_named_struct
(
&
self
,
name
:
&
str
)
->
Self
::
Type
;
fn
type_array
(
&
self
,
ty
:
Self
::
Type
,
len
:
u64
)
->
Self
::
Type
;
fn
type_vector
(
&
self
,
ty
:
Self
::
Type
,
len
:
u64
)
->
Self
::
Type
;
fn
type_kind
(
&
self
,
ty
:
Self
::
Type
)
->
Self
::
TypeKind
;
fn
type_kind
(
&
self
,
ty
:
Self
::
Type
)
->
TypeKind
;
fn
set_struct_body
(
&
self
,
ty
:
Self
::
Type
,
els
:
&
[
Self
::
Type
],
packed
:
bool
);
fn
type_ptr_to
(
&
self
,
ty
:
Self
::
Type
)
->
Self
::
Type
;
fn
element_type
(
&
self
,
ty
:
Self
::
Type
)
->
Self
::
Type
;
...
...
src/librustc_codegen_llvm/intrinsic.rs
浏览文件 @
0514c7b1
...
...
@@ -12,7 +12,7 @@
use
attributes
;
use
intrinsics
::{
self
,
Intrinsic
};
use
llvm
::{
self
,
TypeKind
}
;
use
llvm
;
use
llvm_util
;
use
abi
::{
Abi
,
FnType
,
LlvmType
,
PassMode
};
use
mir
::
place
::
PlaceRef
;
...
...
src/librustc_codegen_llvm/llvm/ffi.rs
浏览文件 @
0514c7b1
...
...
@@ -228,6 +228,30 @@ pub enum TypeKind {
Token
=
16
,
}
impl
TypeKind
{
pub
fn
to_generic
(
self
)
->
common
::
TypeKind
{
match
self
{
TypeKind
::
Void
=>
common
::
TypeKind
::
Void
,
TypeKind
::
Half
=>
common
::
TypeKind
::
Half
,
TypeKind
::
Float
=>
common
::
TypeKind
::
Float
,
TypeKind
::
Double
=>
common
::
TypeKind
::
Double
,
TypeKind
::
X86_FP80
=>
common
::
TypeKind
::
X86_FP80
,
TypeKind
::
FP128
=>
common
::
TypeKind
::
FP128
,
TypeKind
::
PPc_FP128
=>
common
::
TypeKind
::
PPc_FP128
,
TypeKind
::
Label
=>
common
::
TypeKind
::
Label
,
TypeKind
::
Integer
=>
common
::
TypeKind
::
Integer
,
TypeKind
::
Function
=>
common
::
TypeKind
::
Function
,
TypeKind
::
Struct
=>
common
::
TypeKind
::
Struct
,
TypeKind
::
Array
=>
common
::
TypeKind
::
Array
,
TypeKind
::
Pointer
=>
common
::
TypeKind
::
Pointer
,
TypeKind
::
Vector
=>
common
::
TypeKind
::
Vector
,
TypeKind
::
Metadata
=>
common
::
TypeKind
::
Metadata
,
TypeKind
::
X86_MMX
=>
common
::
TypeKind
::
X86_MMX
,
TypeKind
::
Token
=>
common
::
TypeKind
::
Token
,
}
}
}
/// LLVMAtomicRmwBinOp
#[derive(Copy,
Clone)]
#[repr(C)]
...
...
src/librustc_codegen_llvm/type_.rs
浏览文件 @
0514c7b1
...
...
@@ -13,16 +13,16 @@
pub
use
llvm
::
Type
;
use
llvm
;
use
llvm
::{
Bool
,
False
,
True
,
TypeKind
};
use
llvm
::{
Bool
,
False
,
True
};
use
context
::
CodegenCx
;
use
interfaces
::
TypeMethods
;
use
value
::
Value
;
use
syntax
::
ast
;
use
rustc
::
ty
::
layout
::{
self
,
Align
,
Size
};
use
rustc_data_structures
::
small_c_str
::
SmallCStr
;
use
common
;
use
common
::{
self
,
TypeKind
}
;
use
std
::
fmt
;
...
...
@@ -175,7 +175,7 @@ fn type_vector(&self, ty: &'ll Type, len: u64) -> &'ll Type {
fn
type_kind
(
&
self
,
ty
:
&
'll
Type
)
->
TypeKind
{
unsafe
{
llvm
::
LLVMRustGetTypeKind
(
ty
)
llvm
::
LLVMRustGetTypeKind
(
ty
)
.to_generic
()
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录