[llvm] r358067 - MCSymbolicELF: simplify. (Flags & (x << s)) >> s is equivalent to Flags >> s & x
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 03:30:22 PDT 2019
Author: maskray
Date: Wed Apr 10 03:30:22 2019
New Revision: 358067
URL: http://llvm.org/viewvc/llvm-project?rev=358067&view=rev
Log:
MCSymbolicELF: simplify. (Flags & (x << s)) >> s is equivalent to Flags >> s & x
Modified:
llvm/trunk/lib/MC/MCSymbolELF.cpp
Modified: llvm/trunk/lib/MC/MCSymbolELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSymbolELF.cpp?rev=358067&r1=358066&r2=358067&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCSymbolELF.cpp (original)
+++ llvm/trunk/lib/MC/MCSymbolELF.cpp Wed Apr 10 03:30:22 2019
@@ -65,7 +65,7 @@ void MCSymbolELF::setBinding(unsigned Bi
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)
}
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
}
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 Othe
}
unsigned MCSymbolELF::getOther() const {
- unsigned Other = (getFlags() & (0x7 << ELF_STO_Shift)) >> ELF_STO_Shift;
+ unsigned Other = (Flags >> ELF_STO_Shift) & 7;
return Other << 5;
}
More information about the llvm-commits
mailing list