[llvm] r262243 - [Hexagon] Setting sign mismatch flag on expression instead of using bit tricks.
Colin LeMahieu via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 29 11:17:57 PST 2016
Author: colinl
Date: Mon Feb 29 13:17:56 2016
New Revision: 262243
URL: http://llvm.org/viewvc/llvm-project?rev=262243&view=rev
Log:
[Hexagon] Setting sign mismatch flag on expression instead of using bit tricks.
Modified:
llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCExpr.cpp
llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCExpr.h
Modified: llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp?rev=262243&r1=262242&r2=262243&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp Mon Feb 29 13:17:56 2016
@@ -361,20 +361,17 @@ public:
void addSignedImmOperands(MCInst &Inst, unsigned N) const {
assert(N == 1 && "Invalid number of operands!");
- MCExpr const *Expr = getImm();
+ HexagonMCExpr *Expr =
+ const_cast<HexagonMCExpr *>(cast<HexagonMCExpr>(getImm()));
int64_t Value;
if (!Expr->evaluateAsAbsolute(Value)) {
Inst.addOperand(MCOperand::createExpr(Expr));
return;
}
- int64_t Extended = SignExtend64 (Value, 32);
- if ((Extended < 0) == (Value < 0)) {
- Inst.addOperand(MCOperand::createExpr(Expr));
- return;
- }
- // Flip bit 33 to signal signed unsigned mismatch
- Extended ^= 0x100000000;
- Inst.addOperand(MCOperand::createImm(Extended));
+ int64_t Extended = SignExtend64(Value, 32);
+ if ((Extended < 0) != (Value < 0))
+ Expr->setSignMismatch();
+ Inst.addOperand(MCOperand::createExpr(Expr));
}
void addf32ExtOperands(MCInst &Inst, unsigned N) const {
@@ -763,17 +760,15 @@ void HexagonAsmParser::canonicalizeImmed
for (MCOperand &I : MCI)
if (I.isImm()) {
int64_t Value (I.getImm());
- if ((Value & 0x100000000) != (Value & 0x80000000)) {
- // Detect flipped bit 33 wrt bit 32 and signal warning
- Value ^= 0x100000000;
- if (WarnSignedMismatch)
- Warning (MCI.getLoc(), "Signed/Unsigned mismatch");
- }
NewInst.addOperand(MCOperand::createExpr(HexagonMCExpr::create(
MCConstantExpr::create(Value, getContext()), getContext())));
}
- else
+ else {
+ if (I.isExpr() && cast<HexagonMCExpr>(I.getExpr())->signMismatch() &&
+ WarnSignedMismatch)
+ Warning (MCI.getLoc(), "Signed/Unsigned mismatch");
NewInst.addOperand(I);
+ }
MCI = NewInst;
}
Modified: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCExpr.cpp?rev=262243&r1=262242&r2=262243&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCExpr.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCExpr.cpp Mon Feb 29 13:17:56 2016
@@ -67,3 +67,11 @@ HexagonMCExpr::HexagonMCExpr(MCExpr cons
void HexagonMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
Expr->print(OS, MAI);
}
+
+void HexagonMCExpr::setSignMismatch(bool Val) {
+ SignMismatch = Val;
+}
+
+bool HexagonMCExpr::signMismatch() const {
+ return SignMismatch;
+}
\ No newline at end of file
Modified: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCExpr.h?rev=262243&r1=262242&r2=262243&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCExpr.h (original)
+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCExpr.h Mon Feb 29 13:17:56 2016
@@ -31,6 +31,8 @@ public:
bool mustNotExtend() const;
void setS23_2_reloc(bool Val = true);
bool s23_2_reloc() const;
+ void setSignMismatch(bool Val = true);
+ bool signMismatch() const;
private:
HexagonMCExpr(MCExpr const *Expr);
@@ -38,6 +40,7 @@ private:
bool MustNotExtend;
bool MustExtend;
bool S23_2_reloc;
+ bool SignMismatch;
};
} // end namespace llvm
More information about the llvm-commits
mailing list