LLVM 20.0.0git
AArch64BaseInfo.cpp
Go to the documentation of this file.
1//===-- AArch64BaseInfo.cpp - AArch64 Base encoding information------------===//
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 basic encoding and assembly information for AArch64.
10//
11//===----------------------------------------------------------------------===//
12#include "AArch64BaseInfo.h"
15#include "llvm/Support/Regex.h"
16
17using namespace llvm;
18
19namespace llvm {
20 namespace AArch64AT {
21#define GET_AT_IMPL
22#include "AArch64GenSystemOperands.inc"
23 }
24}
25
26
27namespace llvm {
28 namespace AArch64DBnXS {
29#define GET_DBNXS_IMPL
30#include "AArch64GenSystemOperands.inc"
31 }
32}
33
34namespace llvm {
35 namespace AArch64DB {
36#define GET_DB_IMPL
37#include "AArch64GenSystemOperands.inc"
38 }
39}
40
41namespace llvm {
42 namespace AArch64DC {
43#define GET_DC_IMPL
44#include "AArch64GenSystemOperands.inc"
45 }
46}
47
48namespace llvm {
49 namespace AArch64IC {
50#define GET_IC_IMPL
51#include "AArch64GenSystemOperands.inc"
52 }
53}
54
55namespace llvm {
56 namespace AArch64ISB {
57#define GET_ISB_IMPL
58#include "AArch64GenSystemOperands.inc"
59 }
60}
61
62namespace llvm {
63 namespace AArch64TSB {
64#define GET_TSB_IMPL
65#include "AArch64GenSystemOperands.inc"
66 }
67}
68
69namespace llvm {
70 namespace AArch64PRCTX {
71#define GET_PRCTX_IMPL
72#include "AArch64GenSystemOperands.inc"
73 }
74}
75
76namespace llvm {
77 namespace AArch64PRFM {
78#define GET_PRFM_IMPL
79#include "AArch64GenSystemOperands.inc"
80 }
81}
82
83namespace llvm {
84 namespace AArch64SVEPRFM {
85#define GET_SVEPRFM_IMPL
86#include "AArch64GenSystemOperands.inc"
87 }
88}
89
90namespace llvm {
91 namespace AArch64RPRFM {
92#define GET_RPRFM_IMPL
93#include "AArch64GenSystemOperands.inc"
94 } // namespace AArch64RPRFM
95} // namespace llvm
96
97namespace llvm {
98 namespace AArch64SVEPredPattern {
99#define GET_SVEPREDPAT_IMPL
100#include "AArch64GenSystemOperands.inc"
101 }
102}
103
104namespace llvm {
105namespace AArch64SVEVecLenSpecifier {
106#define GET_SVEVECLENSPECIFIER_IMPL
107#include "AArch64GenSystemOperands.inc"
108} // namespace AArch64SVEVecLenSpecifier
109} // namespace llvm
110
111namespace llvm {
112 namespace AArch64ExactFPImm {
113#define GET_EXACTFPIMM_IMPL
114#include "AArch64GenSystemOperands.inc"
115 }
116}
117
118namespace llvm {
119 namespace AArch64PState {
120#define GET_PSTATEIMM0_15_IMPL
121#include "AArch64GenSystemOperands.inc"
122#define GET_PSTATEIMM0_1_IMPL
123#include "AArch64GenSystemOperands.inc"
124 }
125}
126
127namespace llvm {
128 namespace AArch64PSBHint {
129#define GET_PSB_IMPL
130#include "AArch64GenSystemOperands.inc"
131 }
132}
133
134namespace llvm {
135namespace AArch64PHint {
136#define GET_PHINT_IMPL
137#include "AArch64GenSystemOperands.inc"
138} // namespace AArch64PHint
139} // namespace llvm
140
141namespace llvm {
142 namespace AArch64BTIHint {
143#define GET_BTI_IMPL
144#include "AArch64GenSystemOperands.inc"
145 }
146}
147
148namespace llvm {
149 namespace AArch64SysReg {
150#define GET_SYSREG_IMPL
151#include "AArch64GenSystemOperands.inc"
152 }
153}
154
156 // Try to parse an S<op0>_<op1>_<Cn>_<Cm>_<op2> register name
157 static const Regex GenericRegPattern("^S([0-3])_([0-7])_C([0-9]|1[0-5])_C([0-9]|1[0-5])_([0-7])$");
158
159 std::string UpperName = Name.upper();
161 if (!GenericRegPattern.match(UpperName, &Ops))
162 return -1;
163
164 uint32_t Op0 = 0, Op1 = 0, CRn = 0, CRm = 0, Op2 = 0;
165 uint32_t Bits;
166 Ops[1].getAsInteger(10, Op0);
167 Ops[2].getAsInteger(10, Op1);
168 Ops[3].getAsInteger(10, CRn);
169 Ops[4].getAsInteger(10, CRm);
170 Ops[5].getAsInteger(10, Op2);
171 Bits = (Op0 << 14) | (Op1 << 11) | (CRn << 7) | (CRm << 3) | Op2;
172
173 return Bits;
174}
175
177 assert(Bits < 0x10000);
178 uint32_t Op0 = (Bits >> 14) & 0x3;
179 uint32_t Op1 = (Bits >> 11) & 0x7;
180 uint32_t CRn = (Bits >> 7) & 0xf;
181 uint32_t CRm = (Bits >> 3) & 0xf;
182 uint32_t Op2 = Bits & 0x7;
183
184 return "S" + utostr(Op0) + "_" + utostr(Op1) + "_C" + utostr(CRn) + "_C" +
185 utostr(CRm) + "_" + utostr(Op2);
186}
187
188namespace llvm {
189 namespace AArch64TLBI {
190#define GET_TLBITable_IMPL
191#include "AArch64GenSystemOperands.inc"
192 }
193}
194
195namespace llvm {
196 namespace AArch64SVCR {
197#define GET_SVCR_IMPL
198#include "AArch64GenSystemOperands.inc"
199 }
200}
std::string Name
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
This file contains some functions that are useful when dealing with strings.
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr, std::string *Error=nullptr) const
matches - Match the regex against a given String.
Definition: Regex.cpp:83
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
uint32_t parseGenericRegister(StringRef Name)
std::string genericRegisterString(uint32_t Bits)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18