When creating MCAsmBackend pass the CPU string as well. In X86AsmBackend
[oota-llvm.git] / include / llvm / Support / Endian.h
index 1058beff7b9cf9053e602d69c691d1378d64dae5..8d5649dc1f91ec3ab130d168b1a1422d81daef02 100644 (file)
@@ -14,9 +14,8 @@
 #ifndef LLVM_SUPPORT_ENDIAN_H
 #define LLVM_SUPPORT_ENDIAN_H
 
-#include "llvm/Config/config.h"
-#include "llvm/System/Host.h"
-#include "llvm/System/SwapByteOrder.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Support/SwapByteOrder.h"
 #include "llvm/Support/type_traits.h"
 
 namespace llvm {
@@ -48,43 +47,43 @@ struct alignment_access_helper<value_type, unaligned>
 
 } // end namespace detail
 
-namespace endian {\r
-  template<typename value_type, alignment align>\r
-  static value_type read_le(const void *memory) {\r
-    value_type t =\r
-      reinterpret_cast<const detail::alignment_access_helper\r
-        <value_type, align> *>(memory)->val;\r
-    if (sys::isBigEndianHost())\r
-      return sys::SwapByteOrder(t);\r
-    return t;\r
-  }\r
-\r
-  template<typename value_type, alignment align>\r
-  static void write_le(void *memory, value_type value) {\r
-    if (sys::isBigEndianHost())\r
-      value = sys::SwapByteOrder(value);\r
-    reinterpret_cast<detail::alignment_access_helper<value_type, align> *>\r
-      (memory)->val = value;\r
-  }\r
-\r
-  template<typename value_type, alignment align>\r
-  static value_type read_be(const void *memory) {\r
-    value_type t =\r
-      reinterpret_cast<const detail::alignment_access_helper\r
-        <value_type, align> *>(memory)->val;\r
-    if (sys::isLittleEndianHost())\r
-      return sys::SwapByteOrder(t);\r
-    return t;\r
-  }\r
-\r
-  template<typename value_type, alignment align>\r
-  static void write_be(void *memory, value_type value) {\r
-    if (sys::isLittleEndianHost())\r
-      value = sys::SwapByteOrder(value);\r
-    reinterpret_cast<detail::alignment_access_helper<value_type, align> *>\r
-      (memory)->val = value;\r
+namespace endian {
+  template<typename value_type, alignment align>
+  inline value_type read_le(const void *memory) {
+    value_type t =
+      reinterpret_cast<const detail::alignment_access_helper
+        <value_type, align> *>(memory)->val;
+    if (sys::isBigEndianHost())
+      return sys::SwapByteOrder(t);
+    return t;
+  }
+
+  template<typename value_type, alignment align>
+  inline void write_le(void *memory, value_type value) {
+    if (sys::isBigEndianHost())
+      value = sys::SwapByteOrder(value);
+    reinterpret_cast<detail::alignment_access_helper<value_type, align> *>
+      (memory)->val = value;
   }
-};
+
+  template<typename value_type, alignment align>
+  inline value_type read_be(const void *memory) {
+    value_type t =
+      reinterpret_cast<const detail::alignment_access_helper
+        <value_type, align> *>(memory)->val;
+    if (sys::isLittleEndianHost())
+      return sys::SwapByteOrder(t);
+    return t;
+  }
+
+  template<typename value_type, alignment align>
+  inline void write_be(void *memory, value_type value) {
+    if (sys::isLittleEndianHost())
+      value = sys::SwapByteOrder(value);
+    reinterpret_cast<detail::alignment_access_helper<value_type, align> *>
+      (memory)->val = value;
+  }
+}
 
 namespace detail {
 
@@ -99,6 +98,9 @@ public:
   operator value_type() const {
     return endian::read_le<value_type, unaligned>(Value);
   }
+  void operator=(value_type newValue) {
+    endian::write_le<value_type, unaligned>((void *)&Value, newValue);
+  }
 private:
   uint8_t Value[sizeof(value_type)];
 };
@@ -109,6 +111,9 @@ public:
   operator value_type() const {
     return endian::read_be<value_type, unaligned>(Value);
   }
+  void operator=(value_type newValue) {
+    endian::write_be<value_type, unaligned>((void *)&Value, newValue);
+  }
 private:
   uint8_t Value[sizeof(value_type)];
 };
@@ -119,6 +124,9 @@ public:
   operator value_type() const {
     return endian::read_le<value_type, aligned>(&Value);
   }
+  void operator=(value_type newValue) {
+    endian::write_le<value_type, aligned>((void *)&Value, newValue);
+  }
 private:
   value_type Value;
 };
@@ -129,6 +137,9 @@ public:
   operator value_type() const {
     return endian::read_be<value_type, aligned>(&Value);
   }
+  void operator=(value_type newValue) {
+    endian::write_be<value_type, aligned>((void *)&Value, newValue);
+  }
 private:
   value_type Value;
 };