llvm.org GIT mirror llvm / bf75532
Introduce virtual ParseRegister method in TargetAsmParser. Create override of this method in X86/ARM/MBlaze. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124378 91177308-0d34-0410-b5e6-96231b3b80d8 Roman Divacky 9 years ago
4 changed file(s) with 21 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
4040
4141 unsigned getAvailableFeatures() const { return AvailableFeatures; }
4242 void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; }
43
44 virtual bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) = 0;
4345
4446 /// ParseInstruction - Parse one assembly instruction.
4547 ///
5252 bool Error(SMLoc L, const Twine &Msg) { return Parser.Error(L, Msg); }
5353
5454 int TryParseRegister();
55 virtual bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc);
5556 bool TryParseCoprocessorOperandName(SmallVectorImpl&);
5657 bool TryParseRegisterWithWriteBack(SmallVectorImpl &);
5758 bool ParseRegisterList(SmallVectorImpl &);
547548 static unsigned MatchRegisterName(StringRef Name);
548549
549550 /// }
551
552 bool ARMAsmParser::ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) {
553 RegNo = TryParseRegister();
554
555 return (RegNo == (unsigned)-1);
556 }
550557
551558 /// Try to parse a register name. The token must be an Identifier when called,
552559 /// and if it is a register name the token is eaten and the register number is
4040 bool Error(SMLoc L, const Twine &Msg) { return Parser.Error(L, Msg); }
4141
4242 MBlazeOperand *ParseMemory(SmallVectorImpl &Operands);
43 MBlazeOperand *ParseRegister();
43 MBlazeOperand *ParseRegister(unsigned &RegNo);
4444 MBlazeOperand *ParseImmediate();
4545 MBlazeOperand *ParseFsl();
4646 MBlazeOperand* ParseOperand(SmallVectorImpl &Operands);
47
48 virtual bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc);
4749
4850 bool ParseDirectiveWord(unsigned Size, SMLoc L);
4951
383385 return Op;
384386 }
385387
386 MBlazeOperand *MBlazeAsmParser::ParseRegister() {
388 bool MBlazeAsmParser::ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) {
389 return (ParseRegister(RegNo) == 0);
390 }
391
392 MBlazeOperand *MBlazeAsmParser::ParseRegister(unsigned &RegNo) {
387393 SMLoc S = Parser.getTok().getLoc();
388394 SMLoc E = SMLoc::getFromPointer(Parser.getTok().getLoc().getPointer() - 1);
389395
390396 switch (getLexer().getKind()) {
391397 default: return 0;
392398 case AsmToken::Identifier:
393 unsigned RegNo = MatchRegisterName(getLexer().getTok().getIdentifier());
399 RegNo = MatchRegisterName(getLexer().getTok().getIdentifier());
394400 if (RegNo == 0)
395401 return 0;
396402
451457 MBlazeOperand *Op;
452458
453459 // Attempt to parse the next token as a register name
454 Op = ParseRegister();
460 unsigned RegNo;
461 Op = ParseRegister(RegNo);
455462
456463 // Attempt to parse the next token as an FSL immediate
457464 if (!Op)
4343
4444 bool Error(SMLoc L, const Twine &Msg) { return Parser.Error(L, Msg); }
4545
46 bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc);
47
4846 X86Operand *ParseOperand();
4947 X86Operand *ParseMemOperand(unsigned SegReg, SMLoc StartLoc);
5048
7068 setAvailableFeatures(ComputeAvailableFeatures(
7169 &TM.getSubtarget()));
7270 }
71 virtual bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc);
7372
7473 virtual bool ParseInstruction(StringRef Name, SMLoc NameLoc,
7574 SmallVectorImpl &Operands);