Skip to content

Commit 52d87de

Browse files
authored
[Xtensa] Fix register asm parsing. (#95551)
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".
1 parent f06d969 commit 52d87de

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

llvm/lib/Target/Xtensa/AsmParser/XtensaAsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ ParseStatus XtensaAsmParser::parseRegister(OperandVector &Operands,
572572
case AsmToken::Integer:
573573
if (!SR)
574574
return ParseStatus::NoMatch;
575-
RegName = StringRef(std::to_string(getLexer().getTok().getIntVal()));
575+
RegName = getLexer().getTok().getString();
576576
RegNo = MatchRegisterName(RegName);
577577
if (RegNo == 0)
578578
RegNo = MatchRegisterAltName(RegName);

llvm/test/MC/Xtensa/Core/registers.s

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# RUN: llvm-mc %s -triple=xtensa -show-encoding \
2+
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-INST %s
3+
4+
5+
.align 4
6+
LBL0:
7+
8+
#############################################################
9+
## Check special registers parsing
10+
#############################################################
11+
12+
# CHECK-INST: xsr a8, sar
13+
# CHECK: encoding: [0x80,0x03,0x61]
14+
xsr a8, 3

0 commit comments

Comments
 (0)