[llvm] r215240 - Allow large immediates for branch instructions in 32bit mode.
Joerg Sonnenberger
joerg at bec.de
Fri Aug 8 13:57:59 PDT 2014
Author: joerg
Date: Fri Aug 8 15:57:58 2014
New Revision: 215240
URL: http://llvm.org/viewvc/llvm-project?rev=215240&view=rev
Log:
Allow large immediates for branch instructions in 32bit mode.
Added:
llvm/trunk/test/MC/PowerPC/ppc32-ba.s
Modified:
llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
Modified: llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp?rev=215240&r1=215239&r2=215240&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp Fri Aug 8 15:57:58 2014
@@ -432,9 +432,23 @@ public:
bool isS17Imm() const { return Kind == Expression ||
(Kind == Immediate && isInt<17>(getImm())); }
bool isTLSReg() const { return Kind == TLSRegister; }
- bool isDirectBr() const { return Kind == Expression ||
- (Kind == Immediate && isInt<26>(getImm()) &&
- (getImm() & 3) == 0); }
+ bool isDirectBr() const {
+ if (Kind == Expression)
+ return true;
+ if (Kind != Immediate)
+ return false;
+ // Operand must be 64-bit aligned, signed 27-bit immediate.
+ if ((getImm() & 3) != 0)
+ return false;
+ if (isInt<26>(getImm()))
+ return true;
+ if (!IsPPC64) {
+ // In 32-bit mode, large 32-bit quantities wrap around.
+ if (isUInt<32>(getImm()) && isInt<26>(static_cast<int32_t>(getImm())))
+ return true;
+ }
+ return false;
+ }
bool isCondBr() const { return Kind == Expression ||
(Kind == Immediate && isInt<16>(getImm()) &&
(getImm() & 3) == 0); }
Added: llvm/trunk/test/MC/PowerPC/ppc32-ba.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/PowerPC/ppc32-ba.s?rev=215240&view=auto
==============================================================================
--- llvm/trunk/test/MC/PowerPC/ppc32-ba.s (added)
+++ llvm/trunk/test/MC/PowerPC/ppc32-ba.s Fri Aug 8 15:57:58 2014
@@ -0,0 +1,6 @@
+# RUN: llvm-mc -triple powerpc-unknown-unknown --show-encoding %s | FileCheck %s
+
+# Check that large immediates in 32bit mode are accepted.
+
+# CHECK: ba -33554432 # encoding: [0x4a,0x00,0x00,0x02]
+ ba 0xfe000000
More information about the llvm-commits
mailing list