[PATCH] D18571: [lanai] isBrImm should accept any non-constant immediate.
Jacques Pienaar via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 29 13:34:04 PDT 2016
jpienaar created this revision.
jpienaar added a reviewer: majnemer.
jpienaar added a subscriber: llvm-commits.
Herald added a subscriber: joker.eph.
isBrImm should accept any non-constant immediate. Previously it was only accepting LanaiMCExpr ones which was wrong.
http://reviews.llvm.org/D18571
Files:
lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp
test/CodeGen/Lanai/inlineasm-global.ll
Index: test/CodeGen/Lanai/inlineasm-global.ll
===================================================================
--- test/CodeGen/Lanai/inlineasm-global.ll
+++ test/CodeGen/Lanai/inlineasm-global.ll
@@ -0,0 +1,20 @@
+; RUN: llc < %s -march=lanai | FileCheck %s
+
+; CHECK: bt .Ltmp
+; CHECK: Ltmp
+; CHECK-NEXT: bt f
+
+module asm ".globl start"
+module asm "start:"
+module asm "\09 .space 48,0"
+module asm "\09 bt 1f"
+module asm "\09 nop "
+module asm "1: "
+module asm "\09bt f"
+module asm "\09nop"
+
+; Function Attrs: norecurse nounwind readnone
+define void @f() #0 {
+entry:
+ ret void
+}
Index: lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp
===================================================================
--- lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp
+++ lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp
@@ -195,23 +195,12 @@
return false;
// Constant case
- if (const MCConstantExpr *ConstExpr = dyn_cast<MCConstantExpr>(Imm.Value)) {
- int64_t Value = ConstExpr->getValue();
- // Check if value fits in 25 bits with 2 least significant bits 0.
- return isShiftedUInt<23, 2>(static_cast<int32_t>(Value));
- }
-
- // Symbolic reference expression
- if (const LanaiMCExpr *SymbolRefExpr = dyn_cast<LanaiMCExpr>(Imm.Value))
- return SymbolRefExpr->getKind() == LanaiMCExpr::VK_Lanai_None;
-
- // Binary expression
- if (const MCBinaryExpr *BinaryExpr = dyn_cast<MCBinaryExpr>(Imm.Value))
- if (const LanaiMCExpr *SymbolRefExpr =
- dyn_cast<LanaiMCExpr>(BinaryExpr->getLHS()))
- return SymbolRefExpr->getKind() == LanaiMCExpr::VK_Lanai_None;
-
- return false;
+ const MCConstantExpr *MCE = dyn_cast<MCConstantExpr>(Imm.Value);
+ if (!MCE)
+ return true;
+ int64_t Value = MCE->getValue();
+ // Check if value fits in 25 bits with 2 least significant bits 0.
+ return isShiftedUInt<23, 2>(static_cast<int32_t>(Value));
}
bool isBrTarget() { return isBrImm() || isToken(); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18571.51928.patch
Type: text/x-patch
Size: 1996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160329/a38dcea6/attachment.bin>
More information about the llvm-commits
mailing list