From 7c6e42e9273168ba9b1273a1580d569e1bac0e91 Mon Sep 17 00:00:00 2001 From: Jim Grosbach Date: Thu, 21 Jul 2011 23:26:25 +0000 Subject: [PATCH] ARM Asm parser range checking for [0,31] immediates. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135719 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMInstrInfo.td | 1 + lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/Target/ARM/ARMInstrInfo.td b/lib/Target/ARM/ARMInstrInfo.td index 41808c53328..2c26ae01045 100644 --- a/lib/Target/ARM/ARMInstrInfo.td +++ b/lib/Target/ARM/ARMInstrInfo.td @@ -497,6 +497,7 @@ def imm0_15 : Operand, ImmLeaf, ImmLeaf= 0 && Imm < 32; }]>; diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index 5fc78499610..827ad0fb9f9 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -418,6 +418,14 @@ public: int64_t Value = CE->getValue(); return Value >= 0 && Value < 16; } + bool isImm0_31() const { + if (Kind != Immediate) + return false; + const MCConstantExpr *CE = dyn_cast(getImm()); + if (!CE) return false; + int64_t Value = CE->getValue(); + return Value >= 0 && Value < 32; + } bool isImm0_65535() const { if (Kind != Immediate) return false; @@ -672,6 +680,11 @@ public: addExpr(Inst, getImm()); } + void addImm0_31Operands(MCInst &Inst, unsigned N) const { + assert(N == 1 && "Invalid number of operands!"); + addExpr(Inst, getImm()); + } + void addImm0_65535Operands(MCInst &Inst, unsigned N) const { assert(N == 1 && "Invalid number of operands!"); addExpr(Inst, getImm());