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

21

29

30using namespace llvm;

31

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

33

35 : Ctx(MF.getContext()), MF(MF), TM(MF.getTarget()), MAI(*TM.getMCAsmInfo()),

37

41 "Isn't a symbol reference");

42

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

46

48

52

53 if (!Suffix.empty())

54 Name += DL.getPrivateGlobalPrefix();

55

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

64 }

65

66 Name += Suffix;

69

70 return Sym;

71}

72

75

76

77 const MCExpr *Expr = nullptr;

79

81 default:

86 break;

89 break;

92 break;

95 break;

98 break;

101 break;

104 break;

107 break;

110 break;

113 break;

114 }

115

116 if (!Expr) {

118 }

119

123 }

124

126}

127

128std::optional

132 default:

135

137 return std::nullopt;

155

156 return std::nullopt;

157 }

158}

159

161 unsigned Opcode = MI->getOpcode();

163

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

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

167

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

170 }

171

172

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

175 switch (Opcode) {

176 case M68k::TAILJMPj:

177 Opcode = M68k::JMP32j;

178 break;

179 case M68k::TAILJMPq:

180 Opcode = M68k::BRA8;

181 break;

182 }

184 }

185}

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 code to lower M68k MachineInstrs to their corresponding MCInst records.

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

This class is intended to be used as a driving class for all asm writers.

virtual MCSymbol * GetCPISymbol(unsigned CPID) const

Return the symbol for the specified constant pool entry.

MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const

Return the symbol for the specified jump table entry.

MCSymbol * getSymbolPreferLocal(const GlobalValue &GV) const

Similar to getSymbol() but preferred for references.

void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const

MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const

Return the MCSymbol used to satisfy BlockAddress uses of the specified basic block.

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.

M68kMCInstLower(MachineFunction &MF, M68kAsmPrinter &AP)

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

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

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

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

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

MCSymbol * getOrCreateSymbol(const Twine &Name)

Lookup the symbol inside with the specified Name.

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)

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

MCSymbol * getSymbol() const

Return the MCSymbol for this basic block.

const DataLayout & getDataLayout() const

Return the DataLayout attached to the Module associated to this MF.

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.

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.

const Triple & getTargetTriple() const

#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.