LLVM: lib/Target/M68k/MCTargetDesc/M68kInstPrinter.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

28

37

38using namespace llvm;

39

40#define DEBUG_TYPE "asm-printer"

41

42#define PRINT_ALIAS_INSTR

43#include "M68kGenAsmWriter.inc"

44

48

57

58void M68kInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,

60 const MCOperand &MO = MI->getOperand(OpNo);

63 return;

64 }

65

67 printImmediate(MI, OpNo, O);

68 return;

69 }

70

71 assert(MO.isExpr() && "Unknown operand kind in printOperand");

73}

74

75void M68kInstPrinter::printImmediate(const MCInst *MI, unsigned opNum,

77 const MCOperand &MO = MI->getOperand(opNum);

80 else if (MO.isExpr()) {

81 O << '#';

83 } else

85}

86

87void M68kInstPrinter::printMoveMask(const MCInst *MI, unsigned opNum,

89 unsigned Mask = MI->getOperand(opNum).getImm();

90 assert((Mask & 0xFFFF) == Mask && "Mask is always 16 bits");

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106 uint8_t HalfMask;

107 unsigned Reg;

108 for (int s = 0; s < 16; s += 8) {

109 HalfMask = (Mask >> s) & 0xFF;

110

111

112 if (s != 0 && (Mask & 0xFF) && HalfMask)

113 O << '/';

114

115 for (int i = 0; HalfMask; ++i) {

116 if ((HalfMask >> i) & 0b1) {

117 HalfMask ^= 0b1 << i;

120

121 int j = i;

122 while ((HalfMask >> (j + 1)) & 0b1)

123 HalfMask ^= 0b1 << ++j;

124

125 if (j != i) {

126 O << '-';

129 }

130

131 i = j;

132

133 if (HalfMask)

134 O << '/';

135 }

136 }

137 }

138}

139

140void M68kInstPrinter::printDisp(const MCInst *MI, unsigned opNum,

142 const MCOperand &Op = MI->getOperand(opNum);

143 if (Op.isImm()) {

144 O << Op.getImm();

145 return;

146 }

147 assert(Op.isExpr() && "Unknown operand kind in printOperand");

148 MAI.printExpr(O, *Op.getExpr());

149}

150

151

152void M68kInstPrinter::printAbsMem(const MCInst *MI, unsigned opNum,

154 const MCOperand &MO = MI->getOperand(opNum);

155

158 return;

159 }

160

161 assert(MO.isImm() && "absolute memory addressing needs an immediate");

162 O << format("$%0" PRIx64, (uint64_t)MO.getImm());

163}

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

This file contains small standalone helper functions and enum definitions for the M68k target useful ...

This file contains declarations for an M68k MCInst printer.

bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &OS)

void printRegName(raw_ostream &OS, MCRegister Reg) override

Print the assembler register name.

Definition M68kInstPrinter.cpp:45

void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &O) override

Print the specified MCInst to the specified raw_ostream.

Definition M68kInstPrinter.cpp:49

void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O)

static const char * getRegisterName(MCRegister Reg)

void printAnnotation(raw_ostream &OS, StringRef Annot)

Utility function for printing annotations.

Instances of this class represent a single low-level machine instruction.

Instances of this class represent operands of the MCInst class.

MCRegister getReg() const

Returns the register number.

const MCExpr * getExpr() const

Wrapper class representing physical registers. Should be passed by value.

Generic base class for all target subtargets.

StringRef - Represent a constant reference to a string, i.e.

This class implements an extremely fast bulk output stream that can only output to a stream.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

constexpr std::underlying_type_t< E > Mask()

Get a bitmask with 1s in all places up to the high-order bit of E's largest value.

static unsigned getMaskedSpillRegister(unsigned order)

This is an optimization pass for GlobalISel generic memory operations.

format_object< Ts... > format(const char *Fmt, const Ts &... Vals)

These are helper functions used to produce formatted output.

DWARFExpression::Operation Op