Change the codegen Cost Model API for shuffeles. This patch removes the API for broadcast and adds a more general API that accepts an enum of known shuffles.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171022 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nadav Rotem 2012-12-24 08:57:47 +00:00
parent 3a19999413
commit daf7b5c8f2
3 changed files with 10 additions and 5 deletions

View File

@ -71,7 +71,7 @@ public:
virtual unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty) const; virtual unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty) const;
virtual unsigned getBroadcastCost(Type *Tp) const; virtual unsigned getShuffleCost(ShuffleKind Kind, Type *Tp) const;
virtual unsigned getCastInstrCost(unsigned Opcode, Type *Dst, virtual unsigned getCastInstrCost(unsigned Opcode, Type *Dst,
Type *Src) const; Type *Src) const;

View File

@ -157,14 +157,18 @@ class VectorTargetTransformInfo {
public: public:
virtual ~VectorTargetTransformInfo() {} virtual ~VectorTargetTransformInfo() {}
enum ShuffleKind {
Broadcast, // Broadcast element 0 to all other elements.
Reverse // Reverse the order of the vector.
};
/// Returns the expected cost of arithmetic ops, such as mul, xor, fsub, etc. /// Returns the expected cost of arithmetic ops, such as mul, xor, fsub, etc.
virtual unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty) const { virtual unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty) const {
return 1; return 1;
} }
/// Returns the cost of a vector broadcast of a scalar at place zero to a /// Returns the cost of a shuffle instruction of kind Kind and of type Tp.
/// vector of type 'Tp'. virtual unsigned getShuffleCost(ShuffleKind Kind, Type *Tp) const {
virtual unsigned getBroadcastCost(Type *Tp) const {
return 1; return 1;
} }

View File

@ -208,7 +208,8 @@ unsigned VectorTargetTransformImpl::getArithmeticInstrCost(unsigned Opcode,
return 1; return 1;
} }
unsigned VectorTargetTransformImpl::getBroadcastCost(Type *Tp) const { unsigned VectorTargetTransformImpl::getShuffleCost(ShuffleKind Kind,
Type *Tp) const {
return 1; return 1;
} }