LLVM 23.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 {
74 // TODO: Add more flags.
75
76 // Used to differentiate between target-specific "direct" flags and "bitmask"
77 // flags. A machine operand can only have one "direct" flag, but can have
78 // multiple "bitmask" flags.
80
81 MO_RELAX = 0x40
82};
83
84// Given a MachineOperand that may carry out "bitmask" flags, such as MO_RELAX,
85// return LoongArch target-specific "direct" flags.
86static inline unsigned getDirectFlags(const MachineOperand &MO) {
88}
89
90// Add MO_RELAX "bitmask" flag when FeatureRelax is enabled.
91static inline unsigned encodeFlags(unsigned Flags, bool Relax) {
92 return Flags | (Relax ? MO_RELAX : 0);
93}
94
95// \returns true if the given MachineOperand has MO_RELAX "bitmask" flag.
96static inline bool hasRelaxFlag(const MachineOperand &MO) {
97 return MO.getTargetFlags() & MO_RELAX;
98}
99
100// Target-specific flags of LAInst.
101// All definitions must match LoongArchInstrFormats.td.
102enum {
103 // Whether the instruction's rd is normally required to differ from rj and
104 // rk, in the way the 3-register atomic memory operations behave
105 // (Section 2.2.7.1 and 2.2.7.2, LoongArch Reference Manual Volume 1 v1.10;
106 // while Section 2.2.7.3 lacked similar description for the AMCAS
107 // instructions, at least the INE exception is still signaled on Loongson
108 // 3A6000 when its rd == rj).
109 //
110 // Used for generating diagnostics for assembler input that violate the
111 // constraint. As described on the manual, the covered instructions require
112 // rd != rj && rd != rk to work as intended.
115
116 // Whether the instruction belongs to the AMCAS family.
119};
120
121/// \returns true if this instruction's rd is normally required to differ
122/// from rj and rk, in the way 3-register atomic memory operations behave.
123static inline bool isSubjectToAMORdConstraint(uint64_t TSFlags) {
124 return TSFlags & IsSubjectToAMORdConstraintMask;
125}
126
127/// \returns true if this instruction belongs to the AMCAS family.
128static inline bool isAMCAS(uint64_t TSFlags) { return TSFlags & IsAMCASMask; }
129} // end namespace LoongArchII
130
131namespace LoongArchABI {
141
142ABI computeTargetABI(const Triple &TT, const FeatureBitset &FeatureBits,
143 StringRef ABIName);
144ABI getTargetABI(StringRef ABIName);
145
146// Returns the register used to hold the stack pointer after realignment.
148} // end namespace LoongArchABI
149
150} // end namespace llvm
151
152#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:41
MachineOperand class - Representation of each machine instruction operand.
unsigned getTargetFlags() const
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
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 Types.h:26