Skip to content

Commit

Permalink
[Xtensa] Fix register asm parsing. (#95551)
Browse files Browse the repository at this point in the history
Fix passing temporary string object as argument to the StringRef
constructor in "parseRegister" function, because it causes errors in the
test "llvm/test/MC/Xtensa/Core/processor-control.s".
  • Loading branch information
andreisfr authored Jun 17, 2024
1 parent f06d969 commit 52d87de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/Target/Xtensa/AsmParser/XtensaAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ ParseStatus XtensaAsmParser::parseRegister(OperandVector &Operands,
case AsmToken::Integer:
if (!SR)
return ParseStatus::NoMatch;
RegName = StringRef(std::to_string(getLexer().getTok().getIntVal()));
RegName = getLexer().getTok().getString();
RegNo = MatchRegisterName(RegName);
if (RegNo == 0)
RegNo = MatchRegisterAltName(RegName);
Expand Down
14 changes: 14 additions & 0 deletions llvm/test/MC/Xtensa/Core/registers.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# RUN: llvm-mc %s -triple=xtensa -show-encoding \
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-INST %s


.align 4
LBL0:

#############################################################
## Check special registers parsing
#############################################################

# CHECK-INST: xsr a8, sar
# CHECK: encoding: [0x80,0x03,0x61]
xsr a8, 3

0 comments on commit 52d87de

Please sign in to comment.