LLVM 24.0.0git
MipsMCTargetDesc.h
Go to the documentation of this file.
1//===-- MipsMCTargetDesc.h - Mips 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// This file provides Mips specific target descriptions.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSMCTARGETDESC_H
14#define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSMCTARGETDESC_H
15
16#include "llvm/MC/MCRegister.h"
18
19#include <memory>
20
21namespace llvm {
22class MCAsmBackend;
23class MCCodeEmitter;
24class MCContext;
25class MCInstrInfo;
27class MCObjectWriter;
28class MCRegister;
29class MCRegisterInfo;
30class MCStreamer;
31class MCSubtargetInfo;
32class MCTargetOptions;
33class StringRef;
34class Target;
35class Triple;
36
38 MCContext &Ctx);
40 MCContext &Ctx);
41
43 const MCRegisterInfo &MRI,
45
46/// Construct an MIPS Windows COFF machine code streamer which will generate
47/// PE/COFF format object files.
48///
49/// Takes ownership of \p AB and \p CE.
51 std::unique_ptr<MCAsmBackend> &&AB,
52 std::unique_ptr<MCObjectWriter> &&OW,
53 std::unique_ptr<MCCodeEmitter> &&CE);
54
55/// Construct a Mips ELF object writer.
56std::unique_ptr<MCObjectTargetWriter>
57createMipsELFObjectWriter(const Triple &TT, bool IsN32);
58/// Construct a Mips Win COFF object writer.
59std::unique_ptr<MCObjectTargetWriter> createMipsWinCOFFObjectWriter();
60
61namespace MIPS_MC {
62void initLLVMToCVRegMapping(MCRegisterInfo *MRI);
63
64/// COP0 hardware encodings reserve five bits each for REG and SEL.
65constexpr unsigned encodeCOP0Register(unsigned Reg, unsigned Sel) {
66 return (Reg << 5) | Sel;
67}
68constexpr unsigned getCOP0RegNum(unsigned Encoding) { return Encoding >> 5; }
69constexpr unsigned getCOP0Sel(unsigned Encoding) { return Encoding & 31; }
70MCRegister getCOP0Register(const MCRegisterInfo &MRI, unsigned Encoding);
71
73
74/// Match a symbolic name in RegClassID, or return an invalid register.
76 unsigned RegClassID, unsigned AltIdx);
77
78/// Return a GPR name's hardware index, or -1 if unknown.
80 unsigned AltIdx, bool *IsDeprecated = nullptr);
81}
82
83} // End llvm namespace
84
85// Defines symbolic names for Mips registers. This defines a mapping from
86// register name to register number.
87#define GET_REGINFO_ENUM
88#include "MipsGenRegisterInfo.inc"
89
90namespace llvm {
91namespace Mips {
92// Readable names for the GPRs with a dedicated role. Other GPRs use their R<n>
93// names, or the MipsABIInfo accessors when their role depends on the ABI.
94inline constexpr MCPhysReg GP = R28;
95inline constexpr MCPhysReg SP = R29;
96inline constexpr MCPhysReg FP = R30;
97inline constexpr MCPhysReg RA = R31;
98inline constexpr MCPhysReg GP_64 = R28_64;
99inline constexpr MCPhysReg SP_64 = R29_64;
100inline constexpr MCPhysReg FP_64 = R30_64;
101inline constexpr MCPhysReg RA_64 = R31_64;
102} // namespace Mips
103} // namespace llvm
104
105// Defines symbolic names for the Mips instructions.
106#define GET_INSTRINFO_ENUM
107#define GET_INSTRINFO_MC_HELPER_DECLS
108#include "MipsGenInstrInfo.inc"
109
110#define GET_SUBTARGETINFO_ENUM
111#include "MipsGenSubtargetInfo.inc"
112
113#endif
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static LVOptions Options
Definition LVOptions.cpp:25
Register Reg
#define T
MachineRegisterInfo & MRI
Generic interface to target specific assembler backends.
MCCodeEmitter - Generic instruction encoding interface.
Context object for machine code objects.
Definition MCContext.h:83
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
Base class for classes that define behaviour that is specific to both the target and the object forma...
Defines the object file and target independent interfaces used by the assembler backend to write nati...
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
Streaming machine code generation interface.
Definition MCStreamer.h:222
Generic base class for all target subtargets.
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
constexpr unsigned encodeCOP0Register(unsigned Reg, unsigned Sel)
COP0 hardware encodings reserve five bits each for REG and SEL.
MCRegister getCOP0Register(const MCRegisterInfo &MRI, unsigned Encoding)
StringRef selectMipsCPU(const Triple &TT, StringRef CPU)
Select the Mips CPU for the given triple and cpu name.
MCRegister matchRegisterName(StringRef Name, const MCRegisterInfo &MRI, unsigned RegClassID, unsigned AltIdx)
Match a symbolic name in RegClassID, or return an invalid register.
void initLLVMToCVRegMapping(MCRegisterInfo *MRI)
constexpr unsigned getCOP0RegNum(unsigned Encoding)
int getCPURegisterIndex(StringRef Name, const MCRegisterInfo &MRI, unsigned AltIdx, bool *IsDeprecated=nullptr)
Return a GPR name's hardware index, or -1 if unknown.
constexpr unsigned getCOP0Sel(unsigned Encoding)
constexpr MCPhysReg FP_64
constexpr MCPhysReg GP_64
constexpr MCPhysReg FP
constexpr MCPhysReg GP
constexpr MCPhysReg RA_64
constexpr MCPhysReg SP
constexpr MCPhysReg SP_64
constexpr MCPhysReg RA
This is an optimization pass for GlobalISel generic memory operations.
MCCodeEmitter * createMipsMCCodeEmitterEL(const MCInstrInfo &MCII, MCContext &Ctx)
MCCodeEmitter * createMipsMCCodeEmitterEB(const MCInstrInfo &MCII, MCContext &Ctx)
std::unique_ptr< MCObjectTargetWriter > createMipsELFObjectWriter(const Triple &TT, bool IsN32)
Construct a Mips ELF object writer.
MCStreamer * createMipsWinCOFFStreamer(MCContext &C, std::unique_ptr< MCAsmBackend > &&AB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE)
Construct an MIPS Windows COFF machine code streamer which will generate PE/COFF format object files.
std::unique_ptr< MCObjectTargetWriter > createMipsWinCOFFObjectWriter()
Construct a Mips Win COFF object writer.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition MCRegister.h:21
MCAsmBackend * createMipsAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)