Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9c41e1aa
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,发现更多精彩内容 >>
提交
9c41e1aa
编写于
8月 22, 2018
作者:
D
Denis Merigoux
提交者:
Eduard-Mihai Burtescu
11月 16, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed genericity over Value in various functions
Prelude to using associated types in traits rather than type parameters
上级
1ca75068
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
165 addition
and
194 deletion
+165
-194
src/librustc_codegen_llvm/abi.rs
src/librustc_codegen_llvm/abi.rs
+4
-4
src/librustc_codegen_llvm/attributes.rs
src/librustc_codegen_llvm/attributes.rs
+1
-1
src/librustc_codegen_llvm/back/write.rs
src/librustc_codegen_llvm/back/write.rs
+1
-2
src/librustc_codegen_llvm/base.rs
src/librustc_codegen_llvm/base.rs
+5
-8
src/librustc_codegen_llvm/builder.rs
src/librustc_codegen_llvm/builder.rs
+8
-6
src/librustc_codegen_llvm/common.rs
src/librustc_codegen_llvm/common.rs
+12
-21
src/librustc_codegen_llvm/context.rs
src/librustc_codegen_llvm/context.rs
+21
-21
src/librustc_codegen_llvm/debuginfo/gdb.rs
src/librustc_codegen_llvm/debuginfo/gdb.rs
+1
-1
src/librustc_codegen_llvm/declare.rs
src/librustc_codegen_llvm/declare.rs
+9
-9
src/librustc_codegen_llvm/intrinsic.rs
src/librustc_codegen_llvm/intrinsic.rs
+10
-10
src/librustc_codegen_llvm/meth.rs
src/librustc_codegen_llvm/meth.rs
+1
-1
src/librustc_codegen_llvm/mir/block.rs
src/librustc_codegen_llvm/mir/block.rs
+2
-2
src/librustc_codegen_llvm/mir/mod.rs
src/librustc_codegen_llvm/mir/mod.rs
+1
-1
src/librustc_codegen_llvm/mir/operand.rs
src/librustc_codegen_llvm/mir/operand.rs
+7
-9
src/librustc_codegen_llvm/mir/place.rs
src/librustc_codegen_llvm/mir/place.rs
+1
-1
src/librustc_codegen_llvm/mir/rvalue.rs
src/librustc_codegen_llvm/mir/rvalue.rs
+5
-5
src/librustc_codegen_llvm/traits.rs
src/librustc_codegen_llvm/traits.rs
+3
-3
src/librustc_codegen_llvm/type_.rs
src/librustc_codegen_llvm/type_.rs
+71
-72
src/librustc_codegen_llvm/type_of.rs
src/librustc_codegen_llvm/type_of.rs
+2
-3
src/librustc_codegen_llvm/value.rs
src/librustc_codegen_llvm/value.rs
+0
-14
未找到文件。
src/librustc_codegen_llvm/abi.rs
浏览文件 @
9c41e1aa
...
...
@@ -121,7 +121,7 @@ fn llvm_type(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type {
}
}
RegKind
::
Vector
=>
{
Type
::
vector
::
<
Value
>
(
Type
::
i8
(
cx
),
self
.size
.bytes
())
Type
::
vector
(
Type
::
i8
(
cx
),
self
.size
.bytes
())
}
}
}
...
...
@@ -145,7 +145,7 @@ fn llvm_type(&self, cx: &CodegenCx<'ll, '_>) -> &'ll Type {
// Simplify to array when all chunks are the same size and type
if
rem_bytes
==
0
{
return
Type
::
array
::
<
Value
>
(
rest_ll_unit
,
rest_count
);
return
Type
::
array
(
rest_ll_unit
,
rest_count
);
}
}
...
...
@@ -675,9 +675,9 @@ fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
}
if
self
.variadic
{
Type
::
variadic_func
::
<
Value
>
(
&
llargument_tys
,
llreturn_ty
)
Type
::
variadic_func
(
&
llargument_tys
,
llreturn_ty
)
}
else
{
Type
::
func
::
<
Value
>
(
&
llargument_tys
,
llreturn_ty
)
Type
::
func
(
&
llargument_tys
,
llreturn_ty
)
}
}
...
...
src/librustc_codegen_llvm/attributes.rs
浏览文件 @
9c41e1aa
...
...
@@ -127,7 +127,7 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
.filter
(|
l
|
!
l
.is_empty
())
}
pub
fn
apply_target_cpu_attr
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
,
llfn
:
&
'll
Value
)
{
pub
fn
apply_target_cpu_attr
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
llfn
:
&
'll
Value
)
{
let
cpu
=
llvm_util
::
target_cpu
(
cx
.tcx.sess
);
let
target_cpu
=
CString
::
new
(
cpu
)
.unwrap
();
llvm
::
AddFunctionAttrStringValue
(
...
...
src/librustc_codegen_llvm/back/write.rs
浏览文件 @
9c41e1aa
...
...
@@ -49,7 +49,6 @@
use
common
::{
C_bytes_in_context
,
val_ty
};
use
jobserver
::{
Client
,
Acquired
};
use
rustc_demangle
;
use
value
::
Value
;
use
std
::
any
::
Any
;
use
std
::
ffi
::{
CString
,
CStr
};
...
...
@@ -2575,7 +2574,7 @@ fn create_msvc_imps(cgcx: &CodegenContext, llcx: &llvm::Context, llmod: &llvm::M
"
\x01
__imp_"
};
unsafe
{
let
i8p_ty
=
Type
::
i8p_llcx
::
<
Value
>
(
llcx
);
let
i8p_ty
=
Type
::
i8p_llcx
(
llcx
);
let
globals
=
base
::
iter_globals
(
llmod
)
.filter
(|
&
val
|
{
llvm
::
LLVMRustGetLinkage
(
val
)
==
llvm
::
Linkage
::
ExternalLinkage
&&
...
...
src/librustc_codegen_llvm/base.rs
浏览文件 @
9c41e1aa
...
...
@@ -89,7 +89,7 @@
use
syntax
::
attr
;
use
rustc
::
hir
::{
self
,
CodegenFnAttrs
};
use
value
::
{
Value
,
ValueTrait
}
;
use
value
::
Value
;
use
mir
::
operand
::
OperandValue
;
...
...
@@ -391,11 +391,10 @@ pub fn call_assume(bx: &Builder<'_, 'll, '_>, val: &'ll Value) {
}
pub
fn
from_immediate
<
'a
,
'll
:
'a
,
'tcx
:
'll
,
Value
:
?
Sized
,
Builder
:
BuilderMethods
<
'a
,
'll
,
'tcx
,
Value
,
BasicBlock
>>
(
bx
:
&
Builder
,
val
:
&
'll
Value
)
->
&
'll
Value
where
Value
:
ValueTrait
{
)
->
&
'll
Value
{
if
val_ty
(
val
)
==
Type
::
i1
(
bx
.cx
())
{
bx
.zext
(
val
,
Type
::
i8
(
bx
.cx
()))
}
else
{
...
...
@@ -426,7 +425,6 @@ pub fn to_immediate_scalar(
}
pub
fn
call_memcpy
<
'a
,
'll
:
'a
,
'tcx
:
'll
,
Value
:
?
Sized
,
Builder
:
BuilderMethods
<
'a
,
'll
,
'tcx
,
Value
,
BasicBlock
>>
(
bx
:
&
Builder
,
dst
:
&
'll
Value
,
...
...
@@ -435,7 +433,7 @@ pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll,
src_align
:
Align
,
n_bytes
:
&
'll
Value
,
flags
:
MemFlags
,
)
where
Value
:
ValueTrait
{
)
{
if
flags
.contains
(
MemFlags
::
NONTEMPORAL
)
{
// HACK(nox): This is inefficient but there is no nontemporal memcpy.
let
val
=
bx
.load
(
src
,
src_align
);
...
...
@@ -452,7 +450,6 @@ pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll,
}
pub
fn
memcpy_ty
<
'a
,
'll
:
'a
,
'tcx
:
'll
,
Value
:
?
Sized
,
Builder
:
BuilderMethods
<
'a
,
'll
,
'tcx
,
Value
,
BasicBlock
>>
(
bx
:
&
Builder
,
dst
:
&
'll
Value
,
...
...
@@ -461,7 +458,7 @@ pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll,
src_align
:
Align
,
layout
:
TyLayout
<
'tcx
>
,
flags
:
MemFlags
,
)
where
Value
:
ValueTrait
{
)
{
let
size
=
layout
.size
.bytes
();
if
size
==
0
{
return
;
...
...
@@ -558,7 +555,7 @@ fn create_entry_fn(
use_start_lang_item
:
bool
,
)
{
let
llfty
=
Type
::
func
::
<
Value
>
(
&
[
Type
::
c_int
(
cx
),
Type
::
i8p
(
cx
)
.ptr_to
()],
Type
::
c_int
(
cx
));
Type
::
func
(
&
[
Type
::
c_int
(
cx
),
Type
::
i8p
(
cx
)
.ptr_to
()],
Type
::
c_int
(
cx
));
let
main_ret_ty
=
cx
.tcx
.fn_sig
(
rust_main_def_id
)
.output
();
// Given that `main()` has no arguments,
...
...
src/librustc_codegen_llvm/builder.rs
浏览文件 @
9c41e1aa
...
...
@@ -200,7 +200,8 @@ fn invoke(&self,
args
);
let
args
=
self
.check_call
(
"invoke"
,
llfn
,
args
);
let
bundle
=
bundle
.map
(|
b
|
&*
(
OperandBundleDef
::
from_generic
(
b
))
.raw
);
let
bundle
=
bundle
.map
(
OperandBundleDef
::
from_generic
);
let
bundle
=
bundle
.as_ref
()
.map
(|
b
|
&*
b
.raw
);
unsafe
{
llvm
::
LLVMRustBuildInvoke
(
self
.llbuilder
,
...
...
@@ -757,7 +758,7 @@ fn inline_asm_call(&self, asm: *const c_char, cons: *const c_char,
})
.collect
::
<
Vec
<
_
>>
();
debug!
(
"Asm Output Type: {:?}"
,
output
);
let
fty
=
Type
::
func
::
<
Value
>
(
&
argtys
[
..
],
output
);
let
fty
=
Type
::
func
(
&
argtys
[
..
],
output
);
unsafe
{
// Ask LLVM to verify that the constraints are well-formed.
let
constraints_ok
=
llvm
::
LLVMRustInlineAsmVerify
(
fty
,
cons
);
...
...
@@ -853,9 +854,9 @@ fn shuffle_vector(&self, v1: &'ll Value, v2: &'ll Value, mask: &'ll Value) -> &'
fn
vector_splat
(
&
self
,
num_elts
:
usize
,
elt
:
&
'll
Value
)
->
&
'll
Value
{
unsafe
{
let
elt_ty
=
val_ty
(
elt
);
let
undef
=
llvm
::
LLVMGetUndef
(
Type
::
vector
::
<
Value
>
(
elt_ty
,
num_elts
as
u64
));
let
undef
=
llvm
::
LLVMGetUndef
(
Type
::
vector
(
elt_ty
,
num_elts
as
u64
));
let
vec
=
self
.insert_element
(
undef
,
elt
,
C_i32
(
self
.cx
,
0
));
let
vec_i32_ty
=
Type
::
vector
::
<
Value
>
(
Type
::
i32
(
self
.cx
),
num_elts
as
u64
);
let
vec_i32_ty
=
Type
::
vector
(
Type
::
i32
(
self
.cx
),
num_elts
as
u64
);
self
.shuffle_vector
(
vec
,
undef
,
C_null
(
vec_i32_ty
))
}
}
...
...
@@ -1232,7 +1233,8 @@ fn call(&self, llfn: &'ll Value, args: &[&'ll Value],
args
);
let
args
=
self
.check_call
(
"call"
,
llfn
,
args
);
let
bundle
=
bundle
.map
(|
b
|
&*
(
OperandBundleDef
::
from_generic
(
b
))
.raw
);
let
bundle
=
bundle
.map
(
OperandBundleDef
::
from_generic
);
let
bundle
=
bundle
.as_ref
()
.map
(|
b
|
&*
b
.raw
);
unsafe
{
llvm
::
LLVMRustBuildCall
(
...
...
@@ -1260,7 +1262,7 @@ fn struct_gep(&self, ptr: &'ll Value, idx: u64) -> &'ll Value {
}
}
fn
cx
(
&
self
)
->
&
'a
CodegenCx
<
'll
,
'tcx
,
&
'll
Value
>
{
fn
cx
(
&
self
)
->
&
'a
CodegenCx
<
'll
,
'tcx
>
{
&
self
.cx
}
}
src/librustc_codegen_llvm/common.rs
浏览文件 @
9c41e1aa
...
...
@@ -23,7 +23,7 @@
use
declare
;
use
type_
::
Type
;
use
type_of
::
LayoutLlvmExt
;
use
value
::
{
Value
,
ValueTrait
}
;
use
value
::
Value
;
use
rustc
::
ty
::{
self
,
Ty
,
TyCtxt
};
use
rustc
::
ty
::
layout
::{
HasDataLayout
,
LayoutOf
};
...
...
@@ -111,9 +111,9 @@ pub fn bundle(&self) -> &OperandBundleDef<'ll, &'ll Value> {
}
}
pub
fn
val_ty
<
Value
:
?
Sized
>
(
v
:
&
'll
Value
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
val_ty
(
v
:
&
'll
Value
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMTypeOf
(
v
.to_llvm
()
)
llvm
::
LLVMTypeOf
(
v
)
}
}
...
...
@@ -124,21 +124,21 @@ pub fn C_null(t: &'ll Type) -> &'ll Value {
}
}
pub
fn
C_undef
<
Value
:
?
Sized
>
(
t
:
&
'll
Type
)
->
&
'll
Value
where
Value
:
ValueTrait
{
pub
fn
C_undef
(
t
:
&
'll
Type
)
->
&
'll
Value
{
unsafe
{
Value
::
of_llvm
(
llvm
::
LLVMGetUndef
(
t
)
)
llvm
::
LLVMGetUndef
(
t
)
}
}
pub
fn
C_int
<
Value
:
?
Sized
>
(
t
:
&
'll
Type
,
i
:
i64
)
->
&
'll
Value
where
Value
:
ValueTrait
{
pub
fn
C_int
(
t
:
&
'll
Type
,
i
:
i64
)
->
&
'll
Value
{
unsafe
{
Value
::
of_llvm
(
llvm
::
LLVMConstInt
(
t
,
i
as
u64
,
True
)
)
llvm
::
LLVMConstInt
(
t
,
i
as
u64
,
True
)
}
}
pub
fn
C_uint
<
Value
:
?
Sized
>
(
t
:
&
'll
Type
,
i
:
u64
)
->
&
'll
Value
where
Value
:
ValueTrait
{
pub
fn
C_uint
(
t
:
&
'll
Type
,
i
:
u64
)
->
&
'll
Value
{
unsafe
{
Value
::
of_llvm
(
llvm
::
LLVMConstInt
(
t
,
i
,
False
)
)
llvm
::
LLVMConstInt
(
t
,
i
,
False
)
}
}
...
...
@@ -149,17 +149,11 @@ pub fn C_uint_big(t: &'ll Type, u: u128) -> &'ll Value {
}
}
pub
fn
C_bool
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
,
val
:
bool
)
->
&
'll
Value
where
Value
:
ValueTrait
{
pub
fn
C_bool
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
val
:
bool
)
->
&
'll
Value
{
C_uint
(
Type
::
i1
(
cx
),
val
as
u64
)
}
pub
fn
C_i32
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
,
i
:
i32
)
->
&
'll
Value
where
Value
:
ValueTrait
{
pub
fn
C_i32
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
i
:
i32
)
->
&
'll
Value
{
C_int
(
Type
::
i32
(
cx
),
i
as
i64
)
}
...
...
@@ -171,10 +165,7 @@ pub fn C_u64(cx: &CodegenCx<'ll, '_>, i: u64) -> &'ll Value {
C_uint
(
Type
::
i64
(
cx
),
i
)
}
pub
fn
C_usize
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
,
i
:
u64
)
->
&
'll
Value
where
Value
:
ValueTrait
{
pub
fn
C_usize
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
i
:
u64
)
->
&
'll
Value
{
let
bit_size
=
cx
.data_layout
()
.pointer_size
.bits
();
if
bit_size
<
64
{
// make sure it doesn't overflow
...
...
src/librustc_codegen_llvm/context.rs
浏览文件 @
9c41e1aa
...
...
@@ -18,7 +18,7 @@
use
base
;
use
declare
;
use
monomorphize
::
Instance
;
use
value
::
{
Value
,
ValueTrait
}
;
use
value
::
Value
;
use
monomorphize
::
partitioning
::
CodegenUnit
;
use
type_
::
Type
;
...
...
@@ -283,7 +283,7 @@ impl<'a, 'tcx> CodegenCx<'a, 'tcx> {
None
};
let
isize_ty
=
Type
::
ix_llcx
::
<
Value
>
(
llcx
,
tcx
.data_layout.pointer_size
.bits
());
let
isize_ty
=
Type
::
ix_llcx
(
llcx
,
tcx
.data_layout.pointer_size
.bits
());
CodegenCx
{
tcx
,
...
...
@@ -315,7 +315,7 @@ impl<'a, 'tcx> CodegenCx<'a, 'tcx> {
}
}
impl
<
'b
,
'tcx
,
Value
:
?
Sized
>
CodegenCx
<
'b
,
'tcx
,
&
'b
Value
>
where
Value
:
ValueTrait
{
impl
<
'b
,
'tcx
>
CodegenCx
<
'b
,
'tcx
>
{
pub
fn
sess
<
'a
>
(
&
'a
self
)
->
&
'a
Session
{
&
self
.tcx.sess
}
...
...
@@ -329,7 +329,7 @@ pub fn get_intrinsic(&self, key: &str) -> &'b Value {
}
}
impl
<
'b
,
'tcx
>
CodegenCx
<
'b
,
'tcx
,
&
'b
Value
>
{
impl
<
'b
,
'tcx
>
CodegenCx
<
'b
,
'tcx
>
{
/// Generate a new symbol name with the given prefix. This symbol name must
/// only be used for definitions with `internal` or `private` linkage.
pub
fn
generate_local_symbol_name
(
&
self
,
prefix
:
&
str
)
->
String
{
...
...
@@ -379,7 +379,7 @@ pub fn eh_personality(&self) -> &'b Value {
}
else
{
"rust_eh_personality"
};
let
fty
=
Type
::
variadic_func
::
<
Value
>
(
&
[],
Type
::
i32
(
self
));
let
fty
=
Type
::
variadic_func
(
&
[],
Type
::
i32
(
self
));
declare
::
declare_cfn
(
self
,
name
,
fty
)
}
};
...
...
@@ -480,31 +480,31 @@ fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
}
/// Declare any llvm intrinsics that you might need
fn
declare_intrinsic
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
,
fn
declare_intrinsic
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
key
:
&
str
)
->
Option
<&
'll
Value
>
where
Value
:
ValueTrait
{
)
->
Option
<&
'll
Value
>
{
macro_rules!
ifn
{
(
$name:expr
,
fn
()
->
$ret:expr
)
=>
(
if
key
==
$name
{
let
f
=
declare
::
declare_cfn
(
cx
,
$name
,
Type
::
func
::
<
Value
>
(
&
[],
$ret
));
llvm
::
SetUnnamedAddr
(
f
.to_llvm
()
,
false
);
let
f
=
declare
::
declare_cfn
(
cx
,
$name
,
Type
::
func
(
&
[],
$ret
));
llvm
::
SetUnnamedAddr
(
f
,
false
);
cx
.intrinsics
.borrow_mut
()
.insert
(
$name
,
f
.clone
());
return
Some
(
f
);
}
);
(
$name:expr
,
fn
(
...
)
->
$ret:expr
)
=>
(
if
key
==
$name
{
let
f
=
declare
::
declare_cfn
(
cx
,
$name
,
Type
::
variadic_func
::
<
Value
>
(
&
[],
$ret
));
llvm
::
SetUnnamedAddr
(
f
.to_llvm
()
,
false
);
let
f
=
declare
::
declare_cfn
(
cx
,
$name
,
Type
::
variadic_func
(
&
[],
$ret
));
llvm
::
SetUnnamedAddr
(
f
,
false
);
cx
.intrinsics
.borrow_mut
()
.insert
(
$name
,
f
.clone
());
return
Some
(
f
);
}
);
(
$name:expr
,
fn
(
$
(
$arg:expr
),
*
)
->
$ret:expr
)
=>
(
if
key
==
$name
{
let
f
=
declare
::
declare_cfn
(
cx
,
$name
,
Type
::
func
::
<
Value
>
(
&
[
$
(
$arg
),
*
],
$ret
));
llvm
::
SetUnnamedAddr
(
f
.to_llvm
()
,
false
);
let
f
=
declare
::
declare_cfn
(
cx
,
$name
,
Type
::
func
(
&
[
$
(
$arg
),
*
],
$ret
));
llvm
::
SetUnnamedAddr
(
f
,
false
);
cx
.intrinsics
.borrow_mut
()
.insert
(
$name
,
f
.clone
());
return
Some
(
f
);
}
...
...
@@ -525,14 +525,14 @@ fn declare_intrinsic<Value : ?Sized>(
let
t_f32
=
Type
::
f32
(
cx
);
let
t_f64
=
Type
::
f64
(
cx
);
let
t_v2f32
=
Type
::
vector
::
<
Value
>
(
t_f32
,
2
);
let
t_v4f32
=
Type
::
vector
::
<
Value
>
(
t_f32
,
4
);
let
t_v8f32
=
Type
::
vector
::
<
Value
>
(
t_f32
,
8
);
let
t_v16f32
=
Type
::
vector
::
<
Value
>
(
t_f32
,
16
);
let
t_v2f32
=
Type
::
vector
(
t_f32
,
2
);
let
t_v4f32
=
Type
::
vector
(
t_f32
,
4
);
let
t_v8f32
=
Type
::
vector
(
t_f32
,
8
);
let
t_v16f32
=
Type
::
vector
(
t_f32
,
16
);
let
t_v2f64
=
Type
::
vector
::
<
Value
>
(
t_f64
,
2
);
let
t_v4f64
=
Type
::
vector
::
<
Value
>
(
t_f64
,
4
);
let
t_v8f64
=
Type
::
vector
::
<
Value
>
(
t_f64
,
8
);
let
t_v2f64
=
Type
::
vector
(
t_f64
,
2
);
let
t_v4f64
=
Type
::
vector
(
t_f64
,
4
);
let
t_v8f64
=
Type
::
vector
(
t_f64
,
8
);
ifn!
(
"llvm.memset.p0i8.i16"
,
fn
(
i8p
,
t_i8
,
t_i16
,
t_i32
,
i1
)
->
void
);
ifn!
(
"llvm.memset.p0i8.i32"
,
fn
(
i8p
,
t_i8
,
t_i32
,
t_i32
,
i1
)
->
void
);
...
...
src/librustc_codegen_llvm/debuginfo/gdb.rs
浏览文件 @
9c41e1aa
...
...
@@ -56,7 +56,7 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>)
let
section_contents
=
b
"
\x01
gdb_load_rust_pretty_printers.py
\0
"
;
unsafe
{
let
llvm_type
=
Type
::
array
::
<
Value
>
(
Type
::
i8
(
cx
),
let
llvm_type
=
Type
::
array
(
Type
::
i8
(
cx
),
section_contents
.len
()
as
u64
);
let
section_var
=
declare
::
define_global
(
cx
,
section_var_name
,
...
...
src/librustc_codegen_llvm/declare.rs
浏览文件 @
9c41e1aa
...
...
@@ -31,7 +31,7 @@
use
attributes
;
use
context
::
CodegenCx
;
use
type_
::
Type
;
use
value
::
{
Value
,
ValueTrait
}
;
use
value
::
Value
;
/// Declare a global value.
...
...
@@ -51,12 +51,12 @@ pub fn declare_global(cx: &CodegenCx<'ll, '_>, name: &str, ty: &'ll Type) -> &'l
///
/// If there’s a value with the same name already declared, the function will
/// update the declaration and return existing Value instead.
fn
declare_raw_fn
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
,
fn
declare_raw_fn
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
name
:
&
str
,
callconv
:
llvm
::
CallConv
,
ty
:
&
'll
Type
,
)
->
&
'll
Value
where
Value
:
ValueTrait
{
)
->
&
'll
Value
{
debug!
(
"declare_raw_fn(name={:?}, ty={:?})"
,
name
,
ty
);
let
namebuf
=
SmallCStr
::
new
(
name
);
let
llfn
=
unsafe
{
...
...
@@ -105,7 +105,7 @@ fn declare_raw_fn<Value : ?Sized>(
attributes
::
non_lazy_bind
(
cx
.sess
(),
llfn
);
Value
::
of_llvm
(
llfn
)
llfn
}
...
...
@@ -116,11 +116,11 @@ fn declare_raw_fn<Value : ?Sized>(
///
/// If there’s a value with the same name already declared, the function will
/// update the declaration and return existing Value instead.
pub
fn
declare_cfn
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
,
pub
fn
declare_cfn
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
name
:
&
str
,
fn_type
:
&
'll
Type
)
->
&
'll
Value
where
Value
:
ValueTrait
{
)
->
&
'll
Value
{
declare_raw_fn
(
cx
,
name
,
llvm
::
CCallConv
,
fn_type
)
}
...
...
@@ -172,7 +172,7 @@ pub fn define_global(cx: &CodegenCx<'ll, '_>, name: &str, ty: &'ll Type) -> Opti
/// Declare a private global
///
/// Use this function when you intend to define a global without a name.
pub
fn
define_private_global
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
,
ty
:
&
'll
Type
)
->
&
'll
Value
{
pub
fn
define_private_global
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
ty
:
&
'll
Type
)
->
&
'll
Value
{
unsafe
{
llvm
::
LLVMRustInsertPrivateGlobal
(
cx
.llmod
,
ty
)
}
...
...
src/librustc_codegen_llvm/intrinsic.rs
浏览文件 @
9c41e1aa
...
...
@@ -593,7 +593,7 @@ fn ty_to_type(cx: &CodegenCx<'ll, '_>, t: &intrinsics::Type) -> Vec<&'ll Type> {
Vector
(
ref
t
,
ref
llvm_elem
,
length
)
=>
{
let
t
=
llvm_elem
.as_ref
()
.unwrap_or
(
t
);
let
elem
=
one
(
ty_to_type
(
cx
,
t
));
vec!
[
Type
::
vector
::
<
Value
>
(
elem
,
length
as
u64
)]
vec!
[
Type
::
vector
(
elem
,
length
as
u64
)]
}
Aggregate
(
false
,
ref
contents
)
=>
{
let
elems
=
contents
.iter
()
...
...
@@ -644,7 +644,7 @@ fn modify_as_needed(
let
llvm_elem
=
one
(
ty_to_type
(
bx
.cx
,
llvm_elem
));
vec!
[
bx
.bitcast
(
arg
.immediate
(),
Type
::
vector
::
<
Value
>
(
llvm_elem
,
length
as
u64
))
Type
::
vector
(
llvm_elem
,
length
as
u64
))
]
}
intrinsics
::
Type
::
Integer
(
_
,
width
,
llvm_width
)
if
width
!=
llvm_width
=>
{
...
...
@@ -673,7 +673,7 @@ fn modify_as_needed(
intrinsics
::
IntrinsicDef
::
Named
(
name
)
=>
{
let
f
=
declare
::
declare_cfn
(
cx
,
name
,
Type
::
func
::
<
Value
>
(
&
inputs
,
outputs
));
Type
::
func
(
&
inputs
,
outputs
));
bx
.call
(
f
,
&
llargs
,
None
)
}
};
...
...
@@ -1160,7 +1160,7 @@ fn generic_simd_intrinsic(
}
// truncate the mask to a vector of i1s
let
i1
=
Type
::
i1
(
bx
.cx
);
let
i1xn
=
Type
::
vector
::
<
Value
>
(
i1
,
m_len
as
u64
);
let
i1xn
=
Type
::
vector
(
i1
,
m_len
as
u64
);
let
m_i1s
=
bx
.trunc
(
args
[
0
]
.immediate
(),
i1xn
);
return
Ok
(
bx
.select
(
m_i1s
,
args
[
1
]
.immediate
(),
args
[
2
]
.immediate
()));
}
...
...
@@ -1301,7 +1301,7 @@ fn llvm_vector_ty(cx: &CodegenCx<'ll, '_>, elem_ty: ty::Ty, vec_len: usize,
elem_ty
=
elem_ty
.ptr_to
();
no_pointers
-=
1
;
}
Type
::
vector
::
<
Value
>
(
elem_ty
,
vec_len
as
u64
)
Type
::
vector
(
elem_ty
,
vec_len
as
u64
)
}
...
...
@@ -1384,7 +1384,7 @@ fn non_ptr(t: ty::Ty) -> ty::Ty {
// Truncate the mask vector to a vector of i1s:
let
(
mask
,
mask_ty
)
=
{
let
i1
=
Type
::
i1
(
bx
.cx
);
let
i1xn
=
Type
::
vector
::
<
Value
>
(
i1
,
in_len
as
u64
);
let
i1xn
=
Type
::
vector
(
i1
,
in_len
as
u64
);
(
bx
.trunc
(
args
[
2
]
.immediate
(),
i1xn
),
i1xn
)
};
...
...
@@ -1399,7 +1399,7 @@ fn non_ptr(t: ty::Ty) -> ty::Ty {
let
llvm_intrinsic
=
format!
(
"llvm.masked.gather.{}.{}"
,
llvm_elem_vec_str
,
llvm_pointer_vec_str
);
let
f
=
declare
::
declare_cfn
(
bx
.cx
,
&
llvm_intrinsic
,
Type
::
func
::
<
Value
>
(
&
[
Type
::
func
(
&
[
llvm_pointer_vec_ty
,
alignment_ty
,
mask_ty
,
...
...
@@ -1484,7 +1484,7 @@ fn non_ptr(t: ty::Ty) -> ty::Ty {
// Truncate the mask vector to a vector of i1s:
let
(
mask
,
mask_ty
)
=
{
let
i1
=
Type
::
i1
(
bx
.cx
);
let
i1xn
=
Type
::
vector
::
<
Value
>
(
i1
,
in_len
as
u64
);
let
i1xn
=
Type
::
vector
(
i1
,
in_len
as
u64
);
(
bx
.trunc
(
args
[
2
]
.immediate
(),
i1xn
),
i1xn
)
};
...
...
@@ -1501,7 +1501,7 @@ fn non_ptr(t: ty::Ty) -> ty::Ty {
let
llvm_intrinsic
=
format!
(
"llvm.masked.scatter.{}.{}"
,
llvm_elem_vec_str
,
llvm_pointer_vec_str
);
let
f
=
declare
::
declare_cfn
(
bx
.cx
,
&
llvm_intrinsic
,
Type
::
func
::
<
Value
>
(
&
[
llvm_elem_vec_ty
,
Type
::
func
(
&
[
llvm_elem_vec_ty
,
llvm_pointer_vec_ty
,
alignment_ty
,
mask_ty
],
ret_t
));
...
...
@@ -1636,7 +1636,7 @@ fn non_ptr(t: ty::Ty) -> ty::Ty {
// boolean reductions operate on vectors of i1s:
let
i1
=
Type
::
i1
(
bx
.cx
);
let
i1xn
=
Type
::
vector
::
<
Value
>
(
i1
,
in_len
as
u64
);
let
i1xn
=
Type
::
vector
(
i1
,
in_len
as
u64
);
bx
.trunc
(
args
[
0
]
.immediate
(),
i1xn
)
};
return
match
in_elem
.sty
{
...
...
src/librustc_codegen_llvm/meth.rs
浏览文件 @
9c41e1aa
...
...
@@ -52,7 +52,7 @@ pub fn get_fn(self, bx: &Builder<'a, 'll, 'tcx>,
pub
fn
get_usize
(
self
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
,
&
'll
Value
>
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
>
,
llvtable
:
&
'll
Value
)
->
&
'll
Value
{
// Load the data pointer from the object.
...
...
src/librustc_codegen_llvm/mir/block.rs
浏览文件 @
9c41e1aa
...
...
@@ -101,7 +101,7 @@ fn codegen_terminator(&mut self,
};
let
funclet_br
=
|
this
:
&
mut
Self
,
bx
:
Builder
<
'_
,
'll
,
'_
,
&
'll
Value
>
,
target
:
mir
::
BasicBlock
|
{
|
this
:
&
mut
Self
,
bx
:
Builder
<
'_
,
'll
,
'_
>
,
target
:
mir
::
BasicBlock
|
{
let
(
lltarget
,
is_cleanupret
)
=
lltarget
(
this
,
target
);
if
is_cleanupret
{
// micro-optimization: generate a `ret` rather than a jump
...
...
@@ -848,7 +848,7 @@ fn codegen_arguments_untupled(&mut self,
fn
get_personality_slot
(
&
mut
self
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
,
&
'll
Value
>
bx
:
&
Builder
<
'a
,
'll
,
'tcx
>
)
->
PlaceRef
<
'tcx
,
&
'll
Value
>
{
let
cx
=
bx
.cx
;
if
let
Some
(
slot
)
=
self
.personality_slot
{
...
...
src/librustc_codegen_llvm/mir/mod.rs
浏览文件 @
9c41e1aa
...
...
@@ -122,7 +122,7 @@ pub fn monomorphize<T>(&self, value: &T) -> T
pub
fn
set_debug_loc
(
&
mut
self
,
bx
:
&
Builder
<
'_
,
'll
,
'_
,
&
'll
Value
>
,
bx
:
&
Builder
<
'_
,
'll
,
'_
>
,
source_info
:
mir
::
SourceInfo
)
{
let
(
scope
,
span
)
=
self
.debug_loc
(
source_info
);
...
...
src/librustc_codegen_llvm/mir/operand.rs
浏览文件 @
9c41e1aa
...
...
@@ -16,7 +16,7 @@
use
base
;
use
common
::{
CodegenCx
,
C_undef
,
C_usize
};
use
builder
::{
Builder
,
MemFlags
};
use
value
::
{
Value
,
ValueTrait
}
;
use
value
::
Value
;
use
type_of
::
LayoutLlvmExt
;
use
type_
::
Type
;
use
glue
;
...
...
@@ -63,7 +63,7 @@ pub struct OperandRef<'tcx, V> {
pub
layout
:
TyLayout
<
'tcx
>
,
}
impl
<
Value
:
?
Sized
>
fmt
::
Debug
for
OperandRef
<
'tcx
,
&
'll
Value
>
where
Value
:
ValueTrait
{
impl
fmt
::
Debug
for
OperandRef
<
'tcx
,
&
'll
Value
>
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
write!
(
f
,
"OperandRef({:?} @ {:?})"
,
self
.val
,
self
.layout
)
}
...
...
@@ -265,7 +265,7 @@ pub fn store(self, bx: &Builder<'a, 'll, 'tcx>, dest: PlaceRef<'tcx, &'ll Value>
pub
fn
volatile_store
(
self
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
,
&
'll
Value
>
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
>
,
dest
:
PlaceRef
<
'tcx
,
&
'll
Value
>
)
{
self
.store_with_flags
(
bx
,
dest
,
MemFlags
::
VOLATILE
);
...
...
@@ -280,14 +280,12 @@ pub fn unaligned_volatile_store(
}
}
impl
<
'a
,
'll
:
'a
,
'tcx
:
'll
,
Value
:
?
Sized
>
OperandValue
<&
'll
Value
>
where
Value
:
ValueTrait
,
Builder
<
'a
,
'll
,
'tcx
,
&
'll
Value
>
:
BuilderMethods
<
'a
,
'll
,
'tcx
,
Value
,
BasicBlock
>
impl
<
'a
,
'll
:
'a
,
'tcx
:
'll
>
OperandValue
<&
'll
Value
>
where
Builder
<
'a
,
'll
,
'tcx
>
:
BuilderMethods
<
'a
,
'll
,
'tcx
,
Value
,
BasicBlock
>
{
pub
fn
nontemporal_store
(
self
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
,
&
'll
Value
>
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
>
,
dest
:
PlaceRef
<
'tcx
,
&
'll
Value
>
)
{
self
.store_with_flags
(
bx
,
dest
,
MemFlags
::
NONTEMPORAL
);
...
...
@@ -331,7 +329,7 @@ fn store_with_flags<Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>(
impl
OperandValue
<&
'll
Value
>
{
pub
fn
store_unsized
(
self
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
,
&
'll
Value
>
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
>
,
indirect_dest
:
PlaceRef
<
'tcx
,
&
'll
Value
>
)
{
debug!
(
"OperandRef::store_unsized: operand={:?}, indirect_dest={:?}"
,
self
,
indirect_dest
);
...
...
src/librustc_codegen_llvm/mir/place.rs
浏览文件 @
9c41e1aa
...
...
@@ -284,7 +284,7 @@ pub fn project_field(
/// Obtain the actual discriminant of a value.
pub
fn
codegen_get_discr
(
self
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
,
&
'll
Value
>
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
>
,
cast_to
:
Ty
<
'tcx
>
)
->
&
'll
Value
{
let
cast_to
=
bx
.cx
.layout_of
(
cast_to
)
.immediate_llvm_type
(
bx
.cx
);
...
...
src/librustc_codegen_llvm/mir/rvalue.rs
浏览文件 @
9c41e1aa
...
...
@@ -180,10 +180,10 @@ pub fn codegen_rvalue(&mut self,
}
pub
fn
codegen_rvalue_unsized
(
&
mut
self
,
bx
:
Builder
<
'a
,
'll
,
'tcx
,
&
'll
Value
>
,
bx
:
Builder
<
'a
,
'll
,
'tcx
>
,
indirect_dest
:
PlaceRef
<
'tcx
,
&
'll
Value
>
,
rvalue
:
&
mir
::
Rvalue
<
'tcx
>
)
->
Builder
<
'a
,
'll
,
'tcx
,
&
'll
Value
>
->
Builder
<
'a
,
'll
,
'tcx
>
{
debug!
(
"codegen_rvalue_unsized(indirect_dest.llval={:?}, rvalue={:?})"
,
indirect_dest
.llval
,
rvalue
);
...
...
@@ -201,9 +201,9 @@ pub fn codegen_rvalue_unsized(&mut self,
pub
fn
codegen_rvalue_operand
(
&
mut
self
,
bx
:
Builder
<
'a
,
'll
,
'tcx
,
&
'll
Value
>
,
bx
:
Builder
<
'a
,
'll
,
'tcx
>
,
rvalue
:
&
mir
::
Rvalue
<
'tcx
>
)
->
(
Builder
<
'a
,
'll
,
'tcx
,
&
'll
Value
>
,
OperandRef
<
'tcx
,
&
'll
Value
>
)
{
)
->
(
Builder
<
'a
,
'll
,
'tcx
>
,
OperandRef
<
'tcx
,
&
'll
Value
>
)
{
assert
!
(
self
.rvalue_creates_operand
(
rvalue
),
"cannot codegen {:?} to operand"
,
rvalue
);
match
*
rvalue
{
...
...
@@ -753,7 +753,7 @@ enum OverflowOp {
fn
get_overflow_intrinsic
(
oop
:
OverflowOp
,
bx
:
&
Builder
<
'_
,
'll
,
'_
,
&
'll
Value
>
,
bx
:
&
Builder
<
'_
,
'll
,
'_
>
,
ty
:
Ty
)
->
&
'll
Value
{
use
syntax
::
ast
::
IntTy
::
*
;
...
...
src/librustc_codegen_llvm/traits.rs
浏览文件 @
9c41e1aa
...
...
@@ -109,14 +109,14 @@ pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll,
>
{
fn
new_block
<
'b
>
(
cx
:
&
'a
CodegenCx
<
'll
,
'tcx
,
&
'll
Value
>
,
cx
:
&
'a
CodegenCx
<
'll
,
'tcx
>
,
llfn
:
&
'll
Value
,
name
:
&
'b
str
)
->
Self
;
fn
with_cx
(
cx
:
&
'a
CodegenCx
<
'll
,
'tcx
,
&
'll
Value
>
)
->
Self
;
fn
with_cx
(
cx
:
&
'a
CodegenCx
<
'll
,
'tcx
>
)
->
Self
;
fn
build_sibling_block
<
'b
>
(
&
self
,
name
:
&
'b
str
)
->
Self
;
fn
sess
(
&
self
)
->
&
Session
;
fn
cx
(
&
self
)
->
&
'a
CodegenCx
<
'll
,
'tcx
,
&
'll
Value
>
;
fn
cx
(
&
self
)
->
&
'a
CodegenCx
<
'll
,
'tcx
>
;
fn
tcx
(
&
self
)
->
TyCtxt
<
'a
,
'tcx
,
'tcx
>
;
fn
llfn
(
&
self
)
->
&
'll
Value
;
fn
llbb
(
&
self
)
->
&
'll
BasicBlock
;
...
...
src/librustc_codegen_llvm/type_.rs
浏览文件 @
9c41e1aa
...
...
@@ -16,7 +16,6 @@
use
llvm
::{
Bool
,
False
,
True
,
TypeKind
};
use
context
::
CodegenCx
;
use
value
::{
Value
,
ValueTrait
};
use
syntax
::
ast
;
use
rustc
::
ty
::
layout
::{
self
,
Align
,
Size
};
...
...
@@ -41,143 +40,143 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
impl
Type
{
pub
fn
void
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
void
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMVoidTypeInContext
(
cx
.llcx
)
}
}
pub
fn
metadata
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
metadata
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMRustMetadataTypeInContext
(
cx
.llcx
)
}
}
pub
fn
i1
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
i1
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMInt1TypeInContext
(
cx
.llcx
)
}
}
pub
fn
i8
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
i8
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMInt8TypeInContext
(
cx
.llcx
)
}
}
pub
fn
i8_llcx
<
Value
:
?
Sized
>
(
llcx
:
&
llvm
::
Context
)
->
&
Type
where
Value
:
ValueTrait
{
pub
fn
i8_llcx
(
llcx
:
&
llvm
::
Context
)
->
&
Type
{
unsafe
{
llvm
::
LLVMInt8TypeInContext
(
llcx
)
}
}
pub
fn
i16
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
i16
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMInt16TypeInContext
(
cx
.llcx
)
}
}
pub
fn
i32
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
i32
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMInt32TypeInContext
(
cx
.llcx
)
}
}
pub
fn
i64
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
i64
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMInt64TypeInContext
(
cx
.llcx
)
}
}
pub
fn
i128
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
i128
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMIntTypeInContext
(
cx
.llcx
,
128
)
}
}
// Creates an integer type with the given number of bits, e.g. i24
pub
fn
ix
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
,
pub
fn
ix
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
num_bits
:
u64
)
->
&
'll
Type
where
Value
:
ValueTrait
{
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMIntTypeInContext
(
cx
.llcx
,
num_bits
as
c_uint
)
}
}
// Creates an integer type with the given number of bits, e.g. i24
pub
fn
ix_llcx
<
Value
:
?
Sized
>
(
pub
fn
ix_llcx
(
llcx
:
&
llvm
::
Context
,
num_bits
:
u64
)
->
&
Type
where
Value
:
ValueTrait
{
)
->
&
Type
{
unsafe
{
llvm
::
LLVMIntTypeInContext
(
llcx
,
num_bits
as
c_uint
)
}
}
pub
fn
f32
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
f32
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMFloatTypeInContext
(
cx
.llcx
)
}
}
pub
fn
f64
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
f64
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMDoubleTypeInContext
(
cx
.llcx
)
}
}
pub
fn
bool
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
bool
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
Type
::
i8
(
cx
)
}
pub
fn
char
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
char
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
Type
::
i32
(
cx
)
}
pub
fn
i8p
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
i8p
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
Type
::
i8
(
cx
)
.ptr_to
()
}
pub
fn
i8p_llcx
<
Value
:
?
Sized
>
(
llcx
:
&
llvm
::
Context
)
->
&
Type
where
Value
:
ValueTrait
{
Type
::
i8_llcx
::
<
Value
>
(
llcx
)
.ptr_to
()
pub
fn
i8p_llcx
(
llcx
:
&
llvm
::
Context
)
->
&
Type
{
Type
::
i8_llcx
(
llcx
)
.ptr_to
()
}
pub
fn
isize
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
isize
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
cx
.isize_ty
}
pub
fn
c_int
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
)
->
&
'll
Type
where
Value
:
ValueTrait
{
pub
fn
c_int
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
match
&
cx
.tcx.sess.target.target.target_c_int_width
[
..
]
{
"16"
=>
Type
::
i16
(
cx
),
"32"
=>
Type
::
i32
(
cx
),
...
...
@@ -186,10 +185,10 @@ pub fn c_int<Value : ?Sized>(
}
}
pub
fn
int_from_ty
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
,
pub
fn
int_from_ty
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
t
:
ast
::
IntTy
)
->
&
'll
Type
where
Value
:
ValueTrait
{
)
->
&
'll
Type
{
match
t
{
ast
::
IntTy
::
Isize
=>
cx
.isize_ty
,
ast
::
IntTy
::
I8
=>
Type
::
i8
(
cx
),
...
...
@@ -200,10 +199,10 @@ pub fn int_from_ty<Value : ?Sized>(
}
}
pub
fn
uint_from_ty
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
,
pub
fn
uint_from_ty
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
t
:
ast
::
UintTy
)
->
&
'll
Type
where
Value
:
ValueTrait
{
)
->
&
'll
Type
{
match
t
{
ast
::
UintTy
::
Usize
=>
cx
.isize_ty
,
ast
::
UintTy
::
U8
=>
Type
::
i8
(
cx
),
...
...
@@ -214,41 +213,41 @@ pub fn uint_from_ty<Value : ?Sized>(
}
}
pub
fn
float_from_ty
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
,
pub
fn
float_from_ty
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
t
:
ast
::
FloatTy
)
->
&
'll
Type
where
Value
:
ValueTrait
{
)
->
&
'll
Type
{
match
t
{
ast
::
FloatTy
::
F32
=>
Type
::
f32
(
cx
),
ast
::
FloatTy
::
F64
=>
Type
::
f64
(
cx
),
}
}
pub
fn
func
<
Value
:
?
Sized
>
(
pub
fn
func
(
args
:
&
[
&
'll
Type
],
ret
:
&
'll
Type
)
->
&
'll
Type
where
Value
:
ValueTrait
{
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMFunctionType
(
ret
,
args
.as_ptr
(),
args
.len
()
as
c_uint
,
False
)
}
}
pub
fn
variadic_func
<
Value
:
?
Sized
>
(
pub
fn
variadic_func
(
args
:
&
[
&
'll
Type
],
ret
:
&
'll
Type
)
->
&
'll
Type
where
Value
:
ValueTrait
{
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMFunctionType
(
ret
,
args
.as_ptr
(),
args
.len
()
as
c_uint
,
True
)
}
}
pub
fn
struct_
<
Value
:
?
Sized
>
(
cx
:
&
CodegenCx
<
'll
,
'_
,
&
'll
Value
>
,
pub
fn
struct_
(
cx
:
&
CodegenCx
<
'll
,
'_
>
,
els
:
&
[
&
'll
Type
],
packed
:
bool
)
->
&
'll
Type
where
Value
:
ValueTrait
{
)
->
&
'll
Type
{
unsafe
{
llvm
::
LLVMStructTypeInContext
(
cx
.llcx
,
els
.as_ptr
(),
els
.len
()
as
c_uint
,
...
...
@@ -264,13 +263,13 @@ pub fn named_struct(cx: &CodegenCx<'ll, '_>, name: &str) -> &'ll Type {
}
pub
fn
array
<
Value
:
?
Sized
>
(
ty
:
&
Type
,
len
:
u64
)
->
&
Type
where
Value
:
ValueTrait
{
pub
fn
array
(
ty
:
&
Type
,
len
:
u64
)
->
&
Type
{
unsafe
{
llvm
::
LLVMRustArrayType
(
ty
,
len
)
}
}
pub
fn
vector
<
Value
:
?
Sized
>
(
ty
:
&
Type
,
len
:
u64
)
->
&
Type
where
Value
:
ValueTrait
{
pub
fn
vector
(
ty
:
&
Type
,
len
:
u64
)
->
&
Type
{
unsafe
{
llvm
::
LLVMVectorType
(
ty
,
len
as
c_uint
)
}
...
...
@@ -363,7 +362,7 @@ pub fn padding_filler(cx: &CodegenCx<'ll, '_>, size: Size, align: Align) -> &'ll
let
size
=
size
.bytes
();
let
unit_size
=
unit
.size
()
.bytes
();
assert_eq!
(
size
%
unit_size
,
0
);
Type
::
array
::
<
Value
>
(
Type
::
from_integer
(
cx
,
unit
),
size
/
unit_size
)
Type
::
array
(
Type
::
from_integer
(
cx
,
unit
),
size
/
unit_size
)
}
pub
fn
x86_mmx
(
cx
:
&
CodegenCx
<
'll
,
'_
>
)
->
&
'll
Type
{
...
...
src/librustc_codegen_llvm/type_of.rs
浏览文件 @
9c41e1aa
...
...
@@ -16,7 +16,6 @@
use
rustc_target
::
abi
::
FloatTy
;
use
rustc_mir
::
monomorphize
::
item
::
DefPathBasedNames
;
use
type_
::
Type
;
use
value
::
Value
;
use
std
::
fmt
::
Write
;
...
...
@@ -41,7 +40,7 @@ fn uncached_llvm_type<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
return
Type
::
x86_mmx
(
cx
)
}
else
{
let
element
=
layout
.scalar_llvm_type_at
(
cx
,
element
,
Size
::
ZERO
);
return
Type
::
vector
::
<
Value
>
(
element
,
count
);
return
Type
::
vector
(
element
,
count
);
}
}
layout
::
Abi
::
ScalarPair
(
..
)
=>
{
...
...
@@ -94,7 +93,7 @@ fn uncached_llvm_type<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
}
}
layout
::
FieldPlacement
::
Array
{
count
,
..
}
=>
{
Type
::
array
::
<
Value
>
(
layout
.field
(
cx
,
0
)
.llvm_type
(
cx
),
count
)
Type
::
array
(
layout
.field
(
cx
,
0
)
.llvm_type
(
cx
),
count
)
}
layout
::
FieldPlacement
::
Arbitrary
{
..
}
=>
{
match
name
{
...
...
src/librustc_codegen_llvm/value.rs
浏览文件 @
9c41e1aa
...
...
@@ -15,26 +15,12 @@
use
std
::
fmt
;
use
std
::
hash
::{
Hash
,
Hasher
};
pub
trait
ValueTrait
:
fmt
::
Debug
{
fn
to_llvm
(
&
self
)
->
&
llvm
::
Value
;
fn
of_llvm
(
&
llvm
::
Value
)
->
&
Self
;
}
impl
PartialEq
for
Value
{
fn
eq
(
&
self
,
other
:
&
Self
)
->
bool
{
self
as
*
const
_
==
other
as
*
const
_
}
}
impl
ValueTrait
for
Value
{
fn
to_llvm
(
&
self
)
->
&
llvm
::
Value
{
&
self
}
fn
of_llvm
(
v
:
&
llvm
::
Value
)
->
&
Self
{
&
v
}
}
impl
Eq
for
Value
{}
impl
Hash
for
Value
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录