Skip to content

Commit ccd1136

Browse files
committed
Stop using to_hir_binop in codegen
1 parent 6579ed8 commit ccd1136

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

compiler/rustc_codegen_llvm/src/intrinsic.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
1414
use rustc_codegen_ssa::mir::place::PlaceRef;
1515
use rustc_codegen_ssa::traits::*;
1616
use rustc_hir as hir;
17+
use rustc_middle::mir::BinOp;
1718
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf};
1819
use rustc_middle::ty::{self, GenericArgsRef, Ty};
1920
use rustc_middle::{bug, span_bug};
@@ -1104,12 +1105,12 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
11041105
let in_ty = arg_tys[0];
11051106

11061107
let comparison = match name {
1107-
sym::simd_eq => Some(hir::BinOpKind::Eq),
1108-
sym::simd_ne => Some(hir::BinOpKind::Ne),
1109-
sym::simd_lt => Some(hir::BinOpKind::Lt),
1110-
sym::simd_le => Some(hir::BinOpKind::Le),
1111-
sym::simd_gt => Some(hir::BinOpKind::Gt),
1112-
sym::simd_ge => Some(hir::BinOpKind::Ge),
1108+
sym::simd_eq => Some(BinOp::Eq),
1109+
sym::simd_ne => Some(BinOp::Ne),
1110+
sym::simd_lt => Some(BinOp::Lt),
1111+
sym::simd_le => Some(BinOp::Le),
1112+
sym::simd_gt => Some(BinOp::Gt),
1113+
sym::simd_ge => Some(BinOp::Ge),
11131114
_ => None,
11141115
};
11151116

compiler/rustc_codegen_ssa/src/base.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
2020
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
2121
use rustc_data_structures::sync::par_map;
2222
use rustc_data_structures::unord::UnordMap;
23-
use rustc_hir as hir;
2423
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
2524
use rustc_hir::lang_items::LangItem;
2625
use rustc_metadata::EncodedMetadata;
@@ -30,6 +29,7 @@ use rustc_middle::middle::debugger_visualizer::{DebuggerVisualizerFile, Debugger
3029
use rustc_middle::middle::exported_symbols;
3130
use rustc_middle::middle::exported_symbols::SymbolExportKind;
3231
use rustc_middle::middle::lang_items;
32+
use rustc_middle::mir::BinOp;
3333
use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem};
3434
use rustc_middle::query::Providers;
3535
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
@@ -46,32 +46,32 @@ use std::time::{Duration, Instant};
4646

4747
use itertools::Itertools;
4848

49-
pub fn bin_op_to_icmp_predicate(op: hir::BinOpKind, signed: bool) -> IntPredicate {
49+
pub fn bin_op_to_icmp_predicate(op: BinOp, signed: bool) -> IntPredicate {
5050
match op {
51-
hir::BinOpKind::Eq => IntPredicate::IntEQ,
52-
hir::BinOpKind::Ne => IntPredicate::IntNE,
53-
hir::BinOpKind::Lt => {
51+
BinOp::Eq => IntPredicate::IntEQ,
52+
BinOp::Ne => IntPredicate::IntNE,
53+
BinOp::Lt => {
5454
if signed {
5555
IntPredicate::IntSLT
5656
} else {
5757
IntPredicate::IntULT
5858
}
5959
}
60-
hir::BinOpKind::Le => {
60+
BinOp::Le => {
6161
if signed {
6262
IntPredicate::IntSLE
6363
} else {
6464
IntPredicate::IntULE
6565
}
6666
}
67-
hir::BinOpKind::Gt => {
67+
BinOp::Gt => {
6868
if signed {
6969
IntPredicate::IntSGT
7070
} else {
7171
IntPredicate::IntUGT
7272
}
7373
}
74-
hir::BinOpKind::Ge => {
74+
BinOp::Ge => {
7575
if signed {
7676
IntPredicate::IntSGE
7777
} else {
@@ -86,14 +86,14 @@ pub fn bin_op_to_icmp_predicate(op: hir::BinOpKind, signed: bool) -> IntPredicat
8686
}
8787
}
8888

89-
pub fn bin_op_to_fcmp_predicate(op: hir::BinOpKind) -> RealPredicate {
89+
pub fn bin_op_to_fcmp_predicate(op: BinOp) -> RealPredicate {
9090
match op {
91-
hir::BinOpKind::Eq => RealPredicate::RealOEQ,
92-
hir::BinOpKind::Ne => RealPredicate::RealUNE,
93-
hir::BinOpKind::Lt => RealPredicate::RealOLT,
94-
hir::BinOpKind::Le => RealPredicate::RealOLE,
95-
hir::BinOpKind::Gt => RealPredicate::RealOGT,
96-
hir::BinOpKind::Ge => RealPredicate::RealOGE,
91+
BinOp::Eq => RealPredicate::RealOEQ,
92+
BinOp::Ne => RealPredicate::RealUNE,
93+
BinOp::Lt => RealPredicate::RealOLT,
94+
BinOp::Le => RealPredicate::RealOLE,
95+
BinOp::Gt => RealPredicate::RealOGT,
96+
BinOp::Ge => RealPredicate::RealOGE,
9797
op => {
9898
bug!(
9999
"comparison_op_to_fcmp_predicate: expected comparison operator, \
@@ -110,7 +110,7 @@ pub fn compare_simd_types<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
110110
rhs: Bx::Value,
111111
t: Ty<'tcx>,
112112
ret_ty: Bx::Type,
113-
op: hir::BinOpKind,
113+
op: BinOp,
114114
) -> Bx::Value {
115115
let signed = match t.kind() {
116116
ty::Float(_) => {

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::common::IntPredicate;
77
use crate::traits::*;
88
use crate::MemFlags;
99

10-
use rustc_hir as hir;
1110
use rustc_middle::mir;
1211
use rustc_middle::ty::cast::{CastTy, IntTy};
1312
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
@@ -894,9 +893,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
894893
| mir::BinOp::Le
895894
| mir::BinOp::Ge => {
896895
if is_float {
897-
bx.fcmp(base::bin_op_to_fcmp_predicate(op.to_hir_binop()), lhs, rhs)
896+
bx.fcmp(base::bin_op_to_fcmp_predicate(op), lhs, rhs)
898897
} else {
899-
bx.icmp(base::bin_op_to_icmp_predicate(op.to_hir_binop(), is_signed), lhs, rhs)
898+
bx.icmp(base::bin_op_to_icmp_predicate(op, is_signed), lhs, rhs)
900899
}
901900
}
902901
mir::BinOp::Cmp => {
@@ -910,16 +909,16 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
910909
// `PartialOrd`, so only use it in debug for now. Once LLVM can handle it
911910
// better (see <https://github.com/llvm/llvm-project/issues/73417>), it'll
912911
// be worth trying it in optimized builds as well.
913-
let is_gt = bx.icmp(pred(hir::BinOpKind::Gt), lhs, rhs);
912+
let is_gt = bx.icmp(pred(mir::BinOp::Gt), lhs, rhs);
914913
let gtext = bx.zext(is_gt, bx.type_i8());
915-
let is_lt = bx.icmp(pred(hir::BinOpKind::Lt), lhs, rhs);
914+
let is_lt = bx.icmp(pred(mir::BinOp::Lt), lhs, rhs);
916915
let ltext = bx.zext(is_lt, bx.type_i8());
917916
bx.unchecked_ssub(gtext, ltext)
918917
} else {
919918
// These operations are those expected by `tests/codegen/integer-cmp.rs`,
920919
// from <https://github.com/rust-lang/rust/pull/63767>.
921-
let is_lt = bx.icmp(pred(hir::BinOpKind::Lt), lhs, rhs);
922-
let is_ne = bx.icmp(pred(hir::BinOpKind::Ne), lhs, rhs);
920+
let is_lt = bx.icmp(pred(mir::BinOp::Lt), lhs, rhs);
921+
let is_ne = bx.icmp(pred(mir::BinOp::Ne), lhs, rhs);
923922
let ge = bx.select(
924923
is_ne,
925924
bx.cx().const_i8(Ordering::Greater as i8),

compiler/rustc_middle/src/mir/tcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl BorrowKind {
296296
}
297297

298298
impl BinOp {
299-
pub fn to_hir_binop(self) -> hir::BinOpKind {
299+
pub(crate) fn to_hir_binop(self) -> hir::BinOpKind {
300300
match self {
301301
BinOp::Add => hir::BinOpKind::Add,
302302
BinOp::Sub => hir::BinOpKind::Sub,

0 commit comments

Comments
 (0)