llvm.org GIT mirror llvm / 1372b02
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265032 91177308-0d34-0410-b5e6-96231b3b80d8 Jacques Pienaar 4 years ago
2 changed file(s) with 19 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
194194 return false;
195195
196196 // Constant case
197 if (const MCConstantExpr *ConstExpr = dyn_cast(Imm.Value)) {
198 int64_t Value = ConstExpr->getValue();
199 // Check if value fits in 25 bits with 2 least significant bits 0.
200 return isShiftedUInt<23, 2>(static_cast(Value));
201 }
202
203 // Symbolic reference expression
204 if (const LanaiMCExpr *SymbolRefExpr = dyn_cast(Imm.Value))
205 return SymbolRefExpr->getKind() == LanaiMCExpr::VK_Lanai_None;
206
207 // Binary expression
208 if (const MCBinaryExpr *BinaryExpr = dyn_cast(Imm.Value))
209 if (const LanaiMCExpr *SymbolRefExpr =
210 dyn_cast(BinaryExpr->getLHS()))
211 return SymbolRefExpr->getKind() == LanaiMCExpr::VK_Lanai_None;
212
213 return false;
197 const MCConstantExpr *MCE = dyn_cast(Imm.Value);
198 if (!MCE)
199 return true;
200 int64_t Value = MCE->getValue();
201 // Check if value fits in 25 bits with 2 least significant bits 0.
202 return isShiftedUInt<23, 2>(static_cast(Value));
214203 }
215204
216205 bool isBrTarget() { return isBrImm() || isToken(); }
0 // RUN: llvm-mc -triple lanai-unknown-unknown -show-encoding -o - %s | FileCheck %s
1
2 // CHECK: bt .Ltmp0 ! encoding: [0b1110000A,A,A,A]
3 // CHECK-NEXT: ! fixup A - offset: 0, value: .Ltmp0, kind: FIXUP_LANAI_25
4 bt 1f
5 nop
6 1:
7
8 // CHECK: bt foo ! encoding: [0b1110000A,A,A,A]
9 // CHECK-NEXT: ! fixup A - offset: 0, value: foo, kind: FIXUP_LANAI_25
10 bt foo
11 nop
12