aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoakuma <koachan@protonmail.com>2024-06-19 11:31:54 +0700
committerKoakuma <koachan@protonmail.com>2024-06-19 11:31:54 +0700
commit0eb51262adf0dcf34059463764662c677a34c67d (patch)
tree85faa5f82c7d12444186de15dde631c513695bcc
parent014446c130362914b7e6dc839a8f5a86517cec63 (diff)
parentdbda8e2f2cd8764e0badd983915d62a2c3377f4d (diff)
downloadllvm-users/koachan/spr/sparcias-enable-parseforallfeatures-in-matchoperandparserimpl.zip
llvm-users/koachan/spr/sparcias-enable-parseforallfeatures-in-matchoperandparserimpl.tar.gz
llvm-users/koachan/spr/sparcias-enable-parseforallfeatures-in-matchoperandparserimpl.tar.bz2
Created using spr 1.3.5
-rw-r--r--llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp39
-rw-r--r--llvm/lib/Target/Sparc/SparcInstrAliases.td2
-rw-r--r--llvm/test/CodeGen/SPARC/inlineasm.ll2
-rw-r--r--llvm/test/MC/Disassembler/Sparc/sparc-v9.txt10
-rw-r--r--llvm/test/MC/Sparc/sparc-asm-errors.s2
-rw-r--r--llvm/test/MC/Sparc/sparc-mem-asi-instructions.s4
-rw-r--r--llvm/test/MC/Sparc/sparcv9-instructions.s52
7 files changed, 61 insertions, 50 deletions
diff --git a/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp b/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
index f0a3a4e..34531ff 100644
--- a/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
+++ b/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
@@ -1085,13 +1085,24 @@ ParseStatus SparcAsmParser::parseASITag(OperandVector &Operands) {
SMLoc E = Parser.getTok().getEndLoc();
int64_t ASIVal = 0;
- if (is64Bit() && (getLexer().getKind() == AsmToken::Hash)) {
+ switch (getLexer().getKind()) {
+ case AsmToken::LParen:
+ case AsmToken::Integer:
+ case AsmToken::Identifier:
+ case AsmToken::Plus:
+ case AsmToken::Minus:
+ case AsmToken::Tilde:
+ if (getParser().parseAbsoluteExpression(ASIVal) || !isUInt<8>(ASIVal))
+ return Error(S, "invalid ASI number, must be between 0 and 255");
+ break;
+ case AsmToken::Hash: {
// For now we only support named tags for 64-bit/V9 systems.
// TODO: add support for 32-bit/V8 systems.
SMLoc TagStart = getLexer().peekTok(false).getLoc();
Parser.Lex(); // Eat the '#'.
- auto ASIName = Parser.getTok().getString();
- auto ASITag = SparcASITag::lookupASITagByName(ASIName);
+ const StringRef ASIName = Parser.getTok().getString();
+ const SparcASITag::ASITag *ASITag =
+ SparcASITag::lookupASITagByName(ASIName);
if (!ASITag)
ASITag = SparcASITag::lookupASITagByAltName(ASIName);
Parser.Lex(); // Eat the identifier token.
@@ -1100,15 +1111,10 @@ ParseStatus SparcAsmParser::parseASITag(OperandVector &Operands) {
return Error(TagStart, "unknown ASI tag");
ASIVal = ASITag->Encoding;
- } else if (!getParser().parseAbsoluteExpression(ASIVal)) {
- if (!isUInt<8>(ASIVal))
- return Error(S, "invalid ASI number, must be between 0 and 255");
- } else {
- return Error(
- S, is64Bit()
- ? "malformed ASI tag, must be %asi, a constant integer "
- "expression, or a named tag"
- : "malformed ASI tag, must be a constant integer expression");
+ break;
+ }
+ default:
+ return ParseStatus::NoMatch;
}
Operands.push_back(SparcOperand::CreateASITag(ASIVal, S, E));
@@ -1183,7 +1189,8 @@ ParseStatus SparcAsmParser::parseCallTarget(OperandVector &Operands) {
ParseStatus SparcAsmParser::parseOperand(OperandVector &Operands,
StringRef Mnemonic) {
- ParseStatus Res = MatchOperandParserImpl(Operands, Mnemonic);
+ ParseStatus Res =
+ MatchOperandParserImpl(Operands, Mnemonic, /*ParseForAllFeatures=*/true);
// If there wasn't a custom match, try the generic matcher below. Otherwise,
// there was a match, but an error occurred, in which case, just return that
@@ -1230,8 +1237,12 @@ ParseStatus SparcAsmParser::parseOperand(OperandVector &Operands,
// Parse an optional address-space identifier after the address.
// This will be either an immediate constant expression, or, on 64-bit
// processors, the %asi register.
- if (is64Bit() && getLexer().is(AsmToken::Percent)) {
+ if (getLexer().is(AsmToken::Percent)) {
SMLoc S = Parser.getTok().getLoc();
+ if (!is64Bit())
+ return Error(
+ S, "malformed ASI tag, must be a constant integer expression");
+
Parser.Lex(); // Eat the %.
const AsmToken Tok = Parser.getTok();
if (Tok.is(AsmToken::Identifier) && Tok.getString() == "asi") {
diff --git a/llvm/lib/Target/Sparc/SparcInstrAliases.td b/llvm/lib/Target/Sparc/SparcInstrAliases.td
index eedad25..e77b7f5 100644
--- a/llvm/lib/Target/Sparc/SparcInstrAliases.td
+++ b/llvm/lib/Target/Sparc/SparcInstrAliases.td
@@ -568,7 +568,7 @@ let EmitPriority = 0 in {
// or imm, reg, rd -> or reg, imm, rd
def : InstAlias<"or $simm13, $rs1, $rd", (ORri IntRegs:$rd, IntRegs:$rs1, simm13Op:$simm13)>;
- // addc/addx imm, reg, rd -> or reg, imm, rd
+ // addc/addx imm, reg, rd -> addc/addx reg, imm, rd
def : InstAlias<"addx $simm13, $rs1, $rd", (ADDCri IntRegs:$rd, IntRegs:$rs1, simm13Op:$simm13)>;
}
diff --git a/llvm/test/CodeGen/SPARC/inlineasm.ll b/llvm/test/CodeGen/SPARC/inlineasm.ll
index 9817d7c..14ea0a2 100644
--- a/llvm/test/CodeGen/SPARC/inlineasm.ll
+++ b/llvm/test/CodeGen/SPARC/inlineasm.ll
@@ -144,7 +144,7 @@ entry:
ret void
}
-; CHECK-label:test_twinword
+; CHECK-LABEL: test_twinword:
; CHECK: rd %asr5, %i1
; CHECK: srlx %i1, 32, %i0
diff --git a/llvm/test/MC/Disassembler/Sparc/sparc-v9.txt b/llvm/test/MC/Disassembler/Sparc/sparc-v9.txt
index d561216..9e4ff04 100644
--- a/llvm/test/MC/Disassembler/Sparc/sparc-v9.txt
+++ b/llvm/test/MC/Disassembler/Sparc/sparc-v9.txt
@@ -193,16 +193,16 @@
0xef 0x6e 0x40 0x1a
# CHECK: done
-0x81,0xf0,0x00,0x00
+0x81 0xf0 0x00 0x00
# CHECK: retry
-0x83,0xf0,0x00,0x00
+0x83 0xf0 0x00 0x00
# CHECK: saved
-0x81,0x88,0x00,0x00
+0x81 0x88 0x00 0x00
# CHECK: restored
-0x83,0x88,0x00,0x00
+0x83 0x88 0x00 0x00
# CHECK: rdpr %fq, %i5
-0xbb,0x53,0xc0,0x00
+0xbb 0x53 0xc0 0x00
diff --git a/llvm/test/MC/Sparc/sparc-asm-errors.s b/llvm/test/MC/Sparc/sparc-asm-errors.s
index 780f4e7..2b3a2eb 100644
--- a/llvm/test/MC/Sparc/sparc-asm-errors.s
+++ b/llvm/test/MC/Sparc/sparc-asm-errors.s
@@ -11,7 +11,7 @@
! V9: unknown membar tag
membar #BadTag
- ! V8: instruction requires a CPU feature not currently enabled
+ ! V8: unexpected token
! V9: invalid membar mask number
membar -127
diff --git a/llvm/test/MC/Sparc/sparc-mem-asi-instructions.s b/llvm/test/MC/Sparc/sparc-mem-asi-instructions.s
index 39abe7b..8b8503c 100644
--- a/llvm/test/MC/Sparc/sparc-mem-asi-instructions.s
+++ b/llvm/test/MC/Sparc/sparc-mem-asi-instructions.s
@@ -1,9 +1,9 @@
! RUN: not llvm-mc %s -triple=sparc -show-encoding 2>&1 | FileCheck %s --check-prefix=V8
! RUN: not llvm-mc %s -triple=sparcv9 -show-encoding 2>&1 | FileCheck %s --check-prefix=V9
-! V8: error: malformed ASI tag, must be a constant integer expression
+! V8: error: expected absolute expression
! V8-NEXT: lduba [%i0] asi, %o2
-! V9: error: malformed ASI tag, must be %asi, a constant integer expression, or a named tag
+! V9: error: unexpected token
! V9-NEXT: lduba [%i0] asi, %o2
lduba [%i0] asi, %o2
diff --git a/llvm/test/MC/Sparc/sparcv9-instructions.s b/llvm/test/MC/Sparc/sparcv9-instructions.s
index 1b11171..68ae2ac 100644
--- a/llvm/test/MC/Sparc/sparcv9-instructions.s
+++ b/llvm/test/MC/Sparc/sparcv9-instructions.s
@@ -537,112 +537,112 @@
! V9: stxa %g0, [%g2+%i5] #ASI_SNF ! encoding: [0xc0,0xf0,0x90,0x7d]
stxa %g0, [%g2 + %i5] #ASI_SNF
- ! V8: error: invalid operand for instruction
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + 0xf80 ], 1
! V9: prefetch [%i1+3968], #one_read ! encoding: [0xc3,0x6e,0x6f,0x80]
prefetch [ %i1 + 0xf80 ], 1
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + 0xf80 ], #n_reads
! V9: prefetch [%i1+3968], #n_reads ! encoding: [0xc1,0x6e,0x6f,0x80]
prefetch [ %i1 + 0xf80 ], #n_reads
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + 0xf80 ], #one_read
! V9: prefetch [%i1+3968], #one_read ! encoding: [0xc3,0x6e,0x6f,0x80]
prefetch [ %i1 + 0xf80 ], #one_read
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + 0xf80 ], #n_writes
! V9: prefetch [%i1+3968], #n_writes ! encoding: [0xc5,0x6e,0x6f,0x80]
prefetch [ %i1 + 0xf80 ], #n_writes
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + 0xf80 ], #one_write
! V9: prefetch [%i1+3968], #one_write ! encoding: [0xc7,0x6e,0x6f,0x80]
prefetch [ %i1 + 0xf80 ], #one_write
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + 0xf80 ], #page
! V9: prefetch [%i1+3968], #page ! encoding: [0xc9,0x6e,0x6f,0x80]
prefetch [ %i1 + 0xf80 ], #page
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + 0xf80 ], #unified
! V9: prefetch [%i1+3968], #unified ! encoding: [0xe3,0x6e,0x6f,0x80]
prefetch [ %i1 + 0xf80 ], #unified
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + 0xf80 ], #n_reads_strong
! V9: prefetch [%i1+3968], #n_reads_strong ! encoding: [0xe9,0x6e,0x6f,0x80]
prefetch [ %i1 + 0xf80 ], #n_reads_strong
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + 0xf80 ], #one_read_strong
! V9: prefetch [%i1+3968], #one_read_strong ! encoding: [0xeb,0x6e,0x6f,0x80]
prefetch [ %i1 + 0xf80 ], #one_read_strong
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + 0xf80 ], #n_writes_strong
! V9: prefetch [%i1+3968], #n_writes_strong ! encoding: [0xed,0x6e,0x6f,0x80]
prefetch [ %i1 + 0xf80 ], #n_writes_strong
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + 0xf80 ], #one_write_strong
! V9: prefetch [%i1+3968], #one_write_strong ! encoding: [0xef,0x6e,0x6f,0x80]
prefetch [ %i1 + 0xf80 ], #one_write_strong
- ! V8: error: invalid operand for instruction
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + %i2 ], 1
! V9: prefetch [%i1+%i2], #one_read ! encoding: [0xc3,0x6e,0x40,0x1a]
prefetch [ %i1 + %i2 ], 1
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + %i2 ], #n_reads
! V9: prefetch [%i1+%i2], #n_reads ! encoding: [0xc1,0x6e,0x40,0x1a]
prefetch [ %i1 + %i2 ], #n_reads
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + %i2 ], #one_read
! V9: prefetch [%i1+%i2], #one_read ! encoding: [0xc3,0x6e,0x40,0x1a]
prefetch [ %i1 + %i2 ], #one_read
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + %i2 ], #n_writes
! V9: prefetch [%i1+%i2], #n_writes ! encoding: [0xc5,0x6e,0x40,0x1a]
prefetch [ %i1 + %i2 ], #n_writes
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + %i2 ], #one_write
! V9: prefetch [%i1+%i2], #one_write ! encoding: [0xc7,0x6e,0x40,0x1a]
prefetch [ %i1 + %i2 ], #one_write
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + %i2 ], #page
! V9: prefetch [%i1+%i2], #page ! encoding: [0xc9,0x6e,0x40,0x1a]
prefetch [ %i1 + %i2 ], #page
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + %i2 ], #unified
! V9: prefetch [%i1+%i2], #unified ! encoding: [0xe3,0x6e,0x40,0x1a]
prefetch [ %i1 + %i2 ], #unified
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + %i2 ], #n_reads_strong
! V9: prefetch [%i1+%i2], #n_reads_strong ! encoding: [0xe9,0x6e,0x40,0x1a]
prefetch [ %i1 + %i2 ], #n_reads_strong
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + %i2 ], #one_read_strong
! V9: prefetch [%i1+%i2], #one_read_strong ! encoding: [0xeb,0x6e,0x40,0x1a]
prefetch [ %i1 + %i2 ], #one_read_strong
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + %i2 ], #n_writes_strong
! V9: prefetch [%i1+%i2], #n_writes_strong ! encoding: [0xed,0x6e,0x40,0x1a]
prefetch [ %i1 + %i2 ], #n_writes_strong
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetch [ %i1 + %i2 ], #one_write_strong
! V9: prefetch [%i1+%i2], #one_write_strong ! encoding: [0xef,0x6e,0x40,0x1a]
prefetch [ %i1 + %i2 ], #one_write_strong
@@ -657,22 +657,22 @@
! V9: prefetcha [%i1+3968] %asi, #one_read ! encoding: [0xc3,0xee,0x6f,0x80]
prefetcha [ %i1 + 0xf80 ] %asi, #one_read
- ! V8: error: malformed ASI tag, must be a constant integer expression
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetcha [ %i1 + %i2 ] #ASI_SNF, 1
! V9: prefetcha [%i1+%i2] #ASI_SNF, #one_read ! encoding: [0xc3,0xee,0x50,0x7a]
prefetcha [ %i1 + %i2 ] #ASI_SNF, 1
- ! V8: error: malformed ASI tag, must be a constant integer expression
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetcha [ %i1 + %i2 ] #ASI_SNF, #one_read
! V9: prefetcha [%i1+%i2] #ASI_SNF, #one_read ! encoding: [0xc3,0xee,0x50,0x7a]
prefetcha [ %i1 + %i2 ] #ASI_SNF, #one_read
- ! V8: error: invalid operand for instruction
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetcha [ %i1 + %i2 ] 131, 1
! V9: prefetcha [%i1+%i2] #ASI_SNF, #one_read ! encoding: [0xc3,0xee,0x50,0x7a]
prefetcha [ %i1 + %i2 ] 131, 1
- ! V8: error: unexpected token
+ ! V8: error: instruction requires a CPU feature not currently enabled
! V8-NEXT: prefetcha [ %i1 + %i2 ] 131, #one_read
! V9: prefetcha [%i1+%i2] #ASI_SNF, #one_read ! encoding: [0xc3,0xee,0x50,0x7a]
prefetcha [ %i1 + %i2 ] 131, #one_read