Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3a797084
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,发现更多精彩内容 >>
提交
3a797084
编写于
10月 29, 2020
作者:
O
oli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix cranelift build
上级
c4785747
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
28 addition
and
10 deletion
+28
-10
compiler/rustc_codegen_cranelift/src/base.rs
compiler/rustc_codegen_cranelift/src/base.rs
+2
-1
compiler/rustc_codegen_cranelift/src/constant.rs
compiler/rustc_codegen_cranelift/src/constant.rs
+2
-3
compiler/rustc_codegen_cranelift/src/discriminant.rs
compiler/rustc_codegen_cranelift/src/discriminant.rs
+4
-3
compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
+2
-1
compiler/rustc_codegen_cranelift/src/value_and_place.rs
compiler/rustc_codegen_cranelift/src/value_and_place.rs
+4
-2
compiler/rustc_middle/src/ty/consts/int.rs
compiler/rustc_middle/src/ty/consts/int.rs
+14
-0
未找到文件。
compiler/rustc_codegen_cranelift/src/base.rs
浏览文件 @
3a797084
...
...
@@ -499,7 +499,7 @@ fn codegen_stmt<'tcx>(
UnOp
::
Neg
=>
match
layout
.ty
.kind
()
{
ty
::
Int
(
IntTy
::
I128
)
=>
{
// FIXME remove this case once ineg.i128 works
let
zero
=
CValue
::
const_val
(
fx
,
layout
,
0
);
let
zero
=
CValue
::
const_val
(
fx
,
layout
,
ty
::
ScalarInt
::
null
(
layout
.size
)
);
crate
::
num
::
codegen_int_binop
(
fx
,
BinOp
::
Sub
,
zero
,
operand
)
}
ty
::
Int
(
_
)
=>
CValue
::
by_val
(
fx
.bcx
.ins
()
.ineg
(
val
),
layout
),
...
...
@@ -592,6 +592,7 @@ fn is_fat_ptr<'tcx>(
}
else
{
discr
.val
};
let
discr
=
discr
.into
();
let
discr
=
CValue
::
const_val
(
fx
,
fx
.layout_of
(
to_ty
),
discr
);
lval
.write_cvalue
(
fx
,
discr
);
...
...
compiler/rustc_codegen_cranelift/src/constant.rs
浏览文件 @
3a797084
...
...
@@ -186,9 +186,8 @@ pub(crate) fn codegen_const_value<'tcx>(
}
match
x
{
Scalar
::
Raw
{
data
,
size
}
=>
{
assert_eq!
(
u64
::
from
(
size
),
layout
.size
.bytes
());
CValue
::
const_val
(
fx
,
layout
,
data
)
Scalar
::
Raw
(
int
)
=>
{
CValue
::
const_val
(
fx
,
layout
,
int
)
}
Scalar
::
Ptr
(
ptr
)
=>
{
let
alloc_kind
=
fx
.tcx
.get_global_alloc
(
ptr
.alloc_id
);
...
...
compiler/rustc_codegen_cranelift/src/discriminant.rs
浏览文件 @
3a797084
...
...
@@ -30,7 +30,8 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
.ty
.discriminant_for_variant
(
fx
.tcx
,
variant_index
)
.unwrap
()
.val
;
.val
.into
();
let
discr
=
CValue
::
const_val
(
fx
,
ptr
.layout
(),
to
);
ptr
.write_cvalue
(
fx
,
discr
);
}
...
...
@@ -49,7 +50,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
let
niche
=
place
.place_field
(
fx
,
mir
::
Field
::
new
(
tag_field
));
let
niche_value
=
variant_index
.as_u32
()
-
niche_variants
.start
()
.as_u32
();
let
niche_value
=
u128
::
from
(
niche_value
)
.wrapping_add
(
niche_start
);
let
niche_llval
=
CValue
::
const_val
(
fx
,
niche
.layout
(),
niche_value
);
let
niche_llval
=
CValue
::
const_val
(
fx
,
niche
.layout
(),
niche_value
.into
()
);
niche
.write_cvalue
(
fx
,
niche_llval
);
}
}
...
...
@@ -77,7 +78,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
.ty
.discriminant_for_variant
(
fx
.tcx
,
*
index
)
.map_or
(
u128
::
from
(
index
.as_u32
()),
|
discr
|
discr
.val
);
return
CValue
::
const_val
(
fx
,
dest_layout
,
discr_val
);
return
CValue
::
const_val
(
fx
,
dest_layout
,
discr_val
.into
()
);
}
Variants
::
Multiple
{
tag
,
...
...
compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
浏览文件 @
3a797084
...
...
@@ -1064,7 +1064,8 @@ fn swap(bcx: &mut FunctionBuilder<'_>, v: Value) -> Value {
fx
.bcx
.ins
()
.call_indirect
(
f_sig
,
f
,
&
[
data
]);
let
ret_val
=
CValue
::
const_val
(
fx
,
ret
.layout
(),
0
);
let
layout
=
ret
.layout
();
let
ret_val
=
CValue
::
const_val
(
fx
,
layout
,
ty
::
ScalarInt
::
null
(
layout
.size
));
ret
.write_cvalue
(
fx
,
ret_val
);
};
...
...
compiler/rustc_codegen_cranelift/src/value_and_place.rs
浏览文件 @
3a797084
...
...
@@ -231,15 +231,16 @@ pub(crate) fn unsize_value(
pub
(
crate
)
fn
const_val
(
fx
:
&
mut
FunctionCx
<
'_
,
'tcx
,
impl
Module
>
,
layout
:
TyAndLayout
<
'tcx
>
,
const_val
:
u128
,
const_val
:
ty
::
ScalarInt
,
)
->
CValue
<
'tcx
>
{
assert_eq!
(
const_val
.size
(),
layout
.size
);
use
cranelift_codegen
::
ir
::
immediates
::{
Ieee32
,
Ieee64
};
let
clif_ty
=
fx
.clif_type
(
layout
.ty
)
.unwrap
();
if
let
ty
::
Bool
=
layout
.ty
.kind
()
{
assert
!
(
const_val
==
0
||
const_val
==
1
,
const_val
==
ty
::
ScalarInt
::
FALSE
||
const_val
==
ty
::
ScalarInt
::
TRUE
,
"Invalid bool 0x{:032X}"
,
const_val
);
...
...
@@ -247,6 +248,7 @@ pub(crate) fn const_val(
let
val
=
match
layout
.ty
.kind
()
{
ty
::
Uint
(
UintTy
::
U128
)
|
ty
::
Int
(
IntTy
::
I128
)
=>
{
let
const_val
=
const_val
.to_bits
(
layout
.size
)
.unwrap
();
let
lsb
=
fx
.bcx
.ins
()
.iconst
(
types
::
I64
,
const_val
as
u64
as
i64
);
let
msb
=
fx
.bcx
...
...
compiler/rustc_middle/src/ty/consts/int.rs
浏览文件 @
3a797084
...
...
@@ -353,3 +353,17 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!
(
f
,
"{:01$x}"
,
{
self
.data
},
self
.size
as
usize
*
2
)
}
}
impl
fmt
::
UpperHex
for
ScalarInt
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
self
.check_data
();
// Format as hex number wide enough to fit any value of the given `size`.
// So data=20, size=1 will be "0x14", but with size=4 it'll be "0x00000014".
// Using a block `{self.data}` here to force a copy instead of using `self.data`
// directly, because `write!` takes references to its formatting arguments and
// would thus borrow `self.data`. Since `Self`
// is a packed struct, that would create a possibly unaligned reference, which
// is UB on a lot of platforms.
write!
(
f
,
"{:01$X}"
,
{
self
.data
},
self
.size
as
usize
*
2
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录