diff options
author | Dan Gohman <gohman@apple.com> | 2009-04-01 18:45:54 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-04-01 18:45:54 +0000 |
commit | d06cad6dacf2217ce7a88eebf5b0c164b3fbdd41 (patch) | |
tree | faf864647d57a6d0f3e6e16f199b0559be489e5f /include | |
parent | 37c934b0124b43e08e58eb222521c0f188ec9c53 (diff) | |
download | external_llvm-d06cad6dacf2217ce7a88eebf5b0c164b3fbdd41.zip external_llvm-d06cad6dacf2217ce7a88eebf5b0c164b3fbdd41.tar.gz external_llvm-d06cad6dacf2217ce7a88eebf5b0c164b3fbdd41.tar.bz2 |
Use CHAR_BIT instead of hard-coding 8 in several places where it
is appropriate. This helps visually differentiate host-oriented
calculations from target-oriented calculations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68227 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/APInt.h | 4 | ||||
-rw-r--r-- | include/llvm/ADT/BitVector.h | 3 | ||||
-rw-r--r-- | include/llvm/ADT/SparseBitVector.h | 3 | ||||
-rw-r--r-- | include/llvm/Bitcode/BitstreamReader.h | 3 | ||||
-rw-r--r-- | include/llvm/CodeGen/LiveInterval.h | 7 | ||||
-rw-r--r-- | include/llvm/CodeGen/MachineConstantPool.h | 5 | ||||
-rw-r--r-- | include/llvm/CodeGen/SelectionDAGNodes.h | 7 | ||||
-rw-r--r-- | include/llvm/Support/CommandLine.h | 5 |
8 files changed, 23 insertions, 14 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index a309d7f..388316d 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -18,6 +18,7 @@ #include "llvm/Support/DataTypes.h" #include "llvm/Support/MathExtras.h" #include <cassert> +#include <climits> #include <cstring> #include <string> @@ -81,7 +82,8 @@ class APInt { /// This enum is used to hold the constants we needed for APInt. enum { /// Bits in a word - APINT_BITS_PER_WORD = static_cast<unsigned int>(sizeof(uint64_t)) * 8, + APINT_BITS_PER_WORD = static_cast<unsigned int>(sizeof(uint64_t)) * + CHAR_BIT, /// Byte size of a word APINT_WORD_SIZE = static_cast<unsigned int>(sizeof(uint64_t)) }; diff --git a/include/llvm/ADT/BitVector.h b/include/llvm/ADT/BitVector.h index 23fde26..9c046ef 100644 --- a/include/llvm/ADT/BitVector.h +++ b/include/llvm/ADT/BitVector.h @@ -17,6 +17,7 @@ #include "llvm/Support/MathExtras.h" #include <algorithm> #include <cassert> +#include <climits> #include <cstring> namespace llvm { @@ -24,7 +25,7 @@ namespace llvm { class BitVector { typedef unsigned long BitWord; - enum { BITWORD_SIZE = (unsigned)sizeof(BitWord) * 8 }; + enum { BITWORD_SIZE = (unsigned)sizeof(BitWord) * CHAR_BIT }; BitWord *Bits; // Actual bits. unsigned Size; // Size of bitvector in bits. diff --git a/include/llvm/ADT/SparseBitVector.h b/include/llvm/ADT/SparseBitVector.h index dabcb02..70cb7f4 100644 --- a/include/llvm/ADT/SparseBitVector.h +++ b/include/llvm/ADT/SparseBitVector.h @@ -16,6 +16,7 @@ #define LLVM_ADT_SPARSEBITVECTOR_H #include <cassert> +#include <climits> #include <cstring> #include "llvm/Support/DataTypes.h" #include "llvm/ADT/STLExtras.h" @@ -44,7 +45,7 @@ struct SparseBitVectorElement public: typedef unsigned long BitWord; enum { - BITWORD_SIZE = sizeof(BitWord) * 8, + BITWORD_SIZE = sizeof(BitWord) * CHAR_BIT, BITWORDS_PER_ELEMENT = (ElementSize + BITWORD_SIZE - 1) / BITWORD_SIZE, BITS_PER_ELEMENT = ElementSize }; diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/BitstreamReader.h index 7cbd10f..48eaa36 100644 --- a/include/llvm/Bitcode/BitstreamReader.h +++ b/include/llvm/Bitcode/BitstreamReader.h @@ -16,6 +16,7 @@ #define BITSTREAM_READER_H #include "llvm/Bitcode/BitCodes.h" +#include <climits> #include <vector> namespace llvm { @@ -114,7 +115,7 @@ public: /// GetCurrentBitNo - Return the bit # of the bit we are reading. uint64_t GetCurrentBitNo() const { - return (NextChar-FirstChar)*8 + ((32-BitsInCurWord) & 31); + return (NextChar-FirstChar)*CHAR_BIT + ((32-BitsInCurWord) & 31); } /// JumpToBit - Reset the stream to the specified bit number. diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 8e99ee7..c75d594 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -25,6 +25,7 @@ #include "llvm/Support/Allocator.h" #include <iosfwd> #include <cassert> +#include <climits> namespace llvm { class MachineInstr; @@ -115,7 +116,7 @@ namespace llvm { LiveInterval(unsigned Reg, float Weight, bool IsSS = false) : reg(Reg), weight(Weight), preference(0) { if (IsSS) - reg = reg | (1U << (sizeof(unsigned)*8-1)); + reg = reg | (1U << (sizeof(unsigned)*CHAR_BIT-1)); } typedef Ranges::iterator iterator; @@ -159,14 +160,14 @@ namespace llvm { /// isStackSlot - Return true if this is a stack slot interval. /// bool isStackSlot() const { - return reg & (1U << (sizeof(unsigned)*8-1)); + return reg & (1U << (sizeof(unsigned)*CHAR_BIT-1)); } /// getStackSlotIndex - Return stack slot index if this is a stack slot /// interval. int getStackSlotIndex() const { assert(isStackSlot() && "Interval is not a stack slot interval!"); - return reg & ~(1U << (sizeof(unsigned)*8-1)); + return reg & ~(1U << (sizeof(unsigned)*CHAR_BIT-1)); } bool hasAtLeastOneValue() const { return !valnos.empty(); } diff --git a/include/llvm/CodeGen/MachineConstantPool.h b/include/llvm/CodeGen/MachineConstantPool.h index d5bd25c..99996cf 100644 --- a/include/llvm/CodeGen/MachineConstantPool.h +++ b/include/llvm/CodeGen/MachineConstantPool.h @@ -17,6 +17,7 @@ #define LLVM_CODEGEN_MACHINECONSTANTPOOL_H #include <cassert> +#include <climits> #include <vector> namespace llvm { @@ -81,7 +82,7 @@ public: MachineConstantPoolEntry(MachineConstantPoolValue *V, unsigned A) : Alignment(A) { Val.MachineCPVal = V; - Alignment |= 1 << (sizeof(unsigned)*8-1); + Alignment |= 1 << (sizeof(unsigned)*CHAR_BIT-1); } bool isMachineConstantPoolEntry() const { @@ -89,7 +90,7 @@ public: } int getAlignment() const { - return Alignment & ~(1 << (sizeof(unsigned)*8-1)); + return Alignment & ~(1 << (sizeof(unsigned)*CHAR_BIT-1)); } const Type *getType() const; diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 047e612..6cea5d6 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -32,6 +32,7 @@ #include "llvm/Support/DataTypes.h" #include "llvm/CodeGen/DebugLoc.h" #include <cassert> +#include <climits> namespace llvm { @@ -1864,7 +1865,7 @@ protected: getSDVTList(VT)), Offset(o), Alignment(0) { assert((int)Offset >= 0 && "Offset is too large"); Val.MachineCPVal = v; - Offset |= 1 << (sizeof(unsigned)*8-1); + Offset |= 1 << (sizeof(unsigned)*CHAR_BIT-1); } ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, MVT VT, int o, unsigned Align) @@ -1873,7 +1874,7 @@ protected: getSDVTList(VT)), Offset(o), Alignment(Align) { assert((int)Offset >= 0 && "Offset is too large"); Val.MachineCPVal = v; - Offset |= 1 << (sizeof(unsigned)*8-1); + Offset |= 1 << (sizeof(unsigned)*CHAR_BIT-1); } public: @@ -1892,7 +1893,7 @@ public: } int getOffset() const { - return Offset & ~(1 << (sizeof(unsigned)*8-1)); + return Offset & ~(1 << (sizeof(unsigned)*CHAR_BIT-1)); } // Return the alignment of this constant pool object, which is either 0 (for diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index e45ab21..6b05e60 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -25,6 +25,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/ADT/SmallVector.h" #include <cassert> +#include <climits> #include <cstdarg> #include <string> #include <utility> @@ -1109,7 +1110,7 @@ class bits_storage { template<class T> static unsigned Bit(const T &V) { unsigned BitPos = reinterpret_cast<unsigned>(V); - assert(BitPos < sizeof(unsigned) * 8 && + assert(BitPos < sizeof(unsigned) * CHAR_BIT && "enum exceeds width of bit vector!"); return 1 << BitPos; } @@ -1150,7 +1151,7 @@ class bits_storage<DataType, bool> { template<class T> static unsigned Bit(const T &V) { unsigned BitPos = reinterpret_cast<unsigned>(V); - assert(BitPos < sizeof(unsigned) * 8 && + assert(BitPos < sizeof(unsigned) * CHAR_BIT && "enum exceeds width of bit vector!"); return 1 << BitPos; } |