LLVM  14.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"
30 
31 using namespace llvm;
32 
33 #define GET_INSTRINFO_MC_DESC
34 #include "M68kGenInstrInfo.inc"
35 
36 #define GET_SUBTARGETINFO_MC_DESC
37 #include "M68kGenSubtargetInfo.inc"
38 
39 #define GET_REGINFO_MC_DESC
40 #include "M68kGenRegisterInfo.inc"
41 
42 // TODO Implement feature set parsing logics
43 static std::string ParseM68kTriple(const Triple &TT, StringRef CPU) {
44  return "";
45 }
46 
48  MCInstrInfo *X = new MCInstrInfo();
49  InitM68kMCInstrInfo(X); // defined in M68kGenInstrInfo.inc
50  return X;
51 }
52 
55  InitM68kMCRegisterInfo(X, llvm::M68k::A0, 0, 0, llvm::M68k::PC);
56  return X;
57 }
58 
60  StringRef CPU, StringRef FS) {
61  std::string ArchFS = ParseM68kTriple(TT, CPU);
62  if (!FS.empty()) {
63  if (!ArchFS.empty()) {
64  ArchFS = (ArchFS + "," + FS).str();
65  } else {
66  ArchFS = FS.str();
67  }
68  }
69  return createM68kMCSubtargetInfoImpl(TT, CPU, /*TuneCPU=*/CPU, ArchFS);
70 }
71 
73  const Triple &TT,
74  const MCTargetOptions &TO) {
75  MCAsmInfo *MAI = new M68kELFMCAsmInfo(TT);
76 
77  // Initialize initial frame state.
78  // Calculate amount of bytes used for return address storing
79  int StackGrowth = -4;
80 
81  // Initial state of the frame pointer is SP+StackGrowth.
82  // TODO: Add tests for `cfi_*` directives
84  nullptr, MRI.getDwarfRegNum(llvm::M68k::SP, true), -StackGrowth);
85  MAI->addInitialFrameState(Inst);
86 
87  // Add return address to move list
89  nullptr, MRI.getDwarfRegNum(M68k::PC, true), StackGrowth);
90  MAI->addInitialFrameState(Inst);
91 
92  return MAI;
93 }
94 
96  MCContext &Ctx) {
97  // Default to the stock relocation info.
98  return llvm::createMCRelocationInfo(TheTriple, Ctx);
99 }
100 
102  unsigned SyntaxVariant,
103  const MCAsmInfo &MAI,
104  const MCInstrInfo &MII,
105  const MCRegisterInfo &MRI) {
106  return new M68kInstPrinter(MAI, MII, MRI);
107 }
108 
111 
112  // Register the MC asm info.
114 
115  // Register the MC instruction info.
117 
118  // Register the MC register info.
120 
121  // Register the MC subtarget info.
123 
124  // Register the code emitter.
126 
127  // Register the MCInstPrinter.
129 
130  // Register the MC relocation info.
132 
133  // Register the asm backend.
135 }
LLVMInitializeM68kTargetMC
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeM68kTargetMC()
Definition: M68kMCTargetDesc.cpp:109
createM68kMCInstrInfo
static MCInstrInfo * createM68kMCInstrInfo()
Definition: M68kMCTargetDesc.cpp:47
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
createM68kMCRelocationInfo
static MCRelocationInfo * createM68kMCRelocationInfo(const Triple &TheTriple, MCContext &Ctx)
Definition: M68kMCTargetDesc.cpp:95
T
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:72
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
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:45
llvm::getTheM68kTarget
Target & getTheM68kTarget()
Definition: M68kTargetInfo.cpp:18
llvm::TargetRegistry::RegisterMCInstPrinter
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
Definition: TargetRegistry.h:930
createM68kMCAsmInfo
static MCAsmInfo * createM68kMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &TO)
Definition: M68kMCTargetDesc.cpp:72
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
MCSubtargetInfo.h
createM68kMCSubtargetInfo
static MCSubtargetInfo * createM68kMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
Definition: M68kMCTargetDesc.cpp:59
M68kMCAsmInfo.h
llvm::RegisterMCAsmInfoFn
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
Definition: TargetRegistry.h:1097
MCInstPrinter.h
llvm::MCCFIInstruction
Definition: MCDwarf.h:434
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:43
llvm::TargetRegistry::RegisterMCAsmBackend
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
Definition: TargetRegistry.h:877
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:132
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:488
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:850
llvm::MCTargetOptions
Definition: MCTargetOptions.h:36
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:58
createM68kMCInstPrinter
static MCInstPrinter * createM68kMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
Definition: M68kMCTargetDesc.cpp:101
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:817
llvm::TargetRegistry::RegisterMCCodeEmitter
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
Definition: TargetRegistry.h:943
llvm::MCInstrInfo
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:25
llvm::createM68kMCCodeEmitter
MCCodeEmitter * createM68kMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
Definition: M68kMCCodeEmitter.cpp:383
llvm::TargetRegistry::RegisterMCRegInfo
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Definition: TargetRegistry.h:837
M68kTargetInfo.h
llvm::X86AS::FS
@ FS
Definition: X86.h:188
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:526
createM68kMCRegisterInfo
static MCRegisterInfo * createM68kMCRegisterInfo(const Triple &TT)
Definition: M68kMCTargetDesc.cpp:53
M68kInstPrinter.h
TargetRegistry.h
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:75
llvm::TargetRegistry::RegisterMCRelocationInfo
static void RegisterMCRelocationInfo(Target &T, Target::MCRelocationInfoCtorTy Fn)
RegisterMCRelocationInfo - Register an MCRelocationInfo implementation for the given target.
Definition: TargetRegistry.h:992