LLVM 20.0.0git
LoongArchBaseInfo.h
Go to the documentation of this file.
1//=- LoongArchBaseInfo.h - Top level definitions for LoongArch MC -*- 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 contains small standalone enum definitions and helper function
10// definitions for the LoongArch target useful for the compiler back-end and the
11// MC libraries.
12//
13//===----------------------------------------------------------------------===//
14#ifndef LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHBASEINFO_H
15#define LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHBASEINFO_H
16
18#include "llvm/ADT/StringRef.h"
21#include "llvm/MC/MCInstrDesc.h"
23
24namespace llvm {
25
26// This namespace holds all of the target specific flags that instruction info
27// tracks.
28namespace LoongArchII {
29enum {
61 // TODO: Add more flags.
62
63 // Used to differentiate between target-specific "direct" flags and "bitmask"
64 // flags. A machine operand can only have one "direct" flag, but can have
65 // multiple "bitmask" flags.
67
68 MO_RELAX = 0x40
69};
70
71// Given a MachineOperand that may carry out "bitmask" flags, such as MO_RELAX,
72// return LoongArch target-specific "direct" flags.
73static inline unsigned getDirectFlags(const MachineOperand &MO) {
75}
76
77// Add MO_RELAX "bitmask" flag when FeatureRelax is enabled.
78static inline unsigned encodeFlags(unsigned Flags, bool Relax) {
79 return Flags | (Relax ? MO_RELAX : 0);
80}
81
82// \returns true if the given MachineOperand has MO_RELAX "bitmask" flag.
83static inline bool hasRelaxFlag(const MachineOperand &MO) {
84 return MO.getTargetFlags() & MO_RELAX;
85}
86
87// Target-specific flags of LAInst.
88// All definitions must match LoongArchInstrFormats.td.
89enum {
90 // Whether the instruction's rd is normally required to differ from rj and
91 // rk, in the way the 3-register atomic memory operations behave
92 // (Section 2.2.7.1 and 2.2.7.2, LoongArch Reference Manual Volume 1 v1.10;
93 // while Section 2.2.7.3 lacked similar description for the AMCAS
94 // instructions, at least the INE exception is still signaled on Loongson
95 // 3A6000 when its rd == rj).
96 //
97 // Used for generating diagnostics for assembler input that violate the
98 // constraint. As described on the manual, the covered instructions require
99 // rd != rj && rd != rk to work as intended.
102
103 // Whether the instruction belongs to the AMCAS family.
106};
107
108/// \returns true if this instruction's rd is normally required to differ
109/// from rj and rk, in the way 3-register atomic memory operations behave.
110static inline bool isSubjectToAMORdConstraint(uint64_t TSFlags) {
111 return TSFlags & IsSubjectToAMORdConstraintMask;
112}
113
114/// \returns true if this instruction belongs to the AMCAS family.
115static inline bool isAMCAS(uint64_t TSFlags) { return TSFlags & IsAMCASMask; }
116} // end namespace LoongArchII
117
118namespace LoongArchABI {
119enum ABI {
128
129ABI computeTargetABI(const Triple &TT, const FeatureBitset &FeatureBits,
130 StringRef ABIName);
131ABI getTargetABI(StringRef ABIName);
132
133// Returns the register used to hold the stack pointer after realignment.
135} // end namespace LoongArchABI
136
137} // end namespace llvm
138
139#endif // LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHBASEINFO_H
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Container class for subtarget features.
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:33
MachineOperand class - Representation of each machine instruction operand.
unsigned getTargetFlags() const
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
ABI computeTargetABI(const Triple &TT, const FeatureBitset &FeatureBits, StringRef ABIName)
ABI getTargetABI(StringRef ABIName)
static bool isAMCAS(uint64_t TSFlags)
static bool hasRelaxFlag(const MachineOperand &MO)
static bool isSubjectToAMORdConstraint(uint64_t TSFlags)
static unsigned getDirectFlags(const MachineOperand &MO)
static unsigned encodeFlags(unsigned Flags, bool Relax)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18