LLVM  16.0.0git
M68kMCTargetDesc.cpp
Go to the documentation of this file.
1 //===-- M68kMCTargetDesc.cpp - M68k Target Descriptions ---------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file provides M68k target specific descriptions.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #include "M68kMCTargetDesc.h"
15 #include "M68kInstPrinter.h"
16 #include "M68kMCAsmInfo.h"
18 
19 #include "llvm/MC/MCELFStreamer.h"
20 #include "llvm/MC/MCInstPrinter.h"
21 #include "llvm/MC/MCInstrInfo.h"
22 #include "llvm/MC/MCRegisterInfo.h"
24 #include "llvm/MC/MCSymbol.h"
26 #include "llvm/MC/TargetRegistry.h"
30 
31 using namespace llvm;
32 
33 #define GET_INSTRINFO_MC_DESC
34 #define ENABLE_INSTR_PREDICATE_VERIFIER
35 #include "M68kGenInstrInfo.inc"
36 
37 #define GET_SUBTARGETINFO_MC_DESC
38 #include "M68kGenSubtargetInfo.inc"
39 
40 #define GET_REGINFO_MC_DESC
41 #include "M68kGenRegisterInfo.inc"
42 
43 // TODO Implement feature set parsing logics
44 static std::string ParseM68kTriple(const Triple &TT, StringRef CPU) {
45  return "";
46 }
47 
49  MCInstrInfo *X = new MCInstrInfo();
50  InitM68kMCInstrInfo(X); // defined in M68kGenInstrInfo.inc
51  return X;
52 }
53 
56  InitM68kMCRegisterInfo(X, llvm::M68k::A0, 0, 0, llvm::M68k::PC);
57  return X;
58 }
59 
61  StringRef CPU, StringRef FS) {
62  std::string ArchFS = ParseM68kTriple(TT, CPU);
63  if (!FS.empty()) {
64  if (!ArchFS.empty()) {
65  ArchFS = (ArchFS + "," + FS).str();
66  } else {
67  ArchFS = FS.str();
68  }
69  }
70  return createM68kMCSubtargetInfoImpl(TT, CPU, /*TuneCPU=*/CPU, ArchFS);
71 }
72 
74  const Triple &TT,
75  const MCTargetOptions &TO) {
76  MCAsmInfo *MAI = new M68kELFMCAsmInfo(TT);
77 
78  // Initialize initial frame state.
79  // Calculate amount of bytes used for return address storing
80  int StackGrowth = -4;
81 
82  // Initial state of the frame pointer is SP+StackGrowth.
83  // TODO: Add tests for `cfi_*` directives
85  nullptr, MRI.getDwarfRegNum(llvm::M68k::SP, true), -StackGrowth);
86  MAI->addInitialFrameState(Inst);
87 
88  // Add return address to move list
90  nullptr, MRI.getDwarfRegNum(M68k::PC, true), StackGrowth);
91  MAI->addInitialFrameState(Inst);
92 
93  return MAI;
94 }
95 
97  MCContext &Ctx) {
98  // Default to the stock relocation info.
99  return llvm::createMCRelocationInfo(TheTriple, Ctx);
100 }
101 
103  unsigned SyntaxVariant,
104  const MCAsmInfo &MAI,
105  const MCInstrInfo &MII,
106  const MCRegisterInfo &MRI) {
107  return new M68kInstPrinter(MAI, MII, MRI);
108 }
109 
112 
113  // Register the MC asm info.
115 
116  // Register the MC instruction info.
118 
119  // Register the MC register info.
121 
122  // Register the MC subtarget info.
124 
125  // Register the code emitter.
127 
128  // Register the MCInstPrinter.
130 
131  // Register the MC relocation info.
133 
134  // Register the asm backend.
136 }
LLVMInitializeM68kTargetMC
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeM68kTargetMC()
Definition: M68kMCTargetDesc.cpp:110
createM68kMCInstrInfo
static MCInstrInfo * createM68kMCInstrInfo()
Definition: M68kMCTargetDesc.cpp:48
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
createM68kMCRelocationInfo
static MCRelocationInfo * createM68kMCRelocationInfo(const Triple &TheTriple, MCContext &Ctx)
Definition: M68kMCTargetDesc.cpp:96
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:76
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:149
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
llvm::MCRelocationInfo
Create MCExprs from relocations found in an object file.
Definition: MCRelocationInfo.h:24
ErrorHandling.h
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::getTheM68kTarget
Target & getTheM68kTarget()
Definition: M68kTargetInfo.cpp:18
llvm::X86AS::FS
@ FS
Definition: X86.h:200
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::TargetRegistry::RegisterMCInstPrinter
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
Definition: TargetRegistry.h:988
createM68kMCAsmInfo
static MCAsmInfo * createM68kMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &TO)
Definition: M68kMCTargetDesc.cpp:73
MCELFStreamer.h
llvm::createM68kAsmBackend
MCAsmBackend * createM68kAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
Definition: M68kAsmBackend.cpp:234
CommandLine.h
FormattedStream.h
MCInstrInfo.h
MCSymbol.h
llvm::createM68kMCCodeEmitter
MCCodeEmitter * createM68kMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
Definition: M68kMCCodeEmitter.cpp:244
MCSubtargetInfo.h
createM68kMCSubtargetInfo
static MCSubtargetInfo * createM68kMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
Definition: M68kMCTargetDesc.cpp:60
M68kMCAsmInfo.h
llvm::RegisterMCAsmInfoFn
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
Definition: TargetRegistry.h:1178
MCInstPrinter.h
llvm::MCCFIInstruction
Definition: MCDwarf.h:478
llvm::M68kELFMCAsmInfo
Definition: M68kMCAsmInfo.h:22
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
ParseM68kTriple
static std::string ParseM68kTriple(const Triple &TT, StringRef CPU)
Definition: M68kMCTargetDesc.cpp:44
llvm::TargetRegistry::RegisterMCAsmBackend
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
Definition: TargetRegistry.h:935
M68kMCTargetDesc.h
llvm::MCInstPrinter
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:43
LLVM_EXTERNAL_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:127
MCRegisterInfo.h
llvm::M68kInstPrinter
Definition: M68kInstPrinter.h:23
llvm::MCCFIInstruction::cfiDefCfa
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int Offset)
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
Definition: MCDwarf.h:532
llvm::MCAsmInfo::addInitialFrameState
void addInitialFrameState(const MCCFIInstruction &Inst)
Definition: MCAsmInfo.cpp:86
llvm::TargetRegistry::RegisterMCSubtargetInfo
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target.
Definition: TargetRegistry.h:908
llvm::MCTargetOptions
Definition: MCTargetOptions.h:37
llvm::createMCRelocationInfo
MCRelocationInfo * createMCRelocationInfo(const Triple &TT, MCContext &Ctx)
Definition: MCRelocationInfo.cpp:27
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
createM68kMCInstPrinter
static MCInstPrinter * createM68kMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
Definition: M68kMCTargetDesc.cpp:102
MachineLocation.h
llvm::MCRegisterInfo
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Definition: MCRegisterInfo.h:135
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::TargetRegistry::RegisterMCInstrInfo
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target.
Definition: TargetRegistry.h:875
llvm::TargetRegistry::RegisterMCCodeEmitter
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
Definition: TargetRegistry.h:1001
llvm::MCInstrInfo
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
llvm::TargetRegistry::RegisterMCRegInfo
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Definition: TargetRegistry.h:895
M68kTargetInfo.h
llvm::MCCFIInstruction::createOffset
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
Definition: MCDwarf.h:570
createM68kMCRegisterInfo
static MCRegisterInfo * createM68kMCRegisterInfo(const Triple &TT)
Definition: M68kMCTargetDesc.cpp:54
M68kInstPrinter.h
TargetRegistry.h
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:76
llvm::TargetRegistry::RegisterMCRelocationInfo
static void RegisterMCRelocationInfo(Target &T, Target::MCRelocationInfoCtorTy Fn)
RegisterMCRelocationInfo - Register an MCRelocationInfo implementation for the given target.
Definition: TargetRegistry.h:1058