Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8590336d
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,发现更多精彩内容 >>
提交
8590336d
编写于
8月 21, 2018
作者:
D
Denis Merigoux
提交者:
Eduard-Mihai Burtescu
11月 16, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Generalized RealPredicate
上级
51b7f273
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
62 addition
and
16 deletion
+62
-16
src/librustc_codegen_llvm/base.rs
src/librustc_codegen_llvm/base.rs
+8
-8
src/librustc_codegen_llvm/builder.rs
src/librustc_codegen_llvm/builder.rs
+2
-2
src/librustc_codegen_llvm/llvm/ffi.rs
src/librustc_codegen_llvm/llvm/ffi.rs
+23
-0
src/librustc_codegen_llvm/mir/rvalue.rs
src/librustc_codegen_llvm/mir/rvalue.rs
+4
-5
src/librustc_codegen_llvm/traits.rs
src/librustc_codegen_llvm/traits.rs
+25
-1
未找到文件。
src/librustc_codegen_llvm/base.rs
浏览文件 @
8590336d
...
...
@@ -75,7 +75,7 @@
use
rustc_data_structures
::
sync
::
Lrc
;
use
rustc_data_structures
::
indexed_vec
::
Idx
;
use
traits
::{
IntPredicate
,
BuilderMethods
};
use
traits
::{
IntPredicate
,
RealPredicate
,
BuilderMethods
};
use
llvm
::
BasicBlock
;
use
std
::
any
::
Any
;
...
...
@@ -143,14 +143,14 @@ pub fn bin_op_to_icmp_predicate(op: hir::BinOpKind,
}
}
pub
fn
bin_op_to_fcmp_predicate
(
op
:
hir
::
BinOpKind
)
->
llvm
::
RealPredicate
{
pub
fn
bin_op_to_fcmp_predicate
(
op
:
hir
::
BinOpKind
)
->
RealPredicate
{
match
op
{
hir
::
BinOpKind
::
Eq
=>
llvm
::
RealOEQ
,
hir
::
BinOpKind
::
Ne
=>
llvm
::
RealUNE
,
hir
::
BinOpKind
::
Lt
=>
llvm
::
RealOLT
,
hir
::
BinOpKind
::
Le
=>
llvm
::
RealOLE
,
hir
::
BinOpKind
::
Gt
=>
llvm
::
RealOGT
,
hir
::
BinOpKind
::
Ge
=>
llvm
::
RealOGE
,
hir
::
BinOpKind
::
Eq
=>
RealPredicate
::
RealOEQ
,
hir
::
BinOpKind
::
Ne
=>
RealPredicate
::
RealUNE
,
hir
::
BinOpKind
::
Lt
=>
RealPredicate
::
RealOLT
,
hir
::
BinOpKind
::
Le
=>
RealPredicate
::
RealOLE
,
hir
::
BinOpKind
::
Gt
=>
RealPredicate
::
RealOGT
,
hir
::
BinOpKind
::
Ge
=>
RealPredicate
::
RealOGE
,
op
=>
{
bug!
(
"comparison_op_to_fcmp_predicate: expected comparison operator,
\
found {:?}"
,
...
...
src/librustc_codegen_llvm/builder.rs
浏览文件 @
8590336d
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
use
llvm
::{
AtomicRmwBinOp
,
AtomicOrdering
,
SynchronizationScope
,
AsmDialect
};
use
llvm
::{
RealPredicate
,
False
,
OperandBundleDef
};
use
llvm
::{
False
,
OperandBundleDef
};
use
llvm
::{
self
,
BasicBlock
};
use
common
::
*
;
use
type_
::
Type
;
...
...
@@ -697,7 +697,7 @@ fn icmp(&self, op: traits::IntPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'
}
}
fn
fcmp
(
&
self
,
op
:
RealPredicate
,
lhs
:
&
'll
Value
,
rhs
:
&
'll
Value
)
->
&
'll
Value
{
fn
fcmp
(
&
self
,
op
:
traits
::
RealPredicate
,
lhs
:
&
'll
Value
,
rhs
:
&
'll
Value
)
->
&
'll
Value
{
self
.count_insn
(
"fcmp"
);
unsafe
{
llvm
::
LLVMBuildFCmp
(
self
.llbuilder
,
op
as
c_uint
,
lhs
,
rhs
,
noname
())
...
...
src/librustc_codegen_llvm/llvm/ffi.rs
浏览文件 @
8590336d
...
...
@@ -181,6 +181,29 @@ pub enum RealPredicate {
RealPredicateTrue
=
15
,
}
impl
traits
::
RealPredicateMethods
for
RealPredicate
{
fn
convert_to_backend_specific
(
realpred
:
traits
::
RealPredicate
)
->
Self
{
match
realpred
{
traits
::
RealPredicate
::
RealPredicateFalse
=>
RealPredicate
::
RealPredicateFalse
,
traits
::
RealPredicate
::
RealOEQ
=>
RealPredicate
::
RealOEQ
,
traits
::
RealPredicate
::
RealOGT
=>
RealPredicate
::
RealOGT
,
traits
::
RealPredicate
::
RealOGE
=>
RealPredicate
::
RealOGE
,
traits
::
RealPredicate
::
RealOLT
=>
RealPredicate
::
RealOLT
,
traits
::
RealPredicate
::
RealOLE
=>
RealPredicate
::
RealOLE
,
traits
::
RealPredicate
::
RealONE
=>
RealPredicate
::
RealONE
,
traits
::
RealPredicate
::
RealORD
=>
RealPredicate
::
RealORD
,
traits
::
RealPredicate
::
RealUNO
=>
RealPredicate
::
RealUNO
,
traits
::
RealPredicate
::
RealUEQ
=>
RealPredicate
::
RealUEQ
,
traits
::
RealPredicate
::
RealUGT
=>
RealPredicate
::
RealUGT
,
traits
::
RealPredicate
::
RealUGE
=>
RealPredicate
::
RealUGE
,
traits
::
RealPredicate
::
RealULT
=>
RealPredicate
::
RealULT
,
traits
::
RealPredicate
::
RealULE
=>
RealPredicate
::
RealULE
,
traits
::
RealPredicate
::
RealUNE
=>
RealPredicate
::
RealUNE
,
traits
::
RealPredicate
::
RealPredicateTrue
=>
RealPredicate
::
RealPredicateTrue
}
}
}
/// LLVMTypeKind
#[derive(Copy,
Clone,
PartialEq,
Debug)]
#[repr(C)]
...
...
src/librustc_codegen_llvm/mir/rvalue.rs
浏览文件 @
8590336d
...
...
@@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use
llvm
;
use
rustc
::
ty
::{
self
,
Ty
};
use
rustc
::
ty
::
cast
::{
CastTy
,
IntTy
};
use
rustc
::
ty
::
layout
::{
self
,
LayoutOf
};
...
...
@@ -28,7 +27,7 @@
use
type_of
::
LayoutLlvmExt
;
use
value
::
Value
;
use
traits
::{
IntPredicate
,
BuilderMethods
};
use
traits
::{
IntPredicate
,
RealPredicate
,
BuilderMethods
};
use
super
::{
FunctionCx
,
LocalRef
};
use
super
::
operand
::{
OperandRef
,
OperandValue
};
...
...
@@ -962,8 +961,8 @@ fn int_min(signed: bool, int_ty: &Type) -> i128 {
// negation, and the negation can be merged into the select. Therefore, it not necessarily any
// more expensive than a ordered ("normal") comparison. Whether these optimizations will be
// performed is ultimately up to the backend, but at least x86 does perform them.
let
less_or_nan
=
bx
.fcmp
(
llvm
::
RealULT
,
x
,
f_min
);
let
greater
=
bx
.fcmp
(
llvm
::
RealOGT
,
x
,
f_max
);
let
less_or_nan
=
bx
.fcmp
(
RealPredicate
::
RealULT
,
x
,
f_min
);
let
greater
=
bx
.fcmp
(
RealPredicate
::
RealOGT
,
x
,
f_max
);
let
int_max
=
C_uint_big
(
int_ty
,
int_max
(
signed
,
int_ty
));
let
int_min
=
C_uint_big
(
int_ty
,
int_min
(
signed
,
int_ty
)
as
u128
);
let
s0
=
bx
.select
(
less_or_nan
,
int_min
,
fptosui_result
);
...
...
@@ -974,7 +973,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
(
llvm
::
RealOEQ
,
x
,
x
),
s1
,
C_uint
(
int_ty
,
0
))
bx
.select
(
bx
.fcmp
(
RealPredicate
::
RealOEQ
,
x
,
x
),
s1
,
C_uint
(
int_ty
,
0
))
}
else
{
s1
}
...
...
src/librustc_codegen_llvm/traits.rs
浏览文件 @
8590336d
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
use
llvm
::{
AtomicRmwBinOp
,
AtomicOrdering
,
SynchronizationScope
,
AsmDialect
};
use
llvm
::
{
RealPredicate
,
OperandBundleDef
}
;
use
llvm
::
OperandBundleDef
;
use
common
::
*
;
use
type_
::
Type
;
use
libc
::
c_char
;
...
...
@@ -38,6 +38,30 @@ pub trait IntPredicateMethods {
fn
convert_to_backend_specific
(
intpre
:
IntPredicate
)
->
Self
;
}
#[allow(dead_code)]
pub
enum
RealPredicate
{
RealPredicateFalse
,
RealOEQ
,
RealOGT
,
RealOGE
,
RealOLT
,
RealOLE
,
RealONE
,
RealORD
,
RealUNO
,
RealUEQ
,
RealUGT
,
RealUGE
,
RealULT
,
RealULE
,
RealUNE
,
RealPredicateTrue
,
}
pub
trait
RealPredicateMethods
{
fn
convert_to_backend_specific
(
realpred
:
RealPredicate
)
->
Self
;
}
pub
trait
BuilderMethods
<
'a
,
'll
:
'a
,
'tcx
:
'll
,
Value
:
?
Sized
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录