Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit d4448b8

Browse files
committed
Move endian constant from Host.h to SwapByteOrder.h, prune include
Works on this dependency chain: ArrayRef.h -> Hashing.h -> --CUT-- Host.h -> StringMap.h / StringRef.h ArrayRef is very popular, but Host.h is rarely needed. Move the IsBigEndianHost constant to SwapByteOrder.h. Clients of that header are more likely to need it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375316 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent ccf0b77 commit d4448b8

File tree

9 files changed

+36
-32
lines changed

9 files changed

+36
-32
lines changed

include/llvm/ADT/Hashing.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#define LLVM_ADT_HASHING_H
4646

4747
#include "llvm/Support/DataTypes.h"
48-
#include "llvm/Support/Host.h"
4948
#include "llvm/Support/SwapByteOrder.h"
5049
#include "llvm/Support/type_traits.h"
5150
#include <algorithm>

include/llvm/BinaryFormat/Wasm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "llvm/ADT/ArrayRef.h"
1818
#include "llvm/ADT/SmallVector.h"
19+
#include "llvm/ADT/StringRef.h"
1920

2021
namespace llvm {
2122
namespace wasm {

include/llvm/Support/Host.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,11 @@
1515

1616
#include "llvm/ADT/StringMap.h"
1717

18-
#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__)
19-
#include <endian.h>
20-
#elif defined(_AIX)
21-
#include <sys/machine.h>
22-
#elif defined(__sun)
23-
/* Solaris provides _BIG_ENDIAN/_LITTLE_ENDIAN selector in sys/types.h */
24-
#include <sys/types.h>
25-
#define BIG_ENDIAN 4321
26-
#define LITTLE_ENDIAN 1234
27-
#if defined(_BIG_ENDIAN)
28-
#define BYTE_ORDER BIG_ENDIAN
29-
#else
30-
#define BYTE_ORDER LITTLE_ENDIAN
31-
#endif
32-
#else
33-
#if !defined(BYTE_ORDER) && !defined(_WIN32)
34-
#include <machine/endian.h>
35-
#endif
36-
#endif
37-
3818
#include <string>
3919

4020
namespace llvm {
4121
namespace sys {
4222

43-
#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
44-
constexpr bool IsBigEndianHost = true;
45-
#else
46-
constexpr bool IsBigEndianHost = false;
47-
#endif
48-
49-
static const bool IsLittleEndianHost = !IsBigEndianHost;
50-
5123
/// getDefaultTargetTriple() - Return the default target triple the compiler
5224
/// has been configured to produce code for.
5325
///

include/llvm/Support/SHA1.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
#define LLVM_SUPPORT_SHA1_H
1717

1818
#include "llvm/ADT/ArrayRef.h"
19+
#include "llvm/ADT/StringRef.h"
1920

2021
#include <array>
2122
#include <cstdint>
2223

2324
namespace llvm {
2425
template <typename T> class ArrayRef;
25-
class StringRef;
2626

2727
/// A class that wrap the SHA1 algorithm.
2828
class SHA1 {

include/llvm/Support/SwapByteOrder.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,37 @@
2222
#include <stdlib.h>
2323
#endif
2424

25+
#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__)
26+
#include <endian.h>
27+
#elif defined(_AIX)
28+
#include <sys/machine.h>
29+
#elif defined(__sun)
30+
/* Solaris provides _BIG_ENDIAN/_LITTLE_ENDIAN selector in sys/types.h */
31+
#include <sys/types.h>
32+
#define BIG_ENDIAN 4321
33+
#define LITTLE_ENDIAN 1234
34+
#if defined(_BIG_ENDIAN)
35+
#define BYTE_ORDER BIG_ENDIAN
36+
#else
37+
#define BYTE_ORDER LITTLE_ENDIAN
38+
#endif
39+
#else
40+
#if !defined(BYTE_ORDER) && !defined(_WIN32)
41+
#include <machine/endian.h>
42+
#endif
43+
#endif
44+
2545
namespace llvm {
2646
namespace sys {
2747

48+
#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
49+
constexpr bool IsBigEndianHost = true;
50+
#else
51+
constexpr bool IsBigEndianHost = false;
52+
#endif
53+
54+
static const bool IsLittleEndianHost = !IsBigEndianHost;
55+
2856
/// SwapByteOrder_16 - This function returns a byte-swapped representation of
2957
/// the 16-bit argument.
3058
inline uint16_t SwapByteOrder_16(uint16_t value) {

lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
1010

11+
#include "llvm/Support/Host.h"
1112
#include "llvm/Support/TargetRegistry.h"
1213

1314
namespace llvm {

lib/Support/Windows/WindowsSupport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "llvm/ADT/StringRef.h"
3939
#include "llvm/ADT/Twine.h"
4040
#include "llvm/Config/config.h" // Get build system configuration settings
41+
#include "llvm/Support/Allocator.h"
4142
#include "llvm/Support/Chrono.h"
4243
#include "llvm/Support/Compiler.h"
4344
#include "llvm/Support/VersionTuple.h"

lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
#include "X86DisassemblerDecoder.h"
16+
#include "llvm/ADT/StringRef.h"
17+
1518
#include <cstdarg> /* for va_*() */
1619
#include <cstdio> /* for vsnprintf() */
1720
#include <cstdlib> /* for exit() */
1821
#include <cstring> /* for memset() */
1922

20-
#include "X86DisassemblerDecoder.h"
21-
2223
using namespace llvm::X86Disassembler;
2324

2425
/// Specifies whether a ModR/M byte is needed and (if so) which

tools/llvm-exegesis/lib/RegisterValue.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "RegisterValue.h"
1010
#include "llvm/ADT/APFloat.h"
11+
#include "llvm/ADT/StringRef.h"
1112

1213
namespace llvm {
1314
namespace exegesis {

0 commit comments

Comments
 (0)