xref: /minix3/external/bsd/llvm/dist/llvm/lib/Target/R600/AsmParser/AMDGPUAsmParser.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc //===-- AMDGPUAsmParser.cpp - Parse SI asm to MCInst instructions ----------===//
2*0a6a1f1dSLionel Sambuc //
3*0a6a1f1dSLionel Sambuc //                     The LLVM Compiler Infrastructure
4*0a6a1f1dSLionel Sambuc //
5*0a6a1f1dSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6*0a6a1f1dSLionel Sambuc // License. See LICENSE.TXT for details.
7*0a6a1f1dSLionel Sambuc //
8*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
9*0a6a1f1dSLionel Sambuc 
10*0a6a1f1dSLionel Sambuc #include "MCTargetDesc/AMDGPUMCTargetDesc.h"
11*0a6a1f1dSLionel Sambuc #include "llvm/ADT/SmallString.h"
12*0a6a1f1dSLionel Sambuc #include "llvm/ADT/SmallVector.h"
13*0a6a1f1dSLionel Sambuc #include "llvm/ADT/STLExtras.h"
14*0a6a1f1dSLionel Sambuc #include "llvm/ADT/StringSwitch.h"
15*0a6a1f1dSLionel Sambuc #include "llvm/ADT/Twine.h"
16*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCContext.h"
17*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCExpr.h"
18*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCInst.h"
19*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCInstrInfo.h"
20*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCParser/MCAsmLexer.h"
21*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCParser/MCAsmParser.h"
22*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCParser/MCParsedAsmOperand.h"
23*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCRegisterInfo.h"
24*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCStreamer.h"
25*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCSubtargetInfo.h"
26*0a6a1f1dSLionel Sambuc #include "llvm/MC/MCTargetAsmParser.h"
27*0a6a1f1dSLionel Sambuc #include "llvm/Support/SourceMgr.h"
28*0a6a1f1dSLionel Sambuc #include "llvm/Support/TargetRegistry.h"
29*0a6a1f1dSLionel Sambuc #include "llvm/Support/raw_ostream.h"
30*0a6a1f1dSLionel Sambuc 
31*0a6a1f1dSLionel Sambuc using namespace llvm;
32*0a6a1f1dSLionel Sambuc 
33*0a6a1f1dSLionel Sambuc namespace {
34*0a6a1f1dSLionel Sambuc 
35*0a6a1f1dSLionel Sambuc class AMDGPUAsmParser : public MCTargetAsmParser {
36*0a6a1f1dSLionel Sambuc   MCSubtargetInfo &STI;
37*0a6a1f1dSLionel Sambuc   MCAsmParser &Parser;
38*0a6a1f1dSLionel Sambuc 
39*0a6a1f1dSLionel Sambuc 
40*0a6a1f1dSLionel Sambuc   /// @name Auto-generated Match Functions
41*0a6a1f1dSLionel Sambuc   /// {
42*0a6a1f1dSLionel Sambuc 
43*0a6a1f1dSLionel Sambuc #define GET_ASSEMBLER_HEADER
44*0a6a1f1dSLionel Sambuc #include "AMDGPUGenAsmMatcher.inc"
45*0a6a1f1dSLionel Sambuc 
46*0a6a1f1dSLionel Sambuc   /// }
47*0a6a1f1dSLionel Sambuc 
48*0a6a1f1dSLionel Sambuc public:
AMDGPUAsmParser(MCSubtargetInfo & _STI,MCAsmParser & _Parser,const MCInstrInfo & _MII,const MCTargetOptions & Options)49*0a6a1f1dSLionel Sambuc   AMDGPUAsmParser(MCSubtargetInfo &_STI, MCAsmParser &_Parser,
50*0a6a1f1dSLionel Sambuc                const MCInstrInfo &_MII,
51*0a6a1f1dSLionel Sambuc                const MCTargetOptions &Options)
52*0a6a1f1dSLionel Sambuc       : MCTargetAsmParser(), STI(_STI), Parser(_Parser) {
53*0a6a1f1dSLionel Sambuc     setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
54*0a6a1f1dSLionel Sambuc   }
55*0a6a1f1dSLionel Sambuc   bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) override;
56*0a6a1f1dSLionel Sambuc   bool MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
57*0a6a1f1dSLionel Sambuc                                OperandVector &Operands, MCStreamer &Out,
58*0a6a1f1dSLionel Sambuc                                uint64_t &ErrorInfo,
59*0a6a1f1dSLionel Sambuc                                bool MatchingInlineAsm) override;
60*0a6a1f1dSLionel Sambuc   bool ParseDirective(AsmToken DirectiveID) override;
61*0a6a1f1dSLionel Sambuc   OperandMatchResultTy parseOperand(OperandVector &Operands, StringRef Mnemonic);
62*0a6a1f1dSLionel Sambuc   bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
63*0a6a1f1dSLionel Sambuc                         SMLoc NameLoc, OperandVector &Operands) override;
64*0a6a1f1dSLionel Sambuc 
65*0a6a1f1dSLionel Sambuc   bool parseCnt(int64_t &IntVal);
66*0a6a1f1dSLionel Sambuc   OperandMatchResultTy parseSWaitCntOps(OperandVector &Operands);
67*0a6a1f1dSLionel Sambuc };
68*0a6a1f1dSLionel Sambuc 
69*0a6a1f1dSLionel Sambuc class AMDGPUOperand : public MCParsedAsmOperand {
70*0a6a1f1dSLionel Sambuc   enum KindTy {
71*0a6a1f1dSLionel Sambuc     Token,
72*0a6a1f1dSLionel Sambuc     Immediate
73*0a6a1f1dSLionel Sambuc   } Kind;
74*0a6a1f1dSLionel Sambuc 
75*0a6a1f1dSLionel Sambuc public:
AMDGPUOperand(enum KindTy K)76*0a6a1f1dSLionel Sambuc   AMDGPUOperand(enum KindTy K) : MCParsedAsmOperand(), Kind(K) {}
77*0a6a1f1dSLionel Sambuc 
78*0a6a1f1dSLionel Sambuc   struct TokOp {
79*0a6a1f1dSLionel Sambuc     const char *Data;
80*0a6a1f1dSLionel Sambuc     unsigned Length;
81*0a6a1f1dSLionel Sambuc   };
82*0a6a1f1dSLionel Sambuc 
83*0a6a1f1dSLionel Sambuc   struct ImmOp {
84*0a6a1f1dSLionel Sambuc     int64_t Val;
85*0a6a1f1dSLionel Sambuc   };
86*0a6a1f1dSLionel Sambuc 
87*0a6a1f1dSLionel Sambuc   union {
88*0a6a1f1dSLionel Sambuc     TokOp Tok;
89*0a6a1f1dSLionel Sambuc     ImmOp Imm;
90*0a6a1f1dSLionel Sambuc   };
91*0a6a1f1dSLionel Sambuc 
addImmOperands(MCInst & Inst,unsigned N) const92*0a6a1f1dSLionel Sambuc   void addImmOperands(MCInst &Inst, unsigned N) const {
93*0a6a1f1dSLionel Sambuc     Inst.addOperand(MCOperand::CreateImm(getImm()));
94*0a6a1f1dSLionel Sambuc   }
addRegOperands(MCInst & Inst,unsigned N) const95*0a6a1f1dSLionel Sambuc   void addRegOperands(MCInst &Inst, unsigned N) const {
96*0a6a1f1dSLionel Sambuc     llvm_unreachable("addRegOperands");
97*0a6a1f1dSLionel Sambuc   }
getToken() const98*0a6a1f1dSLionel Sambuc   StringRef getToken() const {
99*0a6a1f1dSLionel Sambuc     return StringRef(Tok.Data, Tok.Length);
100*0a6a1f1dSLionel Sambuc   }
isToken() const101*0a6a1f1dSLionel Sambuc   bool isToken() const override {
102*0a6a1f1dSLionel Sambuc     return Kind == Token;
103*0a6a1f1dSLionel Sambuc   }
104*0a6a1f1dSLionel Sambuc 
isImm() const105*0a6a1f1dSLionel Sambuc   bool isImm() const override {
106*0a6a1f1dSLionel Sambuc     return Kind == Immediate;
107*0a6a1f1dSLionel Sambuc   }
108*0a6a1f1dSLionel Sambuc 
getImm() const109*0a6a1f1dSLionel Sambuc   int64_t getImm() const {
110*0a6a1f1dSLionel Sambuc     return Imm.Val;
111*0a6a1f1dSLionel Sambuc   }
112*0a6a1f1dSLionel Sambuc 
isReg() const113*0a6a1f1dSLionel Sambuc   bool isReg() const override {
114*0a6a1f1dSLionel Sambuc     return false;
115*0a6a1f1dSLionel Sambuc   }
116*0a6a1f1dSLionel Sambuc 
getReg() const117*0a6a1f1dSLionel Sambuc   unsigned getReg() const override {
118*0a6a1f1dSLionel Sambuc     return 0;
119*0a6a1f1dSLionel Sambuc   }
120*0a6a1f1dSLionel Sambuc 
isMem() const121*0a6a1f1dSLionel Sambuc   bool isMem() const override {
122*0a6a1f1dSLionel Sambuc     return false;
123*0a6a1f1dSLionel Sambuc   }
124*0a6a1f1dSLionel Sambuc 
getStartLoc() const125*0a6a1f1dSLionel Sambuc   SMLoc getStartLoc() const override {
126*0a6a1f1dSLionel Sambuc     return SMLoc();
127*0a6a1f1dSLionel Sambuc   }
128*0a6a1f1dSLionel Sambuc 
getEndLoc() const129*0a6a1f1dSLionel Sambuc   SMLoc getEndLoc() const override {
130*0a6a1f1dSLionel Sambuc     return SMLoc();
131*0a6a1f1dSLionel Sambuc   }
132*0a6a1f1dSLionel Sambuc 
print(raw_ostream & OS) const133*0a6a1f1dSLionel Sambuc   void print(raw_ostream &OS) const override { }
134*0a6a1f1dSLionel Sambuc 
CreateImm(int64_t Val)135*0a6a1f1dSLionel Sambuc   static std::unique_ptr<AMDGPUOperand> CreateImm(int64_t Val) {
136*0a6a1f1dSLionel Sambuc     auto Op = llvm::make_unique<AMDGPUOperand>(Immediate);
137*0a6a1f1dSLionel Sambuc     Op->Imm.Val = Val;
138*0a6a1f1dSLionel Sambuc     return Op;
139*0a6a1f1dSLionel Sambuc   }
140*0a6a1f1dSLionel Sambuc 
CreateToken(StringRef Str,SMLoc Loc)141*0a6a1f1dSLionel Sambuc   static std::unique_ptr<AMDGPUOperand> CreateToken(StringRef Str, SMLoc Loc) {
142*0a6a1f1dSLionel Sambuc     auto Res = llvm::make_unique<AMDGPUOperand>(Token);
143*0a6a1f1dSLionel Sambuc     Res->Tok.Data = Str.data();
144*0a6a1f1dSLionel Sambuc     Res->Tok.Length = Str.size();
145*0a6a1f1dSLionel Sambuc     return Res;
146*0a6a1f1dSLionel Sambuc   }
147*0a6a1f1dSLionel Sambuc 
148*0a6a1f1dSLionel Sambuc   bool isSWaitCnt() const;
149*0a6a1f1dSLionel Sambuc };
150*0a6a1f1dSLionel Sambuc 
151*0a6a1f1dSLionel Sambuc }
152*0a6a1f1dSLionel Sambuc 
ParseRegister(unsigned & RegNo,SMLoc & StartLoc,SMLoc & EndLoc)153*0a6a1f1dSLionel Sambuc bool AMDGPUAsmParser::ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) {
154*0a6a1f1dSLionel Sambuc   return true;
155*0a6a1f1dSLionel Sambuc }
156*0a6a1f1dSLionel Sambuc 
157*0a6a1f1dSLionel Sambuc 
MatchAndEmitInstruction(SMLoc IDLoc,unsigned & Opcode,OperandVector & Operands,MCStreamer & Out,uint64_t & ErrorInfo,bool MatchingInlineAsm)158*0a6a1f1dSLionel Sambuc bool AMDGPUAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
159*0a6a1f1dSLionel Sambuc                                               OperandVector &Operands,
160*0a6a1f1dSLionel Sambuc                                               MCStreamer &Out,
161*0a6a1f1dSLionel Sambuc                                               uint64_t &ErrorInfo,
162*0a6a1f1dSLionel Sambuc                                               bool MatchingInlineAsm) {
163*0a6a1f1dSLionel Sambuc   MCInst Inst;
164*0a6a1f1dSLionel Sambuc 
165*0a6a1f1dSLionel Sambuc   switch (MatchInstructionImpl(Operands, Inst, ErrorInfo, MatchingInlineAsm)) {
166*0a6a1f1dSLionel Sambuc   case Match_Success:
167*0a6a1f1dSLionel Sambuc     Inst.setLoc(IDLoc);
168*0a6a1f1dSLionel Sambuc     Out.EmitInstruction(Inst, STI);
169*0a6a1f1dSLionel Sambuc     return false;
170*0a6a1f1dSLionel Sambuc   case Match_MissingFeature:
171*0a6a1f1dSLionel Sambuc     return Error(IDLoc, "instruction use requires an option to be enabled");
172*0a6a1f1dSLionel Sambuc   case Match_MnemonicFail:
173*0a6a1f1dSLionel Sambuc     return Error(IDLoc, "unrecognized instruction mnemonic");
174*0a6a1f1dSLionel Sambuc   case Match_InvalidOperand: {
175*0a6a1f1dSLionel Sambuc     if (ErrorInfo != ~0ULL) {
176*0a6a1f1dSLionel Sambuc       if (ErrorInfo >= Operands.size())
177*0a6a1f1dSLionel Sambuc         return Error(IDLoc, "too few operands for instruction");
178*0a6a1f1dSLionel Sambuc 
179*0a6a1f1dSLionel Sambuc     }
180*0a6a1f1dSLionel Sambuc     return Error(IDLoc, "invalid operand for instruction");
181*0a6a1f1dSLionel Sambuc   }
182*0a6a1f1dSLionel Sambuc   }
183*0a6a1f1dSLionel Sambuc   llvm_unreachable("Implement any new match types added!");
184*0a6a1f1dSLionel Sambuc }
185*0a6a1f1dSLionel Sambuc 
ParseDirective(AsmToken DirectiveID)186*0a6a1f1dSLionel Sambuc bool AMDGPUAsmParser::ParseDirective(AsmToken DirectiveID) {
187*0a6a1f1dSLionel Sambuc   return true;
188*0a6a1f1dSLionel Sambuc }
189*0a6a1f1dSLionel Sambuc 
190*0a6a1f1dSLionel Sambuc AMDGPUAsmParser::OperandMatchResultTy
parseOperand(OperandVector & Operands,StringRef Mnemonic)191*0a6a1f1dSLionel Sambuc AMDGPUAsmParser::parseOperand(OperandVector &Operands, StringRef Mnemonic) {
192*0a6a1f1dSLionel Sambuc 
193*0a6a1f1dSLionel Sambuc   // Try to parse with a custom parser
194*0a6a1f1dSLionel Sambuc   OperandMatchResultTy ResTy = MatchOperandParserImpl(Operands, Mnemonic);
195*0a6a1f1dSLionel Sambuc 
196*0a6a1f1dSLionel Sambuc   // If we successfully parsed the operand or if there as an error parsing,
197*0a6a1f1dSLionel Sambuc   // we are done.
198*0a6a1f1dSLionel Sambuc   if (ResTy == MatchOperand_Success || ResTy == MatchOperand_ParseFail)
199*0a6a1f1dSLionel Sambuc     return ResTy;
200*0a6a1f1dSLionel Sambuc 
201*0a6a1f1dSLionel Sambuc   switch(getLexer().getKind()) {
202*0a6a1f1dSLionel Sambuc     case AsmToken::Integer: {
203*0a6a1f1dSLionel Sambuc       int64_t IntVal;
204*0a6a1f1dSLionel Sambuc       if (getParser().parseAbsoluteExpression(IntVal))
205*0a6a1f1dSLionel Sambuc         return MatchOperand_ParseFail;
206*0a6a1f1dSLionel Sambuc       Operands.push_back(AMDGPUOperand::CreateImm(IntVal));
207*0a6a1f1dSLionel Sambuc       return MatchOperand_Success;
208*0a6a1f1dSLionel Sambuc     }
209*0a6a1f1dSLionel Sambuc     default:
210*0a6a1f1dSLionel Sambuc       return MatchOperand_NoMatch;
211*0a6a1f1dSLionel Sambuc   }
212*0a6a1f1dSLionel Sambuc }
213*0a6a1f1dSLionel Sambuc 
ParseInstruction(ParseInstructionInfo & Info,StringRef Name,SMLoc NameLoc,OperandVector & Operands)214*0a6a1f1dSLionel Sambuc bool AMDGPUAsmParser::ParseInstruction(ParseInstructionInfo &Info,
215*0a6a1f1dSLionel Sambuc                                        StringRef Name,
216*0a6a1f1dSLionel Sambuc                                        SMLoc NameLoc, OperandVector &Operands) {
217*0a6a1f1dSLionel Sambuc   // Add the instruction mnemonic
218*0a6a1f1dSLionel Sambuc   Operands.push_back(AMDGPUOperand::CreateToken(Name, NameLoc));
219*0a6a1f1dSLionel Sambuc 
220*0a6a1f1dSLionel Sambuc   if (getLexer().is(AsmToken::EndOfStatement))
221*0a6a1f1dSLionel Sambuc     return false;
222*0a6a1f1dSLionel Sambuc 
223*0a6a1f1dSLionel Sambuc   AMDGPUAsmParser::OperandMatchResultTy Res = parseOperand(Operands, Name);
224*0a6a1f1dSLionel Sambuc   switch (Res) {
225*0a6a1f1dSLionel Sambuc     case MatchOperand_Success: return false;
226*0a6a1f1dSLionel Sambuc     case MatchOperand_ParseFail: return Error(NameLoc,
227*0a6a1f1dSLionel Sambuc                                               "Failed parsing operand");
228*0a6a1f1dSLionel Sambuc     case MatchOperand_NoMatch: return Error(NameLoc, "Not a valid operand");
229*0a6a1f1dSLionel Sambuc   }
230*0a6a1f1dSLionel Sambuc   return true;
231*0a6a1f1dSLionel Sambuc }
232*0a6a1f1dSLionel Sambuc 
233*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
234*0a6a1f1dSLionel Sambuc // s_waitcnt
235*0a6a1f1dSLionel Sambuc //===----------------------------------------------------------------------===//
236*0a6a1f1dSLionel Sambuc 
parseCnt(int64_t & IntVal)237*0a6a1f1dSLionel Sambuc bool AMDGPUAsmParser::parseCnt(int64_t &IntVal) {
238*0a6a1f1dSLionel Sambuc   StringRef CntName = Parser.getTok().getString();
239*0a6a1f1dSLionel Sambuc   int64_t CntVal;
240*0a6a1f1dSLionel Sambuc 
241*0a6a1f1dSLionel Sambuc   Parser.Lex();
242*0a6a1f1dSLionel Sambuc   if (getLexer().isNot(AsmToken::LParen))
243*0a6a1f1dSLionel Sambuc     return true;
244*0a6a1f1dSLionel Sambuc 
245*0a6a1f1dSLionel Sambuc   Parser.Lex();
246*0a6a1f1dSLionel Sambuc   if (getLexer().isNot(AsmToken::Integer))
247*0a6a1f1dSLionel Sambuc     return true;
248*0a6a1f1dSLionel Sambuc 
249*0a6a1f1dSLionel Sambuc   if (getParser().parseAbsoluteExpression(CntVal))
250*0a6a1f1dSLionel Sambuc     return true;
251*0a6a1f1dSLionel Sambuc 
252*0a6a1f1dSLionel Sambuc   if (getLexer().isNot(AsmToken::RParen))
253*0a6a1f1dSLionel Sambuc     return true;
254*0a6a1f1dSLionel Sambuc 
255*0a6a1f1dSLionel Sambuc   Parser.Lex();
256*0a6a1f1dSLionel Sambuc   if (getLexer().is(AsmToken::Amp) || getLexer().is(AsmToken::Comma))
257*0a6a1f1dSLionel Sambuc     Parser.Lex();
258*0a6a1f1dSLionel Sambuc 
259*0a6a1f1dSLionel Sambuc   int CntShift;
260*0a6a1f1dSLionel Sambuc   int CntMask;
261*0a6a1f1dSLionel Sambuc 
262*0a6a1f1dSLionel Sambuc   if (CntName == "vmcnt") {
263*0a6a1f1dSLionel Sambuc     CntMask = 0xf;
264*0a6a1f1dSLionel Sambuc     CntShift = 0;
265*0a6a1f1dSLionel Sambuc   } else if (CntName == "expcnt") {
266*0a6a1f1dSLionel Sambuc     CntMask = 0x7;
267*0a6a1f1dSLionel Sambuc     CntShift = 4;
268*0a6a1f1dSLionel Sambuc   } else if (CntName == "lgkmcnt") {
269*0a6a1f1dSLionel Sambuc     CntMask = 0x7;
270*0a6a1f1dSLionel Sambuc     CntShift = 8;
271*0a6a1f1dSLionel Sambuc   } else {
272*0a6a1f1dSLionel Sambuc     return true;
273*0a6a1f1dSLionel Sambuc   }
274*0a6a1f1dSLionel Sambuc 
275*0a6a1f1dSLionel Sambuc   IntVal &= ~(CntMask << CntShift);
276*0a6a1f1dSLionel Sambuc   IntVal |= (CntVal << CntShift);
277*0a6a1f1dSLionel Sambuc   return false;
278*0a6a1f1dSLionel Sambuc }
279*0a6a1f1dSLionel Sambuc 
280*0a6a1f1dSLionel Sambuc AMDGPUAsmParser::OperandMatchResultTy
parseSWaitCntOps(OperandVector & Operands)281*0a6a1f1dSLionel Sambuc AMDGPUAsmParser::parseSWaitCntOps(OperandVector &Operands) {
282*0a6a1f1dSLionel Sambuc   // Disable all counters by default.
283*0a6a1f1dSLionel Sambuc   // vmcnt   [3:0]
284*0a6a1f1dSLionel Sambuc   // expcnt  [6:4]
285*0a6a1f1dSLionel Sambuc   // lgkmcnt [10:8]
286*0a6a1f1dSLionel Sambuc   int64_t CntVal = 0x77f;
287*0a6a1f1dSLionel Sambuc 
288*0a6a1f1dSLionel Sambuc   switch(getLexer().getKind()) {
289*0a6a1f1dSLionel Sambuc     default: return MatchOperand_ParseFail;
290*0a6a1f1dSLionel Sambuc     case AsmToken::Integer:
291*0a6a1f1dSLionel Sambuc       // The operand can be an integer value.
292*0a6a1f1dSLionel Sambuc       if (getParser().parseAbsoluteExpression(CntVal))
293*0a6a1f1dSLionel Sambuc         return MatchOperand_ParseFail;
294*0a6a1f1dSLionel Sambuc       break;
295*0a6a1f1dSLionel Sambuc 
296*0a6a1f1dSLionel Sambuc     case AsmToken::Identifier:
297*0a6a1f1dSLionel Sambuc       do {
298*0a6a1f1dSLionel Sambuc         if (parseCnt(CntVal))
299*0a6a1f1dSLionel Sambuc           return MatchOperand_ParseFail;
300*0a6a1f1dSLionel Sambuc       } while(getLexer().isNot(AsmToken::EndOfStatement));
301*0a6a1f1dSLionel Sambuc       break;
302*0a6a1f1dSLionel Sambuc   }
303*0a6a1f1dSLionel Sambuc   Operands.push_back(AMDGPUOperand::CreateImm(CntVal));
304*0a6a1f1dSLionel Sambuc   return MatchOperand_Success;
305*0a6a1f1dSLionel Sambuc }
306*0a6a1f1dSLionel Sambuc 
isSWaitCnt() const307*0a6a1f1dSLionel Sambuc bool AMDGPUOperand::isSWaitCnt() const {
308*0a6a1f1dSLionel Sambuc   return isImm();
309*0a6a1f1dSLionel Sambuc }
310*0a6a1f1dSLionel Sambuc 
311*0a6a1f1dSLionel Sambuc /// Force static initialization.
LLVMInitializeR600AsmParser()312*0a6a1f1dSLionel Sambuc extern "C" void LLVMInitializeR600AsmParser() {
313*0a6a1f1dSLionel Sambuc   RegisterMCAsmParser<AMDGPUAsmParser> A(TheAMDGPUTarget);
314*0a6a1f1dSLionel Sambuc   RegisterMCAsmParser<AMDGPUAsmParser> B(TheGCNTarget);
315*0a6a1f1dSLionel Sambuc }
316*0a6a1f1dSLionel Sambuc 
317*0a6a1f1dSLionel Sambuc #define GET_REGISTER_MATCHER
318*0a6a1f1dSLionel Sambuc #define GET_MATCHER_IMPLEMENTATION
319*0a6a1f1dSLionel Sambuc #include "AMDGPUGenAsmMatcher.inc"
320*0a6a1f1dSLionel Sambuc 
321