44 #include <llvm/BinaryFormat/Dwarf.h> 45 #include <llvm/IR/DIBuilder.h> 46 #include <llvm/IR/DebugInfo.h> 47 #include <llvm/IR/Module.h> 48 #include <llvm/IR/Value.h> 49 #include <llvm/Support/MathExtras.h> 62 else if (name[0] !=
'_' && name[0] !=
'$')
65 return (name.size() == 1) || (name[1] !=
'_');
72 llvm::Metadata *sub =
m->
diBuilder->getOrCreateSubrange(0, count);
73 std::vector<llvm::Metadata *> subs;
75 llvm::DINodeArray subArray =
m->
diBuilder->getOrCreateArray(subs);
76 uint64_t size = eltType->getSizeInBits() * count;
77 uint64_t align = eltType->getAlignInBits();
79 return m->
diBuilder->createArrayType(size, align, eltType, subArray);
93 snprintf(buf,
sizeof(buf),
"soa<%d>",
soaWidth);
94 return std::string(buf);
99 FATAL(
"Unhandled variability");
112 snprintf(buf,
sizeof(buf),
"soa<%d>",
soaWidth);
113 return std::string(buf);
116 FATAL(
"Unbound unexpected in Variability::MangleString()");
118 FATAL(
"Unhandled variability");
202 FATAL(
"Unexpected basicType in GetAsUnsignedType()");
271 FATAL(
"Unhandled mask width");
322 ret +=
"unsigned int8";
328 ret +=
"unsigned int16";
334 ret +=
"unsigned int32";
343 ret +=
"unsigned int64";
349 FATAL(
"Logic error in AtomicType::GetString()");
398 FATAL(
"Logic error in AtomicType::Mangle()");
450 FATAL(
"Logic error in AtomicType::GetCDeclaration()");
474 if (isUniform || isVarying) {
477 return llvm::Type::getVoidTy(*ctx);
500 FATAL(
"logic error in lGetAtomicLLVMType");
521 return m->
diBuilder->createBasicType(
"bool", 32 , llvm::dwarf::DW_ATE_unsigned);
524 return m->
diBuilder->createBasicType(
"int8", 8 , llvm::dwarf::DW_ATE_signed);
527 return m->
diBuilder->createBasicType(
"uint8", 8 , llvm::dwarf::DW_ATE_unsigned);
530 return m->
diBuilder->createBasicType(
"int16", 16 , llvm::dwarf::DW_ATE_signed);
533 return m->
diBuilder->createBasicType(
"uint16", 16 , llvm::dwarf::DW_ATE_unsigned);
536 return m->
diBuilder->createBasicType(
"int32", 32 , llvm::dwarf::DW_ATE_signed);
539 return m->
diBuilder->createBasicType(
"uint32", 32 , llvm::dwarf::DW_ATE_unsigned);
542 return m->
diBuilder->createBasicType(
"float", 32 , llvm::dwarf::DW_ATE_float);
545 return m->
diBuilder->createBasicType(
"double", 64 , llvm::dwarf::DW_ATE_float);
548 return m->
diBuilder->createBasicType(
"int64", 64 , llvm::dwarf::DW_ATE_signed);
551 return m->
diBuilder->createBasicType(
"uint64", 64 , llvm::dwarf::DW_ATE_unsigned);
555 FATAL(
"unhandled basic type in AtomicType::GetDIType()");
563 llvm::DINodeArray subArray =
m->
diBuilder->getOrCreateArray(sub);
567 return m->
diBuilder->createVectorType(size, align, unifType, subArray);
693 ret += std::string(
"enum_5B_") +
name + std::string(
"_5D_");
708 ret += std::string(
" ") +
name;
718 snprintf(buf,
sizeof(buf),
"[%d]", vWidth);
738 FATAL(
"Unexpected variability in EnumType::LLVMType()");
745 std::vector<llvm::Metadata *> enumeratorDescriptors;
746 for (
unsigned int i = 0; i <
enumerators.size(); ++i) {
747 unsigned int enumeratorValue;
749 int count =
enumerators[i]->constValue->GetValues(&enumeratorValue);
753 enumeratorDescriptors.push_back(descriptor);
756 llvm::DINodeArray elementArray =
m->
diBuilder->getOrCreateArray(enumeratorDescriptors);
758 llvm::DIType *underlyingType = AtomicType::UniformInt32->
GetDIType(scope);
759 llvm::DIType *diType =
761 32 , elementArray, underlyingType,
name);
768 llvm::DINodeArray subArray =
m->
diBuilder->getOrCreateArray(sub);
772 return m->
diBuilder->createVectorType(size, align, diType, subArray);
778 FATAL(
"Unexpected variability in EnumType::GetDIType()");
905 ret += std::string(
" * ");
911 ret +=
"/*frozen*/ ";
948 bool baseIsFunction = (CastType<FunctionType>(
baseType) != NULL);
950 std::string tempName;
951 if (baseIsBasicVarying || baseIsFunction)
952 tempName += std::string(
"(");
953 tempName += std::string(
" *");
955 tempName +=
" const";
956 tempName += std::string(
" ");
958 if (baseIsBasicVarying || baseIsFunction)
959 tempName += std::string(
")");
962 if (!baseIsFunction) {
973 if (baseIsBasicVarying) {
976 snprintf(buf,
sizeof(buf),
"[%d]", vWidth);
990 llvm::Type *types[2];
1004 FATAL(
"unexpected variability for slice pointer in " 1005 "PointerType::LLVMType");
1008 llvm::ArrayRef<llvm::Type *> typesArrayRef = llvm::ArrayRef<llvm::Type *>(types, 2);
1009 return llvm::StructType::get(*
g->
ctx, typesArrayRef);
1014 llvm::Type *ptype = NULL;
1035 FATAL(
"Unexpected variability in PointerType::LLVMType()");
1047 int ptrAlignBits = bitsSize;
1050 return m->
diBuilder->createPointerType(diTargetType, bitsSize, ptrAlignBits);
1053 llvm::DIDerivedType *eltType =
m->
diBuilder->createPointerType(diTargetType, bitsSize, ptrAlignBits);
1061 FATAL(
"Unexpected variability in PointerType::GetDIType()");
1081 if (
child == NULL) {
1110 const ArrayType *at = CastType<ArrayType>(type);
1114 at = CastType<ArrayType>(type);
1120 if (
child == NULL) {
1128 if (
child == NULL) {
1136 if (
child == NULL) {
1144 if (
child == NULL) {
1152 if (
child == NULL) {
1160 if (
child == NULL) {
1168 if (
child == NULL) {
1176 if (
child == NULL) {
1202 snprintf(buf,
sizeof(buf),
"%d", at->
numElements);
1205 s += std::string(
"[") + std::string(buf) + std::string(
"]");
1206 at = CastType<ArrayType>(at->
child);
1212 if (
child == NULL) {
1223 return s +
"_5B_" + buf +
"_5D_";
1244 snprintf(buf,
sizeof(buf),
"%d", at->
numElements);
1247 s += std::string(
"[") + std::string(buf) + std::string(
"]");
1248 at = CastType<ArrayType>(at->
child);
1253 snprintf(buf,
sizeof(buf),
"[%d]", soaWidth);
1259 snprintf(buf,
sizeof(buf),
"[%d]", vWidth);
1275 if (
child == NULL) {
1289 const ArrayType *at = CastType<ArrayType>(type);
1293 ExprList *exprList = llvm::dyn_cast_or_null<ExprList>(initExpr);
1294 if (exprList == NULL || exprList->
exprs.size() == 0)
1301 at = CastType<ArrayType>(type);
1308 ExprList *nextList = llvm::dyn_cast_or_null<ExprList>(exprList->
exprs[0]);
1309 if (nextList == NULL)
1313 const ArrayType *nextArrayType = CastType<ArrayType>(nextType);
1320 unsigned int nextSize = nextList->exprs.size();
1321 for (
unsigned int i = 1; i < exprList->
exprs.size(); ++i) {
1322 if (exprList->
exprs[i] == NULL) {
1328 ExprList *el = llvm::dyn_cast_or_null<ExprList>(exprList->
exprs[i]);
1329 if (el == NULL || el->
exprs.size() != nextSize) {
1331 "Inconsistent initializer expression list lengths " 1332 "make it impossible to size unsized array dimensions.");
1399 return s + std::string(buf);
1405 snprintf(buf,
sizeof(buf),
"_3C_%d_3E_",
numElements);
1406 return s + std::string(buf);
1413 return s + std::string(buf) +
" " + name;
1451 return llvm::ArrayType::get(bt, numElements);
1453 FATAL(
"Unexpected variability in lGetVectorLLVMType()");
1471 llvm::DINodeArray subArray =
m->
diBuilder->getOrCreateArray(sub);
1472 uint64_t sizeBits = eltType->getSizeInBits() *
numElements;
1473 uint64_t align = eltType->getAlignInBits();
1481 return m->
diBuilder->createVectorType(sizeBits, align, eltType, subArray);
1486 FATAL(
"Unexpected variability in VectorType::GetDIType()");
1510 int nextPow2 = llvm::NextPowerOf2(
numElements - 1);
1513 FATAL(
"VectorType SOA getVectorMemoryCount");
1516 FATAL(
"Unexpected variability in VectorType::getVectorMemoryCount()");
1548 switch (variability.
type) {
1556 snprintf(buf,
sizeof(buf),
"_soa%d_", variability.
soaWidth);
1560 FATAL(
"Unexpected variability in lMangleStructName()");
1569 const llvm::SmallVector<std::string, 8> &en,
const llvm::SmallVector<SourcePos, 8> &ep,
bool ic,
1572 isConst(ic), pos(p) {
1584 if (
name ==
"" ||
name[0] ==
'$') {
1586 static int count = 0;
1587 snprintf(buf,
sizeof(buf),
"$anon%d", count);
1588 name = std::string(buf);
1602 if (nElements == 0) {
1605 for (
int i = 0; i < nElements; ++i) {
1610 }
else if (CastType<FunctionType>(type) != NULL) {
1621 llvm::StructType *st = llvm::StructType::create(*
g->
ctx, elementTypes, mname);
1660 const StructType *st = CastType<StructType>(t);
1753 if (
name[0] ==
'$') {
1755 ret += std::string(
"struct { ") +
name;
1756 for (
unsigned int i = 0; i <
elementTypes.size(); ++i) {
1783 ret += name + std::string(
"_5D_");
1795 ret += std::string(
" ") + n;
1822 auto &dataLayout =
m->
module->getDataLayout();
1823 auto layout = dataLayout.getStructLayout(llvm::dyn_cast_or_null<llvm::StructType>(llvm_type));
1824 std::vector<llvm::Metadata *> elementLLVMTypes;
1828 for (
unsigned int i = 0; i <
elementTypes.size(); ++i) {
1830 uint64_t eltSize = eltType->getSizeInBits();
1833 uint64_t eltAlign = dataLayout.getABITypeAlignment(llvmType) * 8;
1836 auto eltOffset = layout->getElementOffsetInBits(i);
1840 llvm::DIDerivedType *fieldType =
m->
diBuilder->createMemberType(
1841 scope,
elementNames[i], diFile, line, eltSize, eltAlign, eltOffset, llvm::DINode::FlagZero, eltType);
1842 elementLLVMTypes.push_back(fieldType);
1845 llvm::DINodeArray elements =
m->
diBuilder->getOrCreateArray(elementLLVMTypes);
1849 layout->getSizeInBits(),
1850 #if ISPC_LLVM_VERSION <= ISPC_LLVM_9_0 1851 layout->getAlignment() * 8,
1853 layout->getAlignment().value() * 8,
1855 llvm::DINode::FlagZero,
1897 for (
int i = 0; i < (int)st->
elementTypes.size(); ++i) {
1899 const StructType *childStructType = CastType<StructType>(eltType);
1901 if (childStructType != NULL)
1905 "Unable to apply SOA conversion to " 1906 "struct due to \"%s\" member \"%s\" with bound \"%s\" " 1911 }
else if (CastType<ReferenceType>(eltType)) {
1913 "Unable to apply SOA conversion to " 1914 "struct due to member \"%s\" with reference type \"%s\".",
1969 FATAL(
"UndefinedStructType::GetAsSOAType() shouldn't be called.");
2007 ret += std::string(
"struct ") +
name;
2009 ret += std::string(
" ") + n;
2025 llvm::DINodeArray elements;
2030 llvm::DINode::FlagZero,
2178 ret += std::string(
" &");
2232 return llvm::PointerType::get(t, 0);
2241 return m->
diBuilder->createReferenceType(llvm::dwarf::DW_TAG_reference_type, diTargetType);
2248 :
Type(
FUNCTION_TYPE), isTask(false), isExported(false), isExternC(false), isUnmasked(false), returnType(r),
2249 paramTypes(a), paramNames(
llvm::SmallVector<std::string, 8>(a.size(),
"")),
2250 paramDefaults(
llvm::SmallVector<
Expr *, 8>(a.size(), NULL)),
2251 paramPositions(
llvm::SmallVector<
SourcePos, 8>(a.size(), p)) {
2258 const llvm::SmallVector<std::string, 8> &an,
const llvm::SmallVector<Expr *, 8> &ad,
2259 const llvm::SmallVector<SourcePos, 8> &ap,
bool it,
bool is,
bool ec,
bool ium)
2282 FATAL(
"FunctionType::GetBaseType() shouldn't be called");
2287 FATAL(
"FunctionType::GetAsVaryingType shouldn't be called");
2292 FATAL(
"FunctionType::GetAsUniformType shouldn't be called");
2297 FATAL(
"FunctionType::GetAsUnboundVariabilityType shouldn't be called");
2302 FATAL(
"FunctionType::GetAsSOAType() shouldn't be called");
2313 llvm::SmallVector<const Type *, 8> pt;
2314 for (
unsigned int i = 0; i <
paramTypes.size(); ++i) {
2337 for (
unsigned int i = 0; i <
paramTypes.size(); ++i) {
2339 ret +=
"/* ERROR */";
2351 std::string ret =
"___";
2355 for (
unsigned int i = 0; i <
paramTypes.size(); ++i)
2370 for (
unsigned int i = 0; i <
paramTypes.size(); ++i) {
2376 const PointerType *pt = CastType<PointerType>(type);
2377 if (pt != NULL && CastType<ArrayType>(pt->
GetBaseType()) != NULL) {
2398 for (
unsigned int i = 0; i <
paramTypes.size(); ++i) {
2404 const PointerType *pt = CastType<PointerType>(type);
2405 if (pt != NULL && CastType<ArrayType>(pt->
GetBaseType()) != NULL) {
2431 FATAL(
"FunctionType::LLVMType() shouldn't be called");
2437 std::vector<llvm::Metadata *> retArgTypes;
2444 retArgTypes.push_back(t->
GetDIType(scope));
2447 llvm::DITypeRefArray retArgTypesArray =
m->
diBuilder->getOrCreateTypeArray(retArgTypes);
2448 llvm::DIType *diType =
m->
diBuilder->createSubroutineType(retArgTypesArray);
2454 return "/* ERROR */";
2462 ret +=
"extern \"C\" ";
2469 snprintf(buf,
sizeof(buf),
"/*cost=%d*/ ",
costOverride);
2478 Assert(removeMask ==
false);
2481 std::vector<llvm::Type *> llvmArgTypes;
2482 for (
unsigned int i = 0; i <
paramTypes.size(); ++i) {
2490 llvm::Type *t = argType->
LLVMType(ctx);
2495 llvmArgTypes.push_back(t);
2502 std::vector<llvm::Type *> callTypes;
2509 llvm::Type *st = llvm::StructType::get(*ctx, llvmArgTypes);
2510 callTypes.push_back(llvm::PointerType::getUnqual(st));
2523 callTypes = llvmArgTypes;
2530 bool isStorageType =
false;
2531 if (CastType<AtomicType>(
returnType) == NULL)
2532 isStorageType =
true;
2535 llvm::Type *llvmReturnType = retType->
LLVMType(
g->
ctx);
2536 if (llvmReturnType == NULL)
2538 return llvm::FunctionType::get(llvmReturnType, callTypes,
false);
2579 const VectorType *vt = CastType<VectorType>(type);
2583 "Implicit conversion between from vector type " 2584 "\"%s\" to vector type of length %d for %s is not possible.",
2585 type->
GetString().c_str(), vecSize, reason);
2590 const AtomicType *at = CastType<AtomicType>(type);
2593 "Non-atomic type \"%s\" can't be converted to vector type " 2608 if (CastType<FunctionType>(t0) || CastType<FunctionType>(t1)) {
2609 if (CastType<FunctionType>(t0))
2611 if (CastType<FunctionType>(t1))
2639 if (CastType<FunctionType>(t0) || CastType<FunctionType>(t1)) {
2640 Error(pos,
"Incompatible function types \"%s\" and \"%s\" in %s.", t0->
GetString().c_str(),
2650 const PointerType *pt0 = CastType<PointerType>(t0);
2651 const PointerType *pt1 = CastType<PointerType>(t1);
2652 if (pt0 != NULL && pt1 != NULL) {
2659 "Conversion between incompatible pointer types \"%s\" " 2660 "and \"%s\" isn't possible.",
2673 "Implicit conversion between differently sized vector types " 2674 "(%s, %s) for %s is not possible.",
2684 const AtomicType *at = CastType<AtomicType>(t);
2697 const AtomicType *at = CastType<AtomicType>(t);
2707 const AtomicType *at = CastType<AtomicType>(t);
2709 return new VectorType(at, vt1->GetElementCount());
2719 if (et0 != NULL && et1 != NULL) {
2721 Assert(et0->IsVaryingType() == et1->IsVaryingType());
2723 }
else if (et0 != NULL) {
2731 "Implicit conversion from enum type \"%s\" to " 2732 "non-atomic type \"%s\" for %s not possible.",
2736 }
else if (et1 != NULL) {
2742 "Implicit conversion from enum type \"%s\" to " 2743 "non-atomic type \"%s\" for %s not possible.",
2750 if (at0 == NULL || at1 == NULL) {
2752 Error(pos,
"Implicit conversion from type \"%s\" to \"%s\" for %s not possible.", t0->
GetString().c_str(),
2759 return (
int(at0->basicType) >= int(at1->basicType)) ? at0 : at1;
2763 return (CastType<AtomicType>(type) != NULL || CastType<EnumType>(type) != NULL ||
2764 CastType<PointerType>(type) != NULL);
2768 if (a == NULL || b == NULL)
2774 const AtomicType *ata = CastType<AtomicType>(a);
2775 const AtomicType *atb = CastType<AtomicType>(b);
2776 if (ata != NULL && atb != NULL) {
2783 const EnumType *eta = CastType<EnumType>(a);
2784 const EnumType *etb = CastType<EnumType>(b);
2785 if (eta != NULL && etb != NULL)
2787 return (eta->
pos == etb->pos && eta->
GetVariability() == etb->GetVariability());
2789 const ArrayType *arta = CastType<ArrayType>(a);
2790 const ArrayType *artb = CastType<ArrayType>(b);
2791 if (arta != NULL && artb != NULL)
2795 const VectorType *vta = CastType<VectorType>(a);
2796 const VectorType *vtb = CastType<VectorType>(b);
2797 if (vta != NULL && vtb != NULL)
2801 const StructType *sta = CastType<StructType>(a);
2802 const StructType *stb = CastType<StructType>(b);
2805 if ((sta != NULL || usta != NULL) && (stb != NULL || ustb != NULL)) {
2811 const std::string &namea = sta ? sta->
GetStructName() : usta->GetStructName();
2812 const std::string &nameb = stb ? stb->GetStructName() : ustb->GetStructName();
2813 return (namea == nameb);
2816 const PointerType *pta = CastType<PointerType>(a);
2817 const PointerType *ptb = CastType<PointerType>(b);
2818 if (pta != NULL && ptb != NULL)
2825 if (rta != NULL && rtb != NULL)
2830 if (fta != NULL && ftb != NULL) {
virtual bool IsIntType() const =0
static const AtomicType * VaryingInt32
llvm::SmallVector< Expr *, 8 > paramDefaults
static llvm::Type * FloatType
virtual const Type * GetAsVaryingType() const =0
const UndefinedStructType * GetAsUnboundVariabilityType() const
bool IsReferenceType() const
const ArrayType * GetAsVaryingType() const
const StructType * oppositeConstStructType
static const AtomicType * VaryingInt16
bool IsUniformType() const
static bool lCheckTypeEquality(const Type *a, const Type *b, bool ignoreConst)
bool IsUnsignedType() const
bool IsUnsignedType() const
std::string GetString() const
llvm::DIType * GetDIType(llvm::DIScope *scope) const
bool IsUnsignedType() const
llvm::DIFile * GetDIFile() const
std::string Mangle() const
const Type * GetReturnType() const
virtual const Type * GetAsUnsignedType() const
const ReferenceType * GetAsConstType() const
virtual const Type * ResolveUnboundVariability(Variability v) const =0
static const AtomicType * VaryingUInt64
static llvm::Type * DoubleType
std::string Mangle() const
const UndefinedStructType * GetAsNonConstType() const
bool IsVaryingType() const
static PointerType * Void
const PointerType * GetAsUniformType() const
llvm::Type * LLVMStorageType(llvm::LLVMContext *ctx) const
bool IsFrozenSlice() const
bool IsUnsignedType() const
llvm::DIType * GetDIType(llvm::DIScope *scope) const
SourcePos Union(const SourcePos &p1, const SourcePos &p2)
std::string GetString() const
Variability GetVariability() const
llvm::Type * LLVMStorageType(llvm::LLVMContext *ctx) const
const AtomicType * GetAsVaryingType() const
std::string Mangle() const
static llvm::VectorType * VoidPointerVectorType
static llvm::VectorType * BoolVectorType
const Type * GetAsSOAType(int width) const
llvm::DIType * GetDIType(llvm::DIScope *scope) const
const Type * GetBaseType() const
std::string Mangle() const
const AtomicType * GetAsUnboundVariabilityType() const
static const AtomicType * VaryingDouble
std::string Mangle() const
const std::string & GetParameterName(int i) const
const PointerType * GetAsNonConstType() const
llvm::Type * LLVMType(llvm::LLVMContext *ctx) const
Abstract base class for types that represent sequences.
llvm::ArrayType * LLVMType(llvm::LLVMContext *ctx) const
std::string GetString() const
int getVectorMemoryCount() const
std::string GetString() const
std::string GetCDeclaration(const std::string &name) const
const StructType * GetAsUniformType() const
static llvm::Type * BoolType
std::string GetCDeclaration(const std::string &fname) const
const Type * GetElementType() const
const std::string & GetStructName() const
std::string Mangle() const
static std::string lMangleStruct(Variability variability, bool isConst, const std::string &name)
static std::string lMangleStructName(const std::string &name, Variability variability)
PointerType(const Type *t, Variability v, bool isConst, bool isSlice=false, bool frozen=false)
Variability GetVariability() const
static llvm::VectorType * Int32VectorType
int getMaskBitCount() const
const EnumType * GetAsVaryingType() const
static const AtomicType * UniformUInt32
int GetElementNumber(const std::string &name) const
llvm::Type * LLVMType(llvm::LLVMContext *ctx) const
static llvm::VectorType * BoolVectorStorageType
static PointerType * GetVarying(const Type *t)
llvm::Type * LLVMType(llvm::LLVMContext *ctx) const
const VectorType * GetAsConstType() const
int getDataTypeWidth() const
Variability GetVariability() const
int GetNumParameters() const
const Variability variability
static std::map< std::string, llvm::StructType * > lStructTypeMap
std::string Mangle() const
llvm::DIType * GetDIType(llvm::DIScope *scope) const
Type implementation for pointers to other types.
const ReferenceType * GetAsUniformType() const
static llvm::Type * Int16Type
UndefinedStructType(const std::string &name, const Variability variability, bool isConst, SourcePos pos)
const Type * GetBaseType() const
llvm::DIType * GetDIType(llvm::DIScope *scope) const
int TotalElementCount() const
const StructType * GetAsVaryingType() const
const UndefinedStructType * GetAsUniformType() const
const Variability variability
const llvm::SmallVector< std::string, 8 > paramNames
const PointerType * ResolveUnboundVariability(Variability v) const
static llvm::Type * lGetAtomicLLVMType(llvm::LLVMContext *ctx, const AtomicType *aType, bool isStorageType)
static const AtomicType * UniformUInt16
static PointerType * GetUniform(const Type *t, bool isSlice=false)
std::string MangleString() const
const Type * GetBaseType() const
const VectorType * ResolveUnboundVariability(Variability v) const
llvm::DIType * GetDIType(llvm::DIScope *scope) const
std::string GetString() const
virtual llvm::Type * LLVMType(llvm::LLVMContext *ctx) const =0
header file with declarations for symbol and symbol table classes.
static const AtomicType * UniformBool
const StructType * GetAsSOAType(int width) const
const Type * GetAsVaryingType() const
Type representing a reference to another (non-reference) type.
virtual const Type * GetReferenceTarget() const
virtual llvm::DIType * GetDIType(llvm::DIScope *scope) const =0
const AtomicType * GetAsUnsignedType() const
std::string GetString() const
const PointerType * GetAsSOAType(int width) const
VectorType(const AtomicType *base, int size)
static bool IsVoidPointer(const Type *t)
Expr * GetParameterDefault(int i) const
llvm::Type * LLVMType(llvm::LLVMContext *ctx) const
const llvm::SmallVector< std::string, 8 > elementNames
std::vector< Symbol * > enumerators
const VectorType * GetAsUniformType() const
Variability GetVariability() const
static const AtomicType * UniformUInt64
const StructType * ResolveUnboundVariability(Variability v) const
const SourcePos & GetParameterSourcePos(int i) const
const StructType * GetAsUnboundVariabilityType() const
static llvm::VectorType * Int8VectorType
const VectorType * GetAsVaryingType() const
AtomicType(BasicType basicType, Variability v, bool isConst)
std::string Mangle() const
const llvm::SmallVector< SourcePos, 8 > elementPositions
llvm::SmallVector< const Type *, 8 > finalElementTypes
const ReferenceType * GetAsNonConstType() const
static bool checkIfCanBeSOA(const StructType *st)
bool IsUnsignedType() const
const FunctionType * ResolveUnboundVariability(Variability v) const
std::string GetCDeclaration(const std::string &name) const
static llvm::VectorType * FloatVectorType
const Type * GetReferenceTarget() const
std::string GetCDeclaration(const std::string &name) const
std::string Mangle() const
const EnumType * ResolveUnboundVariability(Variability v) const
virtual bool IsBoolType() const =0
Variability GetVariability() const
const AtomicType * GetAsSOAType(int width) const
static llvm::Type * Int64Type
static llvm::Type * Int8Type
static const Type * MoreGeneralType(const Type *type0, const Type *type1, SourcePos pos, const char *reason, bool forceVarying=false, int vecSize=0)
Representation of a structure holding a number of members.
const Type * GetAsSOAType(int width) const
const ArrayType * ResolveUnboundVariability(Variability v) const
const EnumType * GetAsUnboundVariabilityType() const
const VectorType * GetAsSOAType(int width) const
static llvm::VectorType * Int64VectorType
Header file with declarations for various LLVM utility stuff.
const UndefinedStructType * ResolveUnboundVariability(Variability v) const
virtual bool IsFloatType() const =0
Variability GetVariability() const
const ReferenceType * GetAsUnboundVariabilityType() const
const ReferenceType * GetAsVaryingType() const
const EnumType * GetAsSOAType(int width) const
const AtomicType *const base
const Type * GetAsUniformType() const
const AtomicType * GetAsConstType() const
const Type * GetBaseType() const
std::string GetCDeclaration(const std::string &name) const
const AtomicType * asVaryingType
static bool IsBasicType(const Type *type)
AtomicType represents basic types like floats, ints, etc.
static llvm::Type * lGetVectorLLVMType(llvm::LLVMContext *ctx, const VectorType *vType, bool isStorage)
const Type *const returnType
const Type * GetAsUnboundVariabilityType() const
const ArrayType * GetAsUnboundVariabilityType() const
Representation of a range of positions in a source file.
virtual std::string Mangle() const =0
const EnumType * GetAsNonConstType() const
Type implementation for enumerated types.
virtual const Type * GetAsNonConstType() const =0
const Type * GetAsConstType() const
static const AtomicType * VaryingBool
virtual std::string GetString() const =0
std::string GetCDeclaration(const std::string &name) const
Abstract base class for types that represent collections of other types.
int GetElementCount() const
llvm::Type * LLVMType(llvm::LLVMContext *ctx) const
const PointerType * GetAsVaryingType() const
ArrayType(const Type *elementType, int numElements)
const AtomicType * asOtherConstType
void SetEnumerators(const std::vector< Symbol *> &enumerators)
const ArrayType * GetAsUnsignedType() const
const ArrayType * GetAsNonConstType() const
bool IsUnsignedType() const
const BasicType basicType
llvm::DIType * GetDIType(llvm::DIScope *scope) const
static llvm::PointerType * VoidPointerType
const Type *const targetType
static const AtomicType * VaryingInt64
void Error(SourcePos p, const char *fmt,...)
const Type * GetAsNonConstType() const
int GetEnumeratorCount() const
std::string GetCDeclaration(const std::string &name) const
int getVectorWidth() const
std::string GetString() const
const PointerType * GetAsSlice() const
virtual const Type * GetAsSOAType(int width) const =0
const StructType * GetAsConstType() const
ReferenceType(const Type *targetType)
bool IsPointerType() const
const AtomicType * GetElementType() const
const AtomicType * GetBaseType() const
Variability GetVariability() const
bool IsUnsignedType() const
const llvm::SmallVector< const Type *, 8 > elementTypes
const Variability variability
A (short) vector of atomic types.
llvm::Type * LLVMType(llvm::LLVMContext *ctx) const
const Type * GetBaseType() const
static const AtomicType * UniformUInt8
static const Type * lVectorConvert(const Type *type, SourcePos pos, const char *reason, int vecSize)
const VectorType * GetAsUnsignedType() const
const Type * GetElementType(const std::string &name) const
static llvm::Type * Int32Type
const llvm::DataLayout * getDataLayout() const
const std::string GetCStructName() const
virtual const Type * GetAsUniformType() const =0
const UndefinedStructType * GetAsSOAType(int width) const
const EnumType * GetBaseType() const
const EnumType * GetAsConstType() const
std::string GetString() const
const ArrayType * GetAsConstType() const
static llvm::DIType * lCreateDIArray(llvm::DIType *eltType, int count)
const ArrayType * GetAsSOAType(int width) const
static llvm::Type * BoolStorageType
const PointerType * GetAsUnboundVariabilityType() const
const llvm::SmallVector< SourcePos, 8 > paramPositions
std::string GetCDeclarationForDispatch(const std::string &fname) const
static bool Equal(const Type *a, const Type *b)
virtual const Type * GetElementType() const =0
static const AtomicType * VaryingUInt16
std::vector< Expr * > exprs
static const AtomicType * UniformFloat
static const AtomicType * VaryingInt8
const PointerType * GetAsFrozenSlice() const
llvm::DIType * GetDIType(llvm::DIScope *scope) const
virtual bool IsUnsignedType() const =0
llvm::DIType * GetDIType(llvm::DIScope *scope) const
const Type * GetParameterType(int i) const
static const AtomicType * UniformInt32
const Symbol * GetEnumerator(int i) const
Type representing a function (return type + argument types)
Representation of a program symbol.
const PointerType * GetAsNonSlice() const
const VectorType * GetAsUnboundVariabilityType() const
const llvm::SmallVector< const Type *, 8 > paramTypes
virtual bool IsConstType() const =0
Interface class that defines the type abstraction.
static const AtomicType * UniformDouble
const Type * GetBaseType() const
const UndefinedStructType * GetAsConstType() const
virtual Variability GetVariability() const =0
Expr abstract base class and expression implementations.
static const AtomicType * Void
virtual const Type * GetAsConstType() const =0
const StructType * GetAsNonConstType() const
static llvm::VectorType * MaskType
const ReferenceType * ResolveUnboundVariability(Variability v) const
llvm::Type * LLVMType(llvm::LLVMContext *ctx) const
const AtomicType * asUniformType
StructType(const std::string &name, const llvm::SmallVector< const Type *, 8 > &elts, const llvm::SmallVector< std::string, 8 > &eltNames, const llvm::SmallVector< SourcePos, 8 > &eltPositions, bool isConst, Variability variability, SourcePos pos)
bool IsUnsignedType() const
int GetElementCount() const
Expr is the abstract base class that defines the interface that all expression types must implement...
static llvm::VectorType * DoubleVectorType
bool IsUnsignedType() const
virtual std::string GetCDeclaration(const std::string &name) const =0
std::string GetString() const
static const Type * SizeUnsizedArrays(const Type *type, Expr *initExpr)
virtual const Type * GetBaseType() const =0
virtual ArrayType * GetSizedArray(int length) const
std::string GetCDeclaration(const std::string &name) const
static llvm::VectorType * Int16VectorType
llvm::Type * LLVMType(llvm::LLVMContext *ctx) const
static bool lShouldPrintName(const std::string &name)
const AtomicType * GetAsUniformType() const
const ArrayType * GetAsUniformType() const
const PointerType * GetAsConstType() const
Variability GetVariability() const
std::string GetCDeclaration(const std::string &name) const
const AtomicType * ResolveUnboundVariability(Variability v) const
static const AtomicType * VaryingUInt8
const Type * GetBaseType() const
int GetElementCount() const
FunctionType(const Type *returnType, const llvm::SmallVector< const Type *, 8 > &argTypes, SourcePos pos)
Declaration of the Module class, which is the ispc-side representation of the results of compiling a ...
const VectorType * GetAsNonConstType() const
static const AtomicType * UniformInt64
virtual const Type * GetAsUnboundVariabilityType() const =0
static const AtomicType * UniformInt16
const EnumType * GetAsUniformType() const
llvm::DIBuilder * diBuilder
std::string GetString() const
static bool EqualIgnoringConst(const Type *a, const Type *b)
const ReferenceType * asOtherConstType
static const AtomicType * VaryingUInt32
const AtomicType * GetAsNonConstType() const
const UndefinedStructType * GetAsVaryingType() const
static const AtomicType * VaryingFloat
const std::string GetReturnTypeString() const
virtual llvm::Type * LLVMStorageType(llvm::LLVMContext *ctx) const
static const AtomicType * UniformInt8
bool HasUnboundVariability() const
File with declarations for classes related to type representation.
Variability GetVariability() const
llvm::FunctionType * LLVMFunctionType(llvm::LLVMContext *ctx, bool disableMask=false) const
One-dimensional array type.
const Variability variability