LLVM 19.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
21#include "llvm/MC/MCInstrInfo.h"
24#include "llvm/MC/MCSymbol.h"
30
31using 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
44static 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}
unsigned const MachineRegisterInfo * MRI
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:135
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This file contains declarations for an M68k MCInst printer.
This file contains the declarations of the M68k MCAsmInfo properties.
static MCInstrInfo * createM68kMCInstrInfo()
static MCInstPrinter * createM68kMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
static MCAsmInfo * createM68kMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &TO)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeM68kTargetMC()
static std::string ParseM68kTriple(const Triple &TT, StringRef CPU)
static MCRegisterInfo * createM68kMCRegisterInfo(const Triple &TT)
static MCRelocationInfo * createM68kMCRelocationInfo(const Triple &TheTriple, MCContext &Ctx)
static MCSubtargetInfo * createM68kMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
This file provides M68k specific target descriptions.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
void addInitialFrameState(const MCCFIInstruction &Inst)
Definition: MCAsmInfo.cpp:75
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset, SMLoc Loc={})
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
Definition: MCDwarf.h:583
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
Definition: MCDwarf.h:541
Context object for machine code objects.
Definition: MCContext.h:81
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:45
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Create MCExprs from relocations found in an object file.
Generic base class for all target subtargets.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
MCRelocationInfo * createMCRelocationInfo(const Triple &TT, MCContext &Ctx)
MCAsmBackend * createM68kAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
Target & getTheM68kTarget()
MCCodeEmitter * createM68kMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target.
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target.
static void RegisterMCRelocationInfo(Target &T, Target::MCRelocationInfoCtorTy Fn)
RegisterMCRelocationInfo - Register an MCRelocationInfo implementation for the given target.