From d42c594960de54f2a809de7c40263da1a0d7ba4b Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 5 Aug 2013 22:22:01 +0000 Subject: TargetLowering: Add getVectorIdxTy() function v2 This virtual function can be implemented by targets to specify the type to use for the index operand of INSERT_VECTOR_ELT, EXTRACT_VECTOR_ELT, INSERT_SUBVECTOR, EXTRACT_SUBVECTOR. The default implementation returns the result from TargetLowering::getPointerTy() The previous code was using TargetLowering::getPointerTy() for vector indices, because this is guaranteed to be legal on all targets. However, using TargetLowering::getPointerTy() can be a problem for targets with pointer sizes that differ across address spaces. On such targets, when vectors need to be loaded or stored to an address space other than the default 'zero' address space (which is the address space assumed by TargetLowering::getPointerTy()), having an index that is a different size than the pointer can lead to inefficient pointer calculations, (e.g. 64-bit adds for a 32-bit address space). There is no intended functionality change with this patch. llvm-svn: 187748 --- llvm/include/llvm/Target/TargetLowering.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'llvm/include') diff --git a/llvm/include/llvm/Target/TargetLowering.h b/llvm/include/llvm/Target/TargetLowering.h index 095b1ce155b..69bfe707b7a 100644 --- a/llvm/include/llvm/Target/TargetLowering.h +++ b/llvm/include/llvm/Target/TargetLowering.h @@ -156,6 +156,13 @@ public: EVT getShiftAmountTy(EVT LHSTy) const; + /// Returns the type to be used for the index operand of: + /// ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT, + /// ISD::INSERT_SUBVECTOR, and ISD::EXTRACT_SUBVECTOR + virtual MVT getVectorIdxTy() const { + return getPointerTy(); + } + /// Return true if the select operation is expensive for this target. bool isSelectExpensive() const { return SelectIsExpensive; } -- cgit v1.2.3