1234353Sdim//===-- MipsBaseInfo.h - Top level definitions for MIPS MC ------*- C++ -*-===//
2226584Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6226584Sdim//
7226584Sdim//===----------------------------------------------------------------------===//
8226584Sdim//
9226584Sdim// This file contains small standalone helper functions and enum definitions for
10226584Sdim// the Mips target useful for the compiler back-end and the MC libraries.
11226584Sdim//
12226584Sdim//===----------------------------------------------------------------------===//
13280031Sdim#ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSBASEINFO_H
14280031Sdim#define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSBASEINFO_H
15226584Sdim
16234353Sdim#include "MipsFixupKinds.h"
17226584Sdim#include "MipsMCTargetDesc.h"
18234353Sdim#include "llvm/MC/MCExpr.h"
19360784Sdim#include "llvm/MC/MCInstrDesc.h"
20226584Sdim#include "llvm/Support/DataTypes.h"
21226584Sdim#include "llvm/Support/ErrorHandling.h"
22226584Sdim
23226584Sdimnamespace llvm {
24234353Sdim
25234353Sdim/// MipsII - This namespace holds all of the target specific flags that
26234353Sdim/// instruction info tracks.
27234353Sdim///
28234353Sdimnamespace MipsII {
29234353Sdim  /// Target Operand Flag enum.
30234353Sdim  enum TOF {
31234353Sdim    //===------------------------------------------------------------------===//
32234353Sdim    // Mips Specific MachineOperand flags.
33234353Sdim
34234353Sdim    MO_NO_FLAG,
35234353Sdim
36309124Sdim    /// MO_GOT - Represents the offset into the global offset table at which
37234353Sdim    /// the address the relocation entry symbol resides during execution.
38234353Sdim    MO_GOT,
39234353Sdim
40234353Sdim    /// MO_GOT_CALL - Represents the offset into the global offset table at
41234353Sdim    /// which the address of a call site relocation entry symbol resides
42234353Sdim    /// during execution. This is different from the above since this flag
43234353Sdim    /// can only be present in call instructions.
44234353Sdim    MO_GOT_CALL,
45234353Sdim
46234353Sdim    /// MO_GPREL - Represents the offset from the current gp value to be used
47234353Sdim    /// for the relocatable object file being produced.
48234353Sdim    MO_GPREL,
49234353Sdim
50234353Sdim    /// MO_ABS_HI/LO - Represents the hi or low part of an absolute symbol
51234353Sdim    /// address.
52234353Sdim    MO_ABS_HI,
53234353Sdim    MO_ABS_LO,
54234353Sdim
55234353Sdim    /// MO_TLSGD - Represents the offset into the global offset table at which
56234353Sdim    // the module ID and TSL block offset reside during execution (General
57234353Sdim    // Dynamic TLS).
58234353Sdim    MO_TLSGD,
59234353Sdim
60234353Sdim    /// MO_TLSLDM - Represents the offset into the global offset table at which
61234353Sdim    // the module ID and TSL block offset reside during execution (Local
62234353Sdim    // Dynamic TLS).
63234353Sdim    MO_TLSLDM,
64234353Sdim    MO_DTPREL_HI,
65234353Sdim    MO_DTPREL_LO,
66234353Sdim
67234353Sdim    /// MO_GOTTPREL - Represents the offset from the thread pointer (Initial
68234353Sdim    // Exec TLS).
69234353Sdim    MO_GOTTPREL,
70234353Sdim
71234353Sdim    /// MO_TPREL_HI/LO - Represents the hi and low part of the offset from
72234353Sdim    // the thread pointer (Local Exec TLS).
73234353Sdim    MO_TPREL_HI,
74234353Sdim    MO_TPREL_LO,
75234353Sdim
76234353Sdim    // N32/64 Flags.
77234353Sdim    MO_GPOFF_HI,
78234353Sdim    MO_GPOFF_LO,
79234353Sdim    MO_GOT_DISP,
80234353Sdim    MO_GOT_PAGE,
81239462Sdim    MO_GOT_OFST,
82239462Sdim
83239462Sdim    /// MO_HIGHER/HIGHEST - Represents the highest or higher half word of a
84239462Sdim    /// 64-bit symbol address.
85239462Sdim    MO_HIGHER,
86244628Sdim    MO_HIGHEST,
87244628Sdim
88244628Sdim    /// MO_GOT_HI16/LO16, MO_CALL_HI16/LO16 - Relocations used for large GOTs.
89244628Sdim    MO_GOT_HI16,
90244628Sdim    MO_GOT_LO16,
91244628Sdim    MO_CALL_HI16,
92344779Sdim    MO_CALL_LO16,
93344779Sdim
94344779Sdim    /// Helper operand used to generate R_MIPS_JALR
95344779Sdim    MO_JALR
96234353Sdim  };
97234353Sdim
98234353Sdim  enum {
99234353Sdim    //===------------------------------------------------------------------===//
100234353Sdim    // Instruction encodings.  These are the standard/most common forms for
101234353Sdim    // Mips instructions.
102234353Sdim    //
103234353Sdim
104234353Sdim    // Pseudo - This represents an instruction that is a pseudo instruction
105234353Sdim    // or one that has not been implemented yet.  It is illegal to code generate
106234353Sdim    // it, but tolerated for intermediate implementation stages.
107234353Sdim    Pseudo   = 0,
108234353Sdim
109234353Sdim    /// FrmR - This form is for instructions of the format R.
110234353Sdim    FrmR  = 1,
111234353Sdim    /// FrmI - This form is for instructions of the format I.
112234353Sdim    FrmI  = 2,
113234353Sdim    /// FrmJ - This form is for instructions of the format J.
114234353Sdim    FrmJ  = 3,
115234353Sdim    /// FrmFR - This form is for instructions of the format FR.
116234353Sdim    FrmFR = 4,
117234353Sdim    /// FrmFI - This form is for instructions of the format FI.
118234353Sdim    FrmFI = 5,
119234353Sdim    /// FrmOther - This form is for instructions that have no specific format.
120234353Sdim    FrmOther = 6,
121234353Sdim
122309124Sdim    FormMask = 15,
123309124Sdim    /// IsCTI - Instruction is a Control Transfer Instruction.
124309124Sdim    IsCTI = 1 << 4,
125309124Sdim    /// HasForbiddenSlot - Instruction has a forbidden slot.
126314564Sdim    HasForbiddenSlot = 1 << 5,
127314564Sdim    /// HasFCCRegOperand - Instruction uses an $fcc<x> register.
128360784Sdim    HasFCCRegOperand = 1 << 6
129309124Sdim
130234353Sdim  };
131360784Sdim
132360784Sdim  enum OperandType : unsigned {
133360784Sdim    OPERAND_FIRST_MIPS_MEM_IMM = MCOI::OPERAND_FIRST_TARGET,
134360784Sdim    OPERAND_MEM_SIMM9 = OPERAND_FIRST_MIPS_MEM_IMM,
135360784Sdim    OPERAND_LAST_MIPS_MEM_IMM = OPERAND_MEM_SIMM9
136360784Sdim  };
137234353Sdim}
138226584Sdim}
139226584Sdim
140226584Sdim#endif
141