From 4badd6aaf30859ce9b89960d8cae2b9ecd1dacca Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Thu, 31 Mar 2016 17:58:55 +0000 Subject: [PATCH] [lanai] isBrImm should accept any non-constant immediate. isBrImm should accept any non-constant immediate. Previously it was only accepting LanaiMCExpr ones which was wrong. Differential Revision: http://reviews.llvm.org/D18571 llvm-svn: 265032 --- llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp | 23 ++++++---------------- llvm/test/MC/Lanai/ctrl-instructions.s | 13 ++++++++++++ 2 files changed, 19 insertions(+), 17 deletions(-) create mode 100644 llvm/test/MC/Lanai/ctrl-instructions.s diff --git a/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp b/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp index 13f8779..8742cc9 100644 --- a/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp +++ b/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp @@ -195,23 +195,12 @@ public: return false; // Constant case - if (const MCConstantExpr *ConstExpr = dyn_cast(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(Value)); - } - - // Symbolic reference expression - if (const LanaiMCExpr *SymbolRefExpr = dyn_cast(Imm.Value)) - return SymbolRefExpr->getKind() == LanaiMCExpr::VK_Lanai_None; - - // Binary expression - if (const MCBinaryExpr *BinaryExpr = dyn_cast(Imm.Value)) - if (const LanaiMCExpr *SymbolRefExpr = - dyn_cast(BinaryExpr->getLHS())) - return SymbolRefExpr->getKind() == LanaiMCExpr::VK_Lanai_None; - - return false; + const MCConstantExpr *MCE = dyn_cast(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(Value)); } bool isBrTarget() { return isBrImm() || isToken(); } diff --git a/llvm/test/MC/Lanai/ctrl-instructions.s b/llvm/test/MC/Lanai/ctrl-instructions.s new file mode 100644 index 0000000..05e7a95 --- /dev/null +++ b/llvm/test/MC/Lanai/ctrl-instructions.s @@ -0,0 +1,13 @@ +// RUN: llvm-mc -triple lanai-unknown-unknown -show-encoding -o - %s | FileCheck %s + +// CHECK: bt .Ltmp0 ! encoding: [0b1110000A,A,A,A] +// CHECK-NEXT: ! fixup A - offset: 0, value: .Ltmp0, kind: FIXUP_LANAI_25 + bt 1f + nop +1: + +// CHECK: bt foo ! encoding: [0b1110000A,A,A,A] +// CHECK-NEXT: ! fixup A - offset: 0, value: foo, kind: FIXUP_LANAI_25 + bt foo + nop + -- 2.7.4