Index: llvm/include/llvm/MC/MCContext.h =================================================================== --- llvm/include/llvm/MC/MCContext.h +++ llvm/include/llvm/MC/MCContext.h @@ -645,6 +645,8 @@ void deallocate(void *Ptr) {} + void reportWarning(SMLoc L, const Twine &Msg); + bool hadError() { return HadError; } void reportError(SMLoc L, const Twine &Msg); // Unrecoverable error has occurred. Display the best diagnostic we can Index: llvm/lib/MC/MCContext.cpp =================================================================== --- llvm/lib/MC/MCContext.cpp +++ llvm/lib/MC/MCContext.cpp @@ -606,6 +606,19 @@ } //===----------------------------------------------------------------------===// +// Warning Reporting +//===----------------------------------------------------------------------===// + +void MCContext::reportWarning(SMLoc Loc, const Twine &Msg) { + // If we have a source manager use it. Otherwise, try using the inline source + // manager. + if (SrcMgr) + SrcMgr->PrintMessage(Loc, SourceMgr::DK_Warning, Msg); + else if (InlineSrcMgr) + InlineSrcMgr->PrintMessage(Loc, SourceMgr::DK_Warning, Msg); +} + +//===----------------------------------------------------------------------===// // Error Reporting //===----------------------------------------------------------------------===// Index: llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp =================================================================== --- llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp +++ llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp @@ -585,6 +585,8 @@ return 0; } +static bool isBinary = false; + unsigned MipsMCCodeEmitter:: getExprOpValue(const MCExpr *Expr, SmallVectorImpl &Fixups, const MCSubtargetInfo &STI) const { @@ -599,6 +601,7 @@ } if (Kind == MCExpr::Binary) { + isBinary = true; unsigned Res = getExprOpValue(cast(Expr)->getLHS(), Fixups, STI); Res += getExprOpValue(cast(Expr)->getRHS(), Fixups, STI); return Res; @@ -722,6 +725,7 @@ } if (Kind == MCExpr::SymbolRef) { + Ctx.reportWarning(Expr->getLoc(), "should use explicit constraints!"); Mips::Fixups FixupKind = Mips::Fixups(0); switch(cast(Expr)->getKind()) { @@ -732,7 +736,12 @@ break; } // switch - Fixups.push_back(MCFixup::create(0, Expr, MCFixupKind(FixupKind))); + if (!STI.getFeatureBits()[Mips::FeatureMips64]) + Fixups.push_back(MCFixup::create(0, Expr, MCFixupKind(FixupKind))); + else { + if (isBinary) + Fixups.push_back(MCFixup::create(0, Expr, MCFixupKind(Mips::fixup_MIPS_PCLO16))); + } return 0; } return 0; @@ -756,6 +765,7 @@ } // MO must be an Expr. assert(MO.isExpr()); + isBinary = false; return getExprOpValue(MO.getExpr(),Fixups, STI); } Index: llvm/test/MC/Mips/reloc-directive-bad-n64.s =================================================================== --- /dev/null +++ llvm/test/MC/Mips/reloc-directive-bad-n64.s @@ -0,0 +1,10 @@ +# RUN: llvm-mc -triple mips64el-unknown-linux < %s -show-encoding \ +# RUN: -target-abi=n64 2>&1 | FileCheck %s + .text + .global main +main: + nop + daddiu $t9, $ra, main - . # CHECK: :[[@LINE]]:25: warning: should use explicit constraints! + daddiu $t9, $ra, main # CHECK: :[[@LINE]]:25: warning: should use explicit constraints! + nop + .word main