Skip to content

Commit 97825a3

Browse files
denismerigouxeddyb
authored andcommitted
Move doc to trait declarations
1 parent ac34068 commit 97825a3

File tree

17 files changed

+124
-111
lines changed

17 files changed

+124
-111
lines changed

src/librustc_codegen_llvm/asm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use libc::{c_uint, c_char};
2525

2626

2727
impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
28-
// Take an inline assembly expression and splat it out via LLVM
2928
fn codegen_inline_asm(
3029
&self,
3130
ia: &hir::InlineAsm,

src/librustc_codegen_llvm/base.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ pub fn bin_op_to_fcmp_predicate(op: hir::BinOpKind) -> RealPredicate {
156156
}
157157
}
158158

159-
pub fn compare_simd_types<'a, 'tcx: 'a, Builder: BuilderMethods<'a, 'tcx>>(
160-
bx: &Builder,
161-
lhs: Builder::Value,
162-
rhs: Builder::Value,
159+
pub fn compare_simd_types<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
160+
bx: &Bx,
161+
lhs: Bx::Value,
162+
rhs: Bx::Value,
163163
t: Ty<'tcx>,
164-
ret_ty: Builder::Type,
164+
ret_ty: Bx::Type,
165165
op: hir::BinOpKind
166-
) -> Builder::Value {
166+
) -> Bx::Value {
167167
let signed = match t.sty {
168168
ty::Float(_) => {
169169
let cmp = bin_op_to_fcmp_predicate(op);
@@ -332,31 +332,31 @@ pub fn coerce_unsized_into<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
332332
}
333333
}
334334

335-
pub fn cast_shift_expr_rhs<'a, 'tcx: 'a, Builder: BuilderMethods<'a, 'tcx>>(
336-
bx: &Builder,
335+
pub fn cast_shift_expr_rhs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
336+
bx: &Bx,
337337
op: hir::BinOpKind,
338-
lhs: Builder::Value,
339-
rhs: Builder::Value
340-
) -> Builder::Value {
338+
lhs: Bx::Value,
339+
rhs: Bx::Value
340+
) -> Bx::Value {
341341
cast_shift_rhs(bx, op, lhs, rhs, |a, b| bx.trunc(a, b), |a, b| bx.zext(a, b))
342342
}
343343

344-
fn cast_shift_rhs<'a, 'tcx: 'a, F, G, Builder: BuilderMethods<'a, 'tcx>>(
345-
bx: &Builder,
344+
fn cast_shift_rhs<'a, 'tcx: 'a, F, G, Bx: BuilderMethods<'a, 'tcx>>(
345+
bx: &Bx,
346346
op: hir::BinOpKind,
347-
lhs: Builder::Value,
348-
rhs: Builder::Value,
347+
lhs: Bx::Value,
348+
rhs: Bx::Value,
349349
trunc: F,
350350
zext: G
351-
) -> Builder::Value
351+
) -> Bx::Value
352352
where F: FnOnce(
353-
Builder::Value,
354-
Builder::Type
355-
) -> Builder::Value,
353+
Bx::Value,
354+
Bx::Type
355+
) -> Bx::Value,
356356
G: FnOnce(
357-
Builder::Value,
358-
Builder::Type
359-
) -> Builder::Value
357+
Bx::Value,
358+
Bx::Type
359+
) -> Bx::Value
360360
{
361361
// Shifts may have any size int on the rhs
362362
if op.is_shift() {
@@ -412,33 +412,33 @@ pub fn from_immediate<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
412412
}
413413
}
414414

415-
pub fn to_immediate<'a, 'tcx: 'a, Builder: BuilderMethods<'a, 'tcx>>(
416-
bx: &Builder,
417-
val: Builder::Value,
415+
pub fn to_immediate<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
416+
bx: &Bx,
417+
val: Bx::Value,
418418
layout: layout::TyLayout,
419-
) -> Builder::Value {
419+
) -> Bx::Value {
420420
if let layout::Abi::Scalar(ref scalar) = layout.abi {
421421
return to_immediate_scalar(bx, val, scalar);
422422
}
423423
val
424424
}
425425

426-
pub fn to_immediate_scalar<'a, 'tcx: 'a, Builder: BuilderMethods<'a, 'tcx>>(
427-
bx: &Builder,
428-
val: Builder::Value,
426+
pub fn to_immediate_scalar<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
427+
bx: &Bx,
428+
val: Bx::Value,
429429
scalar: &layout::Scalar,
430-
) -> Builder::Value {
430+
) -> Bx::Value {
431431
if scalar.is_bool() {
432432
return bx.trunc(val, bx.cx().type_i1());
433433
}
434434
val
435435
}
436436

437-
pub fn memcpy_ty<'a, 'tcx: 'a, Builder: BuilderMethods<'a, 'tcx>>(
438-
bx: &Builder,
439-
dst: Builder::Value,
437+
pub fn memcpy_ty<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
438+
bx: &Bx,
439+
dst: Bx::Value,
440440
dst_align: Align,
441-
src: Builder::Value,
441+
src: Bx::Value,
442442
src_align: Align,
443443
layout: TyLayout<'tcx>,
444444
flags: MemFlags,

src/librustc_codegen_llvm/builder.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
12651265
}
12661266
}
12671267

1268-
/// Returns the ptr value that should be used for storing `val`.
12691268
fn check_store<'b>(&self,
12701269
val: &'ll Value,
12711270
ptr: &'ll Value) -> &'ll Value {
@@ -1285,7 +1284,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
12851284
}
12861285
}
12871286

1288-
/// Returns the args that should be used for a call to `llfn`.
12891287
fn check_call<'b>(&self,
12901288
typ: &str,
12911289
llfn: &'ll Value,
@@ -1336,14 +1334,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
13361334
self.call_lifetime_intrinsic("llvm.lifetime.end", ptr, size);
13371335
}
13381336

1339-
/// If LLVM lifetime intrinsic support is enabled (i.e. optimizations
1340-
/// on), and `ptr` is nonzero-sized, then extracts the size of `ptr`
1341-
/// and the intrinsic for `lt` and passes them to `emit`, which is in
1342-
/// charge of generating code to call the passed intrinsic on whatever
1343-
/// block of generated code is targeted for the intrinsic.
1344-
///
1345-
/// If LLVM lifetime intrinsic support is disabled (i.e. optimizations
1346-
/// off) or `ptr` is zero-sized, then no-op (does not call `emit`).
13471337
fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: &'ll Value, size: Size) {
13481338
if self.cx.sess().opts.optimize == config::OptLevel::No {
13491339
return;

src/librustc_codegen_llvm/callee.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ pub fn get_fn(
203203
llfn
204204
}
205205

206-
pub fn resolve_and_get_fn<'tcx,
207-
Cx: Backend<'tcx> + MiscMethods<'tcx> + TypeMethods<'tcx>
208-
>(
206+
pub fn resolve_and_get_fn<'tcx, Cx: CodegenMethods<'tcx>>(
209207
cx: &Cx,
210208
def_id: DefId,
211209
substs: &'tcx Substs<'tcx>,

src/librustc_codegen_llvm/common.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ impl BackendTypes for CodegenCx<'ll, 'tcx> {
224224
}
225225

226226
impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
227-
// LLVM constant constructors.
228227
fn const_null(&self, t: &'ll Type) -> &'ll Value {
229228
unsafe {
230229
llvm::LLVMConstNull(t)
@@ -286,9 +285,6 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
286285
self.const_uint(self.type_i8(), i as u64)
287286
}
288287

289-
290-
// This is a 'c-like' raw string, which differs from
291-
// our boxed-and-length-annotated strings.
292288
fn const_cstr(
293289
&self,
294290
s: LocalInternedString,
@@ -316,8 +312,6 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
316312
}
317313
}
318314

319-
// NB: Do not use `do_spill_noroot` to make this into a constant string, or
320-
// you will be kicked off fast isel. See issue #4352 for an example of this.
321315
fn const_str_slice(&self, s: LocalInternedString) -> &'ll Value {
322316
let len = s.len();
323317
let cs = consts::ptrcast(self.const_cstr(s, false),

src/librustc_codegen_llvm/context.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ impl IntrinsicDeclarationMethods<'tcx> for CodegenCx<'b, 'tcx> {
444444
self.declare_intrinsic(key).unwrap_or_else(|| bug!("unknown intrinsic '{}'", key))
445445
}
446446

447-
/// Declare any llvm intrinsics that you might need
448447
fn declare_intrinsic(
449448
&self,
450449
key: &str

src/librustc_codegen_llvm/debuginfo/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,6 @@ impl DebugInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
285285
}
286286

287287
impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
288-
/// Creates the function-specific debug context.
289-
///
290-
/// Returns the FunctionDebugContext for the function which holds state needed
291-
/// for debug info creation. The function may also return another variant of the
292-
/// FunctionDebugContext enum which indicates why no debuginfo should be created
293-
/// for the function.
294288
fn create_function_debug_context(
295289
&self,
296290
instance: Instance<'tcx>,

src/librustc_codegen_llvm/declare.rs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ fn declare_raw_fn(
9797

9898
impl DeclareMethods<'tcx> for CodegenCx<'ll, 'tcx> {
9999

100-
/// Declare a global value.
101-
///
102-
/// If there’s a value with the same name already declared, the function will
103-
/// return its Value instead.
104100
fn declare_global(
105101
&self,
106102
name: &str, ty: &'ll Type
@@ -112,13 +108,6 @@ impl DeclareMethods<'tcx> for CodegenCx<'ll, 'tcx> {
112108
}
113109
}
114110

115-
/// Declare a C ABI function.
116-
///
117-
/// Only use this for foreign function ABIs and glue. For Rust functions use
118-
/// `declare_fn` instead.
119-
///
120-
/// If there’s a value with the same name already declared, the function will
121-
/// update the declaration and return existing Value instead.
122111
fn declare_cfn(
123112
&self,
124113
name: &str,
@@ -127,11 +116,6 @@ impl DeclareMethods<'tcx> for CodegenCx<'ll, 'tcx> {
127116
declare_raw_fn(self, name, llvm::CCallConv, fn_type)
128117
}
129118

130-
131-
/// Declare a Rust function.
132-
///
133-
/// If there’s a value with the same name already declared, the function will
134-
/// update the declaration and return existing Value instead.
135119
fn declare_fn(
136120
&self,
137121
name: &str,
@@ -157,13 +141,6 @@ impl DeclareMethods<'tcx> for CodegenCx<'ll, 'tcx> {
157141
llfn
158142
}
159143

160-
161-
/// Declare a global with an intention to define it.
162-
///
163-
/// Use this function when you intend to define a global. This function will
164-
/// return None if the name already has a definition associated with it. In that
165-
/// case an error should be reported to the user, because it usually happens due
166-
/// to user’s fault (e.g. misuse of #[no_mangle] or #[export_name] attributes).
167144
fn define_global(
168145
&self,
169146
name: &str,
@@ -176,20 +153,12 @@ impl DeclareMethods<'tcx> for CodegenCx<'ll, 'tcx> {
176153
}
177154
}
178155

179-
/// Declare a private global
180-
///
181-
/// Use this function when you intend to define a global without a name.
182156
fn define_private_global(&self, ty: &'ll Type) -> &'ll Value {
183157
unsafe {
184158
llvm::LLVMRustInsertPrivateGlobal(self.llmod, ty)
185159
}
186160
}
187161

188-
/// Declare a Rust function with an intention to define it.
189-
///
190-
/// Use this function when you intend to define a function. This function will
191-
/// return panic if the name already has a definition associated with it. This
192-
/// can happen with #[no_mangle] or #[export_name], for example.
193162
fn define_fn(
194163
&self,
195164
name: &str,
@@ -202,11 +171,6 @@ impl DeclareMethods<'tcx> for CodegenCx<'ll, 'tcx> {
202171
}
203172
}
204173

205-
/// Declare a Rust function with an intention to define it.
206-
///
207-
/// Use this function when you intend to define a function. This function will
208-
/// return panic if the name already has a definition associated with it. This
209-
/// can happen with #[no_mangle] or #[export_name], for example.
210174
fn define_internal_fn(
211175
&self,
212176
name: &str,
@@ -217,16 +181,12 @@ impl DeclareMethods<'tcx> for CodegenCx<'ll, 'tcx> {
217181
llfn
218182
}
219183

220-
221-
/// Get declared value by name.
222184
fn get_declared_value(&self, name: &str) -> Option<&'ll Value> {
223185
debug!("get_declared_value(name={:?})", name);
224186
let namebuf = SmallCStr::new(name);
225187
unsafe { llvm::LLVMRustGetNamedValue(self.llmod, namebuf.as_ptr()) }
226188
}
227189

228-
/// Get defined or externally defined (AvailableExternally linkage) value by
229-
/// name.
230190
fn get_defined_value(&self, name: &str) -> Option<&'ll Value> {
231191
self.get_declared_value(name).and_then(|val|{
232192
let declaration = unsafe {

src/librustc_codegen_llvm/interfaces/asm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use mir::place::PlaceRef;
1414
use rustc::hir::{GlobalAsm, InlineAsm};
1515

1616
pub trait AsmBuilderMethods<'tcx>: HasCodegen<'tcx> {
17+
// Take an inline assembly expression and splat it out via LLVM
1718
fn codegen_inline_asm(
1819
&self,
1920
ia: &InlineAsm,

src/librustc_codegen_llvm/interfaces/builder.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ pub trait BuilderMethods<'a, 'tcx: 'a>:
244244
fn add_incoming_to_phi(&self, phi: Self::Value, val: Self::Value, bb: Self::BasicBlock);
245245
fn set_invariant_load(&self, load: Self::Value);
246246

247+
/// Returns the ptr value that should be used for storing `val`.
247248
fn check_store(&self, val: Self::Value, ptr: Self::Value) -> Self::Value;
249+
250+
/// Returns the args that should be used for a call to `llfn`.
248251
fn check_call<'b>(
249252
&self,
250253
typ: &str,
@@ -256,6 +259,14 @@ pub trait BuilderMethods<'a, 'tcx: 'a>:
256259
fn lifetime_start(&self, ptr: Self::Value, size: Size);
257260
fn lifetime_end(&self, ptr: Self::Value, size: Size);
258261

262+
/// If LLVM lifetime intrinsic support is enabled (i.e. optimizations
263+
/// on), and `ptr` is nonzero-sized, then extracts the size of `ptr`
264+
/// and the intrinsic for `lt` and passes them to `emit`, which is in
265+
/// charge of generating code to call the passed intrinsic on whatever
266+
/// block of generated code is targeted for the intrinsic.
267+
///
268+
/// If LLVM lifetime intrinsic support is disabled (i.e. optimizations
269+
/// off) or `ptr` is zero-sized, then no-op (does not call `emit`).
259270
fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: Self::Value, size: Size);
260271

261272
fn call(

0 commit comments

Comments
 (0)