Path: blob/main/contrib/llvm-project/llvm/lib/Target/Mips/MCTargetDesc/MipsBaseInfo.h
35294 views
//===-- MipsBaseInfo.h - Top level definitions for MIPS MC ------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file contains small standalone helper functions and enum definitions for9// the Mips target useful for the compiler back-end and the MC libraries.10//11//===----------------------------------------------------------------------===//12#ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSBASEINFO_H13#define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSBASEINFO_H1415#include "MipsFixupKinds.h"16#include "MipsMCTargetDesc.h"17#include "llvm/MC/MCExpr.h"18#include "llvm/MC/MCInstrDesc.h"19#include "llvm/Support/DataTypes.h"20#include "llvm/Support/ErrorHandling.h"2122namespace llvm {2324/// MipsII - This namespace holds all of the target specific flags that25/// instruction info tracks.26///27namespace MipsII {28/// Target Operand Flag enum.29enum TOF {30//===------------------------------------------------------------------===//31// Mips Specific MachineOperand flags.3233MO_NO_FLAG,3435/// MO_GOT - Represents the offset into the global offset table at which36/// the address the relocation entry symbol resides during execution.37MO_GOT,3839/// MO_GOT_CALL - Represents the offset into the global offset table at40/// which the address of a call site relocation entry symbol resides41/// during execution. This is different from the above since this flag42/// can only be present in call instructions.43MO_GOT_CALL,4445/// MO_GPREL - Represents the offset from the current gp value to be used46/// for the relocatable object file being produced.47MO_GPREL,4849/// MO_ABS_HI/LO - Represents the hi or low part of an absolute symbol50/// address.51MO_ABS_HI,52MO_ABS_LO,5354/// MO_TLSGD - Represents the offset into the global offset table at which55// the module ID and TSL block offset reside during execution (General56// Dynamic TLS).57MO_TLSGD,5859/// MO_TLSLDM - Represents the offset into the global offset table at which60// the module ID and TSL block offset reside during execution (Local61// Dynamic TLS).62MO_TLSLDM,63MO_DTPREL_HI,64MO_DTPREL_LO,6566/// MO_GOTTPREL - Represents the offset from the thread pointer (Initial67// Exec TLS).68MO_GOTTPREL,6970/// MO_TPREL_HI/LO - Represents the hi and low part of the offset from71// the thread pointer (Local Exec TLS).72MO_TPREL_HI,73MO_TPREL_LO,7475// N32/64 Flags.76MO_GPOFF_HI,77MO_GPOFF_LO,78MO_GOT_DISP,79MO_GOT_PAGE,80MO_GOT_OFST,8182/// MO_HIGHER/HIGHEST - Represents the highest or higher half word of a83/// 64-bit symbol address.84MO_HIGHER,85MO_HIGHEST,8687/// MO_GOT_HI16/LO16, MO_CALL_HI16/LO16 - Relocations used for large GOTs.88MO_GOT_HI16,89MO_GOT_LO16,90MO_CALL_HI16,91MO_CALL_LO16,9293/// Helper operand used to generate R_MIPS_JALR94MO_JALR95};9697enum {98//===------------------------------------------------------------------===//99// Instruction encodings. These are the standard/most common forms for100// Mips instructions.101//102103// Pseudo - This represents an instruction that is a pseudo instruction104// or one that has not been implemented yet. It is illegal to code generate105// it, but tolerated for intermediate implementation stages.106Pseudo = 0,107108/// FrmR - This form is for instructions of the format R.109FrmR = 1,110/// FrmI - This form is for instructions of the format I.111FrmI = 2,112/// FrmJ - This form is for instructions of the format J.113FrmJ = 3,114/// FrmFR - This form is for instructions of the format FR.115FrmFR = 4,116/// FrmFI - This form is for instructions of the format FI.117FrmFI = 5,118/// FrmOther - This form is for instructions that have no specific format.119FrmOther = 6,120121FormMask = 15,122/// IsCTI - Instruction is a Control Transfer Instruction.123IsCTI = 1 << 4,124/// HasForbiddenSlot - Instruction has a forbidden slot.125HasForbiddenSlot = 1 << 5,126/// HasFCCRegOperand - Instruction uses an $fcc<x> register.127HasFCCRegOperand = 1 << 6128129};130131enum OperandType : unsigned {132OPERAND_FIRST_MIPS_MEM_IMM = MCOI::OPERAND_FIRST_TARGET,133OPERAND_MEM_SIMM9 = OPERAND_FIRST_MIPS_MEM_IMM,134OPERAND_LAST_MIPS_MEM_IMM = OPERAND_MEM_SIMM9135};136}137138inline static MCRegister getMSARegFromFReg(MCRegister Reg) {139if (Reg >= Mips::F0 && Reg <= Mips::F31)140return Reg - Mips::F0 + Mips::W0;141else if (Reg >= Mips::D0_64 && Reg <= Mips::D31_64)142return Reg - Mips::D0_64 + Mips::W0;143else144return Mips::NoRegister;145}146}147148#endif149150151