LLVM  14.0.0git
MachORelocation.h
Go to the documentation of this file.
1 //=== MachORelocation.h - Mach-O Relocation Info ----------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the MachORelocation class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 
14 #ifndef LLVM_CODEGEN_MACHORELOCATION_H
15 #define LLVM_CODEGEN_MACHORELOCATION_H
16 
17 #include "llvm/Support/DataTypes.h"
18 
19 namespace llvm {
20 
21  /// MachORelocation - This struct contains information about each relocation
22  /// that needs to be emitted to the file.
23  /// see <mach-o/reloc.h>
25  uint32_t r_address; // offset in the section to what is being relocated
26  uint32_t r_symbolnum; // symbol index if r_extern == 1 else section index
27  bool r_pcrel; // was relocated pc-relative already
28  uint8_t r_length; // length = 2 ^ r_length
29  bool r_extern; //
30  uint8_t r_type; // if not 0, machine-specific relocation type.
31  bool r_scattered; // 1 = scattered, 0 = non-scattered
32  int32_t r_value; // the value the item to be relocated is referring
33  // to.
34  public:
36  if (r_scattered)
37  return (1 << 31) | (r_pcrel << 30) | ((r_length & 3) << 28) |
38  ((r_type & 15) << 24) | (r_address & 0x00FFFFFF);
39  else
40  return (r_symbolnum << 8) | (r_pcrel << 7) | ((r_length & 3) << 5) |
41  (r_extern << 4) | (r_type & 15);
42  }
43  uint32_t getAddress() const { return r_scattered ? r_value : r_address; }
44  uint32_t getRawAddress() const { return r_address; }
45 
46  MachORelocation(uint32_t addr, uint32_t index, bool pcrel, uint8_t len,
47  bool ext, uint8_t type, bool scattered = false,
48  int32_t value = 0) :
49  r_address(addr), r_symbolnum(index), r_pcrel(pcrel), r_length(len),
50  r_extern(ext), r_type(type), r_scattered(scattered), r_value(value) {}
51  };
52 
53 } // end llvm namespace
54 
55 #endif // LLVM_CODEGEN_MACHORELOCATION_H
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::MachORelocation::getAddress
uint32_t getAddress() const
Definition: MachORelocation.h:43
llvm::MachORelocation::MachORelocation
MachORelocation(uint32_t addr, uint32_t index, bool pcrel, uint8_t len, bool ext, uint8_t type, bool scattered=false, int32_t value=0)
Definition: MachORelocation.h:46
llvm::MachORelocation::getPackedFields
uint32_t getPackedFields() const
Definition: MachORelocation.h:35
type
AMD64 Optimization Manual has some nice information about optimizing integer multiplication by a constant How much of it applies to Intel s X86 implementation There are definite trade offs to xmm0 cvttss2siq rdx jb L3 subss xmm0 rax cvttss2siq rdx xorq rdx rax ret instead of xmm1 cvttss2siq rcx movaps xmm2 subss xmm2 cvttss2siq rax rdx xorq rax ucomiss xmm0 cmovb rax ret Seems like the jb branch has high likelihood of being taken It would have saved a few instructions It s not possible to reference and DH registers in an instruction requiring REX prefix divb and mulb both produce results in AH If isel emits a CopyFromReg which gets turned into a movb and that can be allocated a r8b r15b To get around isel emits a CopyFromReg from AX and then right shift it down by and truncate it It s not pretty but it works We need some register allocation magic to make the hack go which would often require a callee saved register Callees usually need to keep this value live for most of their body so it doesn t add a significant burden on them We currently implement this in however this is suboptimal because it means that it would be quite awkward to implement the optimization for callers A better implementation would be to relax the LLVM IR rules for sret arguments to allow a function with an sret argument to have a non void return type
Definition: README-X86-64.txt:70
index
splat index
Definition: README_ALTIVEC.txt:181
llvm::MachORelocation
MachORelocation - This struct contains information about each relocation that needs to be emitted to ...
Definition: MachORelocation.h:24
uint32_t
llvm::MachORelocation::getRawAddress
uint32_t getRawAddress() const
Definition: MachORelocation.h:44
DataTypes.h