Skip to content

Commit 4460972

Browse files
committed
Move doc to trait declarations
1 parent 2e8af91 commit 4460972

File tree

17 files changed

+131
-112
lines changed

17 files changed

+131
-112
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
@@ -158,14 +158,14 @@ pub fn bin_op_to_fcmp_predicate(op: hir::BinOpKind) -> RealPredicate {
158158
}
159159
}
160160

161-
pub fn compare_simd_types<'a, 'll:'a, 'tcx:'ll, Builder : BuilderMethods<'a, 'll, 'tcx>>(
162-
bx: &Builder,
163-
lhs: <Builder::CodegenCx as Backend<'ll>>::Value,
164-
rhs: <Builder::CodegenCx as Backend<'ll>>::Value,
161+
pub fn compare_simd_types<'a, 'll:'a, 'tcx:'ll, Bx : BuilderMethods<'a, 'll, 'tcx>>(
162+
bx: &Bx,
163+
lhs: <Bx::CodegenCx as Backend<'ll>>::Value,
164+
rhs: <Bx::CodegenCx as Backend<'ll>>::Value,
165165
t: Ty<'tcx>,
166-
ret_ty: <Builder::CodegenCx as Backend<'ll>>::Type,
166+
ret_ty: <Bx::CodegenCx as Backend<'ll>>::Type,
167167
op: hir::BinOpKind
168-
) -> <Builder::CodegenCx as Backend<'ll>>::Value {
168+
) -> <Bx::CodegenCx as Backend<'ll>>::Value {
169169
let signed = match t.sty {
170170
ty::Float(_) => {
171171
let cmp = bin_op_to_fcmp_predicate(op);
@@ -337,31 +337,31 @@ pub fn coerce_unsized_into<'a, 'll: 'a, 'tcx: 'll, Bx: BuilderMethods<'a, 'll, '
337337
}
338338
}
339339

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

349-
fn cast_shift_rhs<'a, 'll :'a, 'tcx : 'll, F, G, Builder : BuilderMethods<'a, 'll, 'tcx>>(
350-
bx: &Builder,
349+
fn cast_shift_rhs<'a, 'll :'a, 'tcx : 'll, F, G, Bx : BuilderMethods<'a, 'll, 'tcx>>(
350+
bx: &Bx,
351351
op: hir::BinOpKind,
352-
lhs: <Builder::CodegenCx as Backend<'ll>>::Value,
353-
rhs: <Builder::CodegenCx as Backend<'ll>>::Value,
352+
lhs: <Bx::CodegenCx as Backend<'ll>>::Value,
353+
rhs: <Bx::CodegenCx as Backend<'ll>>::Value,
354354
trunc: F,
355355
zext: G
356-
) -> <Builder::CodegenCx as Backend<'ll>>::Value
356+
) -> <Bx::CodegenCx as Backend<'ll>>::Value
357357
where F: FnOnce(
358-
<Builder::CodegenCx as Backend<'ll>>::Value,
359-
<Builder::CodegenCx as Backend<'ll>>::Type
360-
) -> <Builder::CodegenCx as Backend<'ll>>::Value,
358+
<Bx::CodegenCx as Backend<'ll>>::Value,
359+
<Bx::CodegenCx as Backend<'ll>>::Type
360+
) -> <Bx::CodegenCx as Backend<'ll>>::Value,
361361
G: FnOnce(
362-
<Builder::CodegenCx as Backend<'ll>>::Value,
363-
<Builder::CodegenCx as Backend<'ll>>::Type
364-
) -> <Builder::CodegenCx as Backend<'ll>>::Value
362+
<Bx::CodegenCx as Backend<'ll>>::Value,
363+
<Bx::CodegenCx as Backend<'ll>>::Type
364+
) -> <Bx::CodegenCx as Backend<'ll>>::Value
365365
{
366366
// Shifts may have any size int on the rhs
367367
if op.is_shift() {
@@ -417,32 +417,32 @@ pub fn from_immediate<'a, 'll: 'a, 'tcx: 'll, Bx : BuilderMethods<'a, 'll ,'tcx>
417417
}
418418
}
419419

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

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

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

src/librustc_codegen_llvm/builder.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,6 @@ impl BuilderMethods<'a, 'll, 'tcx>
12321232
}
12331233
}
12341234

1235-
/// Returns the ptr value that should be used for storing `val`.
12361235
fn check_store<'b>(&self,
12371236
val: &'ll Value,
12381237
ptr: &'ll Value) -> &'ll Value {
@@ -1252,7 +1251,6 @@ impl BuilderMethods<'a, 'll, 'tcx>
12521251
}
12531252
}
12541253

1255-
/// Returns the args that should be used for a call to `llfn`.
12561254
fn check_call<'b>(&self,
12571255
typ: &str,
12581256
llfn: &'ll Value,
@@ -1303,14 +1301,6 @@ impl BuilderMethods<'a, 'll, 'tcx>
13031301
self.call_lifetime_intrinsic("llvm.lifetime.end", ptr, size);
13041302
}
13051303

1306-
/// If LLVM lifetime intrinsic support is enabled (i.e. optimizations
1307-
/// on), and `ptr` is nonzero-sized, then extracts the size of `ptr`
1308-
/// and the intrinsic for `lt` and passes them to `emit`, which is in
1309-
/// charge of generating code to call the passed intrinsic on whatever
1310-
/// block of generated code is targeted for the intrinsic.
1311-
///
1312-
/// If LLVM lifetime intrinsic support is disabled (i.e. optimizations
1313-
/// off) or `ptr` is zero-sized, then no-op (does not call `emit`).
13141304
fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: &'ll Value, size: Size) {
13151305
if self.cx.sess().opts.optimize == config::OptLevel::No {
13161306
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
@@ -226,7 +226,6 @@ impl Backend<'ll> for CodegenCx<'ll, 'tcx, &'ll Value> {
226226

227227
impl<'ll, 'tcx : 'll> ConstMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
228228

229-
// LLVM constant constructors.
230229
fn const_null(&self, t: &'ll Type) -> &'ll Value {
231230
unsafe {
232231
llvm::LLVMConstNull(t)
@@ -288,9 +287,6 @@ impl<'ll, 'tcx : 'll> ConstMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Valu
288287
&self.const_uint(&self.type_i8(), i as u64)
289288
}
290289

291-
292-
// This is a 'c-like' raw string, which differs from
293-
// our boxed-and-length-annotated strings.
294290
fn const_cstr(
295291
&self,
296292
s: LocalInternedString,
@@ -318,8 +314,6 @@ impl<'ll, 'tcx : 'll> ConstMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Valu
318314
}
319315
}
320316

321-
// NB: Do not use `do_spill_noroot` to make this into a constant string, or
322-
// you will be kicked off fast isel. See issue #4352 for an example of this.
323317
fn const_str_slice(&self, s: LocalInternedString) -> &'ll Value {
324318
let len = s.len();
325319
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: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ fn declare_raw_fn(
9898

9999
impl DeclareMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
100100

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

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

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

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

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

190-
/// Declare a Rust function with an intention to define it.
191-
///
192-
/// Use this function when you intend to define a function. This function will
193-
/// return panic if the name already has a definition associated with it. This
194-
/// can happen with #[no_mangle] or #[export_name], for example.
195164
fn define_fn(
196165
&self,
197166
name: &str,
@@ -204,11 +173,6 @@ impl DeclareMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
204173
}
205174
}
206175

207-
/// Declare a Rust function with an intention to define it.
208-
///
209-
/// Use this function when you intend to define a function. This function will
210-
/// return panic if the name already has a definition associated with it. This
211-
/// can happen with #[no_mangle] or #[export_name], for example.
212176
fn define_internal_fn(
213177
&self,
214178
name: &str,
@@ -219,16 +183,12 @@ impl DeclareMethods<'ll, 'tcx> for CodegenCx<'ll, 'tcx, &'ll Value> {
219183
llfn
220184
}
221185

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

230-
/// Get defined or externally defined (AvailableExternally linkage) value by
231-
/// name.
232192
fn get_defined_value(&self, name: &str) -> Option<&'ll Value> {
233193
self.get_declared_value(name).and_then(|val|{
234194
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)