LLVM 24.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"
17#include "M68kMCOptions.h"
19
22#include "llvm/MC/MCInstrInfo.h"
24#include "llvm/MC/MCStreamer.h"
26#include "llvm/MC/MCSymbol.h"
32
33using namespace llvm;
34
35#define GET_INSTRINFO_MC_DESC
36#define ENABLE_INSTR_PREDICATE_VERIFIER
37#include "M68kGenInstrInfo.inc"
38
39#define GET_SUBTARGETINFO_MC_DESC
40#include "M68kGenSubtargetInfo.inc"
41
42#define GET_REGINFO_MC_DESC
43#include "M68kGenRegisterInfo.inc"
44
45#define OPTIONS_STRUCT_DEFS
46#include "M68kMCOptions.inc"
47
48// TODO Implement feature set parsing logics
49static std::string ParseM68kTriple(const Triple &TT, StringRef CPU) {
50 return "";
51}
52
54 MCInstrInfo *X = new MCInstrInfo();
55 InitM68kMCInstrInfo(X); // defined in M68kGenInstrInfo.inc
56 return X;
57}
58
61 InitM68kMCRegisterInfo(X, llvm::M68k::A0, 0, 0, llvm::M68k::PC);
62 return X;
63}
64
66 StringRef CPU, StringRef FS) {
67 std::string ArchFS = ParseM68kTriple(TT, CPU);
68 if (!FS.empty()) {
69 if (!ArchFS.empty()) {
70 ArchFS = (ArchFS + "," + FS).str();
71 } else {
72 ArchFS = FS.str();
73 }
74 }
75 return createM68kMCSubtargetInfoImpl(TT, CPU, /*TuneCPU=*/CPU, ArchFS);
76}
77
79 const Triple &TT,
80 const MCTargetOptions &TO) {
81 MCAsmInfo *MAI = new M68kELFMCAsmInfo(TT, TO);
82
83 // Initialize initial frame state.
84 // Calculate amount of bytes used for return address storing
85 int StackGrowth = -4;
86
87 // Initial state of the frame pointer is SP+StackGrowth.
88 // TODO: Add tests for `cfi_*` directives
90 nullptr, MRI.getDwarfRegNum(llvm::M68k::SP, true), -StackGrowth);
91 MAI->addInitialFrameState(Inst);
92
93 // Add return address to move list
95 nullptr, MRI.getDwarfRegNum(M68k::PC, true), StackGrowth);
96 MAI->addInitialFrameState(Inst);
97
98 return MAI;
99}
100
102 MCContext &Ctx) {
103 // Default to the stock relocation info.
104 return llvm::createMCRelocationInfo(TheTriple, Ctx);
105}
106
108 unsigned SyntaxVariant,
109 const MCAsmInfo &MAI,
110 const MCInstrInfo &MII,
111 const MCRegisterInfo &MRI) {
112 return new M68kInstPrinter(MAI, MII, MRI);
113}
114
118
122
123 // Register the MC asm info.
125
126 // Register the MC instruction info.
128
129 // Register the MC register info.
131
132 // Register the MC subtarget info.
134
135 // Register the code emitter.
137
138 // Register the MCInstPrinter.
140
141 // Register the MC relocation info.
143
144 // Register the asm backend.
146
148}
static MCTargetStreamer * createNullTargetStreamer(MCStreamer &S)
#define X(NUM, ENUM, NAME)
Definition ELF.h:665
#define LLVM_EXTERNAL_VISIBILITY
Definition Compiler.h:132
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)
static MCTargetStreamer * createNullTargetStreamer(MCStreamer &S)
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.
#define T
MachineRegisterInfo & MRI
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:67
void addInitialFrameState(const MCCFIInstruction &Inst)
Definition MCAsmInfo.cpp:43
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int64_t 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:628
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
Definition MCDwarf.h:670
Context object for machine code objects.
Definition MCContext.h:83
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Create MCExprs from relocations found in an object file.
Streaming machine code generation interface.
Definition MCStreamer.h:222
Generic base class for all target subtargets.
Target specific streamer interface.
Definition MCStreamer.h:95
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
Registers T::Global with cl::ParseCommandLineOptions.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI 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 RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn)
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.