llvm.org GIT mirror llvm / 67f1c49
Remove host endianness info from TargetData and put it in a new header System/Host.h instead. Instead of getting the endianness from configure, calculate it directly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44959 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan Sands 11 years ago
7 changed file(s) with 66 addition(s) and 61 deletion(s). Raw diff Collapse all Expand all
226226 AC_SUBST(ARCH,$llvm_cv_target_arch)
227227
228228 dnl Check for the endianness of the target
229 AC_C_BIGENDIAN([AC_SUBST([ENDIAN],[big]),
230 AC_DEFINE([MSB_FIRST], [1], [Define if this target is big endian])],
231 [AC_SUBST([ENDIAN],[little]),
232 AC_DEFINE([LSB_FIRST], [1], [Define if this target is little endian])])
229 AC_C_BIGENDIAN(AC_SUBST([ENDIAN],[big]),AC_SUBST([ENDIAN],[little]))
233230
234231 dnl Check for build platform executable suffix if we're crosscompiling
235232 if test "$cross_compiling" = yes; then
827827 LLVM_ON_UNIX
828828 LLVM_ON_WIN32
829829 ARCH
830 ENDIAN
830831 CC
831832 CFLAGS
832833 LDFLAGS
837838 CPP
838839 GREP
839840 EGREP
840 ENDIAN
841841 LLVM_CROSS_COMPILING
842842 BUILD_CC
843843 BUILD_EXEEXT
41824182 case $ac_cv_c_bigendian in
41834183 yes)
41844184 ENDIAN=big
4185 ,
4186
4187 cat >>confdefs.h <<\_ACEOF
4188 #define MSB_FIRST 1
4189 _ACEOF
41904185 ;;
41914186 no)
41924187 ENDIAN=little
4193 ,
4194
4195 cat >>confdefs.h <<\_ACEOF
4196 #define LSB_FIRST 1
4197 _ACEOF
41984188 ;;
41994189 *)
42004190 { { echo "$as_me:$LINENO: error: unknown endianness
98809870 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
98819871 lt_status=$lt_dlunknown
98829872 cat > conftest.$ac_ext <
9883 #line 9884 "configure"
9873 #line 9874 "configure"
98849874 #include "confdefs.h"
98859875
98869876 #if HAVE_DLFCN_H
1181511805 ;;
1181611806 *-*-irix6*)
1181711807 # Find out which ABI we are using.
11818 echo '#line 11819 "configure"' > conftest.$ac_ext
11808 echo '#line 11809 "configure"' > conftest.$ac_ext
1181911809 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
1182011810 (eval $ac_compile) 2>&5
1182111811 ac_status=$?
1345513445 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1345613446 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1345713447 -e 's:$: $lt_compiler_flag:'`
13458 (eval echo "\"\$as_me:13459: $lt_compile\"" >&5)
13448 (eval echo "\"\$as_me:13449: $lt_compile\"" >&5)
1345913449 (eval "$lt_compile" 2>conftest.err)
1346013450 ac_status=$?
1346113451 cat conftest.err >&5
13462 echo "$as_me:13463: \$? = $ac_status" >&5
13452 echo "$as_me:13453: \$? = $ac_status" >&5
1346313453 if (exit $ac_status) && test -s "$ac_outfile"; then
1346413454 # The compiler can only warn and ignore the option if not recognized
1346513455 # So say no if there are warnings other than the usual output.
1372313713 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1372413714 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1372513715 -e 's:$: $lt_compiler_flag:'`
13726 (eval echo "\"\$as_me:13727: $lt_compile\"" >&5)
13716 (eval echo "\"\$as_me:13717: $lt_compile\"" >&5)
1372713717 (eval "$lt_compile" 2>conftest.err)
1372813718 ac_status=$?
1372913719 cat conftest.err >&5
13730 echo "$as_me:13731: \$? = $ac_status" >&5
13720 echo "$as_me:13721: \$? = $ac_status" >&5
1373113721 if (exit $ac_status) && test -s "$ac_outfile"; then
1373213722 # The compiler can only warn and ignore the option if not recognized
1373313723 # So say no if there are warnings other than the usual output.
1382713817 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1382813818 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1382913819 -e 's:$: $lt_compiler_flag:'`
13830 (eval echo "\"\$as_me:13831: $lt_compile\"" >&5)
13820 (eval echo "\"\$as_me:13821: $lt_compile\"" >&5)
1383113821 (eval "$lt_compile" 2>out/conftest.err)
1383213822 ac_status=$?
1383313823 cat out/conftest.err >&5
13834 echo "$as_me:13835: \$? = $ac_status" >&5
13824 echo "$as_me:13825: \$? = $ac_status" >&5
1383513825 if (exit $ac_status) && test -s out/conftest2.$ac_objext
1383613826 then
1383713827 # The compiler can only warn and ignore the option if not recognized
1613516125 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1613616126 lt_status=$lt_dlunknown
1613716127 cat > conftest.$ac_ext <
16138 #line 16139 "configure"
16128 #line 16129 "configure"
1613916129 #include "confdefs.h"
1614016130
1614116131 #if HAVE_DLFCN_H
1623516225 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1623616226 lt_status=$lt_dlunknown
1623716227 cat > conftest.$ac_ext <
16238 #line 16239 "configure"
16228 #line 16229 "configure"
1623916229 #include "confdefs.h"
1624016230
1624116231 #if HAVE_DLFCN_H
1857118561 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1857218562 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1857318563 -e 's:$: $lt_compiler_flag:'`
18574 (eval echo "\"\$as_me:18575: $lt_compile\"" >&5)
18564 (eval echo "\"\$as_me:18565: $lt_compile\"" >&5)
1857518565 (eval "$lt_compile" 2>conftest.err)
1857618566 ac_status=$?
1857718567 cat conftest.err >&5
18578 echo "$as_me:18579: \$? = $ac_status" >&5
18568 echo "$as_me:18569: \$? = $ac_status" >&5
1857918569 if (exit $ac_status) && test -s "$ac_outfile"; then
1858018570 # The compiler can only warn and ignore the option if not recognized
1858118571 # So say no if there are warnings other than the usual output.
1867518665 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1867618666 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
1867718667 -e 's:$: $lt_compiler_flag:'`
18678 (eval echo "\"\$as_me:18679: $lt_compile\"" >&5)
18668 (eval echo "\"\$as_me:18669: $lt_compile\"" >&5)
1867918669 (eval "$lt_compile" 2>out/conftest.err)
1868018670 ac_status=$?
1868118671 cat out/conftest.err >&5
18682 echo "$as_me:18683: \$? = $ac_status" >&5
18672 echo "$as_me:18673: \$? = $ac_status" >&5
1868318673 if (exit $ac_status) && test -s out/conftest2.$ac_objext
1868418674 then
1868518675 # The compiler can only warn and ignore the option if not recognized
2024520235 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2024620236 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2024720237 -e 's:$: $lt_compiler_flag:'`
20248 (eval echo "\"\$as_me:20249: $lt_compile\"" >&5)
20238 (eval echo "\"\$as_me:20239: $lt_compile\"" >&5)
2024920239 (eval "$lt_compile" 2>conftest.err)
2025020240 ac_status=$?
2025120241 cat conftest.err >&5
20252 echo "$as_me:20253: \$? = $ac_status" >&5
20242 echo "$as_me:20243: \$? = $ac_status" >&5
2025320243 if (exit $ac_status) && test -s "$ac_outfile"; then
2025420244 # The compiler can only warn and ignore the option if not recognized
2025520245 # So say no if there are warnings other than the usual output.
2034920339 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2035020340 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2035120341 -e 's:$: $lt_compiler_flag:'`
20352 (eval echo "\"\$as_me:20353: $lt_compile\"" >&5)
20342 (eval echo "\"\$as_me:20343: $lt_compile\"" >&5)
2035320343 (eval "$lt_compile" 2>out/conftest.err)
2035420344 ac_status=$?
2035520345 cat out/conftest.err >&5
20356 echo "$as_me:20357: \$? = $ac_status" >&5
20346 echo "$as_me:20347: \$? = $ac_status" >&5
2035720347 if (exit $ac_status) && test -s out/conftest2.$ac_objext
2035820348 then
2035920349 # The compiler can only warn and ignore the option if not recognized
2255222542 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2255322543 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2255422544 -e 's:$: $lt_compiler_flag:'`
22555 (eval echo "\"\$as_me:22556: $lt_compile\"" >&5)
22545 (eval echo "\"\$as_me:22546: $lt_compile\"" >&5)
2255622546 (eval "$lt_compile" 2>conftest.err)
2255722547 ac_status=$?
2255822548 cat conftest.err >&5
22559 echo "$as_me:22560: \$? = $ac_status" >&5
22549 echo "$as_me:22550: \$? = $ac_status" >&5
2256022550 if (exit $ac_status) && test -s "$ac_outfile"; then
2256122551 # The compiler can only warn and ignore the option if not recognized
2256222552 # So say no if there are warnings other than the usual output.
2282022810 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2282122811 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2282222812 -e 's:$: $lt_compiler_flag:'`
22823 (eval echo "\"\$as_me:22824: $lt_compile\"" >&5)
22813 (eval echo "\"\$as_me:22814: $lt_compile\"" >&5)
2282422814 (eval "$lt_compile" 2>conftest.err)
2282522815 ac_status=$?
2282622816 cat conftest.err >&5
22827 echo "$as_me:22828: \$? = $ac_status" >&5
22817 echo "$as_me:22818: \$? = $ac_status" >&5
2282822818 if (exit $ac_status) && test -s "$ac_outfile"; then
2282922819 # The compiler can only warn and ignore the option if not recognized
2283022820 # So say no if there are warnings other than the usual output.
2292422914 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
2292522915 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
2292622916 -e 's:$: $lt_compiler_flag:'`
22927 (eval echo "\"\$as_me:22928: $lt_compile\"" >&5)
22917 (eval echo "\"\$as_me:22918: $lt_compile\"" >&5)
2292822918 (eval "$lt_compile" 2>out/conftest.err)
2292922919 ac_status=$?
2293022920 cat out/conftest.err >&5
22931 echo "$as_me:22932: \$? = $ac_status" >&5
22921 echo "$as_me:22922: \$? = $ac_status" >&5
2293222922 if (exit $ac_status) && test -s out/conftest2.$ac_objext
2293322923 then
2293422924 # The compiler can only warn and ignore the option if not recognized
3276832758 LLVM_ON_UNIX!$LLVM_ON_UNIX$ac_delim
3276932759 LLVM_ON_WIN32!$LLVM_ON_WIN32$ac_delim
3277032760 ARCH!$ARCH$ac_delim
32761 ENDIAN!$ENDIAN$ac_delim
3277132762 CC!$CC$ac_delim
3277232763 CFLAGS!$CFLAGS$ac_delim
3277332764 LDFLAGS!$LDFLAGS$ac_delim
3277832769 CPP!$CPP$ac_delim
3277932770 GREP!$GREP$ac_delim
3278032771 EGREP!$EGREP$ac_delim
32781 ENDIAN!$ENDIAN$ac_delim
3278232772 LLVM_CROSS_COMPILING!$LLVM_CROSS_COMPILING$ac_delim
3278332773 BUILD_CC!$BUILD_CC$ac_delim
3278432774 BUILD_EXEEXT!$BUILD_EXEEXT$ac_delim
493493 /* Installation prefix directory */
494494 #undef LLVM_PREFIX
495495
496 /* Define if this target is little endian */
497 #undef LSB_FIRST
498
499496 /* Define if the OS needs help to load dependent libraries for dlopen(). */
500497 #undef LTDL_DLOPEN_DEPLIBS
501498
512509
513510 /* Define to the system default library search path. */
514511 #undef LTDL_SYSSEARCHPATH
515
516 /* Define if this target is big endian */
517 #undef MSB_FIRST
518512
519513 /* Define if /dev/zero should be used when mapping RWX memory, or undefine if
520514 its not necessary */
0 //===- llvm/System/Host.h - Host machine characteristics --------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file was developed by Duncan Sands and is distributed under the
5 // University of Illinois Open Source License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Methods for querying the nature of the host machine.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_SYSTEM_HOST_H
14 #define LLVM_SYSTEM_HOST_H
15
16 namespace llvm {
17 namespace sys {
18
19 inline bool littleEndianHost() {
20 union {
21 int i;
22 char c;
23 };
24 i = 1;
25 return c;
26 }
27
28 inline bool bigEndianHost() {
29 return !littleEndianHost();
30 }
31
32 }
33 }
34
35 #endif
141141 bool isLittleEndian() const { return LittleEndian; }
142142 bool isBigEndian() const { return !LittleEndian; }
143143
144 /// Host endianness.
145 bool hostIsLittleEndian() const;
146 bool hostIsBigEndian() const { return !hostIsLittleEndian(); }
147
148144 /// getStringRepresentation - Return the string representation of the
149145 /// TargetData. This representation is in the same format accepted by the
150146 /// string constructor above.
2222 #include "llvm/Support/Debug.h"
2323 #include "llvm/Support/MutexGuard.h"
2424 #include "llvm/System/DynamicLibrary.h"
25 #include "llvm/System/Host.h"
2526 #include "llvm/Target/TargetData.h"
2627 #include
2728 using namespace llvm;
636637 uint8_t *Src = (uint8_t *)Val.IntVal.getRawData();
637638 uint8_t *Dst = (uint8_t *)Ptr;
638639
639 if (getTargetData()->hostIsLittleEndian())
640 if (sys::littleEndianHost())
640641 // Little-endian host - the source is ordered from LSB to MSB.
641642 // Order the destination from LSB to MSB: Do a straight copy.
642643 memcpy(Dst, Src, StoreBytes);
697698 uint8_t *Src = (uint8_t *)Ptr;
698699 uint8_t *Dst = (uint8_t *)Result.IntVal.getRawData();
699700
700 if (getTargetData()->hostIsLittleEndian())
701 if (sys::littleEndianHost())
701702 // Little-endian host - the destination must be ordered from LSB to MSB.
702703 // The source is ordered from LSB to MSB: Do a straight copy.
703704 memcpy(Dst, Src, LoadBytes);
2424 #include "llvm/Support/ManagedStatic.h"
2525 #include "llvm/ADT/DenseMap.h"
2626 #include "llvm/ADT/StringExtras.h"
27 #include "llvm/Config/config.h"
2827 #include
2928 #include
3029 #include
131130 //===----------------------------------------------------------------------===//
132131 // TargetData Class Implementation
133132 //===----------------------------------------------------------------------===//
134
135 bool TargetData::hostIsLittleEndian() const {
136 #ifdef LSB_FIRST
137 return true;
138 #else
139 return false;
140 #endif
141 }
142133
143134 /*!
144135 A TargetDescription string consists of a sequence of hyphen-delimited