Skip to content

Commit 6ce5a6d

Browse files
committed
Move doc to trait declarations
1 parent 845c874 commit 6ce5a6d

File tree

17 files changed

+132
-113
lines changed

17 files changed

+132
-113
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<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx, &'ll Value> {
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
@@ -159,14 +159,14 @@ pub fn bin_op_to_fcmp_predicate(op: hir::BinOpKind) -> RealPredicate {
159159
}
160160
}
161161

162-
pub fn compare_simd_types<'a, 'll:'a, 'tcx:'ll, Builder : BuilderMethods<'a, 'll, 'tcx>>(
163-
bx: &Builder,
164-
lhs: <Builder::CodegenCx as Backend<'ll>>::Value,
165-
rhs: <Builder::CodegenCx as Backend<'ll>>::Value,
162+
pub fn compare_simd_types<'a, 'll:'a, 'tcx:'ll, Bx : BuilderMethods<'a, 'll, 'tcx>>(
163+
bx: &Bx,
164+
lhs: <Bx::CodegenCx as Backend<'ll>>::Value,
165+
rhs: <Bx::CodegenCx as Backend<'ll>>::Value,
166166
t: Ty<'tcx>,
167-
ret_ty: <Builder::CodegenCx as Backend<'ll>>::Type,
167+
ret_ty: <Bx::CodegenCx as Backend<'ll>>::Type,
168168
op: hir::BinOpKind
169-
) -> <Builder::CodegenCx as Backend<'ll>>::Value {
169+
) -> <Bx::CodegenCx as Backend<'ll>>::Value {
170170
let signed = match t.sty {
171171
ty::Float(_) => {
172172
let cmp = bin_op_to_fcmp_predicate(op);
@@ -338,31 +338,31 @@ pub fn coerce_unsized_into<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a, 'll, '
338338
}
339339
}
340340

341-
pub fn cast_shift_expr_rhs<'a, 'll: 'a, 'tcx: 'll, Builder : BuilderMethods<'a, 'll, 'tcx>>(
342-
bx: &Builder,
341+
pub fn cast_shift_expr_rhs<'a, 'll: 'a, 'tcx: 'll, Bx : BuilderMethods<'a, 'll, 'tcx>>(
342+
bx: &Bx,
343343
op: hir::BinOpKind,
344-
lhs: <Builder::CodegenCx as Backend<'ll>>::Value,
345-
rhs: <Builder::CodegenCx as Backend<'ll>>::Value
346-
) -> <Builder::CodegenCx as Backend<'ll>>::Value {
344+
lhs: <Bx::CodegenCx as Backend<'ll>>::Value,
345+
rhs: <Bx::CodegenCx as Backend<'ll>>::Value
346+
) -> <Bx::CodegenCx as Backend<'ll>>::Value {
347347
cast_shift_rhs(bx, op, lhs, rhs, |a, b| bx.trunc(a, b), |a, b| bx.zext(a, b))
348348
}
349349

350-
fn cast_shift_rhs<'a, 'll :'a, 'tcx : 'll, F, G, Builder : BuilderMethods<'a, 'll, 'tcx>>(
351-
bx: &Builder,
350+
fn cast_shift_rhs<'a, 'll :'a, 'tcx : 'll, F, G, Bx : BuilderMethods<'a, 'll, 'tcx>>(
351+
bx: &Bx,
352352
op: hir::BinOpKind,
353-
lhs: <Builder::CodegenCx as Backend<'ll>>::Value,
354-
rhs: <Builder::CodegenCx as Backend<'ll>>::Value,
353+
lhs: <Bx::CodegenCx as Backend<'ll>>::Value,
354+
rhs: <Bx::CodegenCx as Backend<'ll>>::Value,
355355
trunc: F,
356356
zext: G
357-
) -> <Builder::CodegenCx as Backend<'ll>>::Value
357+
) -> <Bx::CodegenCx as Backend<'ll>>::Value
358358
where F: FnOnce(
359-
<Builder::CodegenCx as Backend<'ll>>::Value,
360-
<Builder::CodegenCx as Backend<'ll>>::Type
361-
) -> <Builder::CodegenCx as Backend<'ll>>::Value,
359+
<Bx::CodegenCx as Backend<'ll>>::Value,
360+
<Bx::CodegenCx as Backend<'ll>>::Type
361+
) -> <Bx::CodegenCx as Backend<'ll>>::Value,
362362
G: FnOnce(
363-
<Builder::CodegenCx as Backend<'ll>>::Value,
364-
<Builder::CodegenCx as Backend<'ll>>::Type
365-
) -> <Builder::CodegenCx as Backend<'ll>>::Value
363+
<Bx::CodegenCx as Backend<'ll>>::Value,
364+
<Bx::CodegenCx as Backend<'ll>>::Type
365+
) -> <Bx::CodegenCx as Backend<'ll>>::Value
366366
{
367367
// Shifts may have any size int on the rhs
368368
if op.is_shift() {
@@ -418,32 +418,32 @@ pub fn from_immediate<'a, 'll: 'a, 'tcx: 'll, Bx : BuilderMethods<'a, 'll ,'tcx>
418418
}
419419
}
420420

421-
pub fn to_immediate<'a, 'll: 'a, 'tcx: 'll, Builder : BuilderMethods<'a, 'll, 'tcx>>(
422-
bx: &Builder,
423-
val: <Builder::CodegenCx as Backend<'ll>>::Value,
421+
pub fn to_immediate<'a, 'll: 'a, 'tcx: 'll, Bx : BuilderMethods<'a, 'll, 'tcx>>(
422+
bx: &Bx,
423+
val: <Bx::CodegenCx as Backend<'ll>>::Value,
424424
layout: layout::TyLayout,
425-
) -> <Builder::CodegenCx as Backend<'ll>>::Value {
425+
) -> <Bx::CodegenCx as Backend<'ll>>::Value {
426426
if let layout::Abi::Scalar(ref scalar) = layout.abi {
427427
return to_immediate_scalar(bx, val, scalar);
428428
}
429429
val
430430
}
431431

432-
pub fn to_immediate_scalar<'a, 'll :'a, 'tcx :'ll, Builder : BuilderMethods<'a, 'll, 'tcx>>(
433-
bx: &Builder,
434-
val: <Builder::CodegenCx as Backend<'ll>>::Value,
432+
pub fn to_immediate_scalar<'a, 'll :'a, 'tcx :'ll, Bx : BuilderMethods<'a, 'll, 'tcx>>(
433+
bx: &Bx,
434+
val: <Bx::CodegenCx as Backend<'ll>>::Value,
435435
scalar: &layout::Scalar,
436-
) -> <Builder::CodegenCx as Backend<'ll>>::Value {
436+
) -> <Bx::CodegenCx as Backend<'ll>>::Value {
437437
if scalar.is_bool() {
438438
return bx.trunc(val, bx.cx().type_i1());
439439
}
440440
val
441441
}
442442

443-
pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll, Builder : BuilderMethods<'a, 'll, 'tcx>>(
444-
bx: &Builder,
445-
dst: <Builder::CodegenCx as Backend<'ll>>::Value,
446-
src: <Builder::CodegenCx as Backend<'ll>>::Value,
443+
pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll, Bx : BuilderMethods<'a, 'll, 'tcx>>(
444+
bx: &Bx,
445+
dst: <Bx::CodegenCx as Backend<'ll>>::Value,
446+
src: <Bx::CodegenCx as Backend<'ll>>::Value,
447447
layout: TyLayout<'tcx>,
448448
align: Align,
449449
flags: MemFlags,

src/librustc_codegen_llvm/builder.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,6 @@ impl BuilderMethods<'a, 'll, 'tcx>
12291229
}
12301230
}
12311231

1232-
/// Returns the ptr value that should be used for storing `val`.
12331232
fn check_store<'b>(&self,
12341233
val: &'ll Value,
12351234
ptr: &'ll Value) -> &'ll Value {
@@ -1249,7 +1248,6 @@ impl BuilderMethods<'a, 'll, 'tcx>
12491248
}
12501249
}
12511250

1252-
/// Returns the args that should be used for a call to `llfn`.
12531251
fn check_call<'b>(&self,
12541252
typ: &str,
12551253
llfn: &'ll Value,
@@ -1300,14 +1298,6 @@ impl BuilderMethods<'a, 'll, 'tcx>
13001298
self.call_lifetime_intrinsic("llvm.lifetime.end", ptr, size);
13011299
}
13021300

1303-
/// If LLVM lifetime intrinsic support is enabled (i.e. optimizations
1304-
/// on), and `ptr` is nonzero-sized, then extracts the size of `ptr`
1305-
/// and the intrinsic for `lt` and passes them to `emit`, which is in
1306-
/// charge of generating code to call the passed intrinsic on whatever
1307-
/// block of generated code is targeted for the intrinsic.
1308-
///
1309-
/// If LLVM lifetime intrinsic support is disabled (i.e. optimizations
1310-
/// off) or `ptr` is zero-sized, then no-op (does not call `emit`).
13111301
fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: &'ll Value, size: Size) {
13121302
if self.cx.sess().opts.optimize == config::OptLevel::No {
13131303
return;

src/librustc_codegen_llvm/callee.rs

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

207-
pub fn resolve_and_get_fn<'ll, 'tcx: 'll,
208-
Cx : Backend<'ll> + MiscMethods<'ll, 'tcx> + TypeMethods<'ll, 'tcx>
209-
>(
207+
pub fn resolve_and_get_fn<'ll, 'tcx: 'll, Cx : CodegenMethods<'ll, 'tcx>>(
210208
cx: &Cx,
211209
def_id: DefId,
212210
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 Backend<'ll> for CodegenCx<'ll, 'tcx, &'ll Value> {
224224

225225
impl<'ll, 'tcx : 'll> ConstMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
226226

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<'ll, 'tcx : 'll> ConstMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Valu
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<'ll, 'tcx : 'll> ConstMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Valu
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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,7 @@ impl IntrinsicDeclarationMethods<'b> for CodegenCx<'b, 'tcx, &'b Value> {
446446

447447
declare_intrinsic(self, key).unwrap_or_else(|| bug!("unknown intrinsic '{}'", key))
448448
}
449-
450-
/// Declare any llvm intrinsics that you might need
449+
451450
fn declare_intrinsic(
452451
&self,
453452
key: &str

src/librustc_codegen_llvm/debuginfo/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,6 @@ impl<'ll, 'tcx: 'll> DebugInfoMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll V
290290

291291
type DIScope = &'ll DIScope;
292292

293-
/// Creates the function-specific debug context.
294-
///
295-
/// Returns the FunctionDebugContext for the function which holds state needed
296-
/// for debug info creation. The function may also return another variant of the
297-
/// FunctionDebugContext enum which indicates why no debuginfo should be created
298-
/// for the function.
299293
fn create_function_debug_context(
300294
&self,
301295
instance: Instance<'tcx>,

src/librustc_codegen_llvm/declare.rs

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ fn declare_raw_fn(
9797

9898
impl DeclareMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
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<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
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<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
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<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
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<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
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,
@@ -201,12 +170,7 @@ impl DeclareMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
201170
self.declare_fn(name, fn_type)
202171
}
203172

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

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

227-
/// Get defined or externally defined (AvailableExternally linkage) value by
228-
/// name.
229189
fn get_defined_value(&self, name: &str) -> Option<&'ll Value> {
230190
self.get_declared_value(name).and_then(|val|{
231191
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 super::backend::Backend;
1414
use super::builder::HasCodegen;
1515

1616
pub trait AsmBuilderMethods<'a, 'll: 'a, 'tcx: 'll> : HasCodegen<'a, 'll, '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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,21 +579,33 @@ pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll> : HasCodegen<'a, 'll, 'tcx> +
579579
);
580580
fn set_invariant_load(&self, load: <Self::CodegenCx as Backend<'ll>>::Value);
581581

582+
/// Returns the ptr value that should be used for storing `val`.
582583
fn check_store(
583584
&self,
584585
val: <Self::CodegenCx as Backend<'ll>>::Value,
585586
ptr: <Self::CodegenCx as Backend<'ll>>::Value
586587
) -> <Self::CodegenCx as Backend<'ll>>::Value;
588+
589+
/// Returns the args that should be used for a call to `llfn`.
587590
fn check_call<'b>(
588591
&self,
589592
typ: &str,
590593
llfn: <Self::CodegenCx as Backend<'ll>>::Value,
591594
args: &'b [<Self::CodegenCx as Backend<'ll>>::Value]
592595
) -> Cow<'b, [<Self::CodegenCx as Backend<'ll>>::Value]>
593596
where [<Self::CodegenCx as Backend<'ll>>::Value] : ToOwned;
597+
594598
fn lifetime_start(&self, ptr: <Self::CodegenCx as Backend<'ll>>::Value, size: Size);
595599
fn lifetime_end(&self, ptr: <Self::CodegenCx as Backend<'ll>>::Value, size: Size);
596600

601+
/// If LLVM lifetime intrinsic support is enabled (i.e. optimizations
602+
/// on), and `ptr` is nonzero-sized, then extracts the size of `ptr`
603+
/// and the intrinsic for `lt` and passes them to `emit`, which is in
604+
/// charge of generating code to call the passed intrinsic on whatever
605+
/// block of generated code is targeted for the intrinsic.
606+
///
607+
/// If LLVM lifetime intrinsic support is disabled (i.e. optimizations
608+
/// off) or `ptr` is zero-sized, then no-op (does not call `emit`).
597609
fn call_lifetime_intrinsic(
598610
&self,
599611
intrinsic: &str,

0 commit comments

Comments
 (0)