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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

16

19

22

30

31using namespace llvm;

32

33#define DEBUG_TYPE "m68k-mc-inst-lower"

34

36 : Ctx(AP.OutContext), MF(MF), TM(MF.getTarget()), MAI(*TM.getMCAsmInfo()),

37 AsmPrinter(AP) {}

38

42 "Isn't a symbol reference");

43

44 const auto &TT = TM.getTargetTriple();

45 if (MO.isGlobal() && TT.isOSBinFormatELF())

46 return AsmPrinter.getSymbolPreferLocal(*MO.getGlobal());

47

49

53

54 if (!Suffix.empty())

55 Name += DL.getPrivateGlobalPrefix();

56

59 AsmPrinter.getNameWithPrefix(Name, GV);

62 } else if (MO.isMBB()) {

65 }

66

67 Name += Suffix;

68 if (!Sym)

69 Sym = Ctx.getOrCreateSymbol(Name);

70

71 return Sym;

72}

73

76

77

78 const MCExpr *Expr = nullptr;

80

82 default:

87 break;

90 break;

93 break;

96 break;

99 break;

102 break;

105 break;

108 break;

111 break;

114 break;

115 }

116

117 if (!Expr) {

119 }

120

124 }

125

127}

128

129std::optional

133 default:

136

138 return std::nullopt;

154 MO, AsmPrinter.GetBlockAddressSymbol(MO.getBlockAddress()));

156

157 return std::nullopt;

158 }

159}

160

162 unsigned Opcode = MI->getOpcode();

164

165 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {

167 std::optional MCOp = LowerOperand(MI, MO);

168

169 if (MCOp.has_value() && MCOp.value().isValid())

171 }

172

173

174 if (Opcode == M68k::TAILJMPj || Opcode == M68k::TAILJMPq) {

176 switch (Opcode) {

177 case M68k::TAILJMPj:

178 Opcode = M68k::JMP32j;

179 break;

180 case M68k::TAILJMPq:

181 Opcode = M68k::BRA8;

182 break;

183 }

185 }

186}

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

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

This file contains M68k assembler printer declarations.

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

This file contains the M68k implementation of the TargetInstrInfo class.

This file contains the declarations of the M68k MCAsmInfo properties.

This file contains code to lower M68k MachineInstrs to their corresponding MCInst records.

A parsed version of the target data layout string in and methods for querying it.

MCSymbol * GetSymbolFromOperand(const MachineOperand &MO) const

Lower an MO_GlobalAddress or MO_ExternalSymbol operand to an MCSymbol.

Definition M68kMCInstLower.cpp:40

M68kMCInstLower(MachineFunction &MF, M68kAsmPrinter &AP)

Definition M68kMCInstLower.cpp:35

void Lower(const MachineInstr *MI, MCInst &OutMI) const

Definition M68kMCInstLower.cpp:161

MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const

Definition M68kMCInstLower.cpp:74

std::optional< MCOperand > LowerOperand(const MachineInstr *MI, const MachineOperand &MO) const

Definition M68kMCInstLower.cpp:130

static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())

static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)

Base class for the full range of assembler expressions which are needed for parsing.

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

unsigned getNumOperands() const

void addOperand(const MCOperand Op)

void setOpcode(unsigned Op)

Instances of this class represent operands of the MCInst class.

static MCOperand createExpr(const MCExpr *Val)

static MCOperand createReg(MCRegister Reg)

static MCOperand createImm(int64_t Val)

static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

LLVM_ABI MCSymbol * getSymbol() const

Return the MCSymbol for this basic block.

Representation of each machine instruction.

MachineOperand class - Representation of each machine instruction operand.

const GlobalValue * getGlobal() const

MachineBasicBlock * getMBB() const

bool isSymbol() const

isSymbol - Tests if this is a MO_ExternalSymbol operand.

bool isJTI() const

isJTI - Tests if this is a MO_JumpTableIndex operand.

const BlockAddress * getBlockAddress() const

unsigned getTargetFlags() const

bool isGlobal() const

isGlobal - Tests if this is a MO_GlobalAddress operand.

MachineOperandType getType() const

getType - Returns the MachineOperandType for this operand.

const char * getSymbolName() const

Register getReg() const

getReg - Returns the register number.

MCSymbol * getMCSymbol() const

@ MO_Immediate

Immediate operand.

@ MO_ConstantPoolIndex

Address of indexed Constant in Constant Pool.

@ MO_MCSymbol

MCSymbol reference (for debug/eh info)

@ MO_GlobalAddress

Address of a global value.

@ MO_RegisterMask

Mask of preserved registers.

@ MO_BlockAddress

Address of a basic block.

@ MO_MachineBasicBlock

MachineBasicBlock reference.

@ MO_Register

Register operand.

@ MO_ExternalSymbol

Name of external global symbol.

@ MO_JumpTableIndex

Address of indexed Jump Table for switch.

int64_t getOffset() const

Return the offset from the symbol in this operand.

bool isMBB() const

isMBB - Tests if this is a MO_MachineBasicBlock operand.

LLVM_ABI void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const

Print the appropriate prefix and the specified global variable's name.

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...

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

constexpr bool empty() const

empty - Check if the string is empty.

#define llvm_unreachable(msg)

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

@ MO_GOTOFF

On a symbol operand this indicates that the immediate is the offset to the location of the symbol nam...

@ MO_TLSLDM

On a symbol operand, this indicates that the immediate is the offset to the slot in GOT which stores ...

@ MO_PLT

On a symbol operand this indicates that the immediate is offset to the PLT entry of symbol name from ...

@ MO_TLSLE

On a symbol operand, this indicates that the immediate is the offset to the variable within in the th...

@ MO_GOT

On a symbol operand this indicates that the immediate is the offset to the GOT entry for the symbol n...

@ MO_TLSGD

On a symbol operand, this indicates that the immediate is the offset to the slot in GOT which stores ...

@ MO_ABSOLUTE_ADDRESS

On a symbol operand this indicates that the immediate is the absolute address of the symbol.

@ MO_GOTPCREL

On a symbol operand this indicates that the immediate is offset to the GOT entry for the symbol name ...

@ MO_PC_RELATIVE_ADDRESS

On a symbol operand this indicates that the immediate is the pc-relative address of the symbol.

@ MO_TLSIE

On a symbol operand, this indicates that the immediate is the offset to the variable within the threa...

@ MO_TLSLD

On a symbol operand, this indicates that the immediate is the offset to variable within the thread lo...

This is an optimization pass for GlobalISel generic memory operations.