[PATCH] D13723: [ELF2][mips] Support both big and little endian MIPS 32-bit targets

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 14 06:27:56 PDT 2015


ruiu accepted this revision.
ruiu added a comment.
This revision is now accepted and ready to land.

LGTM with nits.


================
Comment at: ELF/Target.cpp:93
@@ -85,2 +92,3 @@
 
-static void add32le(uint8_t *L, int32_t V) { write32le(L, read32le(L) + V); }
+template <bool LE> static void add32(uint8_t *L, int32_t V);
+template <> void add32<true>(uint8_t *L, int32_t V) {
----------------
ruiu wrote:
> I'd define add32be and use add32le and add32be from add32<>.
> 
>   template <> void add32<true>(uint8_t *L, int32_t V) { add32le(L, V); }
>   template <> void add32<false>(uint8_t *L, int32_t V) { add32be(L, V); }
  template <bool IsLE> would be better for consistency.

================
Comment at: ELF/Target.cpp:93-101
@@ -85,3 +92,11 @@
 
-static void add32le(uint8_t *L, int32_t V) { write32le(L, read32le(L) + V); }
+template <bool LE> static void add32(uint8_t *L, int32_t V);
+template <> void add32<true>(uint8_t *L, int32_t V) {
+  write32le(L, read32le(L) + V);
+}
+template <> void add32<false>(uint8_t *L, int32_t V) {
+  write32be(L, read32be(L) + V);
+}
+
+static void add32le(uint8_t *L, int32_t V) { add32<true>(L, V); }
 static void or32le(uint8_t *L, int32_t V) { write32le(L, read32le(L) | V); }
----------------
I'd define add32be and use add32le and add32be from add32<>.

  template <> void add32<true>(uint8_t *L, int32_t V) { add32le(L, V); }
  template <> void add32<false>(uint8_t *L, int32_t V) { add32be(L, V); }

================
Comment at: ELF/Target.cpp:585-586
@@ +584,4 @@
+                                       const void *RelP, uint32_t Type,
+                                       uint64_t BaseAddr,
+                                       uint64_t SymVA) const {
+  const bool IsLE = ELFT::TargetEndianness == support::little;
----------------
Unrelated style change.


Repository:
  rL LLVM

http://reviews.llvm.org/D13723





More information about the llvm-commits mailing list