[llvm-commits] [llvm] r166593 - in /llvm/trunk: include/llvm/ include/llvm/Target/ lib/Target/ lib/Target/ARM/ lib/Target/CellSPU/ lib/Target/Hexagon/ lib/Target/MBlaze/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/NVPTX/ lib/Target/PowerPC/ lib/Target/Sparc/ lib/Target/X86/ lib/Target/XCore/
Hal Finkel
hfinkel at anl.gov
Wed Oct 24 13:10:35 PDT 2012
----- Original Message -----
> From: "Nadav Rotem" <nrotem at apple.com>
> To: llvm-commits at cs.uiuc.edu
> Sent: Wednesday, October 24, 2012 12:22:41 PM
> Subject: [llvm-commits] [llvm] r166593 - in /llvm/trunk: include/llvm/ include/llvm/Target/ lib/Target/
> lib/Target/ARM/ lib/Target/CellSPU/ lib/Target/Hexagon/ lib/Target/MBlaze/ lib/Target/MSP430/ lib/Target/Mips/
> lib/Target/NVPTX/ lib/Target/PowerPC/ lib/Target/Sparc/ lib/Target/X86/ lib/Target/XCore/
>
> Author: nadav
> Date: Wed Oct 24 12:22:41 2012
> New Revision: 166593
>
> URL: http://llvm.org/viewvc/llvm-project?rev=166593&view=rev
> Log:
> Implement a basic VectorTargetTransformInfo interface to be used by
> the loop and bb vectorizers for modeling the cost of instructions.
>
> Modified:
> llvm/trunk/include/llvm/Target/TargetTransformImpl.h
> llvm/trunk/include/llvm/TargetTransformInfo.h
> llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp
> llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp
> llvm/trunk/lib/Target/Hexagon/HexagonTargetMachine.cpp
> llvm/trunk/lib/Target/MBlaze/MBlazeTargetMachine.cpp
> llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp
> llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp
> llvm/trunk/lib/Target/Mips/MipsTargetMachine.h
> llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.cpp
> llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp
> llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp
> llvm/trunk/lib/Target/TargetTransformImpl.cpp
> llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
> llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp
>
> Modified: llvm/trunk/include/llvm/Target/TargetTransformImpl.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetTransformImpl.h?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Target/TargetTransformImpl.h (original)
> +++ llvm/trunk/include/llvm/Target/TargetTransformImpl.h Wed Oct 24
> 12:22:41 2012
> @@ -47,7 +47,23 @@
> virtual unsigned getJumpBufSize() const;
> };
>
> -class VectorTargetTransformImpl : public VectorTargetTransformInfo {
> };
> +class VectorTargetTransformImpl : public VectorTargetTransformInfo {
> +private:
> + const TargetLowering *TLI;
> +
> +public:
> + explicit VectorTargetTransformImpl(const TargetLowering *TL) :
> TLI(TL) {}
> +
> + virtual ~VectorTargetTransformImpl() {}
> +
> + virtual unsigned getInstrCost(unsigned Opcode, Type *Ty1, Type
> *Ty2) const;
> +
> + virtual unsigned getBroadcastCost(Type *Tp) const;
> +
> + virtual unsigned getMemoryOpCost(unsigned Opcode, Type *Src,
> + unsigned Alignment,
> + unsigned AddressSpace) const;
> +};
>
> } // end llvm namespace
>
>
> Modified: llvm/trunk/include/llvm/TargetTransformInfo.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TargetTransformInfo.h?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/TargetTransformInfo.h (original)
> +++ llvm/trunk/include/llvm/TargetTransformInfo.h Wed Oct 24 12:22:41
> 2012
> @@ -54,10 +54,10 @@
> TargetTransformInfo(const TargetTransformInfo &T) :
> ImmutablePass(ID), STTI(T.STTI), VTTI(T.VTTI) { }
>
> - const ScalarTargetTransformInfo* getScalarTargetTransformInfo() {
> + const ScalarTargetTransformInfo* getScalarTargetTransformInfo()
> const {
> return STTI;
> }
> - const VectorTargetTransformInfo* getVectorTargetTransformInfo() {
> + const VectorTargetTransformInfo* getVectorTargetTransformInfo()
> const {
> return VTTI;
> }
>
> @@ -119,8 +119,43 @@
> }
> };
>
> +/// VectorTargetTransformInfo - This interface is used by the
> vectorizers
> +/// to estimate the profitability of vectorization for different
> instructions.
> class VectorTargetTransformInfo {
> - // TODO: define an interface for VectorTargetTransformInfo.
> +public:
> + virtual ~VectorTargetTransformInfo() {}
> +
> + /// Returns the expected cost of the instruction opcode. The
> opcode is one of
> + /// the enums like Instruction::Add. The type arguments are the
> type of the
> + /// operation.
> + /// Most instructions only use the first type and in that case the
> second
> + /// operand is ignored.
> + ///
> + /// Exceptions:
> + /// * Br instructions do not use any of the types.
> + /// * Select instructions pass the return type as Ty1 and the
> selector as Ty2.
> + /// * Cast instructions pass the destination as Ty1 and the source
> as Ty2.
> + /// * Insert/Extract element pass only the vector type as Ty1.
> + /// * ShuffleVector, Load, Store do not use this call.
Why does ShuffleVector not use this call? Even if it is an over-estimate, I'll need to get the cost of a generic shuffle. Otherwise, I think this looks good.
Thanks again,
Hal
> + virtual unsigned getInstrCost(unsigned Opcode,
> + Type *Ty1 = 0,
> + Type *Ty2 = 0) const {
> + return 1;
> + }
> +
> + /// Returns the cost of a vector broadcast of a scalar at place
> zero to a
> + /// vector of type 'Tp'.
> + virtual unsigned getBroadcastCost(Type *Tp) const {
> + return 1;
> + }
> +
> + /// Returns the cost of Load and Store instructions.
> + virtual unsigned getMemoryOpCost(unsigned Opcode, Type *Src,
> + unsigned Alignment,
> + unsigned AddressSpace) const {
> + return 1;
> + }
> +
> };
>
> } // End llvm namespace
>
> Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Wed Oct 24
> 12:22:41 2012
> @@ -72,7 +72,7 @@
> TLInfo(*this),
> TSInfo(*this),
> FrameLowering(Subtarget),
> - STTI(&TLInfo) {
> + STTI(&TLInfo), VTTI(&TLInfo) {
> if (!Subtarget.hasARMOps())
> report_fatal_error("CPU: '" + Subtarget.getCPUString() + "' does
> not "
> "support ARM mode execution!");
> @@ -106,7 +106,7 @@
> FrameLowering(Subtarget.hasThumb2()
> ? new ARMFrameLowering(Subtarget)
> : (ARMFrameLowering*)new
> Thumb1FrameLowering(Subtarget)),
> - STTI(&TLInfo){
> + STTI(&TLInfo), VTTI(&TLInfo) {
> }
>
> namespace {
>
> Modified: llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/CellSPU/SPUTargetMachine.cpp Wed Oct 24
> 12:22:41 2012
> @@ -44,7 +44,7 @@
> TLInfo(*this),
> TSInfo(*this),
> InstrItins(Subtarget.getInstrItineraryData()),
> - STTI(&TLInfo){
> + STTI(&TLInfo), VTTI(&TLInfo) {
> }
>
> //===----------------------------------------------------------------------===//
>
> Modified: llvm/trunk/lib/Target/Hexagon/HexagonTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonTargetMachine.cpp?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Hexagon/HexagonTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/Hexagon/HexagonTargetMachine.cpp Wed Oct 24
> 12:22:41 2012
> @@ -75,7 +75,7 @@
> TSInfo(*this),
> FrameLowering(Subtarget),
> InstrItins(&Subtarget.getInstrItineraryData()),
> - STTI(&TLInfo) {
> + STTI(&TLInfo), VTTI(&TLInfo) {
> setMCUseCFI(false);
> }
>
>
> Modified: llvm/trunk/lib/Target/MBlaze/MBlazeTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeTargetMachine.cpp?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/MBlaze/MBlazeTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/MBlaze/MBlazeTargetMachine.cpp Wed Oct 24
> 12:22:41 2012
> @@ -42,7 +42,8 @@
> InstrInfo(*this),
> FrameLowering(Subtarget),
> TLInfo(*this), TSInfo(*this), ELFWriterInfo(*this),
> - InstrItins(Subtarget.getInstrItineraryData()), STTI(&TLInfo) {
> + InstrItins(Subtarget.getInstrItineraryData()),
> + STTI(&TLInfo), VTTI(&TLInfo) {
> }
>
> namespace {
>
> Modified: llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp Wed Oct 24
> 12:22:41 2012
> @@ -36,7 +36,7 @@
> // FIXME: Check DataLayout string.
> DL("e-p:16:16:16-i8:8:8-i16:16:16-i32:16:32-n8:16"),
> InstrInfo(*this), TLInfo(*this), TSInfo(*this),
> - FrameLowering(Subtarget), STTI(&TLInfo) { }
> + FrameLowering(Subtarget), STTI(&TLInfo), VTTI(&TLInfo) { }
>
> namespace {
> /// MSP430 Code Generator Pass Configuration Options.
>
> Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp Wed Oct 24
> 12:22:41 2012
> @@ -53,7 +53,7 @@
> InstrInfo(MipsInstrInfo::create(*this)),
> FrameLowering(MipsFrameLowering::create(*this, Subtarget)),
> TLInfo(*this), TSInfo(*this), JITInfo(),
> - ELFWriterInfo(false, isLittle), STTI(&TLInfo) {
> + ELFWriterInfo(false, isLittle), STTI(&TLInfo), VTTI(&TLInfo) {
> }
>
> void MipsebTargetMachine::anchor() { }
>
> Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.h?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MipsTargetMachine.h (original)
> +++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.h Wed Oct 24
> 12:22:41 2012
> @@ -40,7 +40,7 @@
> MipsJITInfo JITInfo;
> MipsELFWriterInfo ELFWriterInfo;
> ScalarTargetTransformImpl STTI;
> - VectorTargetTransformInfo VTTI;
> + VectorTargetTransformImpl VTTI;
>
> public:
> MipsTargetMachine(const Target &T, StringRef TT,
>
> Modified: llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.cpp?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.cpp Wed Oct 24
> 12:22:41 2012
> @@ -73,7 +73,7 @@
> Subtarget(TT, CPU, FS, is64bit),
> DL(Subtarget.getDataLayout()),
> InstrInfo(*this), TLInfo(*this), TSInfo(*this),
> FrameLowering(*this,is64bit),
> - STTI(&TLInfo)
> + STTI(&TLInfo), VTTI(&TLInfo)
> /*FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0)*/ {
> }
>
>
> Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp Wed Oct 24
> 12:22:41 2012
> @@ -44,7 +44,7 @@
> FrameLowering(Subtarget), JITInfo(*this, is64Bit),
> TLInfo(*this), TSInfo(*this),
> InstrItins(Subtarget.getInstrItineraryData()),
> - STTI(&TLInfo){
> + STTI(&TLInfo), VTTI(&TLInfo) {
>
> // The binutils for the BG/P are too old for CFI.
> if (Subtarget.isBGP())
>
> Modified: llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp Wed Oct 24
> 12:22:41 2012
> @@ -36,7 +36,7 @@
> DL(Subtarget.getDataLayout()),
> InstrInfo(Subtarget),
> TLInfo(*this), TSInfo(*this),
> - FrameLowering(Subtarget),STTI(&TLInfo) {
> + FrameLowering(Subtarget), STTI(&TLInfo), VTTI(&TLInfo) {
> }
>
> namespace {
>
> Modified: llvm/trunk/lib/Target/TargetTransformImpl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetTransformImpl.cpp?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/TargetTransformImpl.cpp (original)
> +++ llvm/trunk/lib/Target/TargetTransformImpl.cpp Wed Oct 24 12:22:41
> 2012
> @@ -12,6 +12,12 @@
>
> using namespace llvm;
>
> +//===----------------------------------------------------------------------===//
> +//
> +// Calls used by scalar transformations.
> +//
> +//===----------------------------------------------------------------------===//
> +
> bool ScalarTargetTransformImpl::isLegalAddImmediate(int64_t imm)
> const {
> return TLI->isLegalAddImmediate(imm);
> }
> @@ -41,3 +47,27 @@
> unsigned ScalarTargetTransformImpl::getJumpBufSize() const {
> return TLI->getJumpBufSize();
> }
> +
> +//===----------------------------------------------------------------------===//
> +//
> +// Calls used by the vectorizers.
> +//
> +//===----------------------------------------------------------------------===//
> +
> +unsigned
> +VectorTargetTransformImpl::getInstrCost(unsigned Opcode, Type *Ty1,
> + Type *Ty2) const {
> + return 1;
> +}
> +
> +unsigned
> +VectorTargetTransformImpl::getBroadcastCost(Type *Tp) const {
> + return 1;
> +}
> +
> +unsigned
> +VectorTargetTransformImpl::getMemoryOpCost(unsigned Opcode, Type
> *Src,
> + unsigned Alignment,
> + unsigned AddressSpace)
> const {
> + return 1;
> +}
>
> Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Wed Oct 24
> 12:22:41 2012
> @@ -49,7 +49,7 @@
> TSInfo(*this),
> TLInfo(*this),
> JITInfo(*this),
> - STTI(&TLInfo) {
> + STTI(&TLInfo), VTTI(&TLInfo) {
> }
>
> void X86_64TargetMachine::anchor() { }
> @@ -66,7 +66,7 @@
> TSInfo(*this),
> TLInfo(*this),
> JITInfo(*this),
> - STTI(&TLInfo) {
> + STTI(&TLInfo), VTTI(&TLInfo){
> }
>
> /// X86TargetMachine ctor - Create an X86 target.
>
> Modified: llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp?rev=166593&r1=166592&r2=166593&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp Wed Oct 24
> 12:22:41 2012
> @@ -32,7 +32,7 @@
> InstrInfo(),
> FrameLowering(Subtarget),
> TLInfo(*this),
> - TSInfo(*this), STTI(&TLInfo) {
> + TSInfo(*this), STTI(&TLInfo), VTTI(&TLInfo) {
> }
>
> namespace {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
--
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-commits
mailing list