From e95241bf2875a4cf292ea8cb59100875b6277917 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Wed, 29 Apr 2015 15:00:20 -0700 Subject: [PATCH] Don't repeat `Attribute` in the const names --- src/librustc_llvm/lib.rs | 52 +++++++++++----------- src/librustc_trans/trans/attributes.rs | 52 +++++++++++----------- src/librustc_trans/trans/cabi_aarch64.rs | 6 +-- src/librustc_trans/trans/cabi_arm.rs | 6 +-- src/librustc_trans/trans/cabi_mips.rs | 6 +-- src/librustc_trans/trans/cabi_powerpc.rs | 6 +-- src/librustc_trans/trans/cabi_x86.rs | 8 ++-- src/librustc_trans/trans/cabi_x86_64.rs | 6 +-- src/librustc_trans/trans/cabi_x86_win64.rs | 8 ++-- src/librustc_trans/trans/declare.rs | 4 +- src/librustc_trans/trans/foreign.rs | 4 +- 11 files changed, 79 insertions(+), 79 deletions(-) diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index db88072150a6..2a2aa2bf4cf9 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -125,32 +125,32 @@ pub enum DiagnosticSeverity { bitflags! { flags Attribute : u32 { - const ZExtAttribute = 1 << 0, - const SExtAttribute = 1 << 1, - const NoReturnAttribute = 1 << 2, - const InRegAttribute = 1 << 3, - const StructRetAttribute = 1 << 4, - const NoUnwindAttribute = 1 << 5, - const NoAliasAttribute = 1 << 6, - const ByValAttribute = 1 << 7, - const NestAttribute = 1 << 8, - const ReadNoneAttribute = 1 << 9, - const ReadOnlyAttribute = 1 << 10, - const NoInlineAttribute = 1 << 11, - const AlwaysInlineAttribute = 1 << 12, - const OptimizeForSizeAttribute = 1 << 13, - const StackProtectAttribute = 1 << 14, - const StackProtectReqAttribute = 1 << 15, - const AlignmentAttribute = 1 << 16, - const NoCaptureAttribute = 1 << 21, - const NoRedZoneAttribute = 1 << 22, - const NoImplicitFloatAttribute = 1 << 23, - const NakedAttribute = 1 << 24, - const InlineHintAttribute = 1 << 25, - const StackAttribute = 7 << 26, - const ReturnsTwiceAttribute = 1 << 29, - const UWTableAttribute = 1 << 30, - const NonLazyBindAttribute = 1 << 31, + const ZExt = 1 << 0, + const SExt = 1 << 1, + const NoReturn = 1 << 2, + const InReg = 1 << 3, + const StructRet = 1 << 4, + const NoUnwind = 1 << 5, + const NoAlias = 1 << 6, + const ByVal = 1 << 7, + const Nest = 1 << 8, + const ReadNone = 1 << 9, + const ReadOnly = 1 << 10, + const NoInline = 1 << 11, + const AlwaysInline = 1 << 12, + const OptimizeForSize = 1 << 13, + const StackProtect = 1 << 14, + const StackProtectReq = 1 << 15, + const Alignment = 1 << 16, + const NoCapture = 1 << 21, + const NoRedZone = 1 << 22, + const NoImplicitFloat = 1 << 23, + const Naked = 1 << 24, + const InlineHint = 1 << 25, + const Stack = 7 << 26, + const ReturnsTwice = 1 << 29, + const UWTable = 1 << 30, + const NonLazyBind = 1 << 31, } } diff --git a/src/librustc_trans/trans/attributes.rs b/src/librustc_trans/trans/attributes.rs index b44ccec0127b..b32181426a33 100644 --- a/src/librustc_trans/trans/attributes.rs +++ b/src/librustc_trans/trans/attributes.rs @@ -39,13 +39,13 @@ pub fn split_stack(val: ValueRef, set: bool) { pub fn inline(val: ValueRef, inline: InlineAttr) { use self::InlineAttr::*; match inline { - Hint => llvm::SetFunctionAttribute(val, llvm::Attribute::InlineHintAttribute), - Always => llvm::SetFunctionAttribute(val, llvm::Attribute::AlwaysInlineAttribute), - Never => llvm::SetFunctionAttribute(val, llvm::Attribute::NoInlineAttribute), + Hint => llvm::SetFunctionAttribute(val, llvm::Attribute::InlineHint), + Always => llvm::SetFunctionAttribute(val, llvm::Attribute::AlwaysInline), + Never => llvm::SetFunctionAttribute(val, llvm::Attribute::NoInline), None => { - let attr = llvm::Attribute::InlineHintAttribute | - llvm::Attribute::AlwaysInlineAttribute | - llvm::Attribute::NoInlineAttribute; + let attr = llvm::Attribute::InlineHint | + llvm::Attribute::AlwaysInline | + llvm::Attribute::NoInline; unsafe { llvm::LLVMRemoveFunctionAttr(val, attr.bits() as c_ulonglong) } @@ -57,12 +57,12 @@ pub fn inline(val: ValueRef, inline: InlineAttr) { #[inline] pub fn emit_uwtable(val: ValueRef, emit: bool) { if emit { - llvm::SetFunctionAttribute(val, llvm::Attribute::UWTableAttribute); + llvm::SetFunctionAttribute(val, llvm::Attribute::UWTable); } else { unsafe { llvm::LLVMRemoveFunctionAttr( val, - llvm::Attribute::UWTableAttribute.bits() as c_ulonglong, + llvm::Attribute::UWTable.bits() as c_ulonglong, ); } } @@ -76,11 +76,11 @@ pub fn unwind(val: ValueRef, can_unwind: bool) { unsafe { llvm::LLVMRemoveFunctionAttr( val, - llvm::Attribute::NoUnwindAttribute.bits() as c_ulonglong, + llvm::Attribute::NoUnwind.bits() as c_ulonglong, ); } } else { - llvm::SetFunctionAttribute(val, llvm::Attribute::NoUnwindAttribute); + llvm::SetFunctionAttribute(val, llvm::Attribute::NoUnwind); } } @@ -89,12 +89,12 @@ pub fn unwind(val: ValueRef, can_unwind: bool) { #[allow(dead_code)] // possibly useful function pub fn set_optimize_for_size(val: ValueRef, optimize: bool) { if optimize { - llvm::SetFunctionAttribute(val, llvm::Attribute::OptimizeForSizeAttribute); + llvm::SetFunctionAttribute(val, llvm::Attribute::OptimizeForSize); } else { unsafe { llvm::LLVMRemoveFunctionAttr( val, - llvm::Attribute::OptimizeForSizeAttribute.bits() as c_ulonglong, + llvm::Attribute::OptimizeForSize.bits() as c_ulonglong, ); } } @@ -116,7 +116,7 @@ pub fn from_fn_attrs(ccx: &CrateContext, attrs: &[ast::Attribute], llfn: ValueRe llvm::ColdAttribute as u64) } } else if attr.check_name("allocator") { - llvm::Attribute::NoAliasAttribute.apply_llfn(llvm::ReturnIndex as c_uint, llfn); + llvm::Attribute::NoAlias.apply_llfn(llvm::ReturnIndex as c_uint, llfn); } } } @@ -185,9 +185,9 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx // The outptr can be noalias and nocapture because it's entirely // invisible to the program. We also know it's nonnull as well // as how many bytes we can dereference - attrs.arg(1, llvm::Attribute::StructRetAttribute) - .arg(1, llvm::Attribute::NoAliasAttribute) - .arg(1, llvm::Attribute::NoCaptureAttribute) + attrs.arg(1, llvm::Attribute::StructRet) + .arg(1, llvm::Attribute::NoAlias) + .arg(1, llvm::Attribute::NoCapture) .arg(1, llvm::DereferenceableAttribute(llret_sz)); // Add one more since there's an outptr @@ -199,7 +199,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx // `~` pointer return values never alias because ownership // is transferred ty::ty_uniq(it) if common::type_is_sized(ccx.tcx(), it) => { - attrs.ret(llvm::Attribute::NoAliasAttribute); + attrs.ret(llvm::Attribute::NoAlias); } _ => {} } @@ -216,7 +216,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx } if let ty::ty_bool = ret_ty.sty { - attrs.ret(llvm::Attribute::ZExtAttribute); + attrs.ret(llvm::Attribute::ZExt); } } } @@ -230,20 +230,20 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx // For non-immediate arguments the callee gets its own copy of // the value on the stack, so there are no aliases. It's also // program-invisible so can't possibly capture - attrs.arg(idx, llvm::Attribute::NoAliasAttribute) - .arg(idx, llvm::Attribute::NoCaptureAttribute) + attrs.arg(idx, llvm::Attribute::NoAlias) + .arg(idx, llvm::Attribute::NoCapture) .arg(idx, llvm::DereferenceableAttribute(llarg_sz)); } ty::ty_bool => { - attrs.arg(idx, llvm::Attribute::ZExtAttribute); + attrs.arg(idx, llvm::Attribute::ZExt); } // `~` pointer parameters never alias because ownership is transferred ty::ty_uniq(inner) => { let llsz = machine::llsize_of_real(ccx, type_of::type_of(ccx, inner)); - attrs.arg(idx, llvm::Attribute::NoAliasAttribute) + attrs.arg(idx, llvm::Attribute::NoAlias) .arg(idx, llvm::DereferenceableAttribute(llsz)); } @@ -256,15 +256,15 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx !ty::type_contents(ccx.tcx(), mt.ty).interior_unsafe() => { let llsz = machine::llsize_of_real(ccx, type_of::type_of(ccx, mt.ty)); - attrs.arg(idx, llvm::Attribute::NoAliasAttribute) + attrs.arg(idx, llvm::Attribute::NoAlias) .arg(idx, llvm::DereferenceableAttribute(llsz)); if mt.mutbl == ast::MutImmutable { - attrs.arg(idx, llvm::Attribute::ReadOnlyAttribute); + attrs.arg(idx, llvm::Attribute::ReadOnly); } if let ReLateBound(_, BrAnon(_)) = *b { - attrs.arg(idx, llvm::Attribute::NoCaptureAttribute); + attrs.arg(idx, llvm::Attribute::NoCapture); } } @@ -272,7 +272,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx // reference to escape this function (returned or stored beyond the call by a closure). ty::ty_rptr(&ReLateBound(_, BrAnon(_)), mt) => { let llsz = machine::llsize_of_real(ccx, type_of::type_of(ccx, mt.ty)); - attrs.arg(idx, llvm::Attribute::NoCaptureAttribute) + attrs.arg(idx, llvm::Attribute::NoCapture) .arg(idx, llvm::DereferenceableAttribute(llsz)); } diff --git a/src/librustc_trans/trans/cabi_aarch64.rs b/src/librustc_trans/trans/cabi_aarch64.rs index 2eef67867398..f2434ceee2b8 100644 --- a/src/librustc_trans/trans/cabi_aarch64.rs +++ b/src/librustc_trans/trans/cabi_aarch64.rs @@ -163,7 +163,7 @@ fn is_homogenous_aggregate_ty(ty: Type) -> Option<(Type, u64)> { fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType { if is_reg_ty(ty) { - let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExtAttribute) } else { None }; + let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; return ArgType::direct(ty, None, None, attr); } if let Some((base_ty, members)) = is_homogenous_aggregate_ty(ty) { @@ -185,12 +185,12 @@ fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType { }; return ArgType::direct(ty, Some(llty), None, None); } - ArgType::indirect(ty, Some(Attribute::StructRetAttribute)) + ArgType::indirect(ty, Some(Attribute::StructRet)) } fn classify_arg_ty(ccx: &CrateContext, ty: Type) -> ArgType { if is_reg_ty(ty) { - let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExtAttribute) } else { None }; + let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; return ArgType::direct(ty, None, None, attr); } if let Some((base_ty, members)) = is_homogenous_aggregate_ty(ty) { diff --git a/src/librustc_trans/trans/cabi_arm.rs b/src/librustc_trans/trans/cabi_arm.rs index 689b3b3ad37e..c5116e738048 100644 --- a/src/librustc_trans/trans/cabi_arm.rs +++ b/src/librustc_trans/trans/cabi_arm.rs @@ -131,7 +131,7 @@ fn ty_size(ty: Type, align_fn: TyAlignFn) -> usize { fn classify_ret_ty(ccx: &CrateContext, ty: Type, align_fn: TyAlignFn) -> ArgType { if is_reg_ty(ty) { - let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExtAttribute) } else { None }; + let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; return ArgType::direct(ty, None, None, attr); } let size = ty_size(ty, align_fn); @@ -145,12 +145,12 @@ fn classify_ret_ty(ccx: &CrateContext, ty: Type, align_fn: TyAlignFn) -> ArgType }; return ArgType::direct(ty, Some(llty), None, None); } - ArgType::indirect(ty, Some(Attribute::StructRetAttribute)) + ArgType::indirect(ty, Some(Attribute::StructRet)) } fn classify_arg_ty(ccx: &CrateContext, ty: Type, align_fn: TyAlignFn) -> ArgType { if is_reg_ty(ty) { - let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExtAttribute) } else { None }; + let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; return ArgType::direct(ty, None, None, attr); } let align = align_fn(ty); diff --git a/src/librustc_trans/trans/cabi_mips.rs b/src/librustc_trans/trans/cabi_mips.rs index 2e899f72979d..bcffb238f595 100644 --- a/src/librustc_trans/trans/cabi_mips.rs +++ b/src/librustc_trans/trans/cabi_mips.rs @@ -88,10 +88,10 @@ fn ty_size(ty: Type) -> usize { fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType { if is_reg_ty(ty) { - let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExtAttribute) } else { None }; + let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; ArgType::direct(ty, None, None, attr) } else { - ArgType::indirect(ty, Some(Attribute::StructRetAttribute)) + ArgType::indirect(ty, Some(Attribute::StructRet)) } } @@ -105,7 +105,7 @@ fn classify_arg_ty(ccx: &CrateContext, ty: Type, offset: &mut usize) -> ArgType *offset += align_up_to(size, align * 8) / 8; if is_reg_ty(ty) { - let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExtAttribute) } else { None }; + let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; ArgType::direct(ty, None, None, attr) } else { ArgType::direct( diff --git a/src/librustc_trans/trans/cabi_powerpc.rs b/src/librustc_trans/trans/cabi_powerpc.rs index eae2378a2c51..1bcc8fd6bbb9 100644 --- a/src/librustc_trans/trans/cabi_powerpc.rs +++ b/src/librustc_trans/trans/cabi_powerpc.rs @@ -84,10 +84,10 @@ fn ty_size(ty: Type) -> usize { fn classify_ret_ty(ccx: &CrateContext, ty: Type) -> ArgType { if is_reg_ty(ty) { - let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExtAttribute) } else { None }; + let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; ArgType::direct(ty, None, None, attr) } else { - ArgType::indirect(ty, Some(Attribute::StructRetAttribute)) + ArgType::indirect(ty, Some(Attribute::StructRet)) } } @@ -101,7 +101,7 @@ fn classify_arg_ty(ccx: &CrateContext, ty: Type, offset: &mut usize) -> ArgType *offset += align_up_to(size, align * 8) / 8; if is_reg_ty(ty) { - let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExtAttribute) } else { None }; + let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; ArgType::direct(ty, None, None, attr) } else { ArgType::direct( diff --git a/src/librustc_trans/trans/cabi_x86.rs b/src/librustc_trans/trans/cabi_x86.rs index d9c265d94a79..50a3095dea16 100644 --- a/src/librustc_trans/trans/cabi_x86.rs +++ b/src/librustc_trans/trans/cabi_x86.rs @@ -52,11 +52,11 @@ pub fn compute_abi_info(ccx: &CrateContext, ret_ty = ArgType::direct(rty, Some(t), None, None); } RetPointer => { - ret_ty = ArgType::indirect(rty, Some(Attribute::StructRetAttribute)); + ret_ty = ArgType::indirect(rty, Some(Attribute::StructRet)); } } } else { - let attr = if rty == Type::i1(ccx) { Some(Attribute::ZExtAttribute) } else { None }; + let attr = if rty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; ret_ty = ArgType::direct(rty, None, None, attr); } @@ -67,11 +67,11 @@ pub fn compute_abi_info(ccx: &CrateContext, if size == 0 { ArgType::ignore(t) } else { - ArgType::indirect(t, Some(Attribute::ByValAttribute)) + ArgType::indirect(t, Some(Attribute::ByVal)) } } _ => { - let attr = if t == Type::i1(ccx) { Some(Attribute::ZExtAttribute) } else { None }; + let attr = if t == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; ArgType::direct(t, None, None, attr) } }; diff --git a/src/librustc_trans/trans/cabi_x86_64.rs b/src/librustc_trans/trans/cabi_x86_64.rs index d954a861a726..b64e24591fd9 100644 --- a/src/librustc_trans/trans/cabi_x86_64.rs +++ b/src/librustc_trans/trans/cabi_x86_64.rs @@ -406,19 +406,19 @@ pub fn compute_abi_info(ccx: &CrateContext, None) } } else { - let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExtAttribute) } else { None }; + let attr = if ty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; ArgType::direct(ty, None, None, attr) } } let mut arg_tys = Vec::new(); for t in atys { - let ty = x86_64_ty(ccx, *t, |cls| cls.is_pass_byval(), Attribute::ByValAttribute); + let ty = x86_64_ty(ccx, *t, |cls| cls.is_pass_byval(), Attribute::ByVal); arg_tys.push(ty); } let ret_ty = if ret_def { - x86_64_ty(ccx, rty, |cls| cls.is_ret_bysret(), Attribute::StructRetAttribute) + x86_64_ty(ccx, rty, |cls| cls.is_ret_bysret(), Attribute::StructRet) } else { ArgType::direct(Type::void(ccx), None, None, None) }; diff --git a/src/librustc_trans/trans/cabi_x86_win64.rs b/src/librustc_trans/trans/cabi_x86_win64.rs index 7808b9d27fee..262dcc470596 100644 --- a/src/librustc_trans/trans/cabi_x86_win64.rs +++ b/src/librustc_trans/trans/cabi_x86_win64.rs @@ -31,10 +31,10 @@ pub fn compute_abi_info(ccx: &CrateContext, 2 => ArgType::direct(rty, Some(Type::i16(ccx)), None, None), 4 => ArgType::direct(rty, Some(Type::i32(ccx)), None, None), 8 => ArgType::direct(rty, Some(Type::i64(ccx)), None, None), - _ => ArgType::indirect(rty, Some(Attribute::StructRetAttribute)) + _ => ArgType::indirect(rty, Some(Attribute::StructRet)) }; } else { - let attr = if rty == Type::i1(ccx) { Some(Attribute::ZExtAttribute) } else { None }; + let attr = if rty == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; ret_ty = ArgType::direct(rty, None, None, attr); } @@ -46,11 +46,11 @@ pub fn compute_abi_info(ccx: &CrateContext, 2 => ArgType::direct(rty, Some(Type::i16(ccx)), None, None), 4 => ArgType::direct(rty, Some(Type::i32(ccx)), None, None), 8 => ArgType::direct(rty, Some(Type::i64(ccx)), None, None), - _ => ArgType::indirect(t, Some(Attribute::ByValAttribute)) + _ => ArgType::indirect(t, Some(Attribute::ByVal)) } } _ => { - let attr = if t == Type::i1(ccx) { Some(Attribute::ZExtAttribute) } else { None }; + let attr = if t == Type::i1(ccx) { Some(Attribute::ZExt) } else { None }; ArgType::direct(t, None, None, attr) } }; diff --git a/src/librustc_trans/trans/declare.rs b/src/librustc_trans/trans/declare.rs index 35946491ba17..7849235fdbee 100644 --- a/src/librustc_trans/trans/declare.rs +++ b/src/librustc_trans/trans/declare.rs @@ -71,12 +71,12 @@ pub fn declare_fn(ccx: &CrateContext, name: &str, callconv: llvm::CallConv, ty: llvm::SetUnnamedAddr(llfn, true); if output == ty::FnDiverging { - llvm::SetFunctionAttribute(llfn, llvm::Attribute::NoReturnAttribute); + llvm::SetFunctionAttribute(llfn, llvm::Attribute::NoReturn); } if ccx.tcx().sess.opts.cg.no_redzone .unwrap_or(ccx.tcx().sess.target.target.options.disable_redzone) { - llvm::SetFunctionAttribute(llfn, llvm::Attribute::NoRedZoneAttribute) + llvm::SetFunctionAttribute(llfn, llvm::Attribute::NoRedZone) } if ccx.is_split_stack_supported() && !ccx.sess().opts.cg.no_stack_check { diff --git a/src/librustc_trans/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs index d760b2c52ca1..95c93d76585b 100644 --- a/src/librustc_trans/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -349,8 +349,8 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // The outptr can be noalias and nocapture because it's entirely // invisible to the program. We also know it's nonnull as well // as how many bytes we can dereference - attrs.arg(1, llvm::Attribute::NoAliasAttribute) - .arg(1, llvm::Attribute::NoCaptureAttribute) + attrs.arg(1, llvm::Attribute::NoAlias) + .arg(1, llvm::Attribute::NoCapture) .arg(1, llvm::DereferenceableAttribute(llret_sz)); };