@@ -33,12 +33,6 @@ class SBFAsmParser : public MCTargetAsmParser {
33
33
34
34
SMLoc getLoc () const { return getParser ().getTok ().getLoc (); }
35
35
36
- bool isNewSyntax () {
37
- return getParser ().getAssemblerDialect () == 0 ;
38
- }
39
-
40
- bool PreMatchCheck (OperandVector &Operands);
41
-
42
36
bool MatchAndEmitInstruction (SMLoc IDLoc, unsigned &Opcode,
43
37
OperandVector &Operands, MCStreamer &Out,
44
38
uint64_t &ErrorInfo,
@@ -52,25 +46,14 @@ class SBFAsmParser : public MCTargetAsmParser {
52
46
bool ParseInstruction (ParseInstructionInfo &Info, StringRef Name,
53
47
SMLoc NameLoc, OperandVector &Operands) override ;
54
48
55
- bool parseOldInstruction (ParseInstructionInfo &Info, StringRef Name,
56
- SMLoc NameLoc, OperandVector &Operands);
57
-
58
49
bool ParseDirective (AsmToken DirectiveID) override ;
59
50
60
- // "=" is used as assignment operator for assembly statement, so can't be used
61
- // for symbol assignment (old syntax only).
62
- bool equalIsAsmAssignment () override { return isNewSyntax (); }
63
- // "*" is used for dereferencing memory that it will be the start of
64
- // statement (old syntax only).
65
- bool starIsStartOfStatement () override { return !isNewSyntax (); }
66
-
67
51
#define GET_ASSEMBLER_HEADER
68
52
#include " SBFGenAsmMatcher.inc"
69
53
70
54
bool parseOperand (OperandVector &Operands, StringRef Mnemonic);
71
55
OperandMatchResultTy parseImmediate (OperandVector &Operands);
72
56
OperandMatchResultTy parseRegister (OperandVector &Operands);
73
- OperandMatchResultTy parseOperandAsOperator (OperandVector &Operands);
74
57
OperandMatchResultTy parseMemOperand (OperandVector &Operands);
75
58
76
59
public:
@@ -280,45 +263,14 @@ struct SBFOperand : public MCParsedAsmOperand {
280
263
#define GET_MATCHER_IMPLEMENTATION
281
264
#include " SBFGenAsmMatcher.inc"
282
265
283
- bool SBFAsmParser::PreMatchCheck (OperandVector &Operands) {
284
-
285
- // These checks not needed for the new syntax.
286
- if (isNewSyntax ())
287
- return false ;
288
-
289
- if (Operands.size () == 4 ) {
290
- // check "reg1 = -reg2" and "reg1 = be16/be32/be64/le16/le32/le64 reg2",
291
- // reg1 must be the same as reg2
292
- SBFOperand &Op0 = (SBFOperand &)*Operands[0 ];
293
- SBFOperand &Op1 = (SBFOperand &)*Operands[1 ];
294
- SBFOperand &Op2 = (SBFOperand &)*Operands[2 ];
295
- SBFOperand &Op3 = (SBFOperand &)*Operands[3 ];
296
- if (Op0.isReg () && Op1.isToken () && Op2.isToken () && Op3.isReg ()
297
- && Op1.getToken () == " ="
298
- && (Op2.getToken () == " -" || Op2.getToken () == " be16"
299
- || Op2.getToken () == " be32" || Op2.getToken () == " be64"
300
- || Op2.getToken () == " le16" || Op2.getToken () == " le32"
301
- || Op2.getToken () == " le64" )
302
- && Op0.getReg () != Op3.getReg ())
303
- return true ;
304
- }
305
-
306
- return false ;
307
- }
308
-
309
266
bool SBFAsmParser::MatchAndEmitInstruction (SMLoc IDLoc, unsigned &Opcode,
310
267
OperandVector &Operands,
311
268
MCStreamer &Out, uint64_t &ErrorInfo,
312
269
bool MatchingInlineAsm) {
313
270
MCInst Inst;
314
271
SMLoc ErrorLoc;
315
272
316
- if (PreMatchCheck (Operands))
317
- return Error (IDLoc, " additional inst constraint not met" );
318
-
319
- unsigned Dialect = getParser ().getAssemblerDialect ();
320
- switch (MatchInstructionImpl (Operands, Inst, ErrorInfo, MatchingInlineAsm,
321
- Dialect)) {
273
+ switch (MatchInstructionImpl (Operands, Inst, ErrorInfo, MatchingInlineAsm)) {
322
274
default :
323
275
break ;
324
276
case Match_Success:
@@ -372,75 +324,6 @@ OperandMatchResultTy SBFAsmParser::tryParseRegister(MCRegister &Reg,
372
324
return MatchOperand_NoMatch;
373
325
}
374
326
375
- OperandMatchResultTy
376
- SBFAsmParser::parseOperandAsOperator (OperandVector &Operands) {
377
- if (isNewSyntax ())
378
- llvm_unreachable (" parseOperandAsOperator called for new syntax" );
379
-
380
- SMLoc S = getLoc ();
381
-
382
- if (getLexer ().getKind () == AsmToken::Identifier) {
383
- StringRef Name = getLexer ().getTok ().getIdentifier ();
384
-
385
- if (SBFOperand::isValidIdInMiddle (Name)) {
386
- getLexer ().Lex ();
387
- Operands.push_back (SBFOperand::createToken (Name, S));
388
- return MatchOperand_Success;
389
- }
390
-
391
- return MatchOperand_NoMatch;
392
- }
393
-
394
- switch (getLexer ().getKind ()) {
395
- case AsmToken::Minus:
396
- case AsmToken::Plus: {
397
- if (getLexer ().peekTok ().is (AsmToken::Integer))
398
- return MatchOperand_NoMatch;
399
- [[fallthrough]];
400
- }
401
-
402
- case AsmToken::Equal:
403
- case AsmToken::Greater:
404
- case AsmToken::Less:
405
- case AsmToken::Pipe:
406
- case AsmToken::Star:
407
- case AsmToken::LParen:
408
- case AsmToken::RParen:
409
- case AsmToken::LBrac:
410
- case AsmToken::RBrac:
411
- case AsmToken::Slash:
412
- case AsmToken::Amp:
413
- case AsmToken::Percent:
414
- case AsmToken::Caret: {
415
- StringRef Name = getLexer ().getTok ().getString ();
416
- getLexer ().Lex ();
417
- Operands.push_back (SBFOperand::createToken (Name, S));
418
-
419
- return MatchOperand_Success;
420
- }
421
-
422
- case AsmToken::EqualEqual:
423
- case AsmToken::ExclaimEqual:
424
- case AsmToken::GreaterEqual:
425
- case AsmToken::GreaterGreater:
426
- case AsmToken::LessEqual:
427
- case AsmToken::LessLess: {
428
- Operands.push_back (SBFOperand::createToken (
429
- getLexer ().getTok ().getString ().substr (0 , 1 ), S));
430
- Operands.push_back (SBFOperand::createToken (
431
- getLexer ().getTok ().getString ().substr (1 , 1 ), S));
432
- getLexer ().Lex ();
433
-
434
- return MatchOperand_Success;
435
- }
436
-
437
- default :
438
- break ;
439
- }
440
-
441
- return MatchOperand_NoMatch;
442
- }
443
-
444
327
OperandMatchResultTy SBFAsmParser::parseRegister (OperandVector &Operands) {
445
328
SMLoc S = getLoc ();
446
329
SMLoc E = SMLoc::getFromPointer (S.getPointer () - 1 );
@@ -519,9 +402,6 @@ OperandMatchResultTy SBFAsmParser::parseMemOperand(OperandVector &Operands) {
519
402
// / information, adding to Operands. If operand was parsed, returns false, else
520
403
// / true.
521
404
bool SBFAsmParser::parseOperand (OperandVector &Operands, StringRef Mnemonic) {
522
- if (!isNewSyntax ())
523
- llvm_unreachable (" parseOperand called for old syntax" );
524
-
525
405
// Attempt to parse token as a register.
526
406
if (parseRegister (Operands) == MatchOperand_Success)
527
407
return false ;
@@ -544,10 +424,6 @@ bool SBFAsmParser::parseOperand(OperandVector &Operands, StringRef Mnemonic) {
544
424
// / Parse an SBF instruction.
545
425
bool SBFAsmParser::ParseInstruction (ParseInstructionInfo &Info, StringRef Name,
546
426
SMLoc NameLoc, OperandVector &Operands) {
547
- if (!isNewSyntax ()) {
548
- return parseOldInstruction (Info, Name, NameLoc, Operands);
549
- }
550
-
551
427
// First operand is token for instruction mnemonic.
552
428
Operands.push_back (SBFOperand::createToken (Name, NameLoc));
553
429
@@ -581,71 +457,7 @@ bool SBFAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
581
457
return false ;
582
458
}
583
459
584
- // / Parse an SBF instruction which is in SBF verifier format (old syntax).
585
- bool SBFAsmParser::parseOldInstruction (ParseInstructionInfo &Info,
586
- StringRef Name, SMLoc NameLoc,
587
- OperandVector &Operands) {
588
- if (isNewSyntax ())
589
- llvm_unreachable (" parseOldInstruction called for new syntax" );
590
-
591
- // The first operand could be either register or actually an operator.
592
- unsigned RegNo = MatchRegisterName (Name);
593
-
594
- if (RegNo != 0 ) {
595
- SMLoc E = SMLoc::getFromPointer (NameLoc.getPointer () - 1 );
596
- Operands.push_back (SBFOperand::createReg (RegNo, NameLoc, E));
597
- } else if (SBFOperand::isValidIdAtStart (Name))
598
- Operands.push_back (SBFOperand::createToken (Name, NameLoc));
599
- else
600
- return Error (NameLoc, " invalid register/token name" );
601
-
602
- while (!getLexer ().is (AsmToken::EndOfStatement)) {
603
- // Attempt to parse token as operator
604
- if (parseOperandAsOperator (Operands) == MatchOperand_Success)
605
- continue ;
606
-
607
- // Attempt to parse token as register
608
- if (parseRegister (Operands) == MatchOperand_Success)
609
- continue ;
610
-
611
- // Attempt to parse token as an immediate
612
- if (parseImmediate (Operands) != MatchOperand_Success) {
613
- SMLoc Loc = getLexer ().getLoc ();
614
- return Error (Loc, " unexpected token" );
615
- }
616
- }
617
-
618
- if (getLexer ().isNot (AsmToken::EndOfStatement)) {
619
- SMLoc Loc = getLexer ().getLoc ();
620
-
621
- getParser ().eatToEndOfStatement ();
622
-
623
- return Error (Loc, " unexpected token" );
624
- }
625
-
626
- // Consume the EndOfStatement.
627
- getParser ().Lex ();
628
- return false ;
629
- }
630
-
631
- bool SBFAsmParser::ParseDirective (AsmToken DirectiveID) {
632
- // This returns false if this function recognizes the directive
633
- // regardless of whether it is successfully handles or reports an
634
- // error. Otherwise it returns true to give the generic parser a
635
- // chance at recognizing it.
636
- StringRef IDVal = DirectiveID.getString ();
637
-
638
- if (IDVal == " .syntax_old" ) {
639
- getParser ().setAssemblerDialect (1 );
640
- return false ;
641
- }
642
- if (IDVal == " .syntax_new" ) {
643
- getParser ().setAssemblerDialect (0 );
644
- return false ;
645
- }
646
-
647
- return true ;
648
- }
460
+ bool SBFAsmParser::ParseDirective (AsmToken DirectiveID) { return true ; }
649
461
650
462
extern " C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSBFAsmParser () {
651
463
RegisterMCAsmParser<SBFAsmParser> XX (getTheSBFXTarget ());
0 commit comments