Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
83e07f9f
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,发现更多精彩内容 >>
提交
83e07f9f
编写于
8月 29, 2018
作者:
D
Denis Merigoux
提交者:
Eduard-Mihai Burtescu
11月 16, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added self argument for Codegen CommonMethod trait methods
上级
d3258448
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
119 addition
and
118 deletion
+119
-118
src/librustc_codegen_llvm/builder.rs
src/librustc_codegen_llvm/builder.rs
+3
-3
src/librustc_codegen_llvm/common.rs
src/librustc_codegen_llvm/common.rs
+13
-13
src/librustc_codegen_llvm/interfaces/common.rs
src/librustc_codegen_llvm/interfaces/common.rs
+5
-5
src/librustc_codegen_llvm/intrinsic.rs
src/librustc_codegen_llvm/intrinsic.rs
+34
-34
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
+5
-5
src/librustc_codegen_llvm/mir/constant.rs
src/librustc_codegen_llvm/mir/constant.rs
+4
-4
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
+4
-4
src/librustc_codegen_llvm/mir/place.rs
src/librustc_codegen_llvm/mir/place.rs
+25
-25
src/librustc_codegen_llvm/mir/rvalue.rs
src/librustc_codegen_llvm/mir/rvalue.rs
+24
-23
未找到文件。
src/librustc_codegen_llvm/builder.rs
浏览文件 @
83e07f9f
...
...
@@ -529,8 +529,8 @@ fn range_metadata(&self, load: &'ll Value, range: Range<u128>) {
unsafe
{
let
llty
=
CodegenCx
::
val_ty
(
load
);
let
v
=
[
CodegenCx
::
c_uint_big
(
llty
,
range
.start
),
CodegenCx
::
c_uint_big
(
llty
,
range
.end
)
self
.cx
.
c_uint_big
(
llty
,
range
.start
),
self
.cx
.
c_uint_big
(
llty
,
range
.end
)
];
llvm
::
LLVMSetMetadata
(
load
,
llvm
::
MD_range
as
c_uint
,
...
...
@@ -863,7 +863,7 @@ fn vector_splat(&self, num_elts: usize, elt: &'ll Value) -> &'ll Value {
let
undef
=
llvm
::
LLVMGetUndef
(
type_
::
Type
::
vector
(
elt_ty
,
num_elts
as
u64
));
let
vec
=
self
.insert_element
(
undef
,
elt
,
CodegenCx
::
c_i32
(
self
.cx
,
0
));
let
vec_i32_ty
=
type_
::
Type
::
vector
(
type_
::
Type
::
i32
(
self
.cx
),
num_elts
as
u64
);
self
.shuffle_vector
(
vec
,
undef
,
CodegenCx
::
c_null
(
vec_i32_ty
))
self
.shuffle_vector
(
vec
,
undef
,
self
.cx
.
c_null
(
vec_i32_ty
))
}
}
...
...
src/librustc_codegen_llvm/common.rs
浏览文件 @
83e07f9f
...
...
@@ -208,31 +208,31 @@ fn val_ty(v: &'ll Value) -> &'ll Type {
}
// LLVM constant constructors.
fn
c_null
(
t
:
&
'll
Type
)
->
&
'll
Value
{
fn
c_null
(
&
self
,
t
:
&
'll
Type
)
->
&
'll
Value
{
unsafe
{
llvm
::
LLVMConstNull
(
t
)
}
}
fn
c_undef
(
t
:
&
'll
Type
)
->
&
'll
Value
{
fn
c_undef
(
&
self
,
t
:
&
'll
Type
)
->
&
'll
Value
{
unsafe
{
llvm
::
LLVMGetUndef
(
t
)
}
}
fn
c_int
(
t
:
&
'll
Type
,
i
:
i64
)
->
&
'll
Value
{
fn
c_int
(
&
self
,
t
:
&
'll
Type
,
i
:
i64
)
->
&
'll
Value
{
unsafe
{
llvm
::
LLVMConstInt
(
t
,
i
as
u64
,
True
)
}
}
fn
c_uint
(
t
:
&
'll
Type
,
i
:
u64
)
->
&
'll
Value
{
fn
c_uint
(
&
self
,
t
:
&
'll
Type
,
i
:
u64
)
->
&
'll
Value
{
unsafe
{
llvm
::
LLVMConstInt
(
t
,
i
,
False
)
}
}
fn
c_uint_big
(
t
:
&
'll
Type
,
u
:
u128
)
->
&
'll
Value
{
fn
c_uint_big
(
&
self
,
t
:
&
'll
Type
,
u
:
u128
)
->
&
'll
Value
{
unsafe
{
let
words
=
[
u
as
u64
,
(
u
>>
64
)
as
u64
];
llvm
::
LLVMConstIntOfArbitraryPrecision
(
t
,
2
,
words
.as_ptr
())
...
...
@@ -240,19 +240,19 @@ fn c_uint_big(t: &'ll Type, u: u128) -> &'ll Value {
}
fn
c_bool
(
&
self
,
val
:
bool
)
->
&
'll
Value
{
Self
::
c_uint
(
Type
::
i1
(
&
self
),
val
as
u64
)
&
self
.
c_uint
(
Type
::
i1
(
&
self
),
val
as
u64
)
}
fn
c_i32
(
&
self
,
i
:
i32
)
->
&
'll
Value
{
Self
::
c_int
(
Type
::
i32
(
&
self
),
i
as
i64
)
&
self
.
c_int
(
Type
::
i32
(
&
self
),
i
as
i64
)
}
fn
c_u32
(
&
self
,
i
:
u32
)
->
&
'll
Value
{
Self
::
c_uint
(
Type
::
i32
(
&
self
),
i
as
u64
)
&
self
.
c_uint
(
Type
::
i32
(
&
self
),
i
as
u64
)
}
fn
c_u64
(
&
self
,
i
:
u64
)
->
&
'll
Value
{
Self
::
c_uint
(
Type
::
i64
(
&
self
),
i
)
&
self
.
c_uint
(
Type
::
i64
(
&
self
),
i
)
}
fn
c_usize
(
&
self
,
i
:
u64
)
->
&
'll
Value
{
...
...
@@ -262,11 +262,11 @@ fn c_usize(&self, i: u64) -> &'ll Value {
assert
!
(
i
<
(
1
<<
bit_size
));
}
Self
::
c_uint
(
&
self
.isize_ty
,
i
)
&
self
.
c_uint
(
&
self
.isize_ty
,
i
)
}
fn
c_u8
(
&
self
,
i
:
u8
)
->
&
'll
Value
{
Self
::
c_uint
(
Type
::
i8
(
&
self
),
i
as
u64
)
&
self
.
c_uint
(
Type
::
i8
(
&
self
),
i
as
u64
)
}
...
...
@@ -489,9 +489,9 @@ pub fn shift_mask_val(
// i8/u8 can shift by at most 7, i16/u16 by at most 15, etc.
let
val
=
llty
.int_width
()
-
1
;
if
invert
{
CodegenCx
::
c_int
(
mask_llty
,
!
val
as
i64
)
bx
.cx
.
c_int
(
mask_llty
,
!
val
as
i64
)
}
else
{
CodegenCx
::
c_uint
(
mask_llty
,
val
)
bx
.cx
.
c_uint
(
mask_llty
,
val
)
}
},
TypeKind
::
Vector
=>
{
...
...
src/librustc_codegen_llvm/interfaces/common.rs
浏览文件 @
83e07f9f
...
...
@@ -15,11 +15,11 @@ pub trait CommonMethods : Backend {
fn
val_ty
(
v
:
Self
::
Value
)
->
Self
::
Type
;
// Constant constructors
fn
c_null
(
t
:
Self
::
Type
)
->
Self
::
Value
;
fn
c_undef
(
t
:
Self
::
Type
)
->
Self
::
Value
;
fn
c_int
(
t
:
Self
::
Type
,
i
:
i64
)
->
Self
::
Value
;
fn
c_uint
(
t
:
Self
::
Type
,
i
:
u64
)
->
Self
::
Value
;
fn
c_uint_big
(
t
:
Self
::
Type
,
u
:
u128
)
->
Self
::
Value
;
fn
c_null
(
&
self
,
t
:
Self
::
Type
)
->
Self
::
Value
;
fn
c_undef
(
&
self
,
t
:
Self
::
Type
)
->
Self
::
Value
;
fn
c_int
(
&
self
,
t
:
Self
::
Type
,
i
:
i64
)
->
Self
::
Value
;
fn
c_uint
(
&
self
,
t
:
Self
::
Type
,
i
:
u64
)
->
Self
::
Value
;
fn
c_uint_big
(
&
self
,
t
:
Self
::
Type
,
u
:
u128
)
->
Self
::
Value
;
fn
c_bool
(
&
self
,
val
:
bool
)
->
Self
::
Value
;
fn
c_i32
(
&
self
,
i
:
i32
)
->
Self
::
Value
;
fn
c_u32
(
&
self
,
i
:
u32
)
->
Self
::
Value
;
...
...
src/librustc_codegen_llvm/intrinsic.rs
浏览文件 @
83e07f9f
...
...
@@ -127,11 +127,11 @@ pub fn codegen_intrinsic_call(
},
"likely"
=>
{
let
expect
=
cx
.get_intrinsic
(
&
(
"llvm.expect.i1"
));
bx
.call
(
expect
,
&
[
args
[
0
]
.immediate
(),
CodegenCx
::
c_bool
(
cx
,
true
)],
None
)
bx
.call
(
expect
,
&
[
args
[
0
]
.immediate
(),
bx
.cx
()
.c_bool
(
true
)],
None
)
}
"unlikely"
=>
{
let
expect
=
cx
.get_intrinsic
(
&
(
"llvm.expect.i1"
));
bx
.call
(
expect
,
&
[
args
[
0
]
.immediate
(),
CodegenCx
::
c_bool
(
cx
,
false
)],
None
)
bx
.call
(
expect
,
&
[
args
[
0
]
.immediate
(),
bx
.cx
()
.c_bool
(
false
)],
None
)
}
"try"
=>
{
try_intrinsic
(
bx
,
cx
,
...
...
@@ -147,7 +147,7 @@ pub fn codegen_intrinsic_call(
}
"size_of"
=>
{
let
tp_ty
=
substs
.type_at
(
0
);
CodegenCx
::
c_usize
(
cx
,
cx
.size_of
(
tp_ty
)
.bytes
())
cx
.c_usize
(
cx
.size_of
(
tp_ty
)
.bytes
())
}
"size_of_val"
=>
{
let
tp_ty
=
substs
.type_at
(
0
);
...
...
@@ -156,12 +156,12 @@ pub fn codegen_intrinsic_call(
glue
::
size_and_align_of_dst
(
bx
,
tp_ty
,
Some
(
meta
));
llsize
}
else
{
CodegenCx
::
c_usize
(
cx
,
cx
.size_of
(
tp_ty
)
.bytes
())
cx
.c_usize
(
cx
.size_of
(
tp_ty
)
.bytes
())
}
}
"min_align_of"
=>
{
let
tp_ty
=
substs
.type_at
(
0
);
CodegenCx
::
c_usize
(
cx
,
cx
.align_of
(
tp_ty
)
.abi
())
cx
.c_usize
(
cx
.align_of
(
tp_ty
)
.abi
())
}
"min_align_of_val"
=>
{
let
tp_ty
=
substs
.type_at
(
0
);
...
...
@@ -170,20 +170,20 @@ pub fn codegen_intrinsic_call(
glue
::
size_and_align_of_dst
(
bx
,
tp_ty
,
Some
(
meta
));
llalign
}
else
{
CodegenCx
::
c_usize
(
cx
,
cx
.align_of
(
tp_ty
)
.abi
())
cx
.c_usize
(
cx
.align_of
(
tp_ty
)
.abi
())
}
}
"pref_align_of"
=>
{
let
tp_ty
=
substs
.type_at
(
0
);
CodegenCx
::
c_usize
(
cx
,
cx
.align_of
(
tp_ty
)
.pref
())
cx
.c_usize
(
cx
.align_of
(
tp_ty
)
.pref
())
}
"type_name"
=>
{
let
tp_ty
=
substs
.type_at
(
0
);
let
ty_name
=
Symbol
::
intern
(
&
tp_ty
.to_string
())
.as_str
();
CodegenCx
::
c_str_slice
(
cx
,
ty_name
)
cx
.c_str_slice
(
ty_name
)
}
"type_id"
=>
{
CodegenCx
::
c_u64
(
cx
,
cx
.tcx
.type_id_hash
(
substs
.type_at
(
0
)))
cx
.c_u64
(
cx
.tcx
.type_id_hash
(
substs
.type_at
(
0
)))
}
"init"
=>
{
let
ty
=
substs
.type_at
(
0
);
...
...
@@ -197,8 +197,8 @@ pub fn codegen_intrinsic_call(
false
,
ty
,
llresult
,
CodegenCx
::
c_u8
(
cx
,
0
),
CodegenCx
::
c_usize
(
cx
,
1
)
cx
.c_u8
(
0
),
cx
.c_usize
(
1
)
);
}
return
;
...
...
@@ -210,7 +210,7 @@ pub fn codegen_intrinsic_call(
"needs_drop"
=>
{
let
tp_ty
=
substs
.type_at
(
0
);
CodegenCx
::
c_bool
(
cx
,
bx
.cx
()
.type_needs_drop
(
tp_ty
))
cx
.c_bool
(
bx
.cx
()
.type_needs_drop
(
tp_ty
))
}
"offset"
=>
{
let
ptr
=
args
[
0
]
.immediate
();
...
...
@@ -287,9 +287,9 @@ pub fn codegen_intrinsic_call(
};
bx
.call
(
expect
,
&
[
args
[
0
]
.immediate
(),
CodegenCx
::
c_i32
(
cx
,
rw
),
cx
.c_i32
(
rw
),
args
[
1
]
.immediate
(),
CodegenCx
::
c_i32
(
cx
,
cache_type
)
cx
.c_i32
(
cache_type
)
],
None
)
},
"ctlz"
|
"ctlz_nonzero"
|
"cttz"
|
"cttz_nonzero"
|
"ctpop"
|
"bswap"
|
...
...
@@ -302,12 +302,12 @@ pub fn codegen_intrinsic_call(
Some
((
width
,
signed
))
=>
match
name
{
"ctlz"
|
"cttz"
=>
{
let
y
=
CodegenCx
::
c_bool
(
bx
.cx
(),
false
);
let
y
=
cx
.c_bool
(
false
);
let
llfn
=
cx
.get_intrinsic
(
&
format!
(
"llvm.{}.i{}"
,
name
,
width
));
bx
.call
(
llfn
,
&
[
args
[
0
]
.immediate
(),
y
],
None
)
}
"ctlz_nonzero"
|
"cttz_nonzero"
=>
{
let
y
=
CodegenCx
::
c_bool
(
bx
.cx
(),
true
);
let
y
=
cx
.c_bool
(
true
);
let
llvm_name
=
&
format!
(
"llvm.{}.i{}"
,
&
name
[
..
4
],
width
);
let
llfn
=
cx
.get_intrinsic
(
llvm_name
);
bx
.call
(
llfn
,
&
[
args
[
0
]
.immediate
(),
y
],
None
)
...
...
@@ -388,7 +388,7 @@ pub fn codegen_intrinsic_call(
}
else
{
// rotate_left: (X << (S % BW)) | (X >> ((BW - S) % BW))
// rotate_right: (X << ((BW - S) % BW)) | (X >> (S % BW))
let
width
=
CodegenCx
::
c_uint
(
Type
::
ix
(
cx
,
width
),
width
);
let
width
=
cx
.
c_uint
(
Type
::
ix
(
cx
,
width
),
width
);
let
shift
=
bx
.urem
(
raw_shift
,
width
);
let
inv_shift
=
bx
.urem
(
bx
.sub
(
width
,
raw_shift
),
width
);
let
shift1
=
bx
.shl
(
val
,
if
is_left
{
shift
}
else
{
inv_shift
});
...
...
@@ -725,7 +725,7 @@ fn copy_intrinsic(
)
->
&
'll
Value
{
let
cx
=
bx
.cx
();
let
(
size
,
align
)
=
cx
.size_and_align_of
(
ty
);
let
size
=
CodegenCx
::
c_usize
(
cx
,
size
.bytes
());
let
size
=
cx
.c_usize
(
size
.bytes
());
let
align
=
align
.abi
();
let
dst_ptr
=
bx
.pointercast
(
dst
,
Type
::
i8p
(
cx
));
let
src_ptr
=
bx
.pointercast
(
src
,
Type
::
i8p
(
cx
));
...
...
@@ -746,8 +746,8 @@ fn memset_intrinsic(
)
->
&
'll
Value
{
let
cx
=
bx
.cx
();
let
(
size
,
align
)
=
cx
.size_and_align_of
(
ty
);
let
size
=
CodegenCx
::
c_usize
(
cx
,
size
.bytes
());
let
align
=
CodegenCx
::
c_i32
(
cx
,
align
.abi
()
as
i32
);
let
size
=
cx
.c_usize
(
size
.bytes
());
let
align
=
cx
.c_i32
(
align
.abi
()
as
i32
);
let
dst
=
bx
.pointercast
(
dst
,
Type
::
i8p
(
cx
));
call_memset
(
bx
,
dst
,
val
,
bx
.mul
(
size
,
count
),
align
,
volatile
)
}
...
...
@@ -763,7 +763,7 @@ fn try_intrinsic(
if
bx
.sess
()
.no_landing_pads
()
{
bx
.call
(
func
,
&
[
data
],
None
);
let
ptr_align
=
bx
.tcx
()
.data_layout.pointer_align
;
bx
.store
(
CodegenCx
::
c_null
(
Type
::
i8p
(
&
bx
.cx
())),
dest
,
ptr_align
);
bx
.store
(
bx
.cx
()
.
c_null
(
Type
::
i8p
(
&
bx
.cx
())),
dest
,
ptr_align
);
}
else
if
wants_msvc_seh
(
bx
.sess
())
{
codegen_msvc_try
(
bx
,
cx
,
func
,
data
,
local_ptr
,
dest
);
}
else
{
...
...
@@ -844,7 +844,7 @@ fn codegen_msvc_try(
let
slot
=
bx
.alloca
(
i64p
,
"slot"
,
ptr_align
);
bx
.invoke
(
func
,
&
[
data
],
normal
.llbb
(),
catchswitch
.llbb
(),
None
);
normal
.ret
(
CodegenCx
::
c_i32
(
cx
,
0
));
normal
.ret
(
cx
.c_i32
(
0
));
let
cs
=
catchswitch
.catch_switch
(
None
,
None
,
1
);
catchswitch
.add_handler
(
cs
,
catchpad
.llbb
());
...
...
@@ -854,19 +854,19 @@ fn codegen_msvc_try(
Some
(
did
)
=>
::
consts
::
get_static
(
cx
,
did
),
None
=>
bug!
(
"msvc_try_filter not defined"
),
};
let
tok
=
catchpad
.catch_pad
(
cs
,
&
[
tydesc
,
CodegenCx
::
c_i32
(
cx
,
0
),
slot
]);
let
tok
=
catchpad
.catch_pad
(
cs
,
&
[
tydesc
,
cx
.c_i32
(
0
),
slot
]);
let
addr
=
catchpad
.load
(
slot
,
ptr_align
);
let
i64_align
=
bx
.tcx
()
.data_layout.i64_align
;
let
arg1
=
catchpad
.load
(
addr
,
i64_align
);
let
val1
=
CodegenCx
::
c_i32
(
cx
,
1
);
let
val1
=
cx
.c_i32
(
1
);
let
arg2
=
catchpad
.load
(
catchpad
.inbounds_gep
(
addr
,
&
[
val1
]),
i64_align
);
let
local_ptr
=
catchpad
.bitcast
(
local_ptr
,
i64p
);
catchpad
.store
(
arg1
,
local_ptr
,
i64_align
);
catchpad
.store
(
arg2
,
catchpad
.inbounds_gep
(
local_ptr
,
&
[
val1
]),
i64_align
);
catchpad
.catch_ret
(
tok
,
caught
.llbb
());
caught
.ret
(
CodegenCx
::
c_i32
(
cx
,
1
));
caught
.ret
(
cx
.c_i32
(
1
));
});
// Note that no invoke is used here because by definition this function
...
...
@@ -922,7 +922,7 @@ fn codegen_gnu_try(
let
data
=
llvm
::
get_param
(
bx
.llfn
(),
1
);
let
local_ptr
=
llvm
::
get_param
(
bx
.llfn
(),
2
);
bx
.invoke
(
func
,
&
[
data
],
then
.llbb
(),
catch
.llbb
(),
None
);
then
.ret
(
CodegenCx
::
c_i32
(
cx
,
0
));
then
.ret
(
cx
.c_i32
(
0
));
// Type indicator for the exception being thrown.
//
...
...
@@ -932,11 +932,11 @@ fn codegen_gnu_try(
// rust_try ignores the selector.
let
lpad_ty
=
Type
::
struct_
(
cx
,
&
[
Type
::
i8p
(
cx
),
Type
::
i32
(
cx
)],
false
);
let
vals
=
catch
.landing_pad
(
lpad_ty
,
bx
.cx
()
.eh_personality
(),
1
);
catch
.add_clause
(
vals
,
CodegenCx
::
c_null
(
Type
::
i8p
(
cx
)));
catch
.add_clause
(
vals
,
bx
.cx
()
.
c_null
(
Type
::
i8p
(
cx
)));
let
ptr
=
catch
.extract_value
(
vals
,
0
);
let
ptr_align
=
bx
.tcx
()
.data_layout.pointer_align
;
catch
.store
(
ptr
,
catch
.bitcast
(
local_ptr
,
Type
::
i8p
(
cx
)
.ptr_to
()),
ptr_align
);
catch
.ret
(
CodegenCx
::
c_i32
(
cx
,
1
));
catch
.ret
(
cx
.c_i32
(
1
));
});
// Note that no invoke is used here because by definition this function
...
...
@@ -1125,13 +1125,13 @@ fn generic_simd_intrinsic(
arg_idx
,
total_len
);
None
}
Some
(
idx
)
=>
Some
(
CodegenCx
::
c_i32
(
bx
.cx
(),
idx
as
i32
)),
Some
(
idx
)
=>
Some
(
bx
.cx
()
.c_i32
(
idx
as
i32
)),
}
})
.collect
();
let
indices
=
match
indices
{
Some
(
i
)
=>
i
,
None
=>
return
Ok
(
CodegenCx
::
c_null
(
llret_ty
))
None
=>
return
Ok
(
bx
.cx
()
.
c_null
(
llret_ty
))
};
return
Ok
(
bx
.shuffle_vector
(
args
[
0
]
.immediate
(),
...
...
@@ -1387,7 +1387,7 @@ fn non_ptr(t: ty::Ty) -> ty::Ty {
// Alignment of T, must be a constant integer value:
let
alignment_ty
=
Type
::
i32
(
bx
.cx
());
let
alignment
=
CodegenCx
::
c_i32
(
bx
.cx
(),
bx
.cx
()
.align_of
(
in_elem
)
.abi
()
as
i32
);
let
alignment
=
bx
.cx
()
.c_i32
(
bx
.cx
()
.align_of
(
in_elem
)
.abi
()
as
i32
);
// Truncate the mask vector to a vector of i1s:
let
(
mask
,
mask_ty
)
=
{
...
...
@@ -1487,7 +1487,7 @@ fn non_ptr(t: ty::Ty) -> ty::Ty {
// Alignment of T, must be a constant integer value:
let
alignment_ty
=
Type
::
i32
(
bx
.cx
());
let
alignment
=
CodegenCx
::
c_i32
(
bx
.cx
(),
bx
.cx
()
.align_of
(
in_elem
)
.abi
()
as
i32
);
let
alignment
=
bx
.cx
()
.c_i32
(
bx
.cx
()
.align_of
(
in_elem
)
.abi
()
as
i32
);
// Truncate the mask vector to a vector of i1s:
let
(
mask
,
mask_ty
)
=
{
...
...
@@ -1565,8 +1565,8 @@ fn non_ptr(t: ty::Ty) -> ty::Ty {
}
else
{
// unordered arithmetic reductions do not:
match
f
.bit_width
()
{
32
=>
CodegenCx
::
c_undef
(
Type
::
f32
(
bx
.cx
())),
64
=>
CodegenCx
::
c_undef
(
Type
::
f64
(
bx
.cx
())),
32
=>
bx
.cx
()
.
c_undef
(
Type
::
f32
(
bx
.cx
())),
64
=>
bx
.cx
()
.
c_undef
(
Type
::
f64
(
bx
.cx
())),
v
=>
{
return_error!
(
r#"
unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#
,
...
...
src/librustc_codegen_llvm/meth.rs
浏览文件 @
83e07f9f
...
...
@@ -96,7 +96,7 @@ pub fn get_vtable(
}
// Not in the cache. Build it.
let
nullptr
=
CodegenCx
::
c_null
(
Type
::
i8p
(
cx
));
let
nullptr
=
cx
.
c_null
(
Type
::
i8p
(
cx
));
let
methods
=
tcx
.vtable_methods
(
trait_ref
.with_self_ty
(
tcx
,
ty
));
let
methods
=
methods
.iter
()
.cloned
()
.map
(|
opt_mth
|
{
...
...
src/librustc_codegen_llvm/mir/block.rs
浏览文件 @
83e07f9f
...
...
@@ -172,7 +172,7 @@ fn codegen_terminator(&mut self,
slot
.storage_dead
(
&
bx
);
if
!
bx
.sess
()
.target.target.options.custom_unwind_resume
{
let
mut
lp
=
CodegenCx
::
c_undef
(
self
.landing_pad_type
());
let
mut
lp
=
bx
.cx
()
.
c_undef
(
self
.landing_pad_type
());
lp
=
bx
.insert_value
(
lp
,
lp0
,
0
);
lp
=
bx
.insert_value
(
lp
,
lp1
,
1
);
bx
.resume
(
lp
);
...
...
@@ -210,7 +210,7 @@ fn codegen_terminator(&mut self,
}
}
else
{
let
switch_llty
=
bx
.cx
()
.layout_of
(
switch_ty
)
.immediate_llvm_type
(
bx
.cx
());
let
llval
=
CodegenCx
::
c_uint_big
(
switch_llty
,
values
[
0
]);
let
llval
=
bx
.cx
()
.
c_uint_big
(
switch_llty
,
values
[
0
]);
let
cmp
=
bx
.icmp
(
IntPredicate
::
IntEQ
,
discr
.immediate
(),
llval
);
bx
.cond_br
(
cmp
,
lltrue
,
llfalse
);
}
...
...
@@ -221,7 +221,7 @@ fn codegen_terminator(&mut self,
values
.len
());
let
switch_llty
=
bx
.cx
()
.layout_of
(
switch_ty
)
.immediate_llvm_type
(
bx
.cx
());
for
(
&
value
,
target
)
in
values
.iter
()
.zip
(
targets
)
{
let
llval
=
CodegenCx
::
c_uint_big
(
switch_llty
,
value
);
let
llval
=
bx
.cx
()
.
c_uint_big
(
switch_llty
,
value
);
let
llbb
=
llblock
(
self
,
*
target
);
bx
.add_case
(
switch
,
llval
,
llbb
)
}
...
...
@@ -563,7 +563,7 @@ fn codegen_terminator(&mut self,
let
dest
=
match
ret_dest
{
_
if
fn_ty
.ret
.is_indirect
()
=>
llargs
[
0
],
ReturnDest
::
Nothing
=>
{
CodegenCx
::
c_undef
(
fn_ty
.ret
.memory_ty
(
bx
.cx
())
.ptr_to
())
bx
.cx
()
.
c_undef
(
fn_ty
.ret
.memory_ty
(
bx
.cx
())
.ptr_to
())
}
ReturnDest
::
IndirectOperand
(
dst
,
_
)
|
ReturnDest
::
Store
(
dst
)
=>
dst
.llval
,
...
...
@@ -744,7 +744,7 @@ fn codegen_argument(&mut self,
arg
:
&
ArgType
<
'tcx
,
Ty
<
'tcx
>>
)
{
// Fill padding with undef value, where applicable.
if
let
Some
(
ty
)
=
arg
.pad
{
llargs
.push
(
CodegenCx
::
c_undef
(
ty
.llvm_type
(
bx
.cx
())));
llargs
.push
(
bx
.cx
()
.
c_undef
(
ty
.llvm_type
(
bx
.cx
())));
}
if
arg
.is_ignore
()
{
...
...
src/librustc_codegen_llvm/mir/constant.rs
浏览文件 @
83e07f9f
...
...
@@ -40,11 +40,11 @@ pub fn scalar_to_llvm(
match
cv
{
Scalar
::
Bits
{
size
:
0
,
..
}
=>
{
assert_eq!
(
0
,
layout
.value
.size
(
cx
)
.bytes
());
CodegenCx
::
c_undef
(
Type
::
ix
(
cx
,
0
))
cx
.
c_undef
(
Type
::
ix
(
cx
,
0
))
},
Scalar
::
Bits
{
bits
,
size
}
=>
{
assert_eq!
(
size
as
u64
,
layout
.value
.size
(
cx
)
.bytes
());
let
llval
=
CodegenCx
::
c_uint_big
(
Type
::
ix
(
cx
,
bitsize
),
bits
);
let
llval
=
cx
.
c_uint_big
(
Type
::
ix
(
cx
,
bitsize
),
bits
);
if
layout
.value
==
layout
::
Pointer
{
unsafe
{
llvm
::
LLVMConstIntToPtr
(
llval
,
llty
)
}
}
else
{
...
...
@@ -73,7 +73,7 @@ pub fn scalar_to_llvm(
};
let
llval
=
unsafe
{
llvm
::
LLVMConstInBoundsGEP
(
consts
::
bitcast
(
base_addr
,
Type
::
i8p
(
cx
)),
&
CodegenCx
::
c_usize
(
cx
,
ptr
.offset
.bytes
()),
&
cx
.c_usize
(
ptr
.offset
.bytes
()),
1
,
)
};
if
layout
.value
!=
layout
::
Pointer
{
...
...
@@ -218,7 +218,7 @@ pub fn simd_shuffle_indices(
// We've errored, so we don't have to produce working code.
let
ty
=
self
.monomorphize
(
&
ty
);
let
llty
=
bx
.cx
()
.layout_of
(
ty
)
.llvm_type
(
bx
.cx
());
(
CodegenCx
::
c_undef
(
llty
),
ty
)
(
bx
.cx
()
.
c_undef
(
llty
),
ty
)
})
}
}
src/librustc_codegen_llvm/mir/mod.rs
浏览文件 @
83e07f9f
...
...
@@ -420,7 +420,7 @@ fn create_funclets(
// C++ personality function, but `catch (...)` has no type so
// it's null. The 64 here is actually a bitfield which
// represents that this is a catch-all block.
let
null
=
CodegenCx
::
c_null
(
Type
::
i8p
(
bx
.cx
()));
let
null
=
bx
.cx
()
.
c_null
(
Type
::
i8p
(
bx
.cx
()));
let
sixty_four
=
CodegenCx
::
c_i32
(
bx
.cx
(),
64
);
cleanup
=
cp_bx
.catch_pad
(
cs
,
&
[
null
,
sixty_four
,
null
]);
cp_bx
.br
(
llbb
);
...
...
src/librustc_codegen_llvm/mir/operand.rs
浏览文件 @
83e07f9f
...
...
@@ -73,7 +73,7 @@ pub fn new_zst(cx: &CodegenCx<'ll, 'tcx>,
layout
:
TyLayout
<
'tcx
>
)
->
OperandRef
<
'tcx
,
&
'll
Value
>
{
assert
!
(
layout
.is_zst
());
OperandRef
{
val
:
OperandValue
::
Immediate
(
CodegenCx
::
c_undef
(
layout
.immediate_llvm_type
(
cx
))),
val
:
OperandValue
::
Immediate
(
cx
.
c_undef
(
layout
.immediate_llvm_type
(
cx
))),
layout
}
}
...
...
@@ -167,7 +167,7 @@ pub fn immediate_or_packed_pair(self, bx: &Builder<'a, 'll, 'tcx>) -> &'ll Value
debug!
(
"Operand::immediate_or_packed_pair: packing {:?} into {:?}"
,
self
,
llty
);
// Reconstruct the immediate aggregate.
let
mut
llpair
=
CodegenCx
::
c_undef
(
llty
);
let
mut
llpair
=
bx
.cx
()
.
c_undef
(
llty
);
llpair
=
bx
.insert_value
(
llpair
,
base
::
from_immediate
(
bx
,
a
),
0
);
llpair
=
bx
.insert_value
(
llpair
,
base
::
from_immediate
(
bx
,
b
),
1
);
llpair
...
...
@@ -232,7 +232,7 @@ pub fn extract_field(
// `#[repr(simd)]` types are also immediate.
(
OperandValue
::
Immediate
(
llval
),
&
layout
::
Abi
::
Vector
{
..
})
=>
{
OperandValue
::
Immediate
(
bx
.extract_element
(
llval
,
CodegenCx
::
c_usize
(
bx
.cx
(),
i
as
u64
)))
bx
.extract_element
(
llval
,
bx
.cx
()
.c_usize
(
i
as
u64
)))
}
_
=>
bug!
(
"OperandRef::extract_field({:?}): not applicable"
,
self
)
...
...
@@ -463,7 +463,7 @@ pub fn codegen_operand(&mut self,
// We've errored, so we don't have to produce working code.
let
layout
=
bx
.cx
()
.layout_of
(
ty
);
PlaceRef
::
new_sized
(
CodegenCx
::
c_undef
(
layout
.llvm_type
(
bx
.cx
())
.ptr_to
()),
bx
.cx
()
.
c_undef
(
layout
.llvm_type
(
bx
.cx
())
.ptr_to
()),
layout
,
layout
.align
,
)
.load
(
bx
)
...
...
src/librustc_codegen_llvm/mir/place.rs
浏览文件 @
83e07f9f
...
...
@@ -69,7 +69,7 @@ pub fn from_const_alloc(
let
llval
=
unsafe
{
LLVMConstInBoundsGEP
(
consts
::
bitcast
(
base_addr
,
Type
::
i8p
(
bx
.cx
())),
&
CodegenCx
::
c_usize
(
bx
.cx
(),
offset
.bytes
()),
&
bx
.cx
()
.c_usize
(
offset
.bytes
()),
1
,
)};
let
llval
=
consts
::
bitcast
(
llval
,
layout
.llvm_type
(
bx
.cx
())
.ptr_to
());
...
...
@@ -103,7 +103,7 @@ pub fn len(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Value {
assert_eq!
(
count
,
0
);
self
.llextra
.unwrap
()
}
else
{
CodegenCx
::
c_usize
(
cx
,
count
)
cx
.c_usize
(
count
)
}
}
else
{
bug!
(
"unexpected layout `{:#?}` in PlaceRef::len"
,
self
.layout
)
...
...
@@ -248,7 +248,7 @@ pub fn project_field(
let
meta
=
self
.llextra
;
let
unaligned_offset
=
CodegenCx
::
c_usize
(
cx
,
offset
.bytes
());
let
unaligned_offset
=
cx
.c_usize
(
offset
.bytes
());
// Get the alignment of the field
let
(
_
,
unsized_align
)
=
glue
::
size_and_align_of_dst
(
bx
,
field
.ty
,
meta
);
...
...
@@ -259,7 +259,7 @@ pub fn project_field(
// (unaligned offset + (align - 1)) & -align
// Calculate offset
let
align_sub_1
=
bx
.sub
(
unsized_align
,
CodegenCx
::
c_usize
(
cx
,
1u64
));
let
align_sub_1
=
bx
.sub
(
unsized_align
,
cx
.c_usize
(
1u64
));
let
offset
=
bx
.and
(
bx
.add
(
unaligned_offset
,
align_sub_1
),
bx
.neg
(
unsized_align
));
...
...
@@ -289,14 +289,14 @@ pub fn codegen_get_discr(
)
->
&
'll
Value
{
let
cast_to
=
bx
.cx
()
.layout_of
(
cast_to
)
.immediate_llvm_type
(
bx
.cx
());
if
self
.layout.abi
.is_uninhabited
()
{
return
CodegenCx
::
c_undef
(
cast_to
);
return
bx
.cx
()
.
c_undef
(
cast_to
);
}
match
self
.layout.variants
{
layout
::
Variants
::
Single
{
index
}
=>
{
let
discr_val
=
self
.layout.ty
.ty_adt_def
()
.map_or
(
index
.as_u32
()
as
u128
,
|
def
|
def
.discriminant_for_variant
(
bx
.cx
()
.tcx
,
index
)
.val
);
return
CodegenCx
::
c_uint_big
(
cast_to
,
discr_val
);
return
bx
.cx
()
.
c_uint_big
(
cast_to
,
discr_val
);
}
layout
::
Variants
::
Tagged
{
..
}
|
layout
::
Variants
::
NicheFilling
{
..
}
=>
{},
...
...
@@ -328,22 +328,22 @@ pub fn codegen_get_discr(
// FIXME(eddyb) Check the actual primitive type here.
let
niche_llval
=
if
niche_start
==
0
{
// HACK(eddyb) Using `c_null` as it works on all types.
CodegenCx
::
c_null
(
niche_llty
)
bx
.cx
()
.
c_null
(
niche_llty
)
}
else
{
CodegenCx
::
c_uint_big
(
niche_llty
,
niche_start
)
bx
.cx
()
.
c_uint_big
(
niche_llty
,
niche_start
)
};
bx
.select
(
bx
.icmp
(
IntPredicate
::
IntEQ
,
lldiscr
,
niche_llval
),
CodegenCx
::
c_uint
(
cast_to
,
niche_variants
.start
()
.as_u32
()
as
u64
),
CodegenCx
::
c_uint
(
cast_to
,
dataful_variant
.as_u32
()
as
u64
))
bx
.cx
()
.
c_uint
(
cast_to
,
niche_variants
.start
()
.as_u32
()
as
u64
),
bx
.cx
()
.
c_uint
(
cast_to
,
dataful_variant
.as_u32
()
as
u64
))
}
else
{
// Rebase from niche values to discriminant values.
let
delta
=
niche_start
.wrapping_sub
(
niche_variants
.start
()
.as_u32
()
as
u128
);
let
lldiscr
=
bx
.sub
(
lldiscr
,
CodegenCx
::
c_uint_big
(
niche_llty
,
delta
));
let
lldiscr
=
bx
.sub
(
lldiscr
,
bx
.cx
()
.
c_uint_big
(
niche_llty
,
delta
));
let
lldiscr_max
=
CodegenCx
::
c_uint
(
niche_llty
,
niche_variants
.end
()
.as_u32
()
as
u64
);
bx
.cx
()
.
c_uint
(
niche_llty
,
niche_variants
.end
()
.as_u32
()
as
u64
);
bx
.select
(
bx
.icmp
(
IntPredicate
::
IntULE
,
lldiscr
,
lldiscr_max
),
bx
.intcast
(
lldiscr
,
cast_to
,
false
),
CodegenCx
::
c_uint
(
cast_to
,
dataful_variant
.as_u32
()
as
u64
))
bx
.cx
()
.
c_uint
(
cast_to
,
dataful_variant
.as_u32
()
as
u64
))
}
}
}
...
...
@@ -365,7 +365,7 @@ pub fn codegen_set_discr(&self, bx: &Builder<'a, 'll, 'tcx>, variant_index: Vari
.discriminant_for_variant
(
bx
.tcx
(),
variant_index
)
.val
;
bx
.store
(
CodegenCx
::
c_uint_big
(
ptr
.layout
.llvm_type
(
bx
.cx
()),
to
),
bx
.cx
()
.
c_uint_big
(
ptr
.layout
.llvm_type
(
bx
.cx
()),
to
),
ptr
.llval
,
ptr
.align
);
}
...
...
@@ -381,10 +381,10 @@ pub fn codegen_set_discr(&self, bx: &Builder<'a, 'll, 'tcx>, variant_index: Vari
// Issue #34427: As workaround for LLVM bug on ARM,
// use memset of 0 before assigning niche value.
let
llptr
=
bx
.pointercast
(
self
.llval
,
Type
::
i8
(
bx
.cx
())
.ptr_to
());
let
fill_byte
=
CodegenCx
::
c_u8
(
bx
.cx
(),
0
);
let
fill_byte
=
bx
.cx
()
.c_u8
(
0
);
let
(
size
,
align
)
=
self
.layout
.size_and_align
();
let
size
=
CodegenCx
::
c_usize
(
bx
.cx
(),
size
.bytes
());
let
align
=
CodegenCx
::
c_u32
(
bx
.cx
(),
align
.abi
()
as
u32
);
let
size
=
bx
.cx
()
.c_usize
(
size
.bytes
());
let
align
=
bx
.cx
()
.c_u32
(
align
.abi
()
as
u32
);
base
::
call_memset
(
bx
,
llptr
,
fill_byte
,
size
,
align
,
false
);
}
...
...
@@ -396,9 +396,9 @@ pub fn codegen_set_discr(&self, bx: &Builder<'a, 'll, 'tcx>, variant_index: Vari
// FIXME(eddyb) Check the actual primitive type here.
let
niche_llval
=
if
niche_value
==
0
{
// HACK(eddyb) Using `c_null` as it works on all types.
CodegenCx
::
c_null
(
niche_llty
)
bx
.cx
()
.
c_null
(
niche_llty
)
}
else
{
CodegenCx
::
c_uint_big
(
niche_llty
,
niche_value
)
bx
.cx
()
.
c_uint_big
(
niche_llty
,
niche_value
)
};
OperandValue
::
Immediate
(
niche_llval
)
.store
(
bx
,
niche
);
}
...
...
@@ -409,7 +409,7 @@ pub fn codegen_set_discr(&self, bx: &Builder<'a, 'll, 'tcx>, variant_index: Vari
pub
fn
project_index
(
&
self
,
bx
:
&
Builder
<
'a
,
'll
,
'tcx
>
,
llindex
:
&
'll
Value
)
->
PlaceRef
<
'tcx
,
&
'll
Value
>
{
PlaceRef
{
llval
:
bx
.inbounds_gep
(
self
.llval
,
&
[
CodegenCx
::
c_usize
(
bx
.cx
(),
0
),
llindex
]),
llval
:
bx
.inbounds_gep
(
self
.llval
,
&
[
bx
.cx
()
.c_usize
(
0
),
llindex
]),
llextra
:
None
,
layout
:
self
.layout
.field
(
bx
.cx
(),
0
),
align
:
self
.align
...
...
@@ -484,7 +484,7 @@ pub fn codegen_place(&mut self,
// so we generate an abort
let
fnname
=
bx
.cx
()
.get_intrinsic
(
&
(
"llvm.trap"
));
bx
.call
(
fnname
,
&
[],
None
);
let
llval
=
CodegenCx
::
c_undef
(
layout
.llvm_type
(
bx
.cx
())
.ptr_to
());
let
llval
=
bx
.cx
()
.
c_undef
(
layout
.llvm_type
(
bx
.cx
())
.ptr_to
());
PlaceRef
::
new_sized
(
llval
,
layout
,
layout
.align
)
}
}
...
...
@@ -517,20 +517,20 @@ pub fn codegen_place(&mut self,
mir
::
ProjectionElem
::
ConstantIndex
{
offset
,
from_end
:
false
,
min_length
:
_
}
=>
{
let
lloffset
=
CodegenCx
::
c_usize
(
bx
.cx
(),
offset
as
u64
);
let
lloffset
=
bx
.cx
()
.c_usize
(
offset
as
u64
);
cg_base
.project_index
(
bx
,
lloffset
)
}
mir
::
ProjectionElem
::
ConstantIndex
{
offset
,
from_end
:
true
,
min_length
:
_
}
=>
{
let
lloffset
=
CodegenCx
::
c_usize
(
bx
.cx
(),
offset
as
u64
);
let
lloffset
=
bx
.cx
()
.c_usize
(
offset
as
u64
);
let
lllen
=
cg_base
.len
(
bx
.cx
());
let
llindex
=
bx
.sub
(
lllen
,
lloffset
);
cg_base
.project_index
(
bx
,
llindex
)
}
mir
::
ProjectionElem
::
Subslice
{
from
,
to
}
=>
{
let
mut
subslice
=
cg_base
.project_index
(
bx
,
CodegenCx
::
c_usize
(
bx
.cx
(),
from
as
u64
));
bx
.cx
()
.c_usize
(
from
as
u64
));
let
projected_ty
=
PlaceTy
::
Ty
{
ty
:
cg_base
.layout.ty
}
.projection_ty
(
tcx
,
&
projection
.elem
)
.to_ty
(
bx
.tcx
());
...
...
@@ -538,7 +538,7 @@ pub fn codegen_place(&mut self,
if
subslice
.layout
.is_unsized
()
{
subslice
.llextra
=
Some
(
bx
.sub
(
cg_base
.llextra
.unwrap
(),
CodegenCx
::
c_usize
(
bx
.cx
(),
(
from
as
u64
)
+
(
to
as
u64
))));
bx
.cx
()
.c_usize
(
(
from
as
u64
)
+
(
to
as
u64
))));
}
// Cast the place pointer type to the new
...
...
src/librustc_codegen_llvm/mir/rvalue.rs
浏览文件 @
83e07f9f
...
...
@@ -103,15 +103,15 @@ pub fn codegen_rvalue(&mut self,
return
bx
;
}
let
start
=
dest
.project_index
(
&
bx
,
CodegenCx
::
c_usize
(
bx
.cx
(),
0
))
.llval
;
let
start
=
dest
.project_index
(
&
bx
,
bx
.cx
()
.c_usize
(
0
))
.llval
;
if
let
OperandValue
::
Immediate
(
v
)
=
cg_elem
.val
{
let
align
=
CodegenCx
::
c_i32
(
bx
.cx
(),
dest
.align
.abi
()
as
i32
);
let
size
=
CodegenCx
::
c_usize
(
bx
.cx
(),
dest
.layout.size
.bytes
());
let
align
=
bx
.cx
()
.c_i32
(
dest
.align
.abi
()
as
i32
);
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
{
let
fill
=
CodegenCx
::
c_u8
(
bx
.cx
(),
0
);
let
fill
=
bx
.cx
()
.c_u8
(
0
);
base
::
call_memset
(
&
bx
,
start
,
fill
,
size
,
align
,
false
);
return
bx
;
}
...
...
@@ -124,7 +124,7 @@ pub fn codegen_rvalue(&mut self,
}
}
let
count
=
CodegenCx
::
c_usize
(
bx
.cx
(),
count
);
let
count
=
bx
.cx
()
.c_usize
(
count
);
let
end
=
dest
.project_index
(
&
bx
,
count
)
.llval
;
let
header_bx
=
bx
.build_sibling_block
(
"repeat_loop_header"
);
...
...
@@ -140,7 +140,7 @@ pub fn codegen_rvalue(&mut self,
cg_elem
.val
.store
(
&
body_bx
,
PlaceRef
::
new_sized
(
current
,
cg_elem
.layout
,
dest
.align
));
let
next
=
body_bx
.inbounds_gep
(
current
,
&
[
CodegenCx
::
c_usize
(
bx
.cx
(),
1
)]);
let
next
=
body_bx
.inbounds_gep
(
current
,
&
[
bx
.cx
()
.c_usize
(
1
)]);
body_bx
.br
(
header_bx
.llbb
());
header_bx
.add_incoming_to_phi
(
current
,
next
,
body_bx
.llbb
());
...
...
@@ -292,8 +292,9 @@ pub fn codegen_rvalue_operand(
assert
!
(
cast
.is_llvm_immediate
());
let
ll_t_out
=
cast
.immediate_llvm_type
(
bx
.cx
());
if
operand
.layout.abi
.is_uninhabited
()
{
let
val
=
OperandValue
::
Immediate
(
bx
.cx
()
.c_undef
(
ll_t_out
));
return
(
bx
,
OperandRef
{
val
:
OperandValue
::
Immediate
(
CodegenCx
::
c_undef
(
ll_t_out
))
,
val
,
layout
:
cast
,
});
}
...
...
@@ -307,7 +308,7 @@ pub fn codegen_rvalue_operand(
let
discr_val
=
def
.discriminant_for_variant
(
bx
.cx
()
.tcx
,
index
)
.val
;
let
discr
=
CodegenCx
::
c_uint_big
(
ll_t_out
,
discr_val
);
let
discr
=
bx
.cx
()
.
c_uint_big
(
ll_t_out
,
discr_val
);
return
(
bx
,
OperandRef
{
val
:
OperandValue
::
Immediate
(
discr
),
layout
:
cast
,
...
...
@@ -338,7 +339,7 @@ pub fn codegen_rvalue_operand(
base
::
call_assume
(
&
bx
,
bx
.icmp
(
IntPredicate
::
IntULE
,
llval
,
CodegenCx
::
c_uint_big
(
ll_t_in
,
*
scalar
.valid_range
.end
())
bx
.cx
()
.
c_uint_big
(
ll_t_in
,
*
scalar
.valid_range
.end
())
));
}
}
...
...
@@ -489,7 +490,7 @@ pub fn codegen_rvalue_operand(
mir
::
Rvalue
::
NullaryOp
(
mir
::
NullOp
::
SizeOf
,
ty
)
=>
{
assert
!
(
bx
.cx
()
.type_is_sized
(
ty
));
let
val
=
CodegenCx
::
c_usize
(
bx
.cx
(),
bx
.cx
()
.size_of
(
ty
)
.bytes
());
let
val
=
bx
.cx
()
.c_usize
(
bx
.cx
()
.size_of
(
ty
)
.bytes
());
let
tcx
=
bx
.tcx
();
(
bx
,
OperandRef
{
val
:
OperandValue
::
Immediate
(
val
),
...
...
@@ -500,8 +501,8 @@ pub fn codegen_rvalue_operand(
mir
::
Rvalue
::
NullaryOp
(
mir
::
NullOp
::
Box
,
content_ty
)
=>
{
let
content_ty
:
Ty
<
'tcx
>
=
self
.monomorphize
(
&
content_ty
);
let
(
size
,
align
)
=
bx
.cx
()
.size_and_align_of
(
content_ty
);
let
llsize
=
CodegenCx
::
c_usize
(
bx
.cx
(),
size
.bytes
());
let
llalign
=
CodegenCx
::
c_usize
(
bx
.cx
(),
align
.abi
());
let
llsize
=
bx
.cx
()
.c_usize
(
size
.bytes
());
let
llalign
=
bx
.cx
()
.c_usize
(
align
.abi
());
let
box_layout
=
bx
.cx
()
.layout_of
(
bx
.tcx
()
.mk_box
(
content_ty
));
let
llty_ptr
=
box_layout
.llvm_type
(
bx
.cx
());
...
...
@@ -548,7 +549,7 @@ fn evaluate_array_len(
if
let
LocalRef
::
Operand
(
Some
(
op
))
=
self
.locals
[
index
]
{
if
let
ty
::
Array
(
_
,
n
)
=
op
.layout.ty.sty
{
let
n
=
n
.unwrap_usize
(
bx
.cx
()
.tcx
);
return
CodegenCx
::
c_usize
(
bx
.cx
(),
n
);
return
bx
.cx
()
.c_usize
(
n
);
}
}
}
...
...
@@ -606,7 +607,7 @@ pub fn codegen_scalar_binop(
mir
::
BinOp
::
Shr
=>
common
::
build_unchecked_rshift
(
bx
,
input_ty
,
lhs
,
rhs
),
mir
::
BinOp
::
Ne
|
mir
::
BinOp
::
Lt
|
mir
::
BinOp
::
Gt
|
mir
::
BinOp
::
Eq
|
mir
::
BinOp
::
Le
|
mir
::
BinOp
::
Ge
=>
if
is_unit
{
CodegenCx
::
c_bool
(
bx
.cx
(),
match
op
{
bx
.cx
()
.c_bool
(
match
op
{
mir
::
BinOp
::
Ne
|
mir
::
BinOp
::
Lt
|
mir
::
BinOp
::
Gt
=>
false
,
mir
::
BinOp
::
Eq
|
mir
::
BinOp
::
Le
|
mir
::
BinOp
::
Ge
=>
true
,
_
=>
unreachable!
()
...
...
@@ -685,7 +686,7 @@ pub fn codegen_scalar_checked_binop(&mut self,
// while the current crate doesn't use overflow checks.
if
!
bx
.cx
()
.check_overflow
{
let
val
=
self
.codegen_scalar_binop
(
bx
,
op
,
lhs
,
rhs
,
input_ty
);
return
OperandValue
::
Pair
(
val
,
CodegenCx
::
c_bool
(
bx
.cx
(),
false
));
return
OperandValue
::
Pair
(
val
,
bx
.cx
()
.c_bool
(
false
));
}
let
(
val
,
of
)
=
match
op
{
...
...
@@ -709,7 +710,7 @@ pub fn codegen_scalar_checked_binop(&mut self,
let
invert_mask
=
common
::
shift_mask_val
(
&
bx
,
lhs_llty
,
rhs_llty
,
true
);
let
outer_bits
=
bx
.and
(
rhs
,
invert_mask
);
let
of
=
bx
.icmp
(
IntPredicate
::
IntNE
,
outer_bits
,
CodegenCx
::
c_null
(
rhs_llty
));
let
of
=
bx
.icmp
(
IntPredicate
::
IntNE
,
outer_bits
,
bx
.cx
()
.
c_null
(
rhs_llty
));
let
val
=
self
.codegen_scalar_binop
(
bx
,
op
,
lhs
,
rhs
,
input_ty
);
(
val
,
of
)
...
...
@@ -836,9 +837,9 @@ fn cast_int_to_float(bx: &Builder<'_, 'll, '_>,
use
rustc_apfloat
::
Float
;
const
MAX_F32_PLUS_HALF_ULP
:
u128
=
((
1
<<
(
Single
::
PRECISION
+
1
))
-
1
)
<<
(
Single
::
MAX_EXP
-
Single
::
PRECISION
as
i16
);
let
max
=
CodegenCx
::
c_uint_big
(
int_ty
,
MAX_F32_PLUS_HALF_ULP
);
let
max
=
bx
.cx
()
.
c_uint_big
(
int_ty
,
MAX_F32_PLUS_HALF_ULP
);
let
overflow
=
bx
.icmp
(
IntPredicate
::
IntUGE
,
x
,
max
);
let
infinity_bits
=
CodegenCx
::
c_u32
(
bx
.cx
(),
ieee
::
Single
::
INFINITY
.to_bits
()
as
u32
);
let
infinity_bits
=
bx
.cx
()
.c_u32
(
ieee
::
Single
::
INFINITY
.to_bits
()
as
u32
);
let
infinity
=
consts
::
bitcast
(
infinity_bits
,
float_ty
);
bx
.select
(
overflow
,
infinity
,
bx
.uitofp
(
x
,
float_ty
))
}
else
{
...
...
@@ -907,8 +908,8 @@ fn int_min(signed: bool, int_ty: &Type) -> i128 {
}
let
float_bits_to_llval
=
|
bits
|
{
let
bits_llval
=
match
float_ty
.float_width
()
{
32
=>
CodegenCx
::
c_u32
(
bx
.cx
(),
bits
as
u32
),
64
=>
CodegenCx
::
c_u64
(
bx
.cx
(),
bits
as
u64
),
32
=>
bx
.cx
()
.c_u32
(
bits
as
u32
),
64
=>
bx
.cx
()
.c_u64
(
bits
as
u64
),
n
=>
bug!
(
"unsupported float width {}"
,
n
),
};
consts
::
bitcast
(
bits_llval
,
float_ty
)
...
...
@@ -963,8 +964,8 @@ fn int_min(signed: bool, int_ty: &Type) -> i128 {
// performed is ultimately up to the backend, but at least x86 does perform them.
let
less_or_nan
=
bx
.fcmp
(
RealPredicate
::
RealULT
,
x
,
f_min
);
let
greater
=
bx
.fcmp
(
RealPredicate
::
RealOGT
,
x
,
f_max
);
let
int_max
=
CodegenCx
::
c_uint_big
(
int_ty
,
int_max
(
signed
,
int_ty
));
let
int_min
=
CodegenCx
::
c_uint_big
(
int_ty
,
int_min
(
signed
,
int_ty
)
as
u128
);
let
int_max
=
bx
.cx
()
.
c_uint_big
(
int_ty
,
int_max
(
signed
,
int_ty
));
let
int_min
=
bx
.cx
()
.
c_uint_big
(
int_ty
,
int_min
(
signed
,
int_ty
)
as
u128
);
let
s0
=
bx
.select
(
less_or_nan
,
int_min
,
fptosui_result
);
let
s1
=
bx
.select
(
greater
,
int_max
,
s0
);
...
...
@@ -973,7 +974,7 @@ fn int_min(signed: bool, int_ty: &Type) -> i128 {
// Therefore we only need to execute this step for signed integer types.
if
signed
{
// LLVM has no isNaN predicate, so we use (x == x) instead
bx
.select
(
bx
.fcmp
(
RealPredicate
::
RealOEQ
,
x
,
x
),
s1
,
CodegenCx
::
c_uint
(
int_ty
,
0
))
bx
.select
(
bx
.fcmp
(
RealPredicate
::
RealOEQ
,
x
,
x
),
s1
,
bx
.cx
()
.
c_uint
(
int_ty
,
0
))
}
else
{
s1
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录