mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-14 02:33:53 +00:00
SROA: Use CRTP for OpSplitter to get rid of virtual dispatch and the virtual-dtor warnings that come with it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164140 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4cd56014ae
commit
371d5d86bd
@ -2466,6 +2466,7 @@ private:
|
|||||||
bool visitInstruction(Instruction &I) { return false; }
|
bool visitInstruction(Instruction &I) { return false; }
|
||||||
|
|
||||||
/// \brief Generic recursive split emission class.
|
/// \brief Generic recursive split emission class.
|
||||||
|
template <typename Derived>
|
||||||
class OpSplitter {
|
class OpSplitter {
|
||||||
protected:
|
protected:
|
||||||
/// The builder used to form new instructions.
|
/// The builder used to form new instructions.
|
||||||
@ -2483,11 +2484,9 @@ private:
|
|||||||
/// Initialize the splitter with an insertion point, Ptr and start with a
|
/// Initialize the splitter with an insertion point, Ptr and start with a
|
||||||
/// single zero GEP index.
|
/// single zero GEP index.
|
||||||
OpSplitter(Instruction *InsertionPoint, Value *Ptr)
|
OpSplitter(Instruction *InsertionPoint, Value *Ptr)
|
||||||
: IRB(InsertionPoint), Ptr(Ptr), GEPIndices(1, IRB.getInt32(0)) {}
|
: IRB(InsertionPoint), GEPIndices(1, IRB.getInt32(0)), Ptr(Ptr) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void emitFunc(Type *Ty, Value *&Agg, const Twine &Name) = 0;
|
|
||||||
|
|
||||||
/// \brief Generic recursive split emission routine.
|
/// \brief Generic recursive split emission routine.
|
||||||
///
|
///
|
||||||
/// This method recursively splits an aggregate op (load or store) into
|
/// This method recursively splits an aggregate op (load or store) into
|
||||||
@ -2503,7 +2502,7 @@ private:
|
|||||||
/// whether this is splitting a load or a store respectively.
|
/// whether this is splitting a load or a store respectively.
|
||||||
void emitSplitOps(Type *Ty, Value *&Agg, const Twine &Name) {
|
void emitSplitOps(Type *Ty, Value *&Agg, const Twine &Name) {
|
||||||
if (Ty->isSingleValueType())
|
if (Ty->isSingleValueType())
|
||||||
return emitFunc(Ty, Agg, Name);
|
return static_cast<Derived *>(this)->emitFunc(Ty, Agg, Name);
|
||||||
|
|
||||||
if (ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
|
if (ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
|
||||||
unsigned OldSize = Indices.size();
|
unsigned OldSize = Indices.size();
|
||||||
@ -2539,13 +2538,13 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LoadOpSplitter : public OpSplitter {
|
struct LoadOpSplitter : public OpSplitter<LoadOpSplitter> {
|
||||||
LoadOpSplitter(Instruction *InsertionPoint, Value *Ptr)
|
LoadOpSplitter(Instruction *InsertionPoint, Value *Ptr)
|
||||||
: OpSplitter(InsertionPoint, Ptr) {}
|
: OpSplitter(InsertionPoint, Ptr) {}
|
||||||
|
|
||||||
/// Emit a leaf load of a single value. This is called at the leaves of the
|
/// Emit a leaf load of a single value. This is called at the leaves of the
|
||||||
/// recursive emission to actually load values.
|
/// recursive emission to actually load values.
|
||||||
virtual void emitFunc(Type *Ty, Value *&Agg, const Twine &Name) {
|
void emitFunc(Type *Ty, Value *&Agg, const Twine &Name) {
|
||||||
assert(Ty->isSingleValueType());
|
assert(Ty->isSingleValueType());
|
||||||
// Load the single value and insert it using the indices.
|
// Load the single value and insert it using the indices.
|
||||||
Value *Load = IRB.CreateLoad(IRB.CreateInBoundsGEP(Ptr, GEPIndices,
|
Value *Load = IRB.CreateLoad(IRB.CreateInBoundsGEP(Ptr, GEPIndices,
|
||||||
@ -2571,13 +2570,13 @@ private:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StoreOpSplitter : public OpSplitter {
|
struct StoreOpSplitter : public OpSplitter<StoreOpSplitter> {
|
||||||
StoreOpSplitter(Instruction *InsertionPoint, Value *Ptr)
|
StoreOpSplitter(Instruction *InsertionPoint, Value *Ptr)
|
||||||
: OpSplitter(InsertionPoint, Ptr) {}
|
: OpSplitter(InsertionPoint, Ptr) {}
|
||||||
|
|
||||||
/// Emit a leaf store of a single value. This is called at the leaves of the
|
/// Emit a leaf store of a single value. This is called at the leaves of the
|
||||||
/// recursive emission to actually produce stores.
|
/// recursive emission to actually produce stores.
|
||||||
virtual void emitFunc(Type *Ty, Value *&Agg, const Twine &Name) {
|
void emitFunc(Type *Ty, Value *&Agg, const Twine &Name) {
|
||||||
assert(Ty->isSingleValueType());
|
assert(Ty->isSingleValueType());
|
||||||
// Extract the single value and store it using the indices.
|
// Extract the single value and store it using the indices.
|
||||||
Value *Store = IRB.CreateStore(
|
Value *Store = IRB.CreateStore(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user