Skip to content

Commit 0466dcd

Browse files
committed
Moved common.rs enums
1 parent b0a2c2e commit 0466dcd

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");
@@ -634,7 +635,7 @@ impl BuilderMethods<'a, 'll, 'tcx>
634635
}
635636

636637
fn atomic_store(&self, val: &'ll Value, ptr: &'ll Value,
637-
order: common::AtomicOrdering, align: Align) {
638+
order: rustc_codegen_utils::common::AtomicOrdering, align: Align) {
638639
debug!("Store {:?} -> {:?}", val, ptr);
639640
self.count_insn("store.atomic");
640641
let ptr = self.check_store(val, ptr);
@@ -1165,8 +1166,8 @@ impl BuilderMethods<'a, 'll, 'tcx>
11651166
dst: &'ll Value,
11661167
cmp: &'ll Value,
11671168
src: &'ll Value,
1168-
order: common::AtomicOrdering,
1169-
failure_order: common::AtomicOrdering,
1169+
order: rustc_codegen_utils::common::AtomicOrdering,
1170+
failure_order: rustc_codegen_utils::common::AtomicOrdering,
11701171
weak: bool,
11711172
) -> &'ll Value {
11721173
let weak = if weak { llvm::True } else { llvm::False };
@@ -1184,10 +1185,10 @@ impl BuilderMethods<'a, 'll, 'tcx>
11841185
}
11851186
fn atomic_rmw(
11861187
&self,
1187-
op: common::AtomicRmwBinOp,
1188+
op: rustc_codegen_utils::common::AtomicRmwBinOp,
11881189
dst: &'ll Value,
11891190
src: &'ll Value,
1190-
order: common::AtomicOrdering,
1191+
order: rustc_codegen_utils::common::AtomicOrdering,
11911192
) -> &'ll Value {
11921193
unsafe {
11931194
llvm::LLVMBuildAtomicRMW(
@@ -1200,7 +1201,11 @@ impl BuilderMethods<'a, 'll, 'tcx>
12001201
}
12011202
}
12021203

1203-
fn atomic_fence(&self, order: common::AtomicOrdering, scope: common::SynchronizationScope) {
1204+
fn atomic_fence(
1205+
&self,
1206+
order: rustc_codegen_utils::common::AtomicOrdering,
1207+
scope: rustc_codegen_utils::common::SynchronizationScope
1208+
) {
12041209
unsafe {
12051210
llvm::LLVMRustBuildAtomicFence(
12061211
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

@@ -65,81 +66,6 @@ impl<V> OperandBundleDef<'ll, V> {
6566
}
6667
}
6768

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

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;
@@ -411,7 +411,9 @@ impl IntrinsicCallMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx, &'ll Value>
411411
// This requires that atomic intrinsics follow a specific naming pattern:
412412
// "atomic_<operation>[_<ordering>]", and no ordering means SeqCst
413413
name if name.starts_with("atomic_") => {
414-
use self::AtomicOrdering::*;
414+
use rustc_codegen_utils::common::AtomicOrdering::*;
415+
use rustc_codegen_utils::common::
416+
{SynchronizationScope, AtomicRmwBinOp};
415417

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

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)