Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp =================================================================== --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -1748,6 +1748,9 @@ tmpInst.addOperand(MCOperand::CreateImm(ImmValue)); Instructions.push_back(tmpInst); } else if ((ImmValue & 0xffffffff) == ImmValue) { + if (!AssemblerOptions.back()->isMacro()) + Warning(IDLoc, "macro instruction expanded into multiple instructions"); + // For all other values which are representable as a 32-bit integer: // li d,j => lui d,hi16(j) // ori d,d,lo16(j) @@ -1764,6 +1767,8 @@ Error(IDLoc, "instruction requires a 32-bit immediate"); return true; } + if (!AssemblerOptions.back()->isMacro()) + Warning(IDLoc, "macro instruction expanded into multiple instructions"); // <------- lo32 ------> // <------- hi32 ------> @@ -1793,6 +1798,8 @@ Error(IDLoc, "instruction requires a 32-bit immediate"); return true; } + if (!AssemblerOptions.back()->isMacro()) + Warning(IDLoc, "macro instruction expanded into multiple instructions"); // <------- hi32 ------> <------- lo32 ------> // <- hi16 -> <- lo16 -> @@ -1856,6 +1863,9 @@ tmpInst.addOperand(MCOperand::CreateImm(ImmValue)); Instructions.push_back(tmpInst); } else { + if (!AssemblerOptions.back()->isMacro()) + Warning(IDLoc, "macro instruction expanded into multiple instructions"); + // For any other value of j that is representable as a 32-bit integer. // la d,j(s) => lui d,hi16(j) // ori d,d,lo16(j) @@ -1903,6 +1913,9 @@ tmpInst.addOperand(MCOperand::CreateImm(ImmValue)); Instructions.push_back(tmpInst); } else { + if (!AssemblerOptions.back()->isMacro()) + Warning(IDLoc, "macro instruction expanded into multiple instructions"); + // For any other value of j that is representable as a 32-bit integer. // la d,j => lui d,hi16(j) // ori d,d,lo16(j) @@ -1923,6 +1936,9 @@ void MipsAsmParser::expandLoadAddressSym(MCInst &Inst, SMLoc IDLoc, SmallVectorImpl &Instructions) { + if (!AssemblerOptions.back()->isMacro()) + Warning(IDLoc, "macro instruction expanded into multiple instructions"); + // FIXME: If we do have a valid at register to use, we should generate a // slightly shorter sequence here. MCInst tmpInst; Index: test/MC/Mips/set-nomacro-micromips.s =================================================================== --- /dev/null +++ test/MC/Mips/set-nomacro-micromips.s @@ -0,0 +1,33 @@ +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -mattr=micromips 2>&1 | FileCheck %s + + .text + .type main, @function + .set micromips +main: +# CHECK-NOT: warning: macro instruction expanded into multiple instructions + .set macro + b 132 + b 1332 + b bar + + lwm $16, $17, 8($sp) + swm $16, $17, 8($sp) + + add $4, $5, $6 + + .set noreorder + .set nomacro + b 132 +# CHECK-NOT: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + b 1332 +# CHECK-NOT: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + b bar +# CHECK-NOT: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + + lwm $16, $17, 8($sp) +# CHECK-NOT: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + swm $16, $17, 8($sp) +# CHECK-NOT: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + + add $4, $5, $6 +# CHECK-NOT: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions Index: test/MC/Mips/set-nomacro.s =================================================================== --- /dev/null +++ test/MC/Mips/set-nomacro.s @@ -0,0 +1,46 @@ +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 2>&1 | FileCheck %s + +# CHECK-NOT: warning: macro instruction expanded into multiple instructions + .set macro + li $8, -16 + li $8, 16 + li $8, 161616 + + la $8, 16 + la $8, 161616 + la $8, 16($9) + la $8, 161616($9) + la $8, symbol + + jal $25 + jal $4, $25 + + add $4, $5, $6 + + .set noreorder + .set nomacro + li $8, -16 +# CHECK-NOT: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + li $8, 16 +# CHECK-NOT: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + li $8, 161616 +# CHECK: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + + la $8, 16 +# CHECK-NOT: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + la $8, 161616 +# CHECK: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + la $8, 16($9) +# CHECK-NOT: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + la $8, 161616($9) +# CHECK: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + la $8, symbol +# CHECK: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + + jal $25 +# CHECK-NOT: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + jal $4, $25 +# CHECK-NOT: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions + + add $4, $5, $6 +# CHECK-NOT: [[@LINE-1]]:3: warning: macro instruction expanded into multiple instructions