Coverage Report

Created: 2025-12-27 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/keystone/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h
Line
Count
Source
1
//===-- ARMAsmBackend.h - ARM Assembler Backend -----------------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H
11
#define LLVM_LIB_TARGET_ARM_ARMASMBACKEND_H
12
13
#include "MCTargetDesc/ARMFixupKinds.h"
14
#include "MCTargetDesc/ARMMCTargetDesc.h"
15
#include "llvm/MC/MCAsmBackend.h"
16
#include "llvm/MC/MCSubtargetInfo.h"
17
#include "llvm/Support/TargetRegistry.h"
18
19
namespace llvm_ks {
20
21
class ARMAsmBackend : public MCAsmBackend {
22
  const MCSubtargetInfo *STI;
23
  bool isThumbMode;    // Currently emitting Thumb code.
24
  bool IsLittleEndian; // Big or little endian.
25
public:
26
  ARMAsmBackend(const Target &T, const Triple &TT, bool IsLittle)
27
60.6k
      : MCAsmBackend(), STI(ARM_MC::createARMMCSubtargetInfo(TT, "", "")),
28
60.6k
        isThumbMode(TT.getArchName().startswith("thumb")),
29
60.6k
        IsLittleEndian(IsLittle) {}
30
31
60.6k
  ~ARMAsmBackend() override { delete STI; }
32
33
78.3k
  unsigned getNumFixupKinds() const override {
34
78.3k
    return ARM::NumTargetFixupKinds;
35
78.3k
  }
36
37
10.9k
  bool hasNOP() const { return STI->getFeatureBits()[ARM::HasV6T2Ops]; }
38
39
  const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override;
40
41
  /// processFixupValue - Target hook to process the literal value of a fixup
42
  /// if necessary.
43
  void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout,
44
                         const MCFixup &Fixup, const MCFragment *DF,
45
                         const MCValue &Target, uint64_t &Value,
46
                         bool &IsResolved) override;
47
48
  unsigned adjustFixupValue(const MCFixup &Fixup, uint64_t Value, bool IsPCRel,
49
                            MCContext *Ctx, bool IsLittleEndian,
50
                            bool IsResolved) const;
51
52
  void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
53
                  uint64_t Value, bool IsPCRel, unsigned int &KsError) const override;
54
55
  unsigned getRelaxedOpcode(unsigned Op) const;
56
57
  bool mayNeedRelaxation(const MCInst &Inst) const override;
58
59
  const char *reasonForFixupRelaxation(const MCFixup &Fixup,
60
                                       uint64_t Value) const;
61
62
  bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
63
                            const MCRelaxableFragment *DF,
64
                            const MCAsmLayout &Layout, unsigned &KsError) const override;
65
66
  void relaxInstruction(const MCInst &Inst, MCInst &Res) const override;
67
68
  bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override;
69
70
  void handleAssemblerFlag(MCAssemblerFlag Flag) override;
71
72
0
  unsigned getPointerSize() const { return 4; }
73
10.9k
  bool isThumb() const { return isThumbMode; }
74
8.87k
  void setIsThumb(bool it) { isThumbMode = it; }
75
60.6k
  bool isLittle() const { return IsLittleEndian; }
76
};
77
} // end namespace llvm_ks
78
79
#endif