Skip to content

Commit 0da5170

Browse files
committed
Moved common.rs enums
1 parent 570d3c0 commit 0da5170

File tree

10 files changed

+166
-155
lines changed

10 files changed

+166
-155
lines changed

src/librustc_codegen_llvm/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ use builder::{Builder, MemFlags};
5454
use callee;
5555
use rustc_mir::monomorphize::collector::{self, MonoItemCollectionMode};
5656
use rustc_mir::monomorphize::item::DefPathBasedNames;
57-
use common::{self, RealPredicate, TypeKind};
58-
use rustc_codegen_utils::common::IntPredicate;
57+
use common;
58+
use rustc_codegen_utils::common::{RealPredicate, TypeKind, IntPredicate};
5959
use meth;
6060
use mir;
6161
use context::CodegenCx;

src/librustc_codegen_llvm/builder.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
1212
use llvm::{self, False, OperandBundleDef, BasicBlock};
13-
use common::{self, *};
14-
use rustc_codegen_utils::common::IntPredicate;
13+
use common;
14+
use rustc_codegen_utils::common::{IntPredicate, TypeKind, RealPredicate};
15+
use rustc_codegen_utils;
1516
use context::CodegenCx;
1617
use type_::Type;
1718
use type_of::LayoutLlvmExt;
@@ -514,7 +515,7 @@ impl BuilderMethods<'a, 'll, 'tcx>
514515
fn atomic_load(
515516
&self,
516517
ptr: &'ll Value,
517-
order: common::AtomicOrdering,
518+
order: rustc_codegen_utils::common::AtomicOrdering,
518519
align: Align
519520
) -> &'ll Value {
520521
self.count_insn("load.atomic");
@@ -636,7 +637,7 @@ impl BuilderMethods<'a, 'll, 'tcx>
636637
}
637638

638639
fn atomic_store(&self, val: &'ll Value, ptr: &'ll Value,
639-
order: common::AtomicOrdering, align: Align) {
640+
order: rustc_codegen_utils::common::AtomicOrdering, align: Align) {
640641
debug!("Store {:?} -> {:?}", val, ptr);
641642
self.count_insn("store.atomic");
642643
let ptr = self.check_store(val, ptr);
@@ -1168,8 +1169,8 @@ impl BuilderMethods<'a, 'll, 'tcx>
11681169
dst: &'ll Value,
11691170
cmp: &'ll Value,
11701171
src: &'ll Value,
1171-
order: common::AtomicOrdering,
1172-
failure_order: common::AtomicOrdering,
1172+
order: rustc_codegen_utils::common::AtomicOrdering,
1173+
failure_order: rustc_codegen_utils::common::AtomicOrdering,
11731174
weak: bool,
11741175
) -> &'ll Value {
11751176
let weak = if weak { llvm::True } else { llvm::False };
@@ -1187,10 +1188,10 @@ impl BuilderMethods<'a, 'll, 'tcx>
11871188
}
11881189
fn atomic_rmw(
11891190
&self,
1190-
op: common::AtomicRmwBinOp,
1191+
op: rustc_codegen_utils::common::AtomicRmwBinOp,
11911192
dst: &'ll Value,
11921193
src: &'ll Value,
1193-
order: common::AtomicOrdering,
1194+
order: rustc_codegen_utils::common::AtomicOrdering,
11941195
) -> &'ll Value {
11951196
unsafe {
11961197
llvm::LLVMBuildAtomicRMW(
@@ -1203,7 +1204,11 @@ impl BuilderMethods<'a, 'll, 'tcx>
12031204
}
12041205
}
12051206

1206-
fn atomic_fence(&self, order: common::AtomicOrdering, scope: common::SynchronizationScope) {
1207+
fn atomic_fence(
1208+
&self,
1209+
order: rustc_codegen_utils::common::AtomicOrdering,
1210+
scope: rustc_codegen_utils::common::SynchronizationScope
1211+
) {
12071212
unsafe {
12081213
llvm::LLVMRustBuildAtomicFence(
12091214
self.llbuilder,

src/librustc_codegen_llvm/common.rs

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use rustc::hir;
3030
use interfaces::BuilderMethods;
3131
use mir::constant::const_alloc_to_llvm;
3232
use mir::place::PlaceRef;
33+
use rustc_codegen_utils::common::TypeKind;
3334

3435
use libc::{c_uint, c_char};
3536
use std::iter;
@@ -67,81 +68,6 @@ impl<V> OperandBundleDef<'ll, V> {
6768
}
6869
}
6970

70-
#[allow(dead_code)]
71-
pub enum RealPredicate {
72-
RealPredicateFalse,
73-
RealOEQ,
74-
RealOGT,
75-
RealOGE,
76-
RealOLT,
77-
RealOLE,
78-
RealONE,
79-
RealORD,
80-
RealUNO,
81-
RealUEQ,
82-
RealUGT,
83-
RealUGE,
84-
RealULT,
85-
RealULE,
86-
RealUNE,
87-
RealPredicateTrue
88-
}
89-
90-
pub enum AtomicRmwBinOp {
91-
AtomicXchg,
92-
AtomicAdd,
93-
AtomicSub,
94-
AtomicAnd,
95-
AtomicNand,
96-
AtomicOr,
97-
AtomicXor,
98-
AtomicMax,
99-
AtomicMin,
100-
AtomicUMax,
101-
AtomicUMin
102-
}
103-
104-
pub enum AtomicOrdering {
105-
#[allow(dead_code)]
106-
NotAtomic,
107-
Unordered,
108-
Monotonic,
109-
// Consume, // Not specified yet.
110-
Acquire,
111-
Release,
112-
AcquireRelease,
113-
SequentiallyConsistent,
114-
}
115-
116-
pub enum SynchronizationScope {
117-
// FIXME: figure out if this variant is needed at all.
118-
#[allow(dead_code)]
119-
Other,
120-
SingleThread,
121-
CrossThread,
122-
}
123-
124-
#[derive(Copy, Clone, PartialEq, Debug)]
125-
pub enum TypeKind {
126-
Void,
127-
Half,
128-
Float,
129-
Double,
130-
X86_FP80,
131-
FP128,
132-
PPc_FP128,
133-
Label,
134-
Integer,
135-
Function,
136-
Struct,
137-
Array,
138-
Pointer,
139-
Vector,
140-
Metadata,
141-
X86_MMX,
142-
Token,
143-
}
144-
14571
/*
14672
* A note on nomenclature of linking: "extern", "foreign", and "upcall".
14773
*

src/librustc_codegen_llvm/interfaces/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use common::*;
12-
use rustc_codegen_utils::common::IntPredicate;
12+
use rustc_codegen_utils::common::{IntPredicate, RealPredicate, AtomicOrdering, SynchronizationScope, AtomicRmwBinOp};
1313
use libc::c_char;
1414
use rustc::ty::TyCtxt;
1515
use rustc::ty::layout::{Align, Size};

src/librustc_codegen_llvm/interfaces/type_.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use super::backend::Backend;
1212
use super::builder::HasCodegen;
13-
use common::TypeKind;
13+
use rustc_codegen_utils::common::TypeKind;
1414
use syntax::ast;
1515
use rustc::ty::layout::{self, Align, Size};
1616
use std::cell::RefCell;

src/librustc_codegen_llvm/intrinsic.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ use abi::{Abi, FnType, LlvmType, PassMode};
1717
use mir::place::PlaceRef;
1818
use mir::operand::{OperandRef, OperandValue};
1919
use base::*;
20-
use common::*;
2120
use context::CodegenCx;
2221
use glue;
2322
use type_::Type;
2423
use type_of::LayoutLlvmExt;
2524
use rustc::ty::{self, Ty};
2625
use rustc::ty::layout::{HasDataLayout, LayoutOf};
26+
use rustc_codegen_utils::common::TypeKind;
2727
use rustc::hir;
2828
use syntax::ast;
2929
use syntax::symbol::Symbol;
@@ -424,7 +424,9 @@ impl IntrinsicCallMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx, &'ll Value>
424424
// This requires that atomic intrinsics follow a specific naming pattern:
425425
// "atomic_<operation>[_<ordering>]", and no ordering means SeqCst
426426
name if name.starts_with("atomic_") => {
427-
use self::AtomicOrdering::*;
427+
use rustc_codegen_utils::common::AtomicOrdering::*;
428+
use rustc_codegen_utils::common::
429+
{SynchronizationScope, AtomicRmwBinOp};
428430

429431
let split: Vec<&str> = name.split('_').collect();
430432

src/librustc_codegen_llvm/llvm/ffi.rs

Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use libc::{c_uint, c_int, size_t, c_char};
1919
use libc::{c_ulonglong, c_void};
2020

2121
use std::marker::PhantomData;
22-
use common;
2322
use rustc_codegen_utils;
2423
use syntax;
2524

@@ -184,24 +183,24 @@ pub enum RealPredicate {
184183
}
185184

186185
impl RealPredicate {
187-
pub fn from_generic(realpred: common::RealPredicate) -> Self {
186+
pub fn from_generic(realpred: rustc_codegen_utils::common::RealPredicate) -> Self {
188187
match realpred {
189-
common::RealPredicate::RealPredicateFalse => RealPredicate::RealPredicateFalse,
190-
common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
191-
common::RealPredicate::RealOGT => RealPredicate::RealOGT,
192-
common::RealPredicate::RealOGE => RealPredicate::RealOGE,
193-
common::RealPredicate::RealOLT => RealPredicate::RealOLT,
194-
common::RealPredicate::RealOLE => RealPredicate::RealOLE,
195-
common::RealPredicate::RealONE => RealPredicate::RealONE,
196-
common::RealPredicate::RealORD => RealPredicate::RealORD,
197-
common::RealPredicate::RealUNO => RealPredicate::RealUNO,
198-
common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
199-
common::RealPredicate::RealUGT => RealPredicate::RealUGT,
200-
common::RealPredicate::RealUGE => RealPredicate::RealUGE,
201-
common::RealPredicate::RealULT => RealPredicate::RealULT,
202-
common::RealPredicate::RealULE => RealPredicate::RealULE,
203-
common::RealPredicate::RealUNE => RealPredicate::RealUNE,
204-
common::RealPredicate::RealPredicateTrue => RealPredicate::RealPredicateTrue
188+
rustc_codegen_utils::common::RealPredicate::RealPredicateFalse => RealPredicate::RealPredicateFalse,
189+
rustc_codegen_utils::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
190+
rustc_codegen_utils::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
191+
rustc_codegen_utils::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
192+
rustc_codegen_utils::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
193+
rustc_codegen_utils::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
194+
rustc_codegen_utils::common::RealPredicate::RealONE => RealPredicate::RealONE,
195+
rustc_codegen_utils::common::RealPredicate::RealORD => RealPredicate::RealORD,
196+
rustc_codegen_utils::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
197+
rustc_codegen_utils::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
198+
rustc_codegen_utils::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
199+
rustc_codegen_utils::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
200+
rustc_codegen_utils::common::RealPredicate::RealULT => RealPredicate::RealULT,
201+
rustc_codegen_utils::common::RealPredicate::RealULE => RealPredicate::RealULE,
202+
rustc_codegen_utils::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
203+
rustc_codegen_utils::common::RealPredicate::RealPredicateTrue => RealPredicate::RealPredicateTrue
205204
}
206205
}
207206
}
@@ -216,7 +215,7 @@ pub enum TypeKind {
216215
Double = 3,
217216
X86_FP80 = 4,
218217
FP128 = 5,
219-
PPc_FP128 = 6,
218+
PPC_FP128 = 6,
220219
Label = 7,
221220
Integer = 8,
222221
Function = 9,
@@ -230,25 +229,25 @@ pub enum TypeKind {
230229
}
231230

232231
impl TypeKind {
233-
pub fn to_generic(self) -> common::TypeKind {
232+
pub fn to_generic(self) -> rustc_codegen_utils::common::TypeKind {
234233
match self {
235-
TypeKind::Void => common::TypeKind::Void,
236-
TypeKind::Half => common::TypeKind::Half,
237-
TypeKind::Float => common::TypeKind::Float,
238-
TypeKind::Double => common::TypeKind::Double,
239-
TypeKind::X86_FP80 => common::TypeKind::X86_FP80,
240-
TypeKind::FP128 => common::TypeKind::FP128,
241-
TypeKind::PPc_FP128 => common::TypeKind::PPc_FP128,
242-
TypeKind::Label => common::TypeKind::Label,
243-
TypeKind::Integer => common::TypeKind::Integer,
244-
TypeKind::Function => common::TypeKind::Function,
245-
TypeKind::Struct => common::TypeKind::Struct,
246-
TypeKind::Array => common::TypeKind::Array,
247-
TypeKind::Pointer => common::TypeKind::Pointer,
248-
TypeKind::Vector => common::TypeKind::Vector,
249-
TypeKind::Metadata => common::TypeKind::Metadata,
250-
TypeKind::X86_MMX => common::TypeKind::X86_MMX,
251-
TypeKind::Token => common::TypeKind::Token,
234+
TypeKind::Void => rustc_codegen_utils::common::TypeKind::Void,
235+
TypeKind::Half => rustc_codegen_utils::common::TypeKind::Half,
236+
TypeKind::Float => rustc_codegen_utils::common::TypeKind::Float,
237+
TypeKind::Double => rustc_codegen_utils::common::TypeKind::Double,
238+
TypeKind::X86_FP80 => rustc_codegen_utils::common::TypeKind::X86_FP80,
239+
TypeKind::FP128 => rustc_codegen_utils::common::TypeKind::FP128,
240+
TypeKind::PPC_FP128 => rustc_codegen_utils::common::TypeKind::PPC_FP128,
241+
TypeKind::Label => rustc_codegen_utils::common::TypeKind::Label,
242+
TypeKind::Integer => rustc_codegen_utils::common::TypeKind::Integer,
243+
TypeKind::Function => rustc_codegen_utils::common::TypeKind::Function,
244+
TypeKind::Struct => rustc_codegen_utils::common::TypeKind::Struct,
245+
TypeKind::Array => rustc_codegen_utils::common::TypeKind::Array,
246+
TypeKind::Pointer => rustc_codegen_utils::common::TypeKind::Pointer,
247+
TypeKind::Vector => rustc_codegen_utils::common::TypeKind::Vector,
248+
TypeKind::Metadata => rustc_codegen_utils::common::TypeKind::Metadata,
249+
TypeKind::X86_MMX => rustc_codegen_utils::common::TypeKind::X86_MMX,
250+
TypeKind::Token => rustc_codegen_utils::common::TypeKind::Token,
252251
}
253252
}
254253
}
@@ -271,19 +270,19 @@ pub enum AtomicRmwBinOp {
271270
}
272271

273272
impl AtomicRmwBinOp {
274-
pub fn from_generic(op : common::AtomicRmwBinOp) -> Self {
273+
pub fn from_generic(op : rustc_codegen_utils::common::AtomicRmwBinOp) -> Self {
275274
match op {
276-
common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
277-
common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
278-
common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
279-
common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
280-
common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
281-
common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
282-
common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
283-
common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
284-
common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
285-
common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
286-
common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin
275+
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
276+
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
277+
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
278+
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
279+
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
280+
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
281+
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
282+
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
283+
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
284+
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
285+
rustc_codegen_utils::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin
287286
}
288287
}
289288
}
@@ -304,15 +303,15 @@ pub enum AtomicOrdering {
304303
}
305304

306305
impl AtomicOrdering {
307-
pub fn from_generic(ao : common::AtomicOrdering) -> Self {
306+
pub fn from_generic(ao : rustc_codegen_utils::common::AtomicOrdering) -> Self {
308307
match ao {
309-
common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
310-
common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
311-
common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
312-
common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
313-
common::AtomicOrdering::Release => AtomicOrdering::Release,
314-
common::AtomicOrdering::AcquireRelease => AtomicOrdering::AcquireRelease,
315-
common::AtomicOrdering::SequentiallyConsistent =>
308+
rustc_codegen_utils::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
309+
rustc_codegen_utils::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
310+
rustc_codegen_utils::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
311+
rustc_codegen_utils::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
312+
rustc_codegen_utils::common::AtomicOrdering::Release => AtomicOrdering::Release,
313+
rustc_codegen_utils::common::AtomicOrdering::AcquireRelease => AtomicOrdering::AcquireRelease,
314+
rustc_codegen_utils::common::AtomicOrdering::SequentiallyConsistent =>
316315
AtomicOrdering::SequentiallyConsistent
317316
}
318317
}
@@ -331,11 +330,11 @@ pub enum SynchronizationScope {
331330
}
332331

333332
impl SynchronizationScope {
334-
pub fn from_generic(sc : common::SynchronizationScope) -> Self {
333+
pub fn from_generic(sc : rustc_codegen_utils::common::SynchronizationScope) -> Self {
335334
match sc {
336-
common::SynchronizationScope::Other => SynchronizationScope::Other,
337-
common::SynchronizationScope::SingleThread => SynchronizationScope::SingleThread,
338-
common::SynchronizationScope::CrossThread => SynchronizationScope::CrossThread,
335+
rustc_codegen_utils::common::SynchronizationScope::Other => SynchronizationScope::Other,
336+
rustc_codegen_utils::common::SynchronizationScope::SingleThread => SynchronizationScope::SingleThread,
337+
rustc_codegen_utils::common::SynchronizationScope::CrossThread => SynchronizationScope::CrossThread,
339338
}
340339
}
341340
}

src/librustc_codegen_llvm/mir/rvalue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use std::{u128, i128};
1818

1919
use base;
2020
use callee;
21-
use common::{self, RealPredicate};
22-
use rustc_codegen_utils::common::IntPredicate;
21+
use common;
22+
use rustc_codegen_utils::common::{RealPredicate, IntPredicate};
2323
use monomorphize;
2424
use type_of::LayoutLlvmExt;
2525

0 commit comments

Comments
 (0)