LLVM: lib/Target/MSP430/MCTargetDesc/MSP430AsmBackend.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

23

24using namespace llvm;

25

26namespace {

28 uint8_t OSABI;

29

31 MCContext &Ctx) const;

32

33public:

34 MSP430AsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI)

36 ~MSP430AsmBackend() override = default;

37

38 void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target,

39 uint8_t *Data, uint64_t Value, bool IsResolved) override;

40

41 std::unique_ptr

42 createObjectTargetWriter() const override {

44 }

45

46 MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override {

47

49

50

51

52 {"fixup_32", 0, 32, 0},

53 {"fixup_10_pcrel", 0, 10, 0},

54 {"fixup_16", 0, 16, 0},

55 {"fixup_16_pcrel", 0, 16, 0},

56 {"fixup_16_byte", 0, 16, 0},

57 {"fixup_16_pcrel_byte", 0, 16, 0},

58 {"fixup_2x_pcrel", 0, 10, 0},

59 {"fixup_rl_pcrel", 0, 16, 0},

60 {"fixup_8", 0, 8, 0},

61 {"fixup_sym_diff", 0, 32, 0},

62 };

63

65 "Not all fixup kinds added to Infos array");

66

69

71 }

72

73 bool writeNopData(raw_ostream &OS, uint64_t Count,

74 const MCSubtargetInfo *STI) const override;

75};

76

81 switch (Kind) {

84 Ctx.reportError(Fixup.getLoc(), "fixup value must be 2-byte aligned");

85

86

88

90

92

95

96

98

100 }

101 default:

103 }

104}

105

106void MSP430AsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,

107 const MCValue &Target, uint8_t *Data,

108 uint64_t Value, bool IsResolved) {

109 maybeAddReloc(F, Fixup, Target, Value, IsResolved);

111 MCFixupKindInfo Info = getFixupKindInfo(Fixup.getKind());

113 return;

114

115

117

118 unsigned NumBytes = alignTo(Info.TargetSize + Info.TargetOffset, 8) / 8;

119 assert(Fixup.getOffset() + NumBytes <= F.getSize() &&

120 "Invalid fixup offset!");

121

122

123

124 for (unsigned i = 0; i != NumBytes; ++i) {

125 Data[i] |= uint8_t((Value >> (i * 8)) & 0xff);

126 }

127}

128

129bool MSP430AsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,

130 const MCSubtargetInfo *STI) const {

131 if ((Count % 2) != 0)

132 return false;

133

134

135 uint64_t NopCount = Count / 2;

136 while (NopCount--)

137 OS.write("\x03\x43", 2);

138

139 return true;

140}

141

142}

143

unsigned const MachineRegisterInfo * MRI

static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target, uint64_t Value, MCContext &Ctx, const Triple &TheTriple, bool IsResolved)

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

This file implements a class to represent arbitrary precision integral constant values and operations...

Analysis containing CSE Info

PowerPC TLS Dynamic Call Fixup

Generic interface to target specific assembler backends.

virtual MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const

Get information on a fixup kind.

Context object for machine code objects.

LLVM_ABI void reportError(SMLoc L, const Twine &Msg)

Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...

MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...

Generic base class for all target subtargets.

Target - Wrapper for Target specific information.

LLVM Value Representation.

raw_ostream & write(unsigned char C)

Error applyFixup(LinkGraph &G, Block &B, const Edge &E, const ArmConfig &ArmCfg)

Apply fixup expression for edge to block content.

Context & getContext() const

This is an optimization pass for GlobalISel generic memory operations.

FunctionAddr VTableAddr Value

uint16_t MCFixupKind

Extensible enumeration to represent the type of a fixup.

FunctionAddr VTableAddr Count

FunctionAddr VTableAddr uintptr_t uintptr_t Data

uint64_t alignTo(uint64_t Size, Align A)

Returns a multiple of A needed to store Size bytes.

MCAsmBackend * createMSP430MCAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)

Definition MSP430AsmBackend.cpp:144

std::unique_ptr< MCObjectTargetWriter > createMSP430ELFObjectWriter(uint8_t OSABI)