Skip to content

Commit

Permalink
Don't repeat Attribute in the const names
Browse files Browse the repository at this point in the history
  • Loading branch information
tamird committed May 6, 2015
1 parent 5cfa713 commit e95241b
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 79 deletions.
52 changes: 26 additions & 26 deletions src/librustc_llvm/lib.rs
Expand Up @@ -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,
}
}

Expand Down
52 changes: 26 additions & 26 deletions src/librustc_trans/trans/attributes.rs
Expand Up @@ -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)
}
Expand All @@ -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,
);
}
}
Expand All @@ -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);
}
}

Expand All @@ -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,
);
}
}
Expand All @@ -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);
}
}
}
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
_ => {}
}
Expand All @@ -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);
}
}
}
Expand All @@ -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));
}

Expand All @@ -256,23 +256,23 @@ 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);
}
}

// When a reference in an argument has no named lifetime, it's impossible for that
// 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));
}

Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/trans/cabi_aarch64.rs
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/trans/cabi_arm.rs
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/trans/cabi_mips.rs
Expand Up @@ -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))
}
}

Expand All @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/trans/cabi_powerpc.rs
Expand Up @@ -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))
}
}

Expand All @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_trans/trans/cabi_x86.rs
Expand Up @@ -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);
}

Expand All @@ -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)
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/trans/cabi_x86_64.rs
Expand Up @@ -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)
};
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_trans/trans/cabi_x86_win64.rs
Expand Up @@ -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);
}

Expand All @@ -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)
}
};
Expand Down

0 comments on commit e95241b

Please sign in to comment.