diff options
author | Colin LeMahieu <colinl@codeaurora.org> | 2016-02-29 21:21:56 +0000 |
---|---|---|
committer | Colin LeMahieu <colinl@codeaurora.org> | 2016-02-29 21:21:56 +0000 |
commit | ab9eca4d9fabfae3e78afe785fb8f6a061b4095c (patch) | |
tree | b7b950b52fbc8558835bb033e71fac80f93bbdbe /llvm/lib/Target/Hexagon | |
parent | 53bd9f3d7a21b56389f93972e8d291cf3542684e (diff) | |
download | bcm5719-llvm-ab9eca4d9fabfae3e78afe785fb8f6a061b4095c.tar.gz bcm5719-llvm-ab9eca4d9fabfae3e78afe785fb8f6a061b4095c.zip |
[Hexagon] As a size optimization, not lazy extending TPREL or DTPREL variants since they're usually in range.
llvm-svn: 262258
Diffstat (limited to 'llvm/lib/Target/Hexagon')
-rw-r--r-- | llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp index 220db3a9a82..bfd4e5f54f8 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp @@ -21,6 +21,7 @@ #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCSubtargetInfo.h" +#include "llvm/MC/MCValue.h" namespace llvm { void HexagonMCInstrInfo::addConstant(MCInst &MI, uint64_t Value, @@ -426,19 +427,24 @@ bool HexagonMCInstrInfo::isConstExtended(MCInstrInfo const &MCII, (MCI.getOpcode() != Hexagon::C4_addipc)) return false; - // We could be using an instruction with an extendable immediate and shoehorn - // a global address into it. If it is a global address it will be constant - // extended. We do this for COMBINE. - // We currently only handle isGlobal() because it is the only kind of - // object we are going to end up with here for now. - // In the future we probably should add isSymbol(), etc. assert(!MO.isImm()); if (isa<HexagonMCExpr>(MO.getExpr()) && HexagonMCInstrInfo::mustNotExtend(*MO.getExpr())) return false; int64_t Value; - if (!MO.getExpr()->evaluateAsAbsolute(Value)) - return true; + if (!MO.getExpr()->evaluateAsAbsolute(Value)) { + MCValue Value; + if (!MO.getExpr()->evaluateAsRelocatable(Value, nullptr, nullptr)) + return true; + switch(Value.getAccessVariant()) { + case MCSymbolRefExpr::VariantKind::VK_TPREL: + case MCSymbolRefExpr::VariantKind::VK_DTPREL: + // Don't lazy extend these expression variants + return false; + default: + return true; + } + } int MinValue = HexagonMCInstrInfo::getMinValue(MCII, MCI); int MaxValue = HexagonMCInstrInfo::getMaxValue(MCII, MCI); return (MinValue > Value || Value > MaxValue); |