[PATCH] [mips] [IAS] Fix expansion of negative 32-bit immediates for LI/DLI.
Daniel Sanders
daniel.sanders at imgtec.com
Fri May 8 04:01:40 PDT 2015
With a couple corrections it will LGTM
================
Comment at: lib/Target/Mips/AsmParser/MipsAsmParser.cpp:1762
@@ -1761,5 +1761,3 @@
- tmpInst.setOpcode(Mips::LUi);
- tmpInst.addOperand(MCOperand::CreateReg(DstReg));
- tmpInst.addOperand(MCOperand::CreateImm(Bits31To16));
- Instructions.push_back(tmpInst);
+ if (!Is32BitImm && isUInt<32>(ImmValue)) {
+ // For DLI, expand to an ORi instead of a LUi to avoid sign-extending the
----------------
This isn't quite right. You need to check for ``!isInt<32>(ImmValue)``. That way it will use lui+ori except when it really needs to use ori+dslli+ori such as for 0x80000000.
You'll also need a test to cover this once the check is corrected.
================
Comment at: test/MC/Mips/mips64-expansions.s:13-14
@@ -12,3 +12,4 @@
dli $7, 65538
-# CHECK: lui $7, 1 # encoding: [0x01,0x00,0x07,0x3c]
+# CHECK: ori $7, $zero, 1 # encoding: [0x01,0x00,0x07,0x34]
+# CHECK: dsll $7, $7, 16 # encoding: [0x38,0x3c,0x07,0x00]
# CHECK: ori $7, $7, 2 # encoding: [0x02,0x00,0xe7,0x34]
----------------
This was correct before. 0x10002 should use:
lui ..., 0x1
ori ..., ..., 0x2
================
Comment at: test/MC/Mips/mips64-expansions.s:21-22
@@ -19,3 +20,4 @@
dli $9, 0x10000
-# CHECK: lui $9, 1 # encoding: [0x01,0x00,0x09,0x3c]
+# CHECK: ori $9, $zero, 1 # encoding: [0x01,0x00,0x09,0x34]
+# CHECK: dsll $9, $9, 16 # encoding: [0x38,0x4c,0x09,0x00]
# CHECK-NOT: ori $9, $9, 0 # encoding: [0x00,0x00,0x29,0x35]
----------------
This was correct before. 0x10000 should use
lui ..., 0x1
http://reviews.llvm.org/D8662
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list