Skip to content

Commit

Permalink
Starting to move backend-agnostic code into codegen_utils
Browse files Browse the repository at this point in the history
IntPredicate moved
  • Loading branch information
denismerigoux authored and eddyb committed Nov 16, 2018
1 parent 4ba09ab commit 39fd4d9
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 29 deletions.
3 changes: 2 additions & 1 deletion src/librustc_codegen_llvm/base.rs
Expand Up @@ -53,7 +53,8 @@ use mir::place::PlaceRef;
use builder::{Builder, MemFlags};
use callee;
use rustc_mir::monomorphize::item::DefPathBasedNames;
use common::{self, IntPredicate, RealPredicate, TypeKind};
use common::{self, RealPredicate, TypeKind};
use rustc_codegen_utils::common::IntPredicate;
use meth;
use mir;
use context::CodegenCx;
Expand Down
1 change: 1 addition & 0 deletions src/librustc_codegen_llvm/builder.rs
Expand Up @@ -11,6 +11,7 @@
use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
use llvm::{self, False, OperandBundleDef, BasicBlock};
use common::{self, *};
use rustc_codegen_utils::common::IntPredicate;
use context::CodegenCx;
use type_::Type;
use type_of::LayoutLlvmExt;
Expand Down
13 changes: 0 additions & 13 deletions src/librustc_codegen_llvm/common.rs
Expand Up @@ -64,19 +64,6 @@ impl<'a, V> OperandBundleDef<'a, V> {
}
}

pub enum IntPredicate {
IntEQ,
IntNE,
IntUGT,
IntUGE,
IntULT,
IntULE,
IntSGT,
IntSGE,
IntSLT,
IntSLE
}

#[allow(dead_code)]
pub enum RealPredicate {
RealPredicateFalse,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/glue.rs
Expand Up @@ -14,7 +14,7 @@

use std;

use common::*;
use rustc_codegen_utils::common::IntPredicate;
use meth;
use rustc::ty::layout::LayoutOf;
use rustc::ty::{self, Ty};
Expand Down
1 change: 1 addition & 0 deletions src/librustc_codegen_llvm/interfaces/builder.rs
Expand Up @@ -20,6 +20,7 @@ use libc::c_char;
use mir::operand::OperandRef;
use mir::place::PlaceRef;
use rustc::ty::layout::{Align, Size};
use rustc_codegen_utils::common::IntPredicate;

use std::borrow::Cow;
use std::ops::Range;
Expand Down
23 changes: 12 additions & 11 deletions src/librustc_codegen_llvm/llvm/ffi.rs
Expand Up @@ -20,6 +20,7 @@ use libc::{c_ulonglong, c_void};

use std::marker::PhantomData;
use common;
use rustc_codegen_utils;
use syntax;

use super::RustString;
Expand Down Expand Up @@ -144,18 +145,18 @@ pub enum IntPredicate {
}

impl IntPredicate {
pub fn from_generic(intpre: common::IntPredicate) -> Self {
pub fn from_generic(intpre: rustc_codegen_utils::common::IntPredicate) -> Self {
match intpre {
common::IntPredicate::IntEQ => IntPredicate::IntEQ,
common::IntPredicate::IntNE => IntPredicate::IntNE,
common::IntPredicate::IntUGT => IntPredicate::IntUGT,
common::IntPredicate::IntUGE => IntPredicate::IntUGE,
common::IntPredicate::IntULT => IntPredicate::IntULT,
common::IntPredicate::IntULE => IntPredicate::IntULE,
common::IntPredicate::IntSGT => IntPredicate::IntSGT,
common::IntPredicate::IntSGE => IntPredicate::IntSGE,
common::IntPredicate::IntSLT => IntPredicate::IntSLT,
common::IntPredicate::IntSLE => IntPredicate::IntSLE,
rustc_codegen_utils::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
rustc_codegen_utils::common::IntPredicate::IntNE => IntPredicate::IntNE,
rustc_codegen_utils::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
rustc_codegen_utils::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
rustc_codegen_utils::common::IntPredicate::IntULT => IntPredicate::IntULT,
rustc_codegen_utils::common::IntPredicate::IntULE => IntPredicate::IntULE,
rustc_codegen_utils::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
rustc_codegen_utils::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
rustc_codegen_utils::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
rustc_codegen_utils::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_codegen_llvm/mir/block.rs
Expand Up @@ -17,7 +17,8 @@ use abi::{Abi, FnType, PassMode};
use rustc_target::abi::call::ArgType;
use base;
use builder::MemFlags;
use common::{self, Funclet, IntPredicate};
use common::{self, Funclet};
use rustc_codegen_utils::common::IntPredicate;
use meth;
use monomorphize;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/mir/place.rs
Expand Up @@ -13,7 +13,7 @@ use rustc::ty::layout::{self, Align, TyLayout, LayoutOf, VariantIdx, HasTyCtxt};
use rustc::mir;
use rustc::mir::tcx::PlaceTy;
use builder::MemFlags;
use common::IntPredicate;
use rustc_codegen_utils::common::IntPredicate;
use type_of::LayoutLlvmExt;
use glue;

Expand Down
3 changes: 2 additions & 1 deletion src/librustc_codegen_llvm/mir/rvalue.rs
Expand Up @@ -19,7 +19,8 @@ use std::{u128, i128};
use base;
use builder::MemFlags;
use callee;
use common::{self, IntPredicate, RealPredicate};
use common::{self, RealPredicate};
use rustc_codegen_utils::common::IntPredicate;
use monomorphize;
use type_of::LayoutLlvmExt;

Expand Down
22 changes: 22 additions & 0 deletions src/librustc_codegen_utils/common.rs
@@ -0,0 +1,22 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub enum IntPredicate {
IntEQ,
IntNE,
IntUGT,
IntUGE,
IntULT,
IntULE,
IntSGT,
IntSGE,
IntSLT,
IntSLE
}
1 change: 1 addition & 0 deletions src/librustc_codegen_utils/lib.rs
Expand Up @@ -54,6 +54,7 @@ pub mod codegen_backend;
pub mod symbol_export;
pub mod symbol_names;
pub mod symbol_names_test;
pub mod common;

/// check for the #[rustc_error] annotation, which forces an
/// error in codegen. This is used to write compile-fail tests
Expand Down

0 comments on commit 39fd4d9

Please sign in to comment.