forked from OSchip/llvm-project
				
			[Hexagon] As a size optimization, not lazy extending TPREL or DTPREL variants since they're usually in range.
llvm-svn: 262258
This commit is contained in:
		
							parent
							
								
									53bd9f3d7a
								
							
						
					
					
						commit
						ab9eca4d9f
					
				| 
						 | 
					@ -21,6 +21,7 @@
 | 
				
			||||||
#include "llvm/MC/MCExpr.h"
 | 
					#include "llvm/MC/MCExpr.h"
 | 
				
			||||||
#include "llvm/MC/MCInstrInfo.h"
 | 
					#include "llvm/MC/MCInstrInfo.h"
 | 
				
			||||||
#include "llvm/MC/MCSubtargetInfo.h"
 | 
					#include "llvm/MC/MCSubtargetInfo.h"
 | 
				
			||||||
 | 
					#include "llvm/MC/MCValue.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace llvm {
 | 
					namespace llvm {
 | 
				
			||||||
void HexagonMCInstrInfo::addConstant(MCInst &MI, uint64_t Value,
 | 
					void HexagonMCInstrInfo::addConstant(MCInst &MI, uint64_t Value,
 | 
				
			||||||
| 
						 | 
					@ -426,19 +427,24 @@ bool HexagonMCInstrInfo::isConstExtended(MCInstrInfo const &MCII,
 | 
				
			||||||
           (MCI.getOpcode() != Hexagon::C4_addipc))
 | 
					           (MCI.getOpcode() != Hexagon::C4_addipc))
 | 
				
			||||||
    return false;
 | 
					    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());
 | 
					  assert(!MO.isImm());
 | 
				
			||||||
  if (isa<HexagonMCExpr>(MO.getExpr()) &&
 | 
					  if (isa<HexagonMCExpr>(MO.getExpr()) &&
 | 
				
			||||||
      HexagonMCInstrInfo::mustNotExtend(*MO.getExpr()))
 | 
					      HexagonMCInstrInfo::mustNotExtend(*MO.getExpr()))
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
  int64_t Value;
 | 
					  int64_t Value;
 | 
				
			||||||
  if (!MO.getExpr()->evaluateAsAbsolute(Value))
 | 
					  if (!MO.getExpr()->evaluateAsAbsolute(Value)) {
 | 
				
			||||||
 | 
					    MCValue Value;
 | 
				
			||||||
 | 
					    if (!MO.getExpr()->evaluateAsRelocatable(Value, nullptr, nullptr))
 | 
				
			||||||
      return true;
 | 
					      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 MinValue = HexagonMCInstrInfo::getMinValue(MCII, MCI);
 | 
				
			||||||
  int MaxValue = HexagonMCInstrInfo::getMaxValue(MCII, MCI);
 | 
					  int MaxValue = HexagonMCInstrInfo::getMaxValue(MCII, MCI);
 | 
				
			||||||
  return (MinValue > Value || Value > MaxValue);
 | 
					  return (MinValue > Value || Value > MaxValue);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,8 @@
 | 
				
			||||||
 | 
					# RUN: llvm-mc -arch=hexagon -filetype=obj %s | llvm-objdump -d - | FileCheck %s
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# CHECK-NOT: immext
 | 
				
			||||||
 | 
					r0 = #undefined@TPREL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# CHECK-NOT: immext
 | 
				
			||||||
 | 
					r0 = #undefined@DTPREL
 | 
				
			||||||
		Loading…
	
		Reference in New Issue