[lld] r234947 - ELF: Move Instrcution definition to HexagonEncoding.h.

Rui Ueyama ruiu at google.com
Tue Apr 14 14:41:00 PDT 2015


Author: ruiu
Date: Tue Apr 14 16:41:00 2015
New Revision: 234947

URL: http://llvm.org/viewvc/llvm-project?rev=234947&view=rev
Log:
ELF: Move Instrcution definition to HexagonEncoding.h.

HexagonEncodings.h contains a list of bitmasks. The file is used
only by HexagonRelocationHandler.cpp. The header is odd in the sense
that it uses struct Instruction but it doesn't define the data type.

This patch moves the struct definition to the header.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonEncodings.h
    lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp

Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonEncodings.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonEncodings.h?rev=234947&r1=234946&r2=234947&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonEncodings.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonEncodings.h Tue Apr 14 16:41:00 2015
@@ -6,6 +6,25 @@
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/ErrorHandling.h"
+
+namespace lld {
+namespace elf {
+
+/// \brief Applying fixup on Hexagon requires the relocator to fetch the fixup
+/// mask from the instruction. To fetch the fixup encoding, the linker uses a
+/// static array that contains the instruction mask, the compare mask and the
+/// relocation mask.
+typedef struct {
+  uint32_t insnMask;    // Instruction mask.
+  uint32_t insnCmpMask; // Compare mask.
+  uint32_t insnBitMask; // Relocation mask.
+  bool isDuplex;        // Indicates if the instruction is a duplex instruction.
+} Instruction;
+
 Instruction insn_encodings[] = {
   // InsnMask   CompareMask BitMask IsDuplexInstruction
   { 0xffe00004, 0x40000000, 0x20f8, 0x0 },
@@ -600,3 +619,20 @@ Instruction insn_encodings[] = {
   { 0xff602060, 0x3f000060, 0x1f80, 0x0 },
   { 0xf7c02000, 0x11000000, 0x3000fe, 0x0 },
 };
+
+/// \brief finds the scatter Bits that need to be used to apply relocations
+inline uint32_t findv4bitmask(uint8_t *location) {
+  uint32_t insn = llvm::support::endian::read32le(location);
+  for (int32_t i = 0, e = llvm::array_lengthof(insn_encodings); i < e; i++) {
+    if ((insn & 0xc000) == 0 && !insn_encodings[i].isDuplex)
+      continue;
+    if ((insn & 0xc000) != 0 && insn_encodings[i].isDuplex)
+      continue;
+    if ((insn_encodings[i].insnMask & insn) == insn_encodings[i].insnCmpMask)
+      return insn_encodings[i].insnBitMask;
+  }
+  llvm_unreachable("found unknown Hexagon instruction");
+}
+
+} // namespace elf
+} // namespace lld

Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp?rev=234947&r1=234946&r2=234947&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp Tue Apr 14 16:41:00 2015
@@ -7,10 +7,10 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "HexagonEncodings.h"
 #include "HexagonLinkingContext.h"
 #include "HexagonRelocationHandler.h"
 #include "HexagonTargetHandler.h"
-#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Endian.h"
 
 using namespace lld;
@@ -18,33 +18,6 @@ using namespace lld::elf;
 using namespace llvm::ELF;
 using namespace llvm::support::endian;
 
-/// \brief Applying fixup on Hexagon requires the relocator to fetch the fixup
-/// mask from the instruction. To fetch the fixup encoding, the linker uses a
-/// static array that contains the instruction mask, the compare mask and the
-/// relocation mask.
-typedef struct {
-  uint32_t insnMask;    // Instruction mask.
-  uint32_t insnCmpMask; // Compare mask.
-  uint32_t insnBitMask; // Relocation mask.
-  bool isDuplex;        // Indicates if the instruction is a duplex instruction.
-} Instruction;
-
-#include "HexagonEncodings.h"
-
-/// \brief finds the scatter Bits that need to be used to apply relocations
-inline uint32_t findv4bitmask(uint8_t *location) {
-  uint32_t insn = llvm::support::endian::read32le(location);
-  for (int32_t i = 0, e = llvm::array_lengthof(insn_encodings); i < e; i++) {
-    if ((insn & 0xc000) == 0 && !insn_encodings[i].isDuplex)
-      continue;
-    if ((insn & 0xc000) != 0 && insn_encodings[i].isDuplex)
-      continue;
-    if ((insn_encodings[i].insnMask & insn) == insn_encodings[i].insnCmpMask)
-      return insn_encodings[i].insnBitMask;
-  }
-  llvm_unreachable("found unknown Hexagon instruction");
-}
-
 // Scatter val's bits as specified by the mask. Example:
 //
 //  Val:    0bABCDEFG





More information about the llvm-commits mailing list