LLVM 17.0.0git
XtensaAsmParser.cpp
Go to the documentation of this file.
1//===- XtensaAsmParser.cpp - Parse Xtensa assembly to MCInst instructions -===//
2//
3// The LLVM Compiler Infrastructure
4//
5// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6// See https://llvm.org/LICENSE.txt for license information.
7// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8//
9//===----------------------------------------------------------------------===//
10
13#include "llvm/ADT/STLExtras.h"
15#include "llvm/MC/MCContext.h"
16#include "llvm/MC/MCExpr.h"
17#include "llvm/MC/MCInst.h"
18#include "llvm/MC/MCInstrInfo.h"
23#include "llvm/MC/MCStreamer.h"
27
28using namespace llvm;
29
30#define DEBUG_TYPE "xtensa-asm-parser"
31
32struct XtensaOperand;
33
35
36 SMLoc getLoc() const { return getParser().getTok().getLoc(); }
37
38 // Override MCTargetAsmParser.
39 bool ParseDirective(AsmToken DirectiveID) override;
40 bool parseRegister(MCRegister &RegNo,
41 SMLoc &StartLoc, SMLoc &EndLoc) override;
42 bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
43 SMLoc NameLoc, OperandVector &Operands) override;
44 bool MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
47 bool MatchingInlineAsm) override;
48 unsigned validateTargetOperandClass(MCParsedAsmOperand &Op,
49 unsigned Kind) override;
50
51// Auto-generated instruction matching functions
52#define GET_ASSEMBLER_HEADER
53#include "XtensaGenAsmMatcher.inc"
54
57 bool AllowParens = false, bool SR = false);
58 OperandMatchResultTy parseOperandWithModifier(OperandVector &Operands);
59 bool parseOperand(OperandVector &Operands, StringRef Mnemonic,
60 bool SR = false);
61 bool ParseInstructionWithSR(ParseInstructionInfo &Info, StringRef Name,
62 SMLoc NameLoc, OperandVector &Operands);
63 OperandMatchResultTy tryParseRegister(MCRegister &RegNo, SMLoc &StartLoc,
64 SMLoc &EndLoc) override {
66 }
68
69public:
72#define GET_OPERAND_DIAGNOSTIC_TYPES
73#include "XtensaGenAsmMatcher.inc"
74#undef GET_OPERAND_DIAGNOSTIC_TYPES
75 };
76
80 setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
81 }
82};
83
84// Return true if Expr is in the range [MinValue, MaxValue].
85static bool inRange(const MCExpr *Expr, int64_t MinValue, int64_t MaxValue) {
86 if (auto *CE = dyn_cast<MCConstantExpr>(Expr)) {
87 int64_t Value = CE->getValue();
88 return Value >= MinValue && Value <= MaxValue;
89 }
90 return false;
91}
92
94
95 enum KindTy {
100
101 struct RegOp {
102 unsigned RegNum;
103 };
104
105 struct ImmOp {
106 const MCExpr *Val;
107 };
108
110 union {
114 };
115
117
118public:
120 Kind = o.Kind;
121 StartLoc = o.StartLoc;
122 EndLoc = o.EndLoc;
123 switch (Kind) {
124 case Register:
125 Reg = o.Reg;
126 break;
127 case Immediate:
128 Imm = o.Imm;
129 break;
130 case Token:
131 Tok = o.Tok;
132 break;
133 }
134 }
135
136 bool isToken() const override { return Kind == Token; }
137 bool isReg() const override { return Kind == Register; }
138 bool isImm() const override { return Kind == Immediate; }
139 bool isMem() const override { return false; }
140
141 bool isImm(int64_t MinValue, int64_t MaxValue) const {
142 return Kind == Immediate && inRange(getImm(), MinValue, MaxValue);
143 }
144
145 bool isImm8() const { return isImm(-128, 127); }
146
147 bool isImm8_sh8() const {
148 return isImm(-32768, 32512) &&
149 ((cast<MCConstantExpr>(getImm())->getValue() & 0xFF) == 0);
150 }
151
152 bool isImm12() const { return isImm(-2048, 2047); }
153
154 bool isImm12m() const { return isImm(-2048, 2047); }
155
156 bool isOffset4m32() const {
157 return isImm(0, 60) &&
158 ((cast<MCConstantExpr>(getImm())->getValue() & 0x3) == 0);
159 }
160
161 bool isOffset8m8() const { return isImm(0, 255); }
162
163 bool isOffset8m16() const {
164 return isImm(0, 510) &&
165 ((cast<MCConstantExpr>(getImm())->getValue() & 0x1) == 0);
166 }
167
168 bool isOffset8m32() const {
169 return isImm(0, 1020) &&
170 ((cast<MCConstantExpr>(getImm())->getValue() & 0x3) == 0);
171 }
172
173 bool isUimm4() const { return isImm(0, 15); }
174
175 bool isUimm5() const { return isImm(0, 31); }
176
177 bool isImm8n_7() const { return isImm(-8, 7); }
178
179 bool isShimm1_31() const { return isImm(1, 31); }
180
181 bool isImm16_31() const { return isImm(16, 31); }
182
183 bool isImm1_16() const { return isImm(1, 16); }
184
185 bool isB4const() const {
186 if (Kind != Immediate)
187 return false;
188 if (auto *CE = dyn_cast<MCConstantExpr>(getImm())) {
189 int64_t Value = CE->getValue();
190 switch (Value) {
191 case -1:
192 case 1:
193 case 2:
194 case 3:
195 case 4:
196 case 5:
197 case 6:
198 case 7:
199 case 8:
200 case 10:
201 case 12:
202 case 16:
203 case 32:
204 case 64:
205 case 128:
206 case 256:
207 return true;
208 default:
209 return false;
210 }
211 }
212 return false;
213 }
214
215 bool isB4constu() const {
216 if (Kind != Immediate)
217 return false;
218 if (auto *CE = dyn_cast<MCConstantExpr>(getImm())) {
219 int64_t Value = CE->getValue();
220 switch (Value) {
221 case 32768:
222 case 65536:
223 case 2:
224 case 3:
225 case 4:
226 case 5:
227 case 6:
228 case 7:
229 case 8:
230 case 10:
231 case 12:
232 case 16:
233 case 32:
234 case 64:
235 case 128:
236 case 256:
237 return true;
238 default:
239 return false;
240 }
241 }
242 return false;
243 }
244
245 /// getStartLoc - Gets location of the first token of this operand
246 SMLoc getStartLoc() const override { return StartLoc; }
247 /// getEndLoc - Gets location of the last token of this operand
248 SMLoc getEndLoc() const override { return EndLoc; }
249
250 unsigned getReg() const override {
251 assert(Kind == Register && "Invalid type access!");
252 return Reg.RegNum;
253 }
254
255 const MCExpr *getImm() const {
256 assert(Kind == Immediate && "Invalid type access!");
257 return Imm.Val;
258 }
259
261 assert(Kind == Token && "Invalid type access!");
262 return Tok;
263 }
264
265 void print(raw_ostream &OS) const override {
266 switch (Kind) {
267 case Immediate:
268 OS << *getImm();
269 break;
270 case Register:
271 OS << "<register x";
272 OS << getReg() << ">";
273 break;
274 case Token:
275 OS << "'" << getToken() << "'";
276 break;
277 }
278 }
279
280 static std::unique_ptr<XtensaOperand> createToken(StringRef Str, SMLoc S) {
281 auto Op = std::make_unique<XtensaOperand>(Token);
282 Op->Tok = Str;
283 Op->StartLoc = S;
284 Op->EndLoc = S;
285 return Op;
286 }
287
288 static std::unique_ptr<XtensaOperand> createReg(unsigned RegNo, SMLoc S,
289 SMLoc E) {
290 auto Op = std::make_unique<XtensaOperand>(Register);
291 Op->Reg.RegNum = RegNo;
292 Op->StartLoc = S;
293 Op->EndLoc = E;
294 return Op;
295 }
296
297 static std::unique_ptr<XtensaOperand> createImm(const MCExpr *Val, SMLoc S,
298 SMLoc E) {
299 auto Op = std::make_unique<XtensaOperand>(Immediate);
300 Op->Imm.Val = Val;
301 Op->StartLoc = S;
302 Op->EndLoc = E;
303 return Op;
304 }
305
306 void addExpr(MCInst &Inst, const MCExpr *Expr) const {
307 assert(Expr && "Expr shouldn't be null!");
308 int64_t Imm = 0;
309 bool IsConstant = false;
310
311 if (auto *CE = dyn_cast<MCConstantExpr>(Expr)) {
312 IsConstant = true;
313 Imm = CE->getValue();
314 }
315
316 if (IsConstant)
318 else
320 }
321
322 // Used by the TableGen Code
323 void addRegOperands(MCInst &Inst, unsigned N) const {
324 assert(N == 1 && "Invalid number of operands!");
326 }
327
328 void addImmOperands(MCInst &Inst, unsigned N) const {
329 assert(N == 1 && "Invalid number of operands!");
330 addExpr(Inst, getImm());
331 }
332};
333
334#define GET_REGISTER_MATCHER
335#define GET_MATCHER_IMPLEMENTATION
336#include "XtensaGenAsmMatcher.inc"
337
338unsigned XtensaAsmParser::validateTargetOperandClass(MCParsedAsmOperand &AsmOp,
339 unsigned Kind) {
341}
342
345 if (ErrorInfo != ~0ULL && ErrorInfo < Operands.size()) {
346 SMLoc ErrorLoc = Operands[ErrorInfo]->getStartLoc();
347 if (ErrorLoc == SMLoc())
348 return Loc;
349 return ErrorLoc;
350 }
351 return Loc;
352}
353
354bool XtensaAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
356 MCStreamer &Out,
358 bool MatchingInlineAsm) {
359 MCInst Inst;
360 auto Result =
361 MatchInstructionImpl(Operands, Inst, ErrorInfo, MatchingInlineAsm);
362
363 switch (Result) {
364 default:
365 break;
366 case Match_Success:
367 Inst.setLoc(IDLoc);
368 Out.emitInstruction(Inst, getSTI());
369 return false;
371 return Error(IDLoc, "instruction use requires an option to be enabled");
373 return Error(IDLoc, "unrecognized instruction mnemonic");
375 SMLoc ErrorLoc = IDLoc;
376 if (ErrorInfo != ~0U) {
377 if (ErrorInfo >= Operands.size())
378 return Error(ErrorLoc, "too few operands for instruction");
379
380 ErrorLoc = ((XtensaOperand &)*Operands[ErrorInfo]).getStartLoc();
381 if (ErrorLoc == SMLoc())
382 ErrorLoc = IDLoc;
383 }
384 return Error(ErrorLoc, "invalid operand for instruction");
385 }
386 case Match_InvalidImm8:
387 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
388 "expected immediate in range [-128, 127]");
389 case Match_InvalidImm8_sh8:
390 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
391 "expected immediate in range [-32768, 32512], first 8 bits "
392 "should be zero");
393 case Match_InvalidB4const:
394 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
395 "expected b4const immediate");
396 case Match_InvalidB4constu:
397 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
398 "expected b4constu immediate");
399 case Match_InvalidImm12:
400 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
401 "expected immediate in range [-2048, 2047]");
402 case Match_InvalidImm12m:
403 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
404 "expected immediate in range [-2048, 2047]");
405 case Match_InvalidImm1_16:
406 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
407 "expected immediate in range [1, 16]");
408 case Match_InvalidShimm1_31:
409 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
410 "expected immediate in range [1, 31]");
411 case Match_InvalidUimm4:
412 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
413 "expected immediate in range [0, 15]");
414 case Match_InvalidUimm5:
415 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
416 "expected immediate in range [0, 31]");
417 case Match_InvalidOffset8m8:
418 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
419 "expected immediate in range [0, 255]");
420 case Match_InvalidOffset8m16:
421 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
422 "expected immediate in range [0, 510], first bit "
423 "should be zero");
424 case Match_InvalidOffset8m32:
425 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
426 "expected immediate in range [0, 1020], first 2 bits "
427 "should be zero");
428 case Match_InvalidOffset4m32:
429 return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo),
430 "expected immediate in range [0, 60], first 2 bits "
431 "should be zero");
432 }
433
434 report_fatal_error("Unknown match type detected!");
435}
436
438XtensaAsmParser::parsePCRelTarget(OperandVector &Operands) {
439 MCAsmParser &Parser = getParser();
440 LLVM_DEBUG(dbgs() << "parsePCRelTarget\n");
441
442 SMLoc S = getLexer().getLoc();
443
444 // Expressions are acceptable
445 const MCExpr *Expr = nullptr;
446 if (Parser.parseExpression(Expr)) {
447 // We have no way of knowing if a symbol was consumed so we must ParseFail
449 }
450
451 // Currently not support constants
452 if (Expr->getKind() == MCExpr::ExprKind::Constant) {
453 Error(getLoc(), "unknown operand");
455 }
456
457 Operands.push_back(XtensaOperand::createImm(Expr, S, getLexer().getLoc()));
459}
460
461bool XtensaAsmParser::parseRegister(MCRegister &RegNo, SMLoc &StartLoc,
462 SMLoc &EndLoc) {
463 const AsmToken &Tok = getParser().getTok();
464 StartLoc = Tok.getLoc();
465 EndLoc = Tok.getEndLoc();
466 RegNo = 0;
468
470 getParser().Lex(); // Eat identifier token.
471 return false;
472 }
473
474 return Error(StartLoc, "invalid register name");
475}
476
477OperandMatchResultTy XtensaAsmParser::parseRegister(OperandVector &Operands,
478 bool AllowParens, bool SR) {
479 SMLoc FirstS = getLoc();
480 bool HadParens = false;
481 AsmToken Buf[2];
483
484 // If this a parenthesised register name is allowed, parse it atomically
485 if (AllowParens && getLexer().is(AsmToken::LParen)) {
486 size_t ReadCount = getLexer().peekTokens(Buf);
487 if (ReadCount == 2 && Buf[1].getKind() == AsmToken::RParen) {
488 if ((Buf[0].getKind() == AsmToken::Integer) && (!SR))
490 HadParens = true;
491 getParser().Lex(); // Eat '('
492 }
493 }
494
495 unsigned RegNo = 0;
496
497 switch (getLexer().getKind()) {
498 default:
501 if (!SR)
503 RegName = StringRef(std::to_string(getLexer().getTok().getIntVal()));
504 RegNo = MatchRegisterName(RegName);
505 if (RegNo == 0)
507 break;
510 RegNo = MatchRegisterName(RegName);
511 if (RegNo == 0)
513 break;
514 }
515
516 if (RegNo == 0) {
517 if (HadParens)
518 getLexer().UnLex(Buf[0]);
520 }
521 if (HadParens)
522 Operands.push_back(XtensaOperand::createToken("(", FirstS));
523 SMLoc S = getLoc();
525 getLexer().Lex();
526 Operands.push_back(XtensaOperand::createReg(RegNo, S, E));
527
528 if (HadParens) {
529 getParser().Lex(); // Eat ')'
530 Operands.push_back(XtensaOperand::createToken(")", getLoc()));
531 }
532
534}
535
536OperandMatchResultTy XtensaAsmParser::parseImmediate(OperandVector &Operands) {
537 SMLoc S = getLoc();
538 SMLoc E;
539 const MCExpr *Res;
540
541 switch (getLexer().getKind()) {
542 default:
544 case AsmToken::LParen:
545 case AsmToken::Minus:
546 case AsmToken::Plus:
547 case AsmToken::Tilde:
549 case AsmToken::String:
550 if (getParser().parseExpression(Res))
552 break;
555 if (getParser().parseIdentifier(Identifier))
557
558 MCSymbol *Sym = getContext().getOrCreateSymbol(Identifier);
560 break;
561 }
563 return parseOperandWithModifier(Operands);
564 }
565
567 Operands.push_back(XtensaOperand::createImm(Res, S, E));
569}
570
572XtensaAsmParser::parseOperandWithModifier(OperandVector &Operands) {
574}
575
576/// Looks at a token type and creates the relevant operand
577/// from this information, adding to Operands.
578/// If operand was parsed, returns false, else true.
579bool XtensaAsmParser::parseOperand(OperandVector &Operands, StringRef Mnemonic,
580 bool SR) {
581 // Check if the current operand has a custom associated parser, if so, try to
582 // custom parse the operand, or fallback to the general approach.
583 OperandMatchResultTy ResTy = MatchOperandParserImpl(Operands, Mnemonic);
584 if (ResTy == MatchOperand_Success)
585 return false;
586
587 // If there wasn't a custom match, try the generic matcher below. Otherwise,
588 // there was a match, but an error occurred, in which case, just return that
589 // the operand parsing failed.
590 if (ResTy == MatchOperand_ParseFail)
591 return true;
592
593 // Attempt to parse token as register
594 if (parseRegister(Operands, true, SR) == MatchOperand_Success)
595 return false;
596
597 // Attempt to parse token as an immediate
598 if (parseImmediate(Operands) == MatchOperand_Success) {
599 return false;
600 }
601
602 // Finally we have exhausted all options and must declare defeat.
603 Error(getLoc(), "unknown operand");
604 return true;
605}
606
607bool XtensaAsmParser::ParseInstructionWithSR(ParseInstructionInfo &Info,
608 StringRef Name, SMLoc NameLoc,
610 if ((Name.startswith("wsr.") || Name.startswith("rsr.") ||
611 Name.startswith("xsr.")) &&
612 (Name.size() > 4)) {
613 // Parse case when instruction name is concatenated with SR register
614 // name, like "wsr.sar a1"
615
616 // First operand is token for instruction
617 Operands.push_back(XtensaOperand::createToken(Name.take_front(3), NameLoc));
618
619 StringRef RegName = Name.drop_front(4);
620 unsigned RegNo = MatchRegisterName(RegName);
621
622 if (RegNo == 0)
624
625 if (RegNo == 0) {
626 Error(NameLoc, "invalid register name");
627 return true;
628 }
629
630 // Parse operand
631 if (parseOperand(Operands, Name))
632 return true;
633
634 SMLoc S = getLoc();
636 Operands.push_back(XtensaOperand::createReg(RegNo, S, E));
637 } else {
638 // First operand is token for instruction
639 Operands.push_back(XtensaOperand::createToken(Name, NameLoc));
640
641 // Parse first operand
642 if (parseOperand(Operands, Name))
643 return true;
644
645 if (!getLexer().is(AsmToken::Comma)) {
646 SMLoc Loc = getLexer().getLoc();
648 return Error(Loc, "unexpected token");
649 }
650
651 getLexer().Lex();
652
653 // Parse second operand
654 if (parseOperand(Operands, Name, true))
655 return true;
656 }
657
659 SMLoc Loc = getLexer().getLoc();
661 return Error(Loc, "unexpected token");
662 }
663
664 getParser().Lex(); // Consume the EndOfStatement.
665 return false;
666}
667
668bool XtensaAsmParser::ParseInstruction(ParseInstructionInfo &Info,
669 StringRef Name, SMLoc NameLoc,
671 if (Name.startswith("wsr") || Name.startswith("rsr") ||
672 Name.startswith("xsr")) {
673 return ParseInstructionWithSR(Info, Name, NameLoc, Operands);
674 }
675
676 // First operand is token for instruction
677 Operands.push_back(XtensaOperand::createToken(Name, NameLoc));
678
679 // If there are no more operands, then finish
681 return false;
682
683 // Parse first operand
684 if (parseOperand(Operands, Name))
685 return true;
686
687 // Parse until end of statement, consuming commas between operands
688 while (getLexer().is(AsmToken::Comma)) {
689 // Consume comma token
690 getLexer().Lex();
691
692 // Parse next operand
693 if (parseOperand(Operands, Name))
694 return true;
695 }
696
698 SMLoc Loc = getLexer().getLoc();
700 return Error(Loc, "unexpected token");
701 }
702
703 getParser().Lex(); // Consume the EndOfStatement.
704 return false;
705}
706
707bool XtensaAsmParser::ParseDirective(AsmToken DirectiveID) { return true; }
708
709// Force static initialization.
712}
static unsigned MatchRegisterName(StringRef Name)
static bool isNot(const MachineRegisterInfo &MRI, const MachineInstr &MI)
static unsigned MatchRegisterAltName(StringRef Name)
Maps from the set of all alternative registernames to a register number.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:127
#define LLVM_DEBUG(X)
Definition: Debug.h:101
std::string Name
Symbol * Sym
Definition: ELF_riscv.cpp:463
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
#define RegName(no)
static LVOptions Options
Definition: LVOptions.cpp:25
mir Rename Register Operands
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
raw_pwrite_stream & OS
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
static bool inRange(const MCExpr *Expr, int64_t MinValue, int64_t MaxValue)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXtensaAsmParser()
static SMLoc RefineErrorLoc(const SMLoc Loc, const OperandVector &Operands, uint64_t ErrorInfo)
XtensaAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser, const MCInstrInfo &MII, const MCTargetOptions &Options)
Target independent representation for an assembler token.
Definition: MCAsmMacro.h:21
SMLoc getLoc() const
Definition: MCAsmLexer.cpp:26
SMLoc getEndLoc() const
Definition: MCAsmLexer.cpp:30
StringRef getIdentifier() const
Get the identifier string for the current token, which should be an identifier or a string.
Definition: MCAsmMacro.h:99
Base class for user error types.
Definition: Error.h:348
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
void UnLex(AsmToken const &Token)
Definition: MCAsmLexer.h:93
SMLoc getLoc() const
Get the current source location.
Definition: MCAsmLexer.cpp:22
const AsmToken & getTok() const
Get the current (last) lexed token.
Definition: MCAsmLexer.h:106
const AsmToken & Lex()
Consume the next token from the input stream and return it.
Definition: MCAsmLexer.h:79
virtual size_t peekTokens(MutableArrayRef< AsmToken > Buf, bool ShouldSkipSpace=true)=0
Look ahead an arbitrary number of tokens.
Generic assembler parser interface, for use by target specific assembly parsers.
Definition: MCAsmParser.h:123
virtual void eatToEndOfStatement()=0
Skip to the end of the current statement, for error recovery.
virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc)=0
Parse an arbitrary expression.
const AsmToken & getTok() const
Get the current AsmToken from the stream.
Definition: MCAsmParser.cpp:40
virtual const AsmToken & Lex()=0
Get the next AsmToken in the stream, possibly handling file inclusion first.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:201
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
ExprKind getKind() const
Definition: MCExpr.h:81
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
void setLoc(SMLoc loc)
Definition: MCInst.h:203
void addOperand(const MCOperand Op)
Definition: MCInst.h:210
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
static MCOperand createReg(unsigned Reg)
Definition: MCInst.h:134
static MCOperand createExpr(const MCExpr *Val)
Definition: MCInst.h:162
static MCOperand createImm(int64_t Val)
Definition: MCInst.h:141
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand.
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:24
Streaming machine code generation interface.
Definition: MCStreamer.h:212
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
Generic base class for all target subtargets.
const FeatureBitset & getFeatureBits() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:386
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
MCTargetAsmParser - Generic interface to target specific assembly parsers.
const MCInstrInfo & MII
void setAvailableFeatures(const FeatureBitset &Value)
const MCSubtargetInfo & getSTI() const
const MCSubtargetInfo * STI
Current STI.
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
Represents a location in source code.
Definition: SMLoc.h:23
static SMLoc getFromPointer(const char *Ptr)
Definition: SMLoc.h:36
const char * getPointer() const
Definition: SMLoc.h:34
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:577
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
LLVM Value Representation.
Definition: Value.h:74
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ MatchOperand_NoMatch
@ MatchOperand_ParseFail
@ MatchOperand_Success
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:145
Target & getTheXtensaTarget()
#define N
bool isImm12() const
bool isOffset4m32() const
bool isOffset8m16() const
static std::unique_ptr< XtensaOperand > createToken(StringRef Str, SMLoc S)
bool isImm8_sh8() const
void addRegOperands(MCInst &Inst, unsigned N) const
void addExpr(MCInst &Inst, const MCExpr *Expr) const
void addImmOperands(MCInst &Inst, unsigned N) const
StringRef getToken() const
unsigned getReg() const override
enum XtensaOperand::KindTy Kind
bool isMem() const override
isMem - Is this a memory operand?
bool isImm16_31() const
bool isImm8n_7() const
bool isToken() const override
isToken - Is this a token operand?
SMLoc getStartLoc() const override
getStartLoc - Gets location of the first token of this operand
bool isImm8() const
bool isImm(int64_t MinValue, int64_t MaxValue) const
void print(raw_ostream &OS) const override
print - Print a debug representation of the operand to the given stream.
bool isImm12m() const
bool isReg() const override
isReg - Is this a register operand?
XtensaOperand(KindTy K)
bool isB4constu() const
bool isImm() const override
isImm - Is this an immediate operand?
bool isUimm4() const
static std::unique_ptr< XtensaOperand > createReg(unsigned RegNo, SMLoc S, SMLoc E)
SMLoc getEndLoc() const override
getEndLoc - Gets location of the last token of this operand
const MCExpr * getImm() const
bool isUimm5() const
bool isOffset8m8() const
XtensaOperand(const XtensaOperand &o)
bool isImm1_16() const
bool isB4const() const
static std::unique_ptr< XtensaOperand > createImm(const MCExpr *Val, SMLoc S, SMLoc E)
bool isOffset8m32() const
bool isShimm1_31() const
RegisterMCAsmParser - Helper template for registering a target specific assembly parser,...