MCSymbolicELF: simplify. (Flags & (x << s)) >> s is equivalent to Flags >> s & x

llvm-svn: 358067
This commit is contained in:
Fangrui Song 2019-04-10 10:30:22 +00:00
parent ac59067363
commit bbd798f71c
1 changed files with 4 additions and 6 deletions

View File

@ -65,7 +65,7 @@ void MCSymbolELF::setBinding(unsigned Binding) const {
unsigned MCSymbolELF::getBinding() const {
if (isBindingSet()) {
uint32_t Val = (getFlags() & (0x3 << ELF_STB_Shift)) >> ELF_STB_Shift;
uint32_t Val = (Flags >> ELF_STB_Shift) & 3;
switch (Val) {
default:
llvm_unreachable("Invalid value");
@ -125,7 +125,7 @@ void MCSymbolELF::setType(unsigned Type) const {
}
unsigned MCSymbolELF::getType() const {
uint32_t Val = (getFlags() & (0x7 << ELF_STT_Shift)) >> ELF_STT_Shift;
uint32_t Val = (Flags >> ELF_STT_Shift) & 7;
switch (Val) {
default:
llvm_unreachable("Invalid value");
@ -155,9 +155,7 @@ void MCSymbolELF::setVisibility(unsigned Visibility) {
}
unsigned MCSymbolELF::getVisibility() const {
unsigned Visibility = (getFlags() & (0x3 << ELF_STV_Shift)) >> ELF_STV_Shift;
assert(Visibility == ELF::STV_DEFAULT || Visibility == ELF::STV_INTERNAL ||
Visibility == ELF::STV_HIDDEN || Visibility == ELF::STV_PROTECTED);
unsigned Visibility = (Flags >> ELF_STV_Shift) & 3;
return Visibility;
}
@ -170,7 +168,7 @@ void MCSymbolELF::setOther(unsigned Other) {
}
unsigned MCSymbolELF::getOther() const {
unsigned Other = (getFlags() & (0x7 << ELF_STO_Shift)) >> ELF_STO_Shift;
unsigned Other = (Flags >> ELF_STO_Shift) & 7;
return Other << 5;
}