Remove unused SOAArrayType class and Type::GetSOAType() methods.
This commit is contained in:
23
decl.cpp
23
decl.cpp
@@ -505,29 +505,6 @@ Declarator::GetType(const Type *base, DeclSpecs *ds) const {
|
||||
FATAL("Unexpected decl kind");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Make sure we actually have an array of structs ..
|
||||
const StructType *childStructType =
|
||||
dynamic_cast<const StructType *>(childType);
|
||||
if (childStructType == NULL) {
|
||||
Error(pos, "Illegal to provide soa<%d> qualifier with non-struct "
|
||||
"type \"%s\".", soaWidth, childType->GetString().c_str());
|
||||
return new ArrayType(childType, arraySize == -1 ? 0 : arraySize);
|
||||
}
|
||||
else if ((soaWidth & (soaWidth - 1)) != 0) {
|
||||
Error(pos, "soa<%d> width illegal. Value must be power of two.",
|
||||
soaWidth);
|
||||
return NULL;
|
||||
}
|
||||
else if (arraySize != -1 && (arraySize % soaWidth) != 0) {
|
||||
Error(pos, "soa<%d> width must evenly divide array size %d.",
|
||||
soaWidth, arraySize);
|
||||
return NULL;
|
||||
}
|
||||
return new SOAArrayType(childStructType, arraySize == -1 ? 0 : arraySize,
|
||||
soaWidth);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
216
type.cpp
216
type.cpp
@@ -410,13 +410,6 @@ AtomicType::ResolveUnboundVariability(Variability v) const {
|
||||
}
|
||||
|
||||
|
||||
const Type *
|
||||
AtomicType::GetSOAType(int width) const {
|
||||
Assert(width > 0);
|
||||
return new ArrayType(this, width);
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
AtomicType::GetString() const {
|
||||
std::string ret;
|
||||
@@ -724,13 +717,6 @@ EnumType::GetAsUnboundVariabilityType() const {
|
||||
}
|
||||
|
||||
|
||||
const Type *
|
||||
EnumType::GetSOAType(int width) const {
|
||||
Assert(width > 0);
|
||||
return new ArrayType(this, width);
|
||||
}
|
||||
|
||||
|
||||
const EnumType *
|
||||
EnumType::GetAsConstType() const {
|
||||
if (isConst)
|
||||
@@ -991,13 +977,6 @@ PointerType::ResolveUnboundVariability(Variability v) const {
|
||||
}
|
||||
|
||||
|
||||
const Type *
|
||||
PointerType::GetSOAType(int width) const {
|
||||
FATAL("Unimplemented.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
const PointerType *
|
||||
PointerType::GetAsConstType() const {
|
||||
if (isConst == true)
|
||||
@@ -1283,16 +1262,6 @@ ArrayType::GetAsUnsignedType() const {
|
||||
}
|
||||
|
||||
|
||||
const Type *
|
||||
ArrayType::GetSOAType(int width) const {
|
||||
if (child == NULL) {
|
||||
Assert(m->errorCount > 0);
|
||||
return NULL;
|
||||
}
|
||||
return new ArrayType(child->GetSOAType(width), numElements);
|
||||
}
|
||||
|
||||
|
||||
const ArrayType *
|
||||
ArrayType::GetAsConstType() const {
|
||||
if (child == NULL) {
|
||||
@@ -1476,153 +1445,6 @@ ArrayType::SizeUnsizedArrays(const Type *type, Expr *initExpr) {
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// SOAArrayType
|
||||
|
||||
SOAArrayType::SOAArrayType(const StructType *eltType, int nElem, int sw)
|
||||
: ArrayType(eltType, nElem), soaWidth(sw) {
|
||||
Assert(soaWidth > 0);
|
||||
if (numElements > 0)
|
||||
Assert((numElements % soaWidth) == 0);
|
||||
}
|
||||
|
||||
|
||||
// FIXME: do we need to implement GetBaseType() here to return child->SOAType()?
|
||||
|
||||
const SOAArrayType *
|
||||
SOAArrayType::GetAsVaryingType() const {
|
||||
return new SOAArrayType(dynamic_cast<const StructType *>(child->GetAsVaryingType()),
|
||||
numElements, soaWidth);
|
||||
}
|
||||
|
||||
|
||||
const SOAArrayType *
|
||||
SOAArrayType::GetAsUniformType() const {
|
||||
return new SOAArrayType(dynamic_cast<const StructType *>(child->GetAsUniformType()),
|
||||
numElements, soaWidth);
|
||||
}
|
||||
|
||||
|
||||
const SOAArrayType *
|
||||
SOAArrayType::GetAsUnboundVariabilityType() const {
|
||||
return new SOAArrayType(dynamic_cast<const StructType *>(child->GetAsUnboundVariabilityType()),
|
||||
numElements, soaWidth);
|
||||
}
|
||||
|
||||
const SOAArrayType *
|
||||
SOAArrayType::ResolveUnboundVariability(Variability v) const {
|
||||
const StructType *sc = dynamic_cast<const StructType *>(child->ResolveUnboundVariability(v));
|
||||
Assert(sc != NULL); // ???
|
||||
return new SOAArrayType(sc, numElements, soaWidth);
|
||||
}
|
||||
|
||||
|
||||
const Type *
|
||||
SOAArrayType::GetSOAType(int width) const {
|
||||
return new SOAArrayType(dynamic_cast<const StructType *>(child->GetSOAType(width)),
|
||||
numElements, soaWidth);
|
||||
}
|
||||
|
||||
|
||||
const SOAArrayType *
|
||||
SOAArrayType::GetAsConstType() const {
|
||||
return new SOAArrayType(dynamic_cast<const StructType *>(child->GetAsConstType()),
|
||||
numElements, soaWidth);
|
||||
}
|
||||
|
||||
|
||||
const SOAArrayType *
|
||||
SOAArrayType::GetAsNonConstType() const {
|
||||
return new SOAArrayType(dynamic_cast<const StructType *>(child->GetAsNonConstType()),
|
||||
numElements, soaWidth);
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
SOAArrayType::GetString() const {
|
||||
std::string s;
|
||||
|
||||
char buf[32];
|
||||
sprintf(buf, "soa<%d> ", soaWidth);
|
||||
s += buf;
|
||||
s += GetBaseType()->GetString();
|
||||
|
||||
const ArrayType *at = this;
|
||||
while (at) {
|
||||
char buf[16];
|
||||
if (numElements > 0)
|
||||
sprintf(buf, "%d", at->numElements);
|
||||
else
|
||||
buf[0] = '\0';
|
||||
s += std::string("[") + std::string(buf) + std::string("]");
|
||||
at = dynamic_cast<const ArrayType *>(at->child);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
SOAArrayType::Mangle() const {
|
||||
const Type *t = soaType();
|
||||
return t->Mangle();
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
SOAArrayType::GetCDeclaration(const std::string &name) const {
|
||||
const Type *t = soaType();
|
||||
return t->GetCDeclaration(name);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SOAArrayType::TotalElementCount() const {
|
||||
int sz = numElements / soaWidth;
|
||||
const ArrayType *ct = dynamic_cast<const ArrayType *>(child);
|
||||
if (ct)
|
||||
return sz * ct->TotalElementCount();
|
||||
else
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
LLVM_TYPE_CONST llvm::ArrayType *
|
||||
SOAArrayType::LLVMType(llvm::LLVMContext *ctx) const {
|
||||
if (!child)
|
||||
return NULL;
|
||||
|
||||
const ArrayType *a = soaType();
|
||||
if (!a)
|
||||
return NULL;
|
||||
return a->LLVMType(ctx);
|
||||
}
|
||||
|
||||
|
||||
llvm::DIType
|
||||
SOAArrayType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
if (!child)
|
||||
return llvm::DIType();
|
||||
|
||||
const Type *t = soaType();
|
||||
return t->GetDIType(scope);
|
||||
}
|
||||
|
||||
|
||||
SOAArrayType *
|
||||
SOAArrayType::GetSizedArray(int size) const {
|
||||
if ((size % soaWidth) != 0)
|
||||
return NULL;
|
||||
return new SOAArrayType(dynamic_cast<const StructType *>(child), size, soaWidth);
|
||||
}
|
||||
|
||||
|
||||
const ArrayType *
|
||||
SOAArrayType::soaType() const {
|
||||
const Type *childSOA = child->GetSOAType(soaWidth);
|
||||
return new ArrayType(childSOA, numElements / soaWidth);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// VectorType
|
||||
|
||||
@@ -1699,13 +1521,6 @@ VectorType::ResolveUnboundVariability(Variability v) const {
|
||||
}
|
||||
|
||||
|
||||
const Type *
|
||||
VectorType::GetSOAType(int width) const {
|
||||
// FIXME: is this right??
|
||||
return new ArrayType(this, width);
|
||||
}
|
||||
|
||||
|
||||
const VectorType *
|
||||
VectorType::GetAsConstType() const {
|
||||
return new VectorType(base->GetAsConstType(), numElements);
|
||||
@@ -1920,20 +1735,6 @@ StructType::ResolveUnboundVariability(Variability v) const {
|
||||
}
|
||||
|
||||
|
||||
const Type *
|
||||
StructType::GetSOAType(int width) const {
|
||||
std::vector<const Type *> et;
|
||||
// The SOA version of a structure is just a structure that holds SOAed
|
||||
// versions of its elements
|
||||
for (int i = 0; i < GetElementCount(); ++i) {
|
||||
const Type *t = GetElementType(i);
|
||||
et.push_back(t->GetSOAType(width));
|
||||
}
|
||||
return new StructType(name, et, elementNames, elementPositions,
|
||||
isConst, variability, pos);
|
||||
}
|
||||
|
||||
|
||||
const StructType *
|
||||
StructType::GetAsConstType() const {
|
||||
if (IsConstType())
|
||||
@@ -2248,16 +2049,6 @@ ReferenceType::ResolveUnboundVariability(Variability v) const {
|
||||
}
|
||||
|
||||
|
||||
const Type *
|
||||
ReferenceType::GetSOAType(int width) const {
|
||||
if (targetType == NULL) {
|
||||
Assert(m->errorCount > 0);
|
||||
return NULL;
|
||||
}
|
||||
return new ReferenceType(targetType->GetSOAType(width));
|
||||
}
|
||||
|
||||
|
||||
const ReferenceType *
|
||||
ReferenceType::GetAsConstType() const {
|
||||
if (targetType == NULL) {
|
||||
@@ -2483,13 +2274,6 @@ FunctionType::ResolveUnboundVariability(Variability v) const {
|
||||
}
|
||||
|
||||
|
||||
const Type *
|
||||
FunctionType::GetSOAType(int width) const {
|
||||
FATAL("FunctionType::GetSOAType shouldn't be called");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
const Type *
|
||||
FunctionType::GetAsConstType() const {
|
||||
FATAL("FunctionType::GetAsConstType shouldn't be called");
|
||||
|
||||
79
type.h
79
type.h
@@ -129,10 +129,6 @@ public:
|
||||
For all other types, just returns its own type. */
|
||||
virtual const Type *GetReferenceTarget() const;
|
||||
|
||||
/** Return a new type representing the current type laid out in
|
||||
width-wide SOA (structure of arrays) format. */
|
||||
virtual const Type *GetSOAType(int width) const = 0;
|
||||
|
||||
/** Get a const version of this type. If it's already const, then the old
|
||||
Type pointer is returned. */
|
||||
virtual const Type *GetAsConstType() const = 0;
|
||||
@@ -225,7 +221,6 @@ public:
|
||||
const AtomicType *GetAsUnboundVariabilityType() const;
|
||||
const AtomicType *ResolveUnboundVariability(Variability v) const;
|
||||
const AtomicType *GetAsUnsignedType() const;
|
||||
const Type *GetSOAType(int width) const;
|
||||
const AtomicType *GetAsConstType() const;
|
||||
const AtomicType *GetAsNonConstType() const;
|
||||
|
||||
@@ -315,7 +310,6 @@ public:
|
||||
const EnumType *GetAsUniformType() const;
|
||||
const EnumType *GetAsUnboundVariabilityType() const;
|
||||
const EnumType *ResolveUnboundVariability(Variability v) const;
|
||||
const Type *GetSOAType(int width) const;
|
||||
const EnumType *GetAsConstType() const;
|
||||
const EnumType *GetAsNonConstType() const;
|
||||
|
||||
@@ -370,7 +364,6 @@ public:
|
||||
const PointerType *GetAsUniformType() const;
|
||||
const PointerType *GetAsUnboundVariabilityType() const;
|
||||
const PointerType *ResolveUnboundVariability(Variability v) const;
|
||||
const Type *GetSOAType(int width) const;
|
||||
const PointerType *GetAsConstType() const;
|
||||
const PointerType *GetAsNonConstType() const;
|
||||
|
||||
@@ -466,7 +459,6 @@ public:
|
||||
const ArrayType *ResolveUnboundVariability(Variability v) const;
|
||||
|
||||
const ArrayType *GetAsUnsignedType() const;
|
||||
const Type *GetSOAType(int width) const;
|
||||
const ArrayType *GetAsConstType() const;
|
||||
const ArrayType *GetAsNonConstType() const;
|
||||
|
||||
@@ -497,7 +489,6 @@ public:
|
||||
static const Type *SizeUnsizedArrays(const Type *type, Expr *initExpr);
|
||||
|
||||
private:
|
||||
friend class SOAArrayType;
|
||||
/** Type of the elements of the array. */
|
||||
const Type * const child;
|
||||
/** Number of elements in the array. */
|
||||
@@ -505,72 +496,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
/** @brief "Structure of arrays" array type.
|
||||
|
||||
This type represents an array with elements of a structure type,
|
||||
"SOA-ized" to some width w. This corresponds to replicating the struct
|
||||
element types w times and then having an array of size/w of these
|
||||
widened structs. This memory layout often makes it possible to access
|
||||
data with regular vector loads, rather than gathers that are needed
|
||||
with "AOS" (array of structures) layout.
|
||||
|
||||
@todo Native support for SOA stuff is still a work in progres...
|
||||
*/
|
||||
class SOAArrayType : public ArrayType {
|
||||
public:
|
||||
/**
|
||||
SOAType constructor.
|
||||
|
||||
@param elementType Type of the array elements. Must be a StructType.
|
||||
@param numElements Total number of elements in the array. This
|
||||
parameter may be zero, in which case this is an
|
||||
"unsized" array type. (Arrays of specific size
|
||||
can be converted to unsized arrays to be passed
|
||||
to functions that take array parameters, for
|
||||
example).
|
||||
@param soaWidth If non-zero, this gives the SOA width to use in
|
||||
laying out the array data in memory. (This value
|
||||
must be a power of two). For example, if the
|
||||
array's element type is:
|
||||
<tt>struct { uniform float x, y, z; }</tt>,
|
||||
the SOA width is four, and the number of elements
|
||||
is 12, then the array will be laid out in memory
|
||||
as xxxxyyyyzzzzxxxxyyyyzzzzxxxxyyyyzzzz.
|
||||
*/
|
||||
SOAArrayType(const StructType *elementType, int numElements,
|
||||
int soaWidth);
|
||||
|
||||
const SOAArrayType *GetAsVaryingType() const;
|
||||
const SOAArrayType *GetAsUniformType() const;
|
||||
const SOAArrayType *GetAsUnboundVariabilityType() const;
|
||||
const SOAArrayType *ResolveUnboundVariability(Variability v) const;
|
||||
|
||||
const Type *GetSOAType(int width) const;
|
||||
const SOAArrayType *GetAsConstType() const;
|
||||
const SOAArrayType *GetAsNonConstType() const;
|
||||
|
||||
std::string GetString() const;
|
||||
std::string Mangle() const;
|
||||
std::string GetCDeclaration(const std::string &name) const;
|
||||
|
||||
int TotalElementCount() const;
|
||||
|
||||
LLVM_TYPE_CONST llvm::ArrayType *LLVMType(llvm::LLVMContext *ctx) const;
|
||||
llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
|
||||
|
||||
SOAArrayType *GetSizedArray(int size) const;
|
||||
|
||||
private:
|
||||
/** This member variable records the rate at which the structure
|
||||
elements are replicated. */
|
||||
const int soaWidth;
|
||||
|
||||
/** Returns a regular ArrayType with the struct type's elements widened
|
||||
out and with correspondingly fewer array elements. */
|
||||
const ArrayType *soaType() const;
|
||||
};
|
||||
|
||||
|
||||
/** @brief A (short) vector of atomic types.
|
||||
|
||||
VectorType is used to represent a fixed-size array of elements of an
|
||||
@@ -600,7 +525,6 @@ public:
|
||||
const VectorType *GetAsUnboundVariabilityType() const;
|
||||
const VectorType *ResolveUnboundVariability(Variability v) const;
|
||||
|
||||
const Type *GetSOAType(int width) const;
|
||||
const VectorType *GetAsConstType() const;
|
||||
const VectorType *GetAsNonConstType() const;
|
||||
|
||||
@@ -650,7 +574,6 @@ public:
|
||||
const StructType *GetAsUnboundVariabilityType() const;
|
||||
const StructType *ResolveUnboundVariability(Variability v) const;
|
||||
|
||||
const Type *GetSOAType(int width) const;
|
||||
const StructType *GetAsConstType() const;
|
||||
const StructType *GetAsNonConstType() const;
|
||||
|
||||
@@ -728,7 +651,6 @@ public:
|
||||
const ReferenceType *GetAsUnboundVariabilityType() const;
|
||||
const ReferenceType *ResolveUnboundVariability(Variability v) const;
|
||||
|
||||
const Type *GetSOAType(int width) const;
|
||||
const ReferenceType *GetAsConstType() const;
|
||||
const ReferenceType *GetAsNonConstType() const;
|
||||
|
||||
@@ -780,7 +702,6 @@ public:
|
||||
const Type *GetAsUnboundVariabilityType() const;
|
||||
const FunctionType *ResolveUnboundVariability(Variability v) const;
|
||||
|
||||
const Type *GetSOAType(int width) const;
|
||||
const Type *GetAsConstType() const;
|
||||
const Type *GetAsNonConstType() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user