[llvm] 6790292 - [LoongArch] Modify ParserMethod for the simm26_b operand type
Weining Lu via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 21 02:02:00 PDT 2022
Author: wanglei
Date: 2022-10-21T17:01:46+08:00
New Revision: 67902920628f889cdef402bb0e8ca7a3df51e25f
URL: https://github.com/llvm/llvm-project/commit/67902920628f889cdef402bb0e8ca7a3df51e25f
DIFF: https://github.com/llvm/llvm-project/commit/67902920628f889cdef402bb0e8ca7a3df51e25f.diff
LOG: [LoongArch] Modify ParserMethod for the simm26_b operand type
Modify the ParserMethod of `simm26_b` operand type to `parseImmediate`.
Before that, for the `simm26_b` operand type, the same ParserMethod
was used as `simm26_bl`. When using the internal assembler to process
the blockaddress with `asm` instruction, the wrong blockaddress symbol
would be generated due to the call to the `getOrCreateSymbol()`
interface.
Differential Revision: https://reviews.llvm.org/D136073
Added:
llvm/test/CodeGen/LoongArch/blockaddress-symbol.ll
Modified:
llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/LoongArch/LoongArchInstrInfo.td b/llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
index 2c1aa3aca68ad..e3ac862bb93e5 100644
--- a/llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
+++ b/llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
@@ -202,24 +202,32 @@ def simm21_lsl2 : Operand<OtherVT> {
let DecoderMethod = "decodeSImmOperand<21, 2>";
}
-// TODO: Need split the ParserMethod/PredicateMethod for call/jump/tailcall.
-def SImm26Operand: AsmOperandClass {
- let Name = "SImm26Operand";
+def SImm26OperandB: AsmOperandClass {
+ let Name = "SImm26OperandB";
+ let PredicateMethod = "isSImm26Operand";
let RenderMethod = "addImmOperands";
let DiagnosticType = "InvalidSImm26Operand";
- let ParserMethod = "parseSImm26Operand";
+ let ParserMethod = "parseImmediate";
}
// A symbol or an imm used in B/PseudoBR.
def simm26_b : Operand<OtherVT> {
- let ParserMatchClass = SImm26Operand;
+ let ParserMatchClass = SImm26OperandB;
let EncoderMethod = "getImmOpValueAsr2";
let DecoderMethod = "decodeSImmOperand<26, 2>";
}
+def SImm26OperandBL: AsmOperandClass {
+ let Name = "SImm26OperandBL";
+ let PredicateMethod = "isSImm26Operand";
+ let RenderMethod = "addImmOperands";
+ let DiagnosticType = "InvalidSImm26Operand";
+ let ParserMethod = "parseSImm26Operand";
+}
+
// A symbol or an imm used in BL/PseudoCALL.
def simm26_bl : Operand<GRLenVT> {
- let ParserMatchClass = SImm26Operand;
+ let ParserMatchClass = SImm26OperandBL;
let EncoderMethod = "getImmOpValueAsr2";
let DecoderMethod = "decodeSImmOperand<26, 2>";
}
diff --git a/llvm/test/CodeGen/LoongArch/blockaddress-symbol.ll b/llvm/test/CodeGen/LoongArch/blockaddress-symbol.ll
new file mode 100644
index 0000000000000..3f0d34ea41f63
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/blockaddress-symbol.ll
@@ -0,0 +1,25 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc --mtriple=loongarch32 < %s | FileCheck %s
+; RUN: llc --mtriple=loongarch64 < %s | FileCheck %s
+; RUN: llc --mtriple=loongarch32 --no-integrated-as < %s | FileCheck %s
+; RUN: llc --mtriple=loongarch64 --no-integrated-as < %s | FileCheck %s
+
+;; This regression test is for ensuring the AsmParser does not use the
+;; getOrCreateSymbol interface to create blockaddress symbols.
+;; Otherwise incorrect symbols will be created:
+;; `.Ltmp0` -> `.Ltmp00`.
+
+define void @operand_block_address() nounwind {
+; CHECK-LABEL: operand_block_address:
+; CHECK: # %bb.0:
+; CHECK-NEXT: #APP
+; CHECK-NEXT: b .Ltmp0
+; CHECK-NEXT: #NO_APP
+; CHECK-NEXT: .Ltmp0: # Block address taken
+; CHECK-NEXT: # %bb.1: # %bb
+; CHECK-NEXT: ret
+ call void asm sideeffect "b $0", "i"(i8* blockaddress(@operand_block_address, %bb))
+ br label %bb
+bb:
+ ret void
+}
More information about the llvm-commits
mailing list