LLVM  14.0.0git
CSKYMCTargetDesc.cpp
Go to the documentation of this file.
1 //===-- CSKYMCTargetDesc.cpp - CSKY Target Descriptions -------------------===//
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 /// This file provides CSKY specific target descriptions.
10 ///
11 //===----------------------------------------------------------------------===//
12 
13 #include "CSKYMCTargetDesc.h"
14 #include "CSKYAsmBackend.h"
15 #include "CSKYInstPrinter.h"
16 #include "CSKYMCAsmInfo.h"
17 #include "CSKYMCCodeEmitter.h"
19 #include "llvm/MC/MCInstrInfo.h"
20 #include "llvm/MC/MCRegisterInfo.h"
23 
24 #define GET_INSTRINFO_MC_DESC
25 #include "CSKYGenInstrInfo.inc"
26 
27 #define GET_REGINFO_MC_DESC
28 #include "CSKYGenRegisterInfo.inc"
29 
30 #define GET_SUBTARGETINFO_MC_DESC
31 #include "CSKYGenSubtargetInfo.inc"
32 
33 using namespace llvm;
34 
36  const Triple &TT,
37  const MCTargetOptions &Options) {
38  MCAsmInfo *MAI = new CSKYMCAsmInfo(TT);
39 
40  // Initial state of the frame pointer is SP.
41  unsigned Reg = MRI.getDwarfRegNum(CSKY::R14, true);
43  MAI->addInitialFrameState(Inst);
44  return MAI;
45 }
46 
48  MCInstrInfo *Info = new MCInstrInfo();
49  InitCSKYMCInstrInfo(Info);
50  return Info;
51 }
52 
54  unsigned SyntaxVariant,
55  const MCAsmInfo &MAI,
56  const MCInstrInfo &MII,
57  const MCRegisterInfo &MRI) {
58  return new CSKYInstPrinter(MAI, MII, MRI);
59 }
60 
63  InitCSKYMCRegisterInfo(Info, CSKY::R15);
64  return Info;
65 }
66 
68  StringRef CPU, StringRef FS) {
69  std::string CPUName = std::string(CPU);
70  if (CPUName.empty())
71  CPUName = "generic";
72  return createCSKYMCSubtargetInfoImpl(TT, CPUName, /*TuneCPU=*/CPUName, FS);
73 }
74 
76  auto &CSKYTarget = getTheCSKYTarget();
85 }
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
llvm::CSKYMCAsmInfo
Definition: CSKYMCAsmInfo.h:21
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::createCSKYMCCodeEmitter
MCCodeEmitter * createCSKYMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
Definition: CSKYMCCodeEmitter.cpp:76
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
createCSKYMCSubtargetInfo
static MCSubtargetInfo * createCSKYMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
Definition: CSKYMCTargetDesc.cpp:67
llvm::TargetRegistry::RegisterMCInstPrinter
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
Definition: TargetRegistry.h:930
llvm::getTheCSKYTarget
Target & getTheCSKYTarget()
Definition: CSKYTargetInfo.cpp:13
CSKYAsmBackend.h
MCInstrInfo.h
MCSubtargetInfo.h
llvm::createCSKYAsmBackend
MCAsmBackend * createCSKYAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
Definition: CSKYAsmBackend.cpp:165
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
CSKYMCCodeEmitter.h
llvm::MCCFIInstruction
Definition: MCDwarf.h:434
llvm::TargetRegistry::RegisterMCAsmBackend
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
Definition: TargetRegistry.h:877
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
createCSKYMCAsmInfo
static MCAsmInfo * createCSKYMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options)
Definition: CSKYMCTargetDesc.cpp:35
llvm::TargetRegistry::RegisterMCAsmInfo
static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn)
RegisterMCAsmInfo - Register a MCAsmInfo implementation for the given target.
Definition: TargetRegistry.h:791
CSKYMCTargetDesc.h
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::X86AS::FS
@ FS
Definition: X86.h:188
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
createCSKYMCRegisterInfo
static MCRegisterInfo * createCSKYMCRegisterInfo(const Triple &TT)
Definition: CSKYMCTargetDesc.cpp:61
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::MCRegisterInfo
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Definition: MCRegisterInfo.h:135
CSKYMCAsmInfo.h
CSKYInstPrinter.h
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
LLVMInitializeCSKYTargetMC
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeCSKYTargetMC()
Definition: CSKYMCTargetDesc.cpp:75
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::CSKYInstPrinter
Definition: CSKYInstPrinter.h:21
llvm::TargetRegistry::RegisterMCRegInfo
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Definition: TargetRegistry.h:837
createCSKYMCInstPrinter
static MCInstPrinter * createCSKYMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
Definition: CSKYMCTargetDesc.cpp:53
createCSKYMCInstrInfo
static MCInstrInfo * createCSKYMCInstrInfo()
Definition: CSKYMCTargetDesc.cpp:47
CSKYTargetInfo.h
TargetRegistry.h
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:75