diff --git a/gen/aa.cpp b/gen/aa.cpp index 395f0e86f3..0f118b7f43 100644 --- a/gen/aa.cpp +++ b/gen/aa.cpp @@ -27,7 +27,7 @@ // returns the keytype typeinfo static LLConstant *to_keyti(const Loc &loc, DValue *aa, LLType *targetType) { // keyti param - assert(aa->type->toBasetype()->ty == Taarray); + assert(aa->type->toBasetype()->ty == TY::Taarray); TypeAArray *aatype = static_cast(aa->type->toBasetype()); LLConstant *ti = DtoTypeInfoOf(loc, aatype->index, /*base=*/false); return DtoBitCast(ti, targetType); diff --git a/gen/abi-aarch64.cpp b/gen/abi-aarch64.cpp index 2f77eaba74..3481fa7d00 100644 --- a/gen/abi-aarch64.cpp +++ b/gen/abi-aarch64.cpp @@ -60,7 +60,7 @@ public: } Type *rt = tf->next->toBasetype(); - if (rt->ty == Tstruct || rt->ty == Tsarray) { + if (rt->ty == TY::Tstruct || rt->ty == TY::Tsarray) { auto argTypes = getArgTypes(rt); return !argTypes // FIXME: get rid of sret workaround for 0-sized return // values (static arrays with 0 elements) @@ -75,7 +75,7 @@ public: bool preferPassByRef(Type *t) override { t = t->toBasetype(); - if (!(t->ty == Tstruct || t->ty == Tsarray)) + if (!(t->ty == TY::Tstruct || t->ty == TY::Tsarray)) return false; auto argTypes = getArgTypes(t); diff --git a/gen/abi-arm.cpp b/gen/abi-arm.cpp index bdedf33cd9..a2254c4f5d 100644 --- a/gen/abi-arm.cpp +++ b/gen/abi-arm.cpp @@ -38,8 +38,8 @@ struct ArmTargetABI : TargetABI { if (!isPOD(rt)) return true; - return rt->ty == Tsarray || - (rt->ty == Tstruct && rt->size() > 4 && + return rt->ty == TY::Tsarray || + (rt->ty == TY::Tstruct && rt->size() > 4 && (gTargetMachine->Options.FloatABIType == llvm::FloatABI::Soft || !isHFVA(rt, hfvaToArray.maxElements))); } @@ -50,7 +50,7 @@ struct ArmTargetABI : TargetABI { // converts back to non-byval. Without this special handling the // optimzer generates bad code (e.g. std.random unittest crash). t = t->toBasetype(); - return ((t->ty == Tsarray || t->ty == Tstruct) && t->size() > 64); + return ((t->ty == TY::Tsarray || t->ty == TY::Tstruct) && t->size() > 64); // Note: byval can have a codegen problem with -O1 and higher. // What happens is that load instructions are being incorrectly @@ -72,7 +72,7 @@ struct ArmTargetABI : TargetABI { void rewriteFunctionType(IrFuncTy &fty) override { Type *retTy = fty.ret->type->toBasetype(); - if (!fty.ret->byref && retTy->ty == Tstruct) { + if (!fty.ret->byref && retTy->ty == TY::Tstruct) { // Rewrite HFAs only because union HFAs are turned into IR types that are // non-HFA and messes up register selection if (isHFVA(retTy, hfvaToArray.maxElements, &fty.ret->ltype)) { @@ -99,8 +99,8 @@ struct ArmTargetABI : TargetABI { // TODO: want to also rewrite Tsarray as i32 arrays, but sometimes // llvm selects an aligned ldrd instruction even though the ptr is // unaligned (e.g. walking through members of array char[5][]). - // if (ty->ty == Tstruct || ty->ty == Tsarray) - if (ty->ty == Tstruct) { + // if (ty->ty == TY::Tstruct || ty->ty == TY::Tsarray) + if (ty->ty == TY::Tstruct) { // Rewrite HFAs only because union HFAs are turned into IR types that are // non-HFA and messes up register selection if (isHFVA(ty, hfvaToArray.maxElements, &arg.ltype)) { diff --git a/gen/abi-mips64.cpp b/gen/abi-mips64.cpp index 09af371b7a..77b3d10cdf 100644 --- a/gen/abi-mips64.cpp +++ b/gen/abi-mips64.cpp @@ -39,12 +39,12 @@ struct MIPS64TargetABI : TargetABI { // because otherwise LLVM tries to actually return the array in a number // of physical registers, which leads, depending on the target, to // either horrendous codegen or backend crashes. - return (rt->ty == Tstruct || rt->ty == Tsarray); + return (rt->ty == TY::Tstruct || rt->ty == TY::Tsarray); } bool passByVal(TypeFunction *, Type *t) override { TY ty = t->toBasetype()->ty; - return ty == Tstruct || ty == Tsarray; + return ty == TY::Tstruct || ty == TY::Tsarray; } void rewriteFunctionType(IrFuncTy &fty) override { diff --git a/gen/abi-nvptx.cpp b/gen/abi-nvptx.cpp index ac44193b76..b64de73c69 100644 --- a/gen/abi-nvptx.cpp +++ b/gen/abi-nvptx.cpp @@ -26,7 +26,7 @@ struct NVPTXTargetABI : TargetABI { } bool passByVal(TypeFunction *, Type *t) override { t = t->toBasetype(); - return ((t->ty == Tsarray || t->ty == Tstruct) && t->size() > 64); + return ((t->ty == TY::Tsarray || t->ty == TY::Tstruct) && t->size() > 64); } bool reverseExplicitParams(TypeFunction *) override { return false; } void rewriteFunctionType(IrFuncTy &fty) override { @@ -41,7 +41,7 @@ struct NVPTXTargetABI : TargetABI { void rewriteArgument(IrFuncTy &fty, IrFuncTyArg &arg) override { Type *ty = arg.type->toBasetype(); llvm::Optional ptr; - if (ty->ty == Tstruct && + if (ty->ty == TY::Tstruct && (ptr = toDcomputePointer(static_cast(ty)->sym))) { pointerRewite.applyTo(arg); } diff --git a/gen/abi-ppc.cpp b/gen/abi-ppc.cpp index fa33da9be1..3508fab137 100644 --- a/gen/abi-ppc.cpp +++ b/gen/abi-ppc.cpp @@ -46,7 +46,7 @@ struct PPCTargetABI : TargetABI { // returned in r3/r4 (ppc) or in r3 (ppc64). Looking at the IR // generated by clang this seems not to be implemented. Regardless // of size, the aggregate is always returned as sret. - return rt->ty == Tsarray || rt->ty == Tstruct; + return rt->ty == TY::Tsarray || rt->ty == TY::Tstruct; } bool passByVal(TypeFunction *, Type *t) override { @@ -54,7 +54,7 @@ struct PPCTargetABI : TargetABI { // On ppc64, they are always passed by value. However, clang // used byval for type > 64 bytes. t = t->toBasetype(); - return (t->ty == Tsarray || t->ty == Tstruct) && + return (t->ty == TY::Tsarray || t->ty == TY::Tstruct) && (!Is64Bit || t->size() > 64); } @@ -75,7 +75,7 @@ struct PPCTargetABI : TargetABI { void rewriteArgument(IrFuncTy &fty, IrFuncTyArg &arg) override { Type *ty = arg.type->toBasetype(); - if (ty->ty == Tstruct || ty->ty == Tsarray) { + if (ty->ty == TY::Tstruct || ty->ty == TY::Tsarray) { if (canRewriteAsInt(ty, Is64Bit)) { integerRewrite.applyTo(arg); } else { diff --git a/gen/abi-ppc64le.cpp b/gen/abi-ppc64le.cpp index 0539510535..73b8ca4fcd 100644 --- a/gen/abi-ppc64le.cpp +++ b/gen/abi-ppc64le.cpp @@ -43,8 +43,8 @@ struct PPC64LETargetABI : TargetABI { bool passByVal(TypeFunction *, Type *t) override { t = t->toBasetype(); - return t->ty == Tsarray || (t->ty == Tstruct && t->size() > 16 && - !isHFVA(t, hfvaToArray.maxElements)); + return t->ty == TY::Tsarray || (t->ty == TY::Tstruct && t->size() > 16 && + !isHFVA(t, hfvaToArray.maxElements)); } void rewriteFunctionType(IrFuncTy &fty) override { @@ -63,8 +63,8 @@ struct PPC64LETargetABI : TargetABI { void rewriteArgument(IrFuncTy &fty, IrFuncTyArg &arg) override { Type *ty = arg.type->toBasetype(); - if (ty->ty == Tstruct || ty->ty == Tsarray) { - if (ty->ty == Tstruct && + if (ty->ty == TY::Tstruct || ty->ty == TY::Tsarray) { + if (ty->ty == TY::Tstruct && isHFVA(ty, hfvaToArray.maxElements, &arg.ltype)) { hfvaToArray.applyTo(arg, arg.ltype); } else if (canRewriteAsInt(ty, true)) { diff --git a/gen/abi-spirv.cpp b/gen/abi-spirv.cpp index 52c985b385..f0c459c649 100644 --- a/gen/abi-spirv.cpp +++ b/gen/abi-spirv.cpp @@ -26,7 +26,7 @@ struct SPIRVTargetABI : TargetABI { } bool passByVal(TypeFunction *, Type *t) override { t = t->toBasetype(); - return ((t->ty == Tsarray || t->ty == Tstruct) && t->size() > 64); + return ((t->ty == TY::Tsarray || t->ty == TY::Tstruct) && t->size() > 64); } bool reverseExplicitParams(TypeFunction *) override { return false; } void rewriteFunctionType(IrFuncTy &fty) override { @@ -41,7 +41,7 @@ struct SPIRVTargetABI : TargetABI { void rewriteArgument(IrFuncTy &fty, IrFuncTyArg &arg) override { Type *ty = arg.type->toBasetype(); llvm::Optional ptr; - if (ty->ty == Tstruct && + if (ty->ty == TY::Tstruct && (ptr = toDcomputePointer(static_cast(ty)->sym))) { pointerRewite.applyTo(arg); } diff --git a/gen/abi-win64.cpp b/gen/abi-win64.cpp index c3810b61c7..55a2f24323 100644 --- a/gen/abi-win64.cpp +++ b/gen/abi-win64.cpp @@ -39,7 +39,7 @@ private: bool isX87(Type *t) const { return !isMSVC // 64-bit reals for MSVC targets - && (t->ty == Tfloat80 || t->ty == Timaginary80); + && (t->ty == TY::Tfloat80 || t->ty == TY::Timaginary80); } bool passPointerToHiddenCopy(Type *t, bool isReturnValue, @@ -68,7 +68,7 @@ private: // MSVC++ seems to enforce by-ref passing only for structs with // copy ctor (incl. `= delete`). if (isMSVCpp) { - if (t->ty == Tstruct) { + if (t->ty == TY::Tstruct) { StructDeclaration *sd = static_cast(t)->sym; assert(sd); if (sd->postblit || sd->hasCopyCtor) @@ -91,8 +91,8 @@ private: // LDC-specific exceptions: slices and delegates are left alone (as non- // rewritten IR structs) and passed/returned as 2 separate args => passed in // up to 2 GP registers and returned in RAX & RDX. - return isAggregate(t) && !canRewriteAsInt(t) && t->ty != Tarray && - t->ty != Tdelegate; + return isAggregate(t) && !canRewriteAsInt(t) && t->ty != TY::Tarray && + t->ty != TY::Tdelegate; } public: @@ -127,7 +127,8 @@ public: Type *rt = tf->next->toBasetype(); // for non-static member functions, MSVC++ enforces sret for all structs - if (isMSVC && tf->linkage == LINK::cpp && needsThis && rt->ty == Tstruct) { + if (isMSVC && tf->linkage == LINK::cpp && needsThis && + rt->ty == TY::Tstruct) { return true; } diff --git a/gen/abi-x86-64.cpp b/gen/abi-x86-64.cpp index b1e89c80dc..58367c0f0e 100644 --- a/gen/abi-x86-64.cpp +++ b/gen/abi-x86-64.cpp @@ -188,7 +188,7 @@ private: if (te->sym->ident == Id::__c_complex_real) return true; } - return rt->toBasetype()->ty == Tcomplex80; + return rt->toBasetype()->ty == TY::Tcomplex80; } RegCount &getRegCount(IrFuncTy &fty) { @@ -246,7 +246,7 @@ void X86_64TargetABI::rewriteArgument(IrFuncTy &fty, IrFuncTyArg &arg, return; } - if (t->ty == Tcomplex32 || t->ty == Tstruct || t->ty == Tsarray) { + if (t->ty == TY::Tcomplex32 || t->ty == TY::Tstruct || t->ty == TY::Tsarray) { if (LLType *rewrittenType = getRewrittenArgType(t)) argTypesRewrite.applyToIfNotObsolete(arg, rewrittenType); } @@ -401,11 +401,11 @@ const char *X86_64TargetABI::objcMsgSendFunc(Type *ret, } if (ret) { // complex long double return - if (ret->ty == Tcomplex80) { + if (ret->ty == TY::Tcomplex80) { return "objc_msgSend_fp2ret"; } // long double return - if (ret->ty == Tfloat80 || ret->ty == Timaginary80) { + if (ret->ty == TY::Tfloat80 || ret->ty == TY::Timaginary80) { return "objc_msgSend_fpret"; } } diff --git a/gen/abi-x86.cpp b/gen/abi-x86.cpp index be66f39702..81e228c897 100644 --- a/gen/abi-x86.cpp +++ b/gen/abi-x86.cpp @@ -118,7 +118,7 @@ struct X86TargetABI : TargetABI { // extern(C) and all others: // * cfloat will be rewritten as 64-bit integer and returned in registers // * sret for cdouble and creal - return rt->ty != Tcomplex32; + return rt->ty != TY::Tcomplex32; } // non-extern(D): some OSs don't return structs in registers at all @@ -128,7 +128,7 @@ struct X86TargetABI : TargetABI { const bool isMSVCpp = isMSVC && tf->linkage == LINK::cpp; // for non-static member functions, MSVC++ enforces sret for all structs - if (isMSVCpp && needsThis && rt->ty == Tstruct) { + if (isMSVCpp && needsThis && rt->ty == TY::Tstruct) { return true; } @@ -160,7 +160,7 @@ struct X86TargetABI : TargetABI { Type *rt = getExtraLoweredReturnType(fty.type); if (isAggregate(rt) && canRewriteAsInt(rt) && // don't rewrite cfloat for extern(D) - !(externD && rt->ty == Tcomplex32)) { + !(externD && rt->ty == TY::Tcomplex32)) { integerRewrite.applyToIfNotObsolete(*fty.ret); } } @@ -210,7 +210,7 @@ struct X86TargetABI : TargetABI { auto sz = lastTy->size(); if (!lastTy->isfloating() && (sz == 1 || sz == 2 || sz == 4)) { // rewrite aggregates as integers to make inreg work - if (lastTy->ty == Tstruct || lastTy->ty == Tsarray) { + if (lastTy->ty == TY::Tstruct || lastTy->ty == TY::Tsarray) { integerRewrite.applyTo(*last); // undo byval semantics applied via passByVal() returning true last->byref = false; @@ -233,7 +233,7 @@ struct X86TargetABI : TargetABI { size_t i = 0; while (i < fty.args.size()) { Type *type = fty.args[i]->type->toBasetype(); - if (type->ty == Tstruct) { + if (type->ty == TY::Tstruct) { // Do not pass empty structs at all for C++ ABI compatibility. // Tests with clang reveal that more complex "empty" types, for // example a struct containing an empty struct, are not diff --git a/gen/abi.cpp b/gen/abi.cpp index 0d6eb7a572..9861062d13 100644 --- a/gen/abi.cpp +++ b/gen/abi.cpp @@ -71,7 +71,7 @@ bool TargetABI::isHFVA(Type *t, int maxNumElements, LLType **hfvaType) { bool TargetABI::isHVA(Type *t, int maxNumElements, LLType **hvaType) { Type *rewriteType = nullptr; if (::isHFVA(t, maxNumElements, &rewriteType) && - rewriteType->nextOf()->ty == Tvector) { + rewriteType->nextOf()->ty == TY::Tvector) { if (hvaType) *hvaType = DtoType(rewriteType); return true; @@ -118,8 +118,8 @@ bool TargetABI::isAggregate(Type *t) { // FIXME: dynamic arrays can currently not be rewritten as they are used // by runtime functions, for which we don't apply the rewrites yet // when calling them - return ty == Tstruct || ty == Tsarray || - /*ty == Tarray ||*/ ty == Tdelegate || t->iscomplex(); + return ty == TY::Tstruct || ty == TY::Tsarray || + /*ty == TY::Tarray ||*/ ty == TY::Tdelegate || t->iscomplex(); } namespace { @@ -139,7 +139,7 @@ bool hasCtor(StructDeclaration *s) { bool TargetABI::isPOD(Type *t, bool excludeStructsWithCtor) { t = t->baseElemOf(); - if (t->ty != Tstruct) + if (t->ty != TY::Tstruct) return true; StructDeclaration *sd = static_cast(t)->sym; return sd->isPOD() && !(excludeStructsWithCtor && hasCtor(sd)); @@ -159,7 +159,7 @@ bool TargetABI::skipReturnValueRewrite(IrFuncTy &fty) { return true; auto ty = fty.ret->type->toBasetype()->ty; - return ty == Tvoid || ty == Tnoreturn; + return ty == TY::Tvoid || ty == TY::Tnoreturn; } ////////////////////////////////////////////////////////////////////////////// @@ -301,7 +301,7 @@ struct IntrinsicABI : TargetABI { void rewriteArgument(IrFuncTy &fty, IrFuncTyArg &arg) override { Type *ty = arg.type->toBasetype(); - if (ty->ty != Tstruct) { + if (ty->ty != TY::Tstruct) { return; } // TODO: Check that no unions are passed in or returned. @@ -316,7 +316,7 @@ struct IntrinsicABI : TargetABI { void rewriteFunctionType(IrFuncTy &fty) override { if (!fty.arg_sret) { Type *rt = fty.ret->type->toBasetype(); - if (rt->ty == Tstruct) { + if (rt->ty == TY::Tstruct) { Logger::println("Intrinsic ABI: Transforming return type"); rewriteArgument(fty, *fty.ret); } diff --git a/gen/arrays.cpp b/gen/arrays.cpp index 1192438846..90f3e5f92e 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -42,7 +42,7 @@ LLValue *DtoSlice(LLValue *ptr, LLValue *length, LLType *elemType = nullptr) { LLValue *DtoSlice(Expression *e) { DValue *dval = toElem(e); - if (dval->type->toBasetype()->ty == Tsarray) { + if (dval->type->toBasetype()->ty == TY::Tsarray) { // Convert static array to slice return DtoSlice(DtoLVal(dval), DtoArrayLen(dval)); } @@ -57,11 +57,11 @@ static LLValue *DtoSlicePtr(Expression *e) { Loc loc; LLStructType *type = DtoArrayType(LLType::getInt8Ty(gIR->context())); Type *vt = dval->type->toBasetype(); - if (vt->ty == Tarray) { + if (vt->ty == TY::Tarray) { return makeLValue(loc, dval); } - bool isStaticArray = vt->ty == Tsarray; + bool isStaticArray = vt->ty == TY::Tsarray; LLValue *val = isStaticArray ? DtoLVal(dval) : makeLValue(loc, dval); LLValue *array = DtoRawAlloca(type, 0, ".array"); LLValue *len = isStaticArray ? DtoArrayLen(dval) : DtoConstSize_t(1); @@ -87,7 +87,7 @@ LLStructType *DtoArrayType(LLType *t) { LLArrayType *DtoStaticArrayType(Type *t) { t = t->toBasetype(); - assert(t->ty == Tsarray); + assert(t->ty == TY::Tsarray); TypeSArray *tsa = static_cast(t); Type *tnext = tsa->nextOf(); @@ -179,7 +179,7 @@ static void DtoArrayInit(const Loc &loc, LLValue *ptr, LLValue *length, static Type *DtoArrayElementType(Type *arrayType) { assert(arrayType->toBasetype()->nextOf()); Type *t = arrayType->toBasetype()->nextOf()->toBasetype(); - while (t->ty == Tsarray) { + while (t->ty == TY::Tsarray) { t = t->nextOf()->toBasetype(); } return t; @@ -217,7 +217,7 @@ static void copySlice(const Loc &loc, LLValue *dstarr, LLValue *dstlen, // Determine whether t is an array of structs that need a postblit. static bool arrayNeedsPostblit(Type *t) { t = DtoArrayElementType(t); - if (t->ty == Tstruct) { + if (t->ty == TY::Tstruct) { return static_cast(t)->sym->postblit != nullptr; } return false; @@ -235,8 +235,8 @@ void DtoArrayAssign(const Loc &loc, DValue *lhs, DValue *rhs, int op, assert(t->nextOf()); // reference assignment for dynamic array? - if (t->ty == Tarray && !lhs->isSlice()) { - assert(t2->ty == Tarray || t2->ty == Tsarray); + if (t->ty == TY::Tarray && !lhs->isSlice()) { + assert(t2->ty == TY::Tarray || t2->ty == TY::Tsarray); if (rhs->isNull()) { DtoSetArrayToNull(DtoLVal(lhs)); } else { @@ -259,8 +259,9 @@ void DtoArrayAssign(const Loc &loc, DValue *lhs, DValue *rhs, int op, // Be careful to handle void arrays correctly when modifying this (see tests // for DMD issue 7493). // TODO: This should use AssignExp::memset. - LLValue *realRhsArrayPtr = - (t2->ty == Tarray || t2->ty == Tsarray) ? DtoArrayPtr(rhs) : nullptr; + LLValue *realRhsArrayPtr = (t2->ty == TY::Tarray || t2->ty == TY::Tsarray) + ? DtoArrayPtr(rhs) + : nullptr; if (realRhsArrayPtr && realRhsArrayPtr->getType() == realLhsPtr->getType()) { // T[] = T[] T[] = T[n] // T[n] = T[n] T[n] = T[] @@ -268,7 +269,7 @@ void DtoArrayAssign(const Loc &loc, DValue *lhs, DValue *rhs, int op, LLValue *rhsLength = DtoArrayLen(rhs); const bool needsPostblit = (op != TOKblit && arrayNeedsPostblit(t) && - (!canSkipPostblit || t2->ty == Tarray)); + (!canSkipPostblit || t2->ty == TY::Tarray)); if (!needsDestruction && !needsPostblit) { // fast version @@ -278,7 +279,7 @@ void DtoArrayAssign(const Loc &loc, DValue *lhs, DValue *rhs, int op, DtoMemSetZero(lhsPtr, lhsSize); } else { bool knownInBounds = - isConstructing || (t->ty == Tsarray && t2->ty == Tsarray); + isConstructing || (t->ty == TY::Tsarray && t2->ty == TY::Tsarray); if (!knownInBounds) { if (auto constLhsLength = llvm::dyn_cast(lhsLength)) { if (auto constRhsLength = @@ -368,7 +369,7 @@ LLConstant *DtoConstArrayInitializer(ArrayInitializer *arrinit, // for statis arrays, dmd does not include any trailing default // initialized elements in the value/index lists - if (arrty->ty == Tsarray) { + if (arrty->ty == TY::Tsarray) { TypeSArray *tsa = static_cast(arrty); arrlen = static_cast(tsa->dim->toInteger()); } @@ -383,7 +384,7 @@ LLConstant *DtoConstArrayInitializer(ArrayInitializer *arrinit, // get elem type Type *elemty; - if (arrty->ty == Tvector) { + if (arrty->ty == TY::Tvector) { elemty = static_cast(arrty)->elementType(); } else { elemty = arrty->nextOf(); @@ -459,7 +460,7 @@ LLConstant *DtoConstArrayInitializer(ArrayInitializer *arrinit, constarr = LLConstantStruct::getAnon(gIR->context(), initvals); // FIXME should this pack? } else { - if (arrty->ty == Tvector) { + if (arrty->ty == TY::Tvector) { constarr = llvm::ConstantVector::get(initvals); } else { constarr = @@ -470,7 +471,7 @@ LLConstant *DtoConstArrayInitializer(ArrayInitializer *arrinit, // std::cout << "constarr: " << *constarr << std::endl; // if the type is a static array, we're done - if (arrty->ty == Tsarray || arrty->ty == Tvector) { + if (arrty->ty == TY::Tsarray || arrty->ty == TY::Tvector) { return constarr; } @@ -482,7 +483,7 @@ LLConstant *DtoConstArrayInitializer(ArrayInitializer *arrinit, LLGlobalValue::InternalLinkage, constarr, ".constarray"); - if (arrty->ty == Tpointer) { + if (arrty->ty == TY::Tpointer) { // we need to return pointer to the static array. return DtoBitCast(gvar, DtoType(arrty)); } @@ -524,7 +525,7 @@ bool isConstLiteral(Expression *e, bool immutableType) { // If dynamic array: assume not constant because the array is expected to // be newly allocated. See GH 1924. Type *arrayType = ale->type->toBasetype(); - if (arrayType->ty == Tarray) + if (arrayType->ty == TY::Tarray) return false; } @@ -786,7 +787,7 @@ DSliceValue *DtoResizeDynArray(const Loc &loc, Type *arrayType, DValue *array, assert(array); assert(newdim); assert(arrayType); - assert(arrayType->toBasetype()->ty == Tarray); + assert(arrayType->toBasetype()->ty == TY::Tarray); // decide on what runtime function to call based on whether the type is zero // initialized @@ -997,40 +998,41 @@ LLValue *DtoArrayEqCmp_impl(const Loc &loc, const char *func, DValue *l, /// See `validCompareWithMemcmp`. bool validCompareWithMemcmpType(Type *t) { switch (t->ty) { - case Tsarray: { + case TY::Tsarray: { auto *elemType = t->baseElemOf(); return validCompareWithMemcmpType(elemType); } - case Tstruct: + case TY::Tstruct: // TODO: Implement when structs can be compared with memcmp. Remember that // structs can have a user-defined opEquals, alignment padding bytes (in // arrays), and padding bytes. return false; - case Tvoid: - case Tint8: - case Tuns8: - case Tint16: - case Tuns16: - case Tint32: - case Tuns32: - case Tint64: - case Tuns64: - case Tint128: - case Tuns128: - case Tbool: - case Tchar: - case Twchar: - case Tdchar: - case Tpointer: + case TY::Tvoid: + case TY::Tint8: + case TY::Tuns8: + case TY::Tint16: + case TY::Tuns16: + case TY::Tint32: + case TY::Tuns32: + case TY::Tint64: + case TY::Tuns64: + case TY::Tint128: + case TY::Tuns128: + case TY::Tbool: + case TY::Tchar: + case TY::Twchar: + case TY::Tdchar: + case TY::Tpointer: return true; // TODO: Determine whether this can be "return true" too: - // case Tvector: - } + // case TY::Tvector: - return false; + default: + return false; + } } /// When `true` is returned, `l` and `r` can be compared using `memcmp`. @@ -1086,8 +1088,9 @@ LLValue *DtoArrayEqCmp_memcmp(const Loc &loc, DValue *l, DValue *r, auto *l_length = DtoArrayLen(l); // Early return for the simple case of comparing two static arrays. - const bool staticArrayComparison = (l->type->toBasetype()->ty == Tsarray) && - (r->type->toBasetype()->ty == Tsarray); + const bool staticArrayComparison = + (l->type->toBasetype()->ty == TY::Tsarray) && + (r->type->toBasetype()->ty == TY::Tsarray); if (staticArrayComparison) { // TODO: simply codegen when comparing static arrays with different length (int[3] == int[2]) return callMemcmp(loc, irs, l_ptr, r_ptr, l_length); @@ -1165,7 +1168,7 @@ LLValue *DtoArrayLen(DValue *v) { LOG_SCOPE; Type *t = v->type->toBasetype(); - if (t->ty == Tarray) { + if (t->ty == TY::Tarray) { if (v->isNull()) { return DtoConstSize_t(0); } @@ -1176,7 +1179,7 @@ LLValue *DtoArrayLen(DValue *v) { assert(slice); return slice->getLength(); } - if (t->ty == Tsarray) { + if (t->ty == TY::Tsarray) { assert(!v->isSlice()); assert(!v->isNull()); TypeSArray *sarray = static_cast(t); @@ -1196,7 +1199,7 @@ LLValue *DtoArrayPtr(DValue *v) { LLType *wantedLLPtrType = DtoPtrToType(t->nextOf()); LLValue *ptr = nullptr; - if (t->ty == Tarray) { + if (t->ty == TY::Tarray) { if (v->isNull()) { ptr = getNullPtr(wantedLLPtrType); } else if (v->isLVal()) { @@ -1206,7 +1209,7 @@ LLValue *DtoArrayPtr(DValue *v) { assert(slice); ptr = slice->getPtr(); } - } else if (t->ty == Tsarray) { + } else if (t->ty == TY::Tsarray) { assert(!v->isSlice()); assert(!v->isNull()); ptr = DtoLVal(v); @@ -1226,14 +1229,14 @@ DValue *DtoCastArray(const Loc &loc, DValue *u, Type *to) { Type *totype = to->toBasetype(); Type *fromtype = u->type->toBasetype(); - if (fromtype->ty != Tarray && fromtype->ty != Tsarray) { + if (fromtype->ty != TY::Tarray && fromtype->ty != TY::Tsarray) { error(loc, "can't cast `%s` to `%s`", u->type->toChars(), to->toChars()); fatal(); } IF_LOG Logger::cout() << "from array or sarray" << '\n'; - if (totype->ty == Tpointer) { + if (totype->ty == TY::Tpointer) { IF_LOG Logger::cout() << "to pointer" << '\n'; LLValue *ptr = DtoArrayPtr(u); if (ptr->getType() != tolltype) { @@ -1242,12 +1245,12 @@ DValue *DtoCastArray(const Loc &loc, DValue *u, Type *to) { return new DImValue(to, ptr); } - if (totype->ty == Tarray) { + if (totype->ty == TY::Tarray) { IF_LOG Logger::cout() << "to array" << '\n'; LLValue *length = nullptr; LLValue *ptr = nullptr; - if (fromtype->ty == Tsarray) { + if (fromtype->ty == TY::Tsarray) { length = DtoConstSize_t( static_cast(fromtype)->dim->toUInteger()); ptr = DtoLVal(u); @@ -1282,11 +1285,11 @@ DValue *DtoCastArray(const Loc &loc, DValue *u, Type *to) { return new DSliceValue(to, length, DtoBitCast(ptr, ptrty)); } - if (totype->ty == Tsarray) { + if (totype->ty == TY::Tsarray) { IF_LOG Logger::cout() << "to sarray" << '\n'; LLValue *ptr = nullptr; - if (fromtype->ty == Tsarray) { + if (fromtype->ty == TY::Tsarray) { ptr = DtoLVal(u); } else { size_t tosize = static_cast(totype)->dim->toInteger(); @@ -1300,7 +1303,7 @@ DValue *DtoCastArray(const Loc &loc, DValue *u, Type *to) { return new DLValue(to, DtoBitCast(ptr, getPtrToType(tolltype))); } - if (totype->ty == Tbool) { + if (totype->ty == TY::Tbool) { // return (arr.ptr !is null) LLValue *ptr = DtoArrayPtr(u); LLConstant *nul = getNullPtr(ptr->getType()); @@ -1313,16 +1316,16 @@ DValue *DtoCastArray(const Loc &loc, DValue *u, Type *to) { void DtoIndexBoundsCheck(const Loc &loc, DValue *arr, DValue *index) { Type *arrty = arr->type->toBasetype(); - assert( - (arrty->ty == Tsarray || arrty->ty == Tarray || arrty->ty == Tpointer) && - "Can only array bounds check for static or dynamic arrays"); + assert((arrty->ty == TY::Tsarray || arrty->ty == TY::Tarray || + arrty->ty == TY::Tpointer) && + "Can only array bounds check for static or dynamic arrays"); if (!index) { // Caller supplied no index, known in-bounds. return; } - if (arrty->ty == Tpointer) { + if (arrty->ty == TY::Tpointer) { // Length of pointers is unknown, ingore. return; } diff --git a/gen/asm-x86.h b/gen/asm-x86.h index 464a85cbcf..a0a57ce74a 100644 --- a/gen/asm-x86.h +++ b/gen/asm-x86.h @@ -3185,7 +3185,7 @@ struct AsmProcessor { // Tfloat64 TY ty = v->type->toBasetype()->ty; operand->dataSizeHint = - (ty == Tfloat80 || ty == Timaginary80) && + (ty == TY::Tfloat80 || ty == TY::Timaginary80) && !global.params.targetTriple->isWindowsMSVCEnvironment() ? Extended_Ptr : static_cast(v->type->size(Loc())); diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index ffedcff3e5..7125e02023 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -606,7 +606,7 @@ void CompoundAsmStatement_toIR(CompoundAsmStatement *stmt, IRState *p) { bool useabiret = false; p->asmBlock->asmBlock->abiret = nullptr; if (thisfunc->fbody->endsWithAsm() == stmt && - thisfunc->type->nextOf()->ty != Tvoid) { + thisfunc->type->nextOf()->ty != TY::Tvoid) { // there can't be goto forwarders in this case assert(gotoToVal.empty()); emitABIReturnAsmStmt(asmblock, stmt->loc, thisfunc); diff --git a/gen/binops.cpp b/gen/binops.cpp index 3e94811a38..06c225b53c 100644 --- a/gen/binops.cpp +++ b/gen/binops.cpp @@ -22,7 +22,7 @@ ////////////////////////////////////////////////////////////////////////////// dinteger_t undoStrideMul(const Loc &loc, Type *t, dinteger_t offset) { - assert(t->ty == Tpointer); + assert(t->ty == TY::Tpointer); d_uns64 elemSize = t->nextOf()->size(loc); assert((offset % elemSize) == 0 && "Expected offset by an integer amount of elements"); @@ -127,7 +127,7 @@ DValue *emitPointerOffset(Loc loc, DValue *base, Expression *offset, // a null constant and returns the other operand (AA) as new DImValue. // Returns null if type is not an AA. DValue *isAssociativeArrayAndNull(Type *type, LLValue *lhs, LLValue *rhs) { - if (type->ty != Taarray) + if (type->ty != TY::Taarray) return nullptr; if (auto constantL = isaConstant(lhs)) { @@ -151,14 +151,15 @@ DValue *binAdd(const Loc &loc, Type *type, DValue *lhs, Expression *rhs, Type *lhsType = lhs->type->toBasetype(); Type *rhsType = rhs->type->toBasetype(); - if (lhsType != rhsType && lhsType->ty == Tpointer && rhsType->isintegral()) { + if (lhsType != rhsType && lhsType->ty == TY::Tpointer && + rhsType->isintegral()) { Logger::println("Adding integer to pointer"); return emitPointerOffset(loc, lhs, rhs, false, type, loadLhsAfterRhs); } auto rvals = evalSides(lhs, rhs, loadLhsAfterRhs); - if (type->ty == Tnull) + if (type->ty == TY::Tnull) return DtoNullValue(type, loc); if (type->iscomplex()) return DtoComplexAdd(loc, type, rvals.lhs, rvals.rhs); @@ -182,14 +183,15 @@ DValue *binMin(const Loc &loc, Type *type, DValue *lhs, Expression *rhs, Type *lhsType = lhs->type->toBasetype(); Type *rhsType = rhs->type->toBasetype(); - if (lhsType != rhsType && lhsType->ty == Tpointer && rhsType->isintegral()) { + if (lhsType != rhsType && lhsType->ty == TY::Tpointer && + rhsType->isintegral()) { Logger::println("Subtracting integer from pointer"); return emitPointerOffset(loc, lhs, rhs, true, type, loadLhsAfterRhs); } auto rvals = evalSides(lhs, rhs, loadLhsAfterRhs); - if (lhsType->ty == Tpointer && rhsType->ty == Tpointer) { + if (lhsType->ty == TY::Tpointer && rhsType->ty == TY::Tpointer) { LLValue *l = DtoRVal(rvals.lhs); LLValue *r = DtoRVal(rvals.rhs); LLType *llSizeT = DtoSize_t(); @@ -202,7 +204,7 @@ DValue *binMin(const Loc &loc, Type *type, DValue *lhs, Expression *rhs, return new DImValue(type, diff); } - if (type->ty == Tnull) + if (type->ty == TY::Tnull) return DtoNullValue(type, loc); if (type->iscomplex()) return DtoComplexMin(loc, type, rvals.lhs, rvals.rhs); @@ -366,7 +368,7 @@ LLValue *DtoBinFloatsEquals(const Loc &loc, DValue *lhs, DValue *rhs, TOK op) { LLValue *r = DtoRVal(rhs); res = (op == TOKequal ? gIR->ir->CreateFCmpOEQ(l, r) : gIR->ir->CreateFCmpUNE(l, r)); - if (lhs->type->toBasetype()->ty == Tvector) { + if (lhs->type->toBasetype()->ty == TY::Tvector) { res = mergeVectorEquals(res, op); } } else { diff --git a/gen/classes.cpp b/gen/classes.cpp index fd95d210fe..377165e8ca 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -231,14 +231,14 @@ DValue *DtoCastClass(const Loc &loc, DValue *val, Type *_to) { Type *to = _to->toBasetype(); // class -> pointer - if (to->ty == Tpointer) { + if (to->ty == TY::Tpointer) { IF_LOG Logger::println("to pointer"); LLType *tolltype = DtoType(_to); LLValue *rval = DtoBitCast(DtoRVal(val), tolltype); return new DImValue(_to, rval); } // class -> bool - if (to->ty == Tbool) { + if (to->ty == TY::Tbool) { IF_LOG Logger::println("to bool"); LLValue *llval = DtoRVal(val); LLValue *zero = LLConstant::getNullValue(llval->getType()); @@ -257,13 +257,13 @@ DValue *DtoCastClass(const Loc &loc, DValue *val, Type *_to) { return DtoCastInt(loc, &im, _to); } // class -> typeof(null) - if (to->ty == Tnull) { + if (to->ty == TY::Tnull) { IF_LOG Logger::println("to %s", to->toChars()); return new DImValue(_to, LLConstant::getNullValue(DtoType(_to))); } // must be class/interface - assert(to->ty == Tclass); + assert(to->ty == TY::Tclass); TypeClass *tc = static_cast(to); // from type @@ -416,7 +416,7 @@ LLValue *DtoVirtualFunctionPointer(DValue *inst, FuncDeclaration *fdecl) { // sanity checks assert(fdecl->isVirtual()); assert(!fdecl->isFinalFunc()); - assert(inst->type->toBasetype()->ty == Tclass); + assert(inst->type->toBasetype()->ty == TY::Tclass); // slot 0 is always ClassInfo/Interface* unless it is a CPP class assert(fdecl->vtblIndex > 0 || (fdecl->vtblIndex == 0 && diff --git a/gen/complex.cpp b/gen/complex.cpp index d1f5fa1903..3351b6bb91 100644 --- a/gen/complex.cpp +++ b/gen/complex.cpp @@ -33,12 +33,12 @@ LLType *DtoComplexBaseType(Type *t) { switch (t->toBasetype()->ty) { default: llvm_unreachable("Unexpected complex floating point type"); - case Tcomplex32: - return DtoType(Type::basic[Tfloat32]); - case Tcomplex64: - return DtoType(Type::basic[Tfloat64]); - case Tcomplex80: - return DtoType(Type::basic[Tfloat80]); + case TY::Tcomplex32: + return DtoType(Type::tfloat32); + case TY::Tcomplex64: + return DtoType(Type::tfloat64); + case TY::Tcomplex80: + return DtoType(Type::tfloat80); } } @@ -49,13 +49,13 @@ LLConstant *DtoConstComplex(Type *_ty, real_t re, real_t im) { switch (_ty->toBasetype()->ty) { default: llvm_unreachable("Unexpected complex floating point type"); - case Tcomplex32: + case TY::Tcomplex32: base = Type::tfloat32; break; - case Tcomplex64: + case TY::Tcomplex64: base = Type::tfloat64; break; - case Tcomplex80: + case TY::Tcomplex80: base = Type::tfloat80; break; } @@ -76,15 +76,15 @@ DValue *DtoComplex(const Loc &loc, Type *to, DValue *val) { switch (to->toBasetype()->ty) { default: llvm_unreachable("Unexpected complex floating point type"); - case Tcomplex32: + case TY::Tcomplex32: baserety = Type::tfloat32; baseimty = Type::timaginary32; break; - case Tcomplex64: + case TY::Tcomplex64: baserety = Type::tfloat64; baseimty = Type::timaginary64; break; - case Tcomplex80: + case TY::Tcomplex80: baserety = Type::tfloat80; baseimty = Type::timaginary80; break; @@ -121,15 +121,15 @@ void DtoGetComplexParts(const Loc &loc, Type *to, DValue *val, DValue *&re, switch (to->toBasetype()->ty) { default: llvm_unreachable("Unexpected complex floating point type"); - case Tcomplex32: + case TY::Tcomplex32: baserety = Type::tfloat32; baseimty = Type::timaginary32; break; - case Tcomplex64: + case TY::Tcomplex64: baserety = Type::tfloat64; baseimty = Type::timaginary64; break; - case Tcomplex80: + case TY::Tcomplex80: baserety = Type::tfloat80; baseimty = Type::timaginary80; break; @@ -462,20 +462,20 @@ DValue *DtoCastComplex(const Loc &loc, DValue *val, Type *_to) { switch (vty->ty) { default: llvm_unreachable("Unexpected complex floating point type"); - case Tcomplex32: + case TY::Tcomplex32: extractty = Type::timaginary32; break; - case Tcomplex64: + case TY::Tcomplex64: extractty = Type::timaginary64; break; - case Tcomplex80: + case TY::Tcomplex80: extractty = Type::timaginary80; break; } auto im = new DImValue(extractty, impart); return DtoCastFloat(loc, im, to); } - if (to->ty == Tbool) { + if (to->ty == TY::Tbool) { return new DImValue( _to, DtoComplexEquals(loc, TOKnotequal, val, DtoNullValue(vty))); } @@ -487,13 +487,13 @@ DValue *DtoCastComplex(const Loc &loc, DValue *val, Type *_to) { switch (vty->ty) { default: llvm_unreachable("Unexpected complex floating point type"); - case Tcomplex32: + case TY::Tcomplex32: extractty = Type::tfloat32; break; - case Tcomplex64: + case TY::Tcomplex64: extractty = Type::tfloat64; break; - case Tcomplex80: + case TY::Tcomplex80: extractty = Type::tfloat80; break; } diff --git a/gen/dcompute/targetOCL.cpp b/gen/dcompute/targetOCL.cpp index e6050f945a..60e2670a81 100644 --- a/gen/dcompute/targetOCL.cpp +++ b/gen/dcompute/targetOCL.cpp @@ -142,17 +142,17 @@ public: std::string basicTypeToString(Type *t) { std::stringstream ss; auto ty = t->ty; - if (ty == Tint8) + if (ty == TY::Tint8) ss << "char"; - else if (ty == Tuns8) + else if (ty == TY::Tuns8) ss << "uchar"; - else if (ty == Tvector) { + else if (ty == TY::Tvector) { TypeVector *vec = static_cast(t); auto size = vec->size(Loc()); auto basety = vec->basetype->ty; - if (basety == Tint8) + if (basety == TY::Tint8) ss << "char"; - else if (basety == Tuns8) + else if (basety == TY::Tuns8) ss << "uchar"; else ss << vec->basetype->toChars(); @@ -171,7 +171,7 @@ public: std::string tyName; std::string accessQual = "none"; int addrspace = 0; - if (v->type->ty == Tstruct && + if (v->type->ty == TY::Tstruct && (ptr = toDcomputePointer(static_cast(v->type)->sym))) { addrspace = ptr->addrspace; tyName = basicTypeToString(ptr->type) + "*"; diff --git a/gen/declarations.cpp b/gen/declarations.cpp index 5e0aa32c74..d3878717b1 100644 --- a/gen/declarations.cpp +++ b/gen/declarations.cpp @@ -86,7 +86,7 @@ public: return; } - if (decl->type->ty == Terror) { + if (decl->type->ty == TY::Terror) { decl->error("had semantic errors when compiling"); decl->ir->setDefined(); return; @@ -122,7 +122,7 @@ public: return; } - if (decl->type->ty == Terror) { + if (decl->type->ty == TY::Terror) { decl->error("had semantic errors when compiling"); decl->ir->setDefined(); return; @@ -181,7 +181,7 @@ public: return; } - if (decl->type->ty == Terror) { + if (decl->type->ty == TY::Terror) { decl->error("had semantic errors when compiling"); decl->ir->setDefined(); return; @@ -245,7 +245,7 @@ public: return; } - if (decl->type->ty == Terror) { + if (decl->type->ty == TY::Terror) { decl->error("had semantic errors when compiling"); decl->ir->setDefined(); return; @@ -279,7 +279,7 @@ public: IF_LOG Logger::println("Ignoring EnumDeclaration::codegen: '%s'", decl->toPrettyChars()); - if (decl->type->ty == Terror) { + if (decl->type->ty == TY::Terror) { decl->error("had semantic errors when compiling"); return; } diff --git a/gen/dibuilder.cpp b/gen/dibuilder.cpp index aa94d2cf87..67e3deb6cf 100644 --- a/gen/dibuilder.cpp +++ b/gen/dibuilder.cpp @@ -250,54 +250,54 @@ DIType DIBuilder::CreateBasicType(Type *type) { // find encoding unsigned Encoding; switch (t->ty) { - case Tbool: + case TY::Tbool: Encoding = DW_ATE_boolean; break; - case Tchar: + case TY::Tchar: if (emitCodeView) { // VS debugger does not support DW_ATE_UTF for char Encoding = DW_ATE_unsigned_char; break; } // fall through - case Twchar: - case Tdchar: + case TY::Twchar: + case TY::Tdchar: Encoding = DW_ATE_UTF; break; - case Tint8: + case TY::Tint8: if (emitCodeView) { // VS debugger does not support DW_ATE_signed for 8-bit Encoding = DW_ATE_signed_char; break; } // fall through - case Tint16: - case Tint32: - case Tint64: - case Tint128: + case TY::Tint16: + case TY::Tint32: + case TY::Tint64: + case TY::Tint128: Encoding = DW_ATE_signed; break; - case Tuns8: + case TY::Tuns8: if (emitCodeView) { // VS debugger does not support DW_ATE_unsigned for 8-bit Encoding = DW_ATE_unsigned_char; break; } // fall through - case Tuns16: - case Tuns32: - case Tuns64: - case Tuns128: + case TY::Tuns16: + case TY::Tuns32: + case TY::Tuns64: + case TY::Tuns128: Encoding = DW_ATE_unsigned; break; - case Tfloat32: - case Tfloat64: - case Tfloat80: + case TY::Tfloat32: + case TY::Tfloat64: + case TY::Tfloat80: Encoding = DW_ATE_float; break; - case Timaginary32: - case Timaginary64: - case Timaginary80: + case TY::Timaginary32: + case TY::Timaginary64: + case TY::Timaginary80: if (emitCodeView) { // DW_ATE_imaginary_float not supported by the LLVM DWARF->CodeView // conversion @@ -306,9 +306,9 @@ DIType DIBuilder::CreateBasicType(Type *type) { } Encoding = DW_ATE_imaginary_float; break; - case Tcomplex32: - case Tcomplex64: - case Tcomplex80: + case TY::Tcomplex32: + case TY::Tcomplex64: + case TY::Tcomplex80: if (emitCodeView) { // DW_ATE_complex_float not supported by the LLVM DWARF->CodeView // conversion @@ -408,13 +408,13 @@ DIType DIBuilder::CreateComplexType(Type *type) { Type *elemtype = nullptr; switch (t->ty) { - case Tcomplex32: + case TY::Tcomplex32: elemtype = Type::tfloat32; break; - case Tcomplex64: + case TY::Tcomplex64: elemtype = Type::tfloat64; break; - case Tcomplex80: + case TY::Tcomplex80: elemtype = Type::tfloat80; break; default: @@ -531,11 +531,11 @@ void DIBuilder::AddStaticMembers(AggregateDeclaration *ad, DIFile file, } DIType DIBuilder::CreateCompositeType(Type *t) { - assert((t->ty == Tstruct || t->ty == Tclass) && + assert((t->ty == TY::Tstruct || t->ty == TY::Tclass) && "Unsupported type for debug info in DIBuilder::CreateCompositeType"); AggregateDeclaration *ad; - if (t->ty == Tstruct) { + if (t->ty == TY::Tstruct) { ad = static_cast(t)->sym; } else { ad = static_cast(t)->sym; @@ -544,7 +544,7 @@ DIType DIBuilder::CreateCompositeType(Type *t) { // Use the actual type associated with the declaration, ignoring any // const/wrappers. LLType *T = DtoType(ad->type); - if (t->ty == Tclass) + if (t->ty == TY::Tclass) T = T->getPointerElementType(); IrAggr *irAggr = getIrAggr(ad, true); @@ -578,8 +578,8 @@ DIType DIBuilder::CreateCompositeType(Type *t) { const auto uniqueIdentifier = uniqueIdent(t); // set diCompositeType to handle recursive types properly - unsigned tag = (t->ty == Tstruct) ? llvm::dwarf::DW_TAG_structure_type - : llvm::dwarf::DW_TAG_class_type; + unsigned tag = (t->ty == TY::Tstruct) ? llvm::dwarf::DW_TAG_structure_type + : llvm::dwarf::DW_TAG_class_type; irAggr->diCompositeType = DBuilder.createReplaceableCompositeType(tag, name, scope, file, lineNum); @@ -604,7 +604,7 @@ DIType DIBuilder::CreateCompositeType(Type *t) { const auto elemsArray = DBuilder.getOrCreateArray(elems); DIType ret; - if (t->ty == Tclass) { + if (t->ty == TY::Tclass) { ret = DBuilder.createClassType( scope, name, file, lineNum, sizeInBits, alignmentInBits, classOffsetInBits, DIFlags::FlagZero, derivedFrom, elemsArray, @@ -653,7 +653,7 @@ DIType DIBuilder::CreateSArrayType(TypeSArray *type) { Type *te = type; llvm::SmallVector subscripts; - for (; te->ty == Tsarray; te = te->nextOf()) { + for (; te->ty == TY::Tsarray; te = te->nextOf()) { TypeSArray *tsa = static_cast(te); const auto count = tsa->dim->toInteger(); #if LDC_LLVM_VER >= 1100 @@ -762,12 +762,12 @@ DIType DIBuilder::CreateUnspecifiedType(Dsymbol *sym) { //////////////////////////////////////////////////////////////////////////////// DIType DIBuilder::CreateTypeDescription(Type *t, bool voidToUbyte) { - if (voidToUbyte && t->toBasetype()->ty == Tvoid) + if (voidToUbyte && t->toBasetype()->ty == TY::Tvoid) t = Type::tuns8; - if (t->ty == Tvoid || t->ty == Tnoreturn) + if (t->ty == TY::Tvoid || t->ty == TY::Tnoreturn) return nullptr; - if (t->ty == Tnull) { + if (t->ty == TY::Tnull) { // display null as void* return DBuilder.createPointerType(CreateTypeDescription(Type::tvoid), 8, 8, /* DWARFAddressSpace */ llvm::None, @@ -787,7 +787,7 @@ DIType DIBuilder::CreateTypeDescription(Type *t, bool voidToUbyte) { return CreateSArrayType(tsa); if (auto taa = t->isTypeAArray()) return CreateAArrayType(taa); - if (t->ty == Tstruct) + if (t->ty == TY::Tstruct) return CreateCompositeType(t); if (auto tc = t->isTypeClass()) { LLType *T = DtoType(t); @@ -1193,7 +1193,7 @@ void DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd, } else { // 2) dynamic arrays, delegates and vectors TY ty = type->toBasetype()->ty; - if (ty == Tarray || ty == Tdelegate || ty == Tvector) + if (ty == TY::Tarray || ty == TY::Tdelegate || ty == TY::Tvector) forceAsLocal = true; } } diff --git a/gen/dvalue.cpp b/gen/dvalue.cpp index 16bff7be89..77026e3906 100644 --- a/gen/dvalue.cpp +++ b/gen/dvalue.cpp @@ -67,9 +67,10 @@ DImValue::DImValue(Type *t, llvm::Value *v) : DRValue(t, v) { // TODO: get rid of Tfunction exception // v may be an addrspace qualified pointer so strip it before doing a pointer // equality check. - assert(t->toBasetype()->ty == Tfunction || + assert(t->toBasetype()->ty == TY::Tfunction || stripAddrSpaces(v->getType()) == DtoType(t)); - assert(t->toBasetype()->ty != Tarray && "use DSliceValue for dynamic arrays"); + assert(t->toBasetype()->ty != TY::Tarray && + "use DSliceValue for dynamic arrays"); } //////////////////////////////////////////////////////////////////////////////// @@ -82,7 +83,7 @@ DConstValue::DConstValue(Type *t, LLConstant *con) : DRValue(t, con) { DSliceValue::DSliceValue(Type *t, LLValue *pair, LLValue *length, LLValue *ptr) : DRValue(t, pair), length(length), ptr(ptr) { - assert(t->toBasetype()->ty == Tarray); + assert(t->toBasetype()->ty == TY::Tarray); // v may be an addrspace qualified pointer so strip it before doing a pointer // equality check. assert(stripAddrSpaces(pair->getType()) == DtoType(t)); @@ -120,7 +121,7 @@ bool DFuncValue::definedInFuncEntryBB() { DLValue::DLValue(Type *t, LLValue *v) : DValue(t, v) { // v may be an addrspace qualified pointer so strip it before doing a pointer // equality check. - assert(t->toBasetype()->ty == Ttuple || + assert(t->toBasetype()->ty == TY::Ttuple || stripAddrSpaces(v->getType()) == DtoPtrToType(t)); } @@ -133,7 +134,7 @@ DRValue *DLValue::getRVal() { LLValue *rval = DtoLoad(val); const auto ty = type->toBasetype()->ty; - if (ty == Tbool) { + if (ty == TY::Tbool) { assert(rval->getType() == llvm::Type::getInt8Ty(gIR->context())); if (isOptimizationEnabled()) { @@ -146,7 +147,7 @@ DRValue *DLValue::getRVal() { // truncate to i1 rval = gIR->ir->CreateTrunc(rval, llvm::Type::getInt1Ty(gIR->context())); - } else if (ty == Tarray) { + } else if (ty == TY::Tarray) { return new DSliceValue(type, rval); } diff --git a/gen/functions.cpp b/gen/functions.cpp index fef1cdf144..cf9a1bcbe1 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -68,7 +68,7 @@ llvm::FunctionType *DtoFunctionType(Type *type, IrFuncTy &irFty, Type *thistype, LOG_SCOPE // sanity check - assert(type->ty == Tfunction); + assert(type->ty == TY::Tfunction); TypeFunction *f = static_cast(type); assert(f->next && "Encountered function type with invalid return type; " "trying to codegen function ignored by the frontend?"); @@ -94,7 +94,7 @@ llvm::FunctionType *DtoFunctionType(Type *type, IrFuncTy &irFty, Type *thistype, newIrFty.ret = new IrFuncTyArg(Type::tint32, false); } else { Type *rt = f->next; - const bool byref = f->isref() && rt->toBasetype()->ty != Tvoid; + const bool byref = f->isref() && rt->toBasetype()->ty != TY::Tvoid; llvm::AttrBuilder attrs; if (abi->returnInArg(f, fd && fd->needThis())) { @@ -126,8 +126,8 @@ llvm::FunctionType *DtoFunctionType(Type *type, IrFuncTy &irFty, Type *thistype, if (fd && fd->isCtorDeclaration()) { attrs.addAttribute(LLAttribute::Returned); } - newIrFty.arg_this = - new IrFuncTyArg(thistype, thistype->toBasetype()->ty == Tstruct, attrs); + newIrFty.arg_this = new IrFuncTyArg( + thistype, thistype->toBasetype()->ty == TY::Tstruct, attrs); ++nextLLArgIdx; } else if (nesttype) { // Add the context pointer for nested functions @@ -377,9 +377,9 @@ void DtoResolveFunction(FuncDeclaration *fdecl, const bool willDeclare) { Type *type = fdecl->type; // If errors occurred compiling it, such as bugzilla 6118 - if (type && type->ty == Tfunction) { + if (type && type->ty == TY::Tfunction) { Type *next = static_cast(type)->next; - if (!next || next->ty == Terror) { + if (!next || next->ty == TY::Terror) { return; } } @@ -422,7 +422,7 @@ void DtoResolveFunction(FuncDeclaration *fdecl, const bool willDeclare) { fdecl->llvmInternal = LLVMinline_ir; fdecl->linkage = LINK::c; Type *type = fdecl->type; - assert(type->ty == Tfunction); + assert(type->ty == TY::Tfunction); static_cast(type)->linkage = LINK::c; DtoFunctionType(fdecl); @@ -679,7 +679,7 @@ void DtoDeclareFunction(FuncDeclaration *fdecl, const bool willDefine) { // the codegen options allow skipping PLT. func->addFnAttr(LLAttribute::NonLazyBind); } - if (f->next->toBasetype()->ty == Tnoreturn) { + if (f->next->toBasetype()->ty == TY::Tnoreturn) { func->addFnAttr(LLAttribute::NoReturn); } @@ -1033,11 +1033,11 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) { return; } - if ((fd->type && fd->type->ty == Terror) || - (fd->type && fd->type->ty == Tfunction && + if ((fd->type && fd->type->ty == TY::Terror) || + (fd->type && fd->type->ty == TY::Tfunction && static_cast(fd->type)->next == nullptr) || - (fd->type && fd->type->ty == Tfunction && - static_cast(fd->type)->next->ty == Terror)) { + (fd->type && fd->type->ty == TY::Tfunction && + static_cast(fd->type)->next->ty == TY::Terror)) { IF_LOG Logger::println( "Ignoring; has error type, no return type or returns error type"); fd->ir->setDefined(); @@ -1400,7 +1400,7 @@ DValue *DtoArgument(Parameter *fnarg, Expression *argexp) { // lazy arg if (fnarg && (fnarg->storageClass & STClazy)) { - assert(argexp->type->toBasetype()->ty == Tdelegate); + assert(argexp->type->toBasetype()->ty == TY::Tdelegate); assert(!arg->isLVal()); return arg; } diff --git a/gen/inlineir.cpp b/gen/inlineir.cpp index a4a1ced11d..f644d2e4b7 100644 --- a/gen/inlineir.cpp +++ b/gen/inlineir.cpp @@ -177,7 +177,7 @@ DValue *DtoInlineIRExpr(const Loc &loc, FuncDeclaration *fdecl, } stream << ")\n{\n" << code; - if (ret->ty == Tvoid) { + if (ret->ty == TY::Tvoid) { stream << "\nret void"; } stream << "\n}"; diff --git a/gen/irstate.cpp b/gen/irstate.cpp index 447c404aac..22b3d3040f 100644 --- a/gen/irstate.cpp +++ b/gen/irstate.cpp @@ -128,7 +128,7 @@ bool IRState::emitArrayBoundsChecks() { } Type *t = func()->decl->type; - return t->ty == Tfunction && ((TypeFunction *)t)->trust == TRUST::safe; + return t->ty == TY::Tfunction && ((TypeFunction *)t)->trust == TRUST::safe; } LLConstant * diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 3cb3f75e51..b0d812e199 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -135,7 +135,7 @@ void DtoDeleteArray(const Loc &loc, DValue *arr) { // the TypeInfo argument must be null if the type has no dtor Type *elementType = arr->type->nextOf(); - bool hasDtor = (elementType->toBasetype()->ty == Tstruct && + bool hasDtor = (elementType->toBasetype()->ty == TY::Tstruct && elementType->needsDestruction()); LLValue *typeInfo = !hasDtor ? getNullPtr(fty->getParamType(1)) : DtoTypeInfoOf(loc, elementType); @@ -367,11 +367,11 @@ void DtoAssign(const Loc &loc, DValue *lhs, DValue *rhs, int op, LOG_SCOPE; Type *t = lhs->type->toBasetype(); - assert(t->ty != Tvoid && "Cannot assign values of type void."); + assert(t->ty != TY::Tvoid && "Cannot assign values of type void."); - if (t->ty == Tbool) { + if (t->ty == TY::Tbool) { DtoStoreZextI8(DtoRVal(rhs), DtoLVal(lhs)); - } else if (t->ty == Tstruct) { + } else if (t->ty == TY::Tstruct) { // don't copy anything to empty structs if (static_cast(t)->sym->fields.length > 0) { llvm::Value *src = DtoLVal(rhs); @@ -383,9 +383,9 @@ void DtoAssign(const Loc &loc, DValue *lhs, DValue *rhs, int op, if (src != dst) DtoMemCpy(dst, src); } - } else if (t->ty == Tarray || t->ty == Tsarray) { + } else if (t->ty == TY::Tarray || t->ty == TY::Tsarray) { DtoArrayAssign(loc, lhs, rhs, op, canSkipPostblit); - } else if (t->ty == Tdelegate) { + } else if (t->ty == TY::Tdelegate) { LLValue *l = DtoLVal(lhs); LLValue *r = DtoRVal(rhs); IF_LOG { @@ -393,8 +393,8 @@ void DtoAssign(const Loc &loc, DValue *lhs, DValue *rhs, int op, Logger::cout() << "rhs: " << *r << '\n'; } DtoStore(r, l); - } else if (t->ty == Tclass) { - assert(rhs->type->toBasetype()->ty == Tclass); + } else if (t->ty == TY::Tclass) { + assert(rhs->type->toBasetype()->ty == TY::Tclass); LLValue *l = DtoLVal(lhs); LLValue *r = DtoRVal(rhs); IF_LOG { @@ -454,13 +454,13 @@ DValue *DtoNullValue(Type *type, Loc loc) { } // integer, floating, pointer, assoc array, delegate and class have no special // representation - if (basetype->isintegral() || basetype->isfloating() || basety == Tpointer || - basety == Tnull || basety == Tclass || basety == Tdelegate || - basety == Taarray) { + if (basetype->isintegral() || basetype->isfloating() || + basety == TY::Tpointer || basety == TY::Tnull || basety == TY::Tclass || + basety == TY::Tdelegate || basety == TY::Taarray) { return new DNullValue(type, LLConstant::getNullValue(lltype)); } // dynamic array - if (basety == Tarray) { + if (basety == TY::Tarray) { LLValue *len = DtoConstSize_t(0); LLValue *ptr = getNullPtr(DtoPtrToType(basetype->nextOf())); return new DSliceValue(type, len, ptr); @@ -488,13 +488,13 @@ DValue *DtoCastInt(const Loc &loc, DValue *val, Type *_to) { size_t fromsz = from->size(); size_t tosz = to->size(); - if (to->ty == Tbool) { + if (to->ty == TY::Tbool) { LLValue *zero = LLConstantInt::get(rval->getType(), 0, false); rval = gIR->ir->CreateICmpNE(rval, zero); } else if (to->isintegral()) { - if (fromsz < tosz || from->ty == Tbool) { + if (fromsz < tosz || from->ty == TY::Tbool) { IF_LOG Logger::cout() << "cast to: " << *tolltype << '\n'; - if (isLLVMUnsigned(from) || from->ty == Tbool) { + if (isLLVMUnsigned(from) || from->ty == TY::Tbool) { rval = new llvm::ZExtInst(rval, tolltype, "", gIR->scopebb()); } else { rval = new llvm::SExtInst(rval, tolltype, "", gIR->scopebb()); @@ -512,7 +512,7 @@ DValue *DtoCastInt(const Loc &loc, DValue *val, Type *_to) { } else { rval = new llvm::SIToFPInst(rval, tolltype, "", gIR->scopebb()); } - } else if (to->ty == Tpointer) { + } else if (to->ty == TY::Tpointer) { IF_LOG Logger::cout() << "cast pointer: " << *tolltype << '\n'; rval = gIR->ir->CreateIntToPtr(rval, tolltype); } else { @@ -530,18 +530,19 @@ DValue *DtoCastPtr(const Loc &loc, DValue *val, Type *to) { Type *totype = to->toBasetype(); Type *fromtype = val->type->toBasetype(); (void)fromtype; - assert(fromtype->ty == Tpointer || fromtype->ty == Tfunction); + assert(fromtype->ty == TY::Tpointer || fromtype->ty == TY::Tfunction); LLValue *rval; - if (totype->ty == Tpointer || totype->ty == Tclass || totype->ty == Taarray) { + if (totype->ty == TY::Tpointer || totype->ty == TY::Tclass || + totype->ty == TY::Taarray) { LLValue *src = DtoRVal(val); IF_LOG { Logger::cout() << "src: " << *src << '\n'; Logger::cout() << "to type: " << *tolltype << '\n'; } rval = DtoBitCast(src, tolltype); - } else if (totype->ty == Tbool) { + } else if (totype->ty == TY::Tbool) { LLValue *src = DtoRVal(val); LLValue *zero = LLConstant::getNullValue(src->getType()); rval = gIR->ir->CreateICmpNE(src, zero); @@ -572,7 +573,7 @@ DValue *DtoCastFloat(const Loc &loc, DValue *val, Type *to) { LLValue *rval; - if (totype->ty == Tbool) { + if (totype->ty == TY::Tbool) { rval = DtoRVal(val); LLValue *zero = LLConstant::getNullValue(rval->getType()); rval = gIR->ir->CreateFCmpUNE(rval, zero); @@ -607,10 +608,10 @@ DValue *DtoCastFloat(const Loc &loc, DValue *val, Type *to) { } DValue *DtoCastDelegate(const Loc &loc, DValue *val, Type *to) { - if (to->toBasetype()->ty == Tdelegate) { + if (to->toBasetype()->ty == TY::Tdelegate) { return DtoPaintType(loc, val, to); } - if (to->toBasetype()->ty == Tbool) { + if (to->toBasetype()->ty == TY::Tbool) { return new DImValue(to, DtoDelegateEquals(TOKnotequal, DtoRVal(val), nullptr)); } @@ -620,11 +621,11 @@ DValue *DtoCastDelegate(const Loc &loc, DValue *val, Type *to) { } DValue *DtoCastVector(const Loc &loc, DValue *val, Type *to) { - assert(val->type->toBasetype()->ty == Tvector); + assert(val->type->toBasetype()->ty == TY::Tvector); Type *totype = to->toBasetype(); LLType *tolltype = DtoType(to); - if (totype->ty == Tsarray) { + if (totype->ty == TY::Tsarray) { // Reinterpret-cast without copy if the source vector is in memory. if (val->isLVal()) { LLValue *vector = DtoLVal(val); @@ -639,7 +640,7 @@ DValue *DtoCastVector(const Loc &loc, DValue *val, Type *to) { LLValue *array = DtoAllocaDump(vector, tolltype, DtoAlignment(val->type)); return new DLValue(to, array); } - if (totype->ty == Tvector && to->size() == val->type->size()) { + if (totype->ty == TY::Tvector && to->size() == val->type->size()) { return new DImValue(to, DtoBitCast(DtoRVal(val), tolltype)); } error(loc, "invalid cast from `%s` to `%s`", val->type->toChars(), @@ -649,7 +650,7 @@ DValue *DtoCastVector(const Loc &loc, DValue *val, Type *to) { DValue *DtoCastStruct(const Loc &loc, DValue *val, Type *to) { Type *const totype = to->toBasetype(); - if (totype->ty == Tstruct) { + if (totype->ty == TY::Tstruct) { // This a cast to repaint a struct to another type, which the language // allows for identical layouts (opCast() and so on have been lowered // earlier by the frontend). @@ -668,8 +669,8 @@ DValue *DtoCast(const Loc &loc, DValue *val, Type *to) { Type *fromtype = val->type->toBasetype(); Type *totype = to->toBasetype(); - if (fromtype->ty == Taarray) { - if (totype->ty == Taarray) { + if (fromtype->ty == TY::Taarray) { + if (totype->ty == TY::Taarray) { // reinterpret-cast keeping lvalue-ness, IR types will match up if (val->isLVal()) return new DLValue(to, DtoLVal(val)); @@ -677,12 +678,12 @@ DValue *DtoCast(const Loc &loc, DValue *val, Type *to) { } // DMD allows casting AAs to void*, even if they are internally // implemented as structs. - if (totype->ty == Tpointer) { + if (totype->ty == TY::Tpointer) { IF_LOG Logger::println("Casting AA to pointer."); LLValue *rval = DtoBitCast(DtoRVal(val), DtoType(to)); return new DImValue(to, rval); } - if (totype->ty == Tbool) { + if (totype->ty == TY::Tbool) { IF_LOG Logger::println("Casting AA to bool."); LLValue *rval = DtoRVal(val); LLValue *zero = LLConstant::getNullValue(rval->getType()); @@ -698,7 +699,7 @@ DValue *DtoCast(const Loc &loc, DValue *val, Type *to) { to->toChars()); LOG_SCOPE; - if (fromtype->ty == Tvector) { + if (fromtype->ty == TY::Tvector) { // First, handle vector types (which can also be isintegral()). return DtoCastVector(loc, val, to); } @@ -713,20 +714,20 @@ DValue *DtoCast(const Loc &loc, DValue *val, Type *to) { } switch (fromtype->ty) { - case Tclass: + case TY::Tclass: return DtoCastClass(loc, val, to); - case Tarray: - case Tsarray: + case TY::Tarray: + case TY::Tsarray: return DtoCastArray(loc, val, to); - case Tpointer: - case Tfunction: + case TY::Tpointer: + case TY::Tfunction: return DtoCastPtr(loc, val, to); - case Tdelegate: + case TY::Tdelegate: return DtoCastDelegate(loc, val, to); - case Tstruct: + case TY::Tstruct: return DtoCastStruct(loc, val, to); - case Tnull: - case Tnoreturn: + case TY::Tnull: + case TY::Tnoreturn: return DtoNullValue(to, loc); default: error(loc, "invalid cast from `%s` to `%s`", val->type->toChars(), @@ -742,9 +743,9 @@ DValue *DtoPaintType(const Loc &loc, DValue *val, Type *to) { IF_LOG Logger::println("repainting from '%s' to '%s'", from->toChars(), to->toChars()); - if (from->ty == Tarray) { + if (from->ty == TY::Tarray) { Type *at = to->toBasetype(); - assert(at->ty == Tarray); + assert(at->ty == TY::Tarray); Type *elem = at->nextOf()->pointerTo(); if (DSliceValue *slice = val->isSlice()) { return new DSliceValue(to, slice->getLength(), @@ -761,9 +762,9 @@ DValue *DtoPaintType(const Loc &loc, DValue *val, Type *to) { ptr = DtoBitCast(ptr, DtoType(elem)); return new DImValue(to, DtoAggrPair(len, ptr)); } - if (from->ty == Tdelegate) { + if (from->ty == TY::Tdelegate) { Type *dgty = to->toBasetype(); - assert(dgty->ty == Tdelegate); + assert(dgty->ty == TY::Tdelegate); if (val->isLVal()) { LLValue *ptr = DtoLVal(val); assert(isaPointer(ptr)); @@ -779,14 +780,16 @@ DValue *DtoPaintType(const Loc &loc, DValue *val, Type *to) { IF_LOG Logger::cout() << "dg: " << *aggr << '\n'; return new DImValue(to, aggr); } - if (from->ty == Tpointer || from->ty == Tclass || from->ty == Taarray) { + if (from->ty == TY::Tpointer || from->ty == TY::Tclass || + from->ty == TY::Taarray) { Type *b = to->toBasetype(); - assert(b->ty == Tpointer || b->ty == Tclass || b->ty == Taarray); + assert(b->ty == TY::Tpointer || b->ty == TY::Tclass || + b->ty == TY::Taarray); LLValue *ptr = DtoBitCast(DtoRVal(val), DtoType(b)); return new DImValue(to, ptr); } - if (from->ty == Tsarray) { - assert(to->toBasetype()->ty == Tsarray); + if (from->ty == TY::Tsarray) { + assert(to->toBasetype()->ty == TY::Tsarray); LLValue *ptr = DtoBitCast(DtoLVal(val), DtoPtrToType(to)); return new DLValue(to, ptr); } @@ -1128,7 +1131,7 @@ LLConstant *DtoConstExpInit(const Loc &loc, Type *targetType, Expression *exp) { if (llType == targetLLType) return val; - if (baseTargetType->ty == Tsarray) { + if (baseTargetType->ty == TY::Tsarray) { Logger::println("Building constant array initializer from scalar."); assert(baseValType->size() > 0); @@ -1138,7 +1141,7 @@ LLConstant *DtoConstExpInit(const Loc &loc, Type *targetType, Expression *exp) { // may be a multi-dimensional array init, e.g., `char[2][3] x = 0xff` baseValType = stripModifiers(baseValType); LLSmallVector dims; // { 3, 2 } - for (auto t = baseTargetType; t->ty == Tsarray;) { + for (auto t = baseTargetType; t->ty == TY::Tsarray;) { dims.push_back(static_cast(t)->dim->toUInteger()); auto elementType = stripModifiers(t->nextOf()->toBasetype()); if (elementType->equals(baseValType)) @@ -1159,11 +1162,11 @@ LLConstant *DtoConstExpInit(const Loc &loc, Type *targetType, Expression *exp) { return val; } - if (baseTargetType->ty == Tvector) { + if (baseTargetType->ty == TY::Tvector) { Logger::println("Building constant vector initializer from scalar."); TypeVector *tv = static_cast(baseTargetType); - assert(tv->basetype->ty == Tsarray); + assert(tv->basetype->ty == TY::Tsarray); dinteger_t elemCount = static_cast(tv->basetype)->dim->toInteger(); #if LDC_LLVM_VER >= 1200 @@ -1318,7 +1321,7 @@ size_t getMemberSize(Type *type) { //////////////////////////////////////////////////////////////////////////////// Type *stripModifiers(Type *type, bool transitive) { - if (type->ty == Tfunction) { + if (type->ty == TY::Tfunction) { return type; } @@ -1349,7 +1352,7 @@ void callPostblit(const Loc &loc, Expression *exp, LLValue *val) { Type *tb = exp->type->toBasetype(); if ((exp->op == TOKvar || exp->op == TOKdotvar || exp->op == TOKstar || exp->op == TOKthis || exp->op == TOKindex) && - tb->ty == Tstruct) { + tb->ty == TY::Tstruct) { StructDeclaration *sd = static_cast(tb)->sym; if (sd->postblit) { FuncDeclaration *fd = sd->postblit; @@ -1359,7 +1362,7 @@ void callPostblit(const Loc &loc, Expression *exp, LLValue *val) { } Expressions args; DFuncValue dfn(fd, DtoCallee(fd), val); - DtoCallFunction(loc, Type::basic[Tvoid], &dfn, &args); + DtoCallFunction(loc, Type::tvoid, &dfn, &args); } } } @@ -1372,7 +1375,9 @@ bool isSpecialRefVar(VarDeclaration *vd) { //////////////////////////////////////////////////////////////////////////////// -bool isLLVMUnsigned(Type *t) { return t->isunsigned() || t->ty == Tpointer; } +bool isLLVMUnsigned(Type *t) { + return t->isunsigned() || t->ty == TY::Tpointer; +} //////////////////////////////////////////////////////////////////////////////// @@ -1527,7 +1532,7 @@ DValue *DtoSymbolAddress(const Loc &loc, Type *type, Declaration *decl) { } if (vd->storage_class & STClazy) { Logger::println("lazy parameter"); - assert(type->ty == Tdelegate); + assert(type->ty == TY::Tdelegate); } assert(!isSpecialRefVar(vd) && "Code not expected to handle special " "ref vars, although it can easily be " @@ -1581,8 +1586,8 @@ DValue *DtoSymbolAddress(const Loc &loc, Type *type, Declaration *decl) { // LDC extension: void[]-typed `__traits(initSymbol)`, for classes too auto tb = sdecl->type->toBasetype(); - if (tb->ty != Tstruct) { - assert(tb->ty == Tarray && tb->nextOf()->ty == Tvoid); + if (tb->ty != TY::Tstruct) { + assert(tb->ty == TY::Tarray && tb->nextOf()->ty == TY::Tvoid); const auto size = DtoConstSize_t(ad->structsize); llvm::Constant *ptr = sd && sd->zeroInit @@ -1896,8 +1901,8 @@ DValue *makeVarDValue(Type *type, VarDeclaration *vd, llvm::Value *storage) { // The type of globals is determined by their initializer, and the front-end // may inject implicit casts for class references and static arrays. assert(vd->isDataseg() || (vd->storage_class & STCextern) || - type->toBasetype()->ty == Tclass || - type->toBasetype()->ty == Tsarray); + type->toBasetype()->ty == TY::Tclass || + type->toBasetype()->ty == TY::Tsarray); llvm::Type *pointeeType = val->getType()->getPointerElementType(); if (isSpecialRef) pointeeType = pointeeType->getPointerElementType(); diff --git a/gen/naked.cpp b/gen/naked.cpp index 3f6eaf4c54..c93277141c 100644 --- a/gen/naked.cpp +++ b/gen/naked.cpp @@ -268,8 +268,8 @@ void emitABIReturnAsmStmt(IRAsmBlock *asmblock, const Loc &loc, // x86 if (triple.getArch() == llvm::Triple::x86) { - if (rt->isintegral() || rt->ty == Tpointer || rt->ty == Tclass || - rt->ty == Taarray) { + if (rt->isintegral() || rt->ty == TY::Tpointer || rt->ty == TY::Tclass || + rt->ty == TY::Taarray) { if (rt->size() == 8) { as->out_c = "=A,"; } else { @@ -281,7 +281,7 @@ void emitABIReturnAsmStmt(IRAsmBlock *asmblock, const Loc &loc, // extern(D) always returns on the FPU stack as->out_c = "={st},={st(1)},"; asmblock->retn = 2; - } else if (rt->ty == Tcomplex32) { + } else if (rt->ty == TY::Tcomplex32) { // non-extern(D) cfloat is returned as i64 as->out_c = "=A,"; asmblock->retty = LLType::getInt64Ty(gIR->context()); @@ -295,7 +295,7 @@ void emitABIReturnAsmStmt(IRAsmBlock *asmblock, const Loc &loc, } else { as->out_c = "={st},"; } - } else if (rt->ty == Tarray || rt->ty == Tdelegate) { + } else if (rt->ty == TY::Tarray || rt->ty == TY::Tdelegate) { as->out_c = "={ax},={dx},"; asmblock->retn = 2; #if 0 @@ -332,8 +332,8 @@ void emitABIReturnAsmStmt(IRAsmBlock *asmblock, const Loc &loc, // x86_64 else if (triple.getArch() == llvm::Triple::x86_64) { - if (rt->isintegral() || rt->ty == Tpointer || rt->ty == Tclass || - rt->ty == Taarray) { + if (rt->isintegral() || rt->ty == TY::Tpointer || rt->ty == TY::Tclass || + rt->ty == TY::Taarray) { as->out_c = "={ax},"; } else if (rt->isfloating()) { const bool isWin64 = triple.isOSWindows(); @@ -372,7 +372,7 @@ void emitABIReturnAsmStmt(IRAsmBlock *asmblock, const Loc &loc, // Plain float/double/ifloat/idouble as->out_c = "={xmm0},"; } - } else if (rt->ty == Tarray || rt->ty == Tdelegate) { + } else if (rt->ty == TY::Tarray || rt->ty == TY::Tdelegate) { as->out_c = "={ax},={dx},"; asmblock->retn = 2; } else { @@ -442,7 +442,7 @@ DValue *DtoInlineAsmExpr(const Loc &loc, FuncDeclaration *fd, DtoInlineAsmExpr(loc, code, constraints, operands, irReturnType); // work around missing tuple support for users of the return value - if (sretPointer || returnType->ty == Tstruct) { + if (sretPointer || returnType->ty == TY::Tstruct) { auto lvalue = sretPointer; if (!lvalue) lvalue = DtoAlloca(returnType, ".__asm_tuple_ret"); diff --git a/gen/pragma.cpp b/gen/pragma.cpp index 63a7a00544..78a5ed5f04 100644 --- a/gen/pragma.cpp +++ b/gen/pragma.cpp @@ -369,10 +369,10 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s, case LLVMglobal_crt_dtor: { const unsigned char flag = llvm_internal == LLVMglobal_crt_ctor ? 1 : 2; const int count = applyFunctionPragma(s, [=](FuncDeclaration *fd) { - assert(fd->type->ty == Tfunction); + assert(fd->type->ty == TY::Tfunction); TypeFunction *type = static_cast(fd->type); Type *retType = type->next; - if (retType->ty != Tvoid || type->parameterList.length() > 0 || + if (retType->ty != TY::Tvoid || type->parameterList.length() > 0 || (fd->isMember() && !fd->isStatic())) { error(s->loc, "the `%s` pragma is only allowed on `void` functions which take " diff --git a/gen/semantic-dcompute.cpp b/gen/semantic-dcompute.cpp index 4e52c5a49b..c3bd411081 100644 --- a/gen/semantic-dcompute.cpp +++ b/gen/semantic-dcompute.cpp @@ -92,12 +92,12 @@ struct DComputeSemanticAnalyser : public StoppableVisitor { return; } - if (decl->type->ty == Taarray) { + if (decl->type->ty == TY::Taarray) { decl->error("associative arrays not allowed in `@compute` code"); stop = true; } // includes interfaces - else if (decl->type->ty == Tclass) { + else if (decl->type->ty == TY::Tclass) { decl->error("interfaces and classes not allowed in `@compute` code"); } } @@ -112,7 +112,7 @@ struct DComputeSemanticAnalyser : public StoppableVisitor { // Nogc enforcement. // No need to check AssocArrayLiteral because AA's are banned anyway void visit(ArrayLiteralExp *e) override { - if (e->type->ty != Tarray || !e->elements || !e->elements->length) + if (e->type->ty != TY::Tarray || !e->elements || !e->elements->length) return; e->error("array literal in `@compute` code not allowed"); stop = true; diff --git a/gen/statements.cpp b/gen/statements.cpp index 2f17cd9f19..6efdcf3b7a 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -193,10 +193,11 @@ public: if (!stmt->exp) { // implicitly return 0 for the main function returnValue = LLConstant::getNullValue(funcType->getReturnType()); - } else if ((rtb->ty == Tvoid || rtb->ty == Tnoreturn) && !isMainFunc) { + } else if ((rtb->ty == TY::Tvoid || rtb->ty == TY::Tnoreturn) && + !isMainFunc) { // evaluate expression for side effects - assert(stmt->exp->type->toBasetype()->ty == Tvoid || - stmt->exp->type->toBasetype()->ty == Tnoreturn); + assert(stmt->exp->type->toBasetype()->ty == TY::Tvoid || + stmt->exp->type->toBasetype()->ty == TY::Tnoreturn); toElem(stmt->exp); } else if (funcType->getReturnType()->isVoidTy()) { // if the IR function's return type is void (but not the D one), it uses diff --git a/gen/structs.cpp b/gen/structs.cpp index ad93a621c7..63668fe668 100644 --- a/gen/structs.cpp +++ b/gen/structs.cpp @@ -74,7 +74,7 @@ void DtoResolveStruct(StructDeclaration *sd, const Loc &callerLoc) { LLValue *DtoStructEquals(TOK op, DValue *lhs, DValue *rhs) { Type *t = lhs->type->toBasetype(); - assert(t->ty == Tstruct); + assert(t->ty == TY::Tstruct); // set predicate llvm::ICmpInst::Predicate cmpop; @@ -102,7 +102,7 @@ LLValue *DtoStructEquals(TOK op, DValue *lhs, DValue *rhs) { /// specified type. /// Union types will get expanded into a struct, with a type for each member. LLType *DtoUnpaddedStructType(Type *dty) { - assert(dty->ty == Tstruct); + assert(dty->ty == TY::Tstruct); typedef llvm::DenseMap CacheT; static llvm::ManagedStatic cache; @@ -119,7 +119,7 @@ LLType *DtoUnpaddedStructType(Type *dty) { for (unsigned i = 0; i < fields.length; i++) { LLType *fty; - if (fields[i]->type->ty == Tstruct) { + if (fields[i]->type->ty == TY::Tstruct) { // Nested structs are the only members that can contain padding fty = DtoUnpaddedStructType(fields[i]->type); } else { @@ -137,7 +137,7 @@ LLType *DtoUnpaddedStructType(Type *dty) { /// Note: v must be a pointer to a struct, but the return value will be a /// first-class struct value. LLValue *DtoUnpaddedStruct(Type *dty, LLValue *v) { - assert(dty->ty == Tstruct); + assert(dty->ty == TY::Tstruct); TypeStruct *sty = static_cast(dty); VarDeclarations &fields = sty->sym->fields; @@ -146,7 +146,7 @@ LLValue *DtoUnpaddedStruct(Type *dty, LLValue *v) { for (unsigned i = 0; i < fields.length; i++) { LLValue *fieldptr = DtoIndexAggregate(v, sty->sym, fields[i]); LLValue *fieldval; - if (fields[i]->type->ty == Tstruct) { + if (fields[i]->type->ty == TY::Tstruct) { // Nested structs are the only members that can contain padding fieldval = DtoUnpaddedStruct(fields[i]->type, fieldptr); } else { @@ -159,14 +159,14 @@ LLValue *DtoUnpaddedStruct(Type *dty, LLValue *v) { /// Undo the transformation performed by DtoUnpaddedStruct, writing to lval. void DtoPaddedStruct(Type *dty, LLValue *v, LLValue *lval) { - assert(dty->ty == Tstruct); + assert(dty->ty == TY::Tstruct); TypeStruct *sty = static_cast(dty); VarDeclarations &fields = sty->sym->fields; for (unsigned i = 0; i < fields.length; i++) { LLValue *fieldptr = DtoIndexAggregate(lval, sty->sym, fields[i]); LLValue *fieldval = DtoExtractValue(v, i); - if (fields[i]->type->ty == Tstruct) { + if (fields[i]->type->ty == TY::Tstruct) { // Nested structs are the only members that can contain padding DtoPaddedStruct(fields[i]->type, fieldval, fieldptr); } else { diff --git a/gen/target.cpp b/gen/target.cpp index 38dcd70f15..8f56f4e708 100644 --- a/gen/target.cpp +++ b/gen/target.cpp @@ -181,7 +181,7 @@ void Target::_init(const Param ¶ms) { */ unsigned Target::alignsize(Type *type) { assert(type->isTypeBasic()); - if (type->ty == Tvoid) { + if (type->ty == TY::Tvoid) { return 1; } return gDataLayout->getABITypeAlignment(DtoType(type)); @@ -207,7 +207,7 @@ Type *Target::va_listType(const Loc &loc, Scope *sc) { * null if unhandled */ const char *TargetCPP::typeMangle(Type *t) { - if (t->ty == Tfloat80) { + if (t->ty == TY::Tfloat80) { const auto &triple = *global.params.targetTriple; // `long double` on Android/x64 is __float128 and mangled as `g` bool isAndroidX64 = triple.getEnvironment() == llvm::Triple::Android && diff --git a/gen/tocall.cpp b/gen/tocall.cpp index 8c89bd1186..f49bfdf962 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -45,10 +45,10 @@ IrFuncTy &DtoIrTypeFunction(DValue *fnval) { TypeFunction *DtoTypeFunction(DValue *fnval) { Type *type = fnval->type->toBasetype(); - if (type->ty == Tfunction) { + if (type->ty == TY::Tfunction) { return static_cast(type); } - if (type->ty == Tdelegate) { + if (type->ty == TY::Tdelegate) { // FIXME: There is really no reason why the function type should be // unmerged at this stage, but the frontend still seems to produce such // cases; for example for the uint(uint) next type of the return type of @@ -63,7 +63,7 @@ TypeFunction *DtoTypeFunction(DValue *fnval) { // root cause. Type *next = merge(type->nextOf()); - assert(next->ty == Tfunction); + assert(next->ty == TY::Tfunction); return static_cast(next); } @@ -74,10 +74,10 @@ TypeFunction *DtoTypeFunction(DValue *fnval) { LLValue *DtoCallableValue(DValue *fn) { Type *type = fn->type->toBasetype(); - if (type->ty == Tfunction) { + if (type->ty == TY::Tfunction) { return DtoRVal(fn); } - if (type->ty == Tdelegate) { + if (type->ty == TY::Tdelegate) { if (fn->isLVal()) { LLValue *dg = DtoLVal(fn); LLValue *funcptr = DtoGEP(dg, 0, 1); @@ -365,7 +365,7 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e, } Expression *exp = (*e->arguments)[0]; DValue *expv = toElem(exp); - if (expv->type->toBasetype()->ty != Tint32) { + if (expv->type->toBasetype()->ty != TY::Tint32) { expv = DtoCast(e->loc, expv, Type::tint32); } result = new DImValue(e->type, @@ -472,7 +472,7 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e, e->error("`cmpxchg` instruction expects 6 arguments"); fatal(); } - if (e->type->ty != Tstruct) { + if (e->type->ty != TY::Tstruct) { e->error("`cmpxchg` instruction returns a struct"); fatal(); } @@ -660,7 +660,7 @@ public: : args(args), attrs(attrs), loc(loc), fnval(fnval), argexps(argexps), resulttype(resulttype), sretPointer(sretPointer), // computed: - isDelegateCall(fnval->type->toBasetype()->ty == Tdelegate), + isDelegateCall(fnval->type->toBasetype()->ty == TY::Tdelegate), dfnval(fnval->isFunc()), irFty(DtoIrTypeFunction(fnval)), tf(DtoTypeFunction(fnval)), llArgTypesBegin(llCalleeType->param_begin()) {} @@ -904,7 +904,7 @@ DValue *DtoCallFunction(const Loc &loc, Type *resulttype, DValue *fnval, LLValue *retllval = irFty.arg_sret ? args[sretArgIndex] : static_cast(call); bool retValIsLVal = - (tf->isref() && returnTy != Tvoid) || (irFty.arg_sret != nullptr); + (tf->isref() && returnTy != TY::Tvoid) || (irFty.arg_sret != nullptr); if (!retValIsLVal) { // let the ABI transform the return value back @@ -923,7 +923,7 @@ DValue *DtoCallFunction(const Loc &loc, Type *resulttype, DValue *fnval, IF_LOG Logger::println("repainting return value from '%s' to '%s'", returntype->toChars(), rbase->toChars()); switch (rbase->ty) { - case Tarray: + case TY::Tarray: if (tf->isref()) { retllval = DtoBitCast(retllval, DtoType(rbase->pointerTo())); } else { @@ -931,8 +931,8 @@ DValue *DtoCallFunction(const Loc &loc, Type *resulttype, DValue *fnval, } break; - case Tsarray: - if (nextbase->ty == Tvector && !tf->isref()) { + case TY::Tsarray: + if (nextbase->ty == TY::Tvector && !tf->isref()) { if (retValIsLVal) { retllval = DtoBitCast(retllval, DtoType(rbase->pointerTo())); } else { @@ -946,9 +946,9 @@ DValue *DtoCallFunction(const Loc &loc, Type *resulttype, DValue *fnval, } goto unknownMismatch; - case Tclass: - case Taarray: - case Tpointer: + case TY::Tclass: + case TY::Taarray: + case TY::Tpointer: if (tf->isref()) { retllval = DtoBitCast(retllval, DtoType(rbase->pointerTo())); } else { @@ -956,8 +956,8 @@ DValue *DtoCallFunction(const Loc &loc, Type *resulttype, DValue *fnval, } break; - case Tstruct: - if (nextbase->ty == Taarray && !tf->isref()) { + case TY::Tstruct: + if (nextbase->ty == TY::Taarray && !tf->isref()) { // In the D2 frontend, the associative array type and its // object.AssociativeArray representation are used // interchangably in some places. However, AAs are returned @@ -1047,7 +1047,7 @@ DValue *DtoCallFunction(const Loc &loc, Type *resulttype, DValue *fnval, return new DLValue(resulttype, retllval); } - if (rbase->ty == Tarray) { + if (rbase->ty == TY::Tarray) { return new DSliceValue(resulttype, retllval); } diff --git a/gen/toconstelem.cpp b/gen/toconstelem.cpp index 2d57494f51..32031d6d70 100644 --- a/gen/toconstelem.cpp +++ b/gen/toconstelem.cpp @@ -73,7 +73,7 @@ public: if (SymbolDeclaration *sdecl = e->var->isSymbolDeclaration()) { // This is the static initialiser (init symbol) for aggregates. // Exclude void[]-typed `__traits(initSymbol)` (LDC extension). - if (sdecl->type->toBasetype()->ty == Tstruct) { + if (sdecl->type->toBasetype()->ty == TY::Tstruct) { const auto sd = sdecl->dsym->isStructDeclaration(); assert(sd); IF_LOG Logger::print("Sym: sd=%s\n", sd->toChars()); @@ -146,7 +146,7 @@ public: e->type->toChars(), e->toChars()); LOG_SCOPE; LLType *t = DtoType(e->type); - if (e->type->ty == Tarray) { + if (e->type->ty == TY::Tarray) { assert(isaStruct(t)); result = llvm::ConstantAggregateZero::get(t); } else { @@ -172,7 +172,7 @@ public: Type *const t = e->type->toBasetype(); - if (t->ty == Tsarray) { + if (t->ty == TY::Tsarray) { result = buildStringLiteralConstant(e, false); return; } @@ -185,9 +185,9 @@ public: LLConstant *arrptr = llvm::ConstantExpr::getGetElementPtr( isaPointer(gvar)->getElementType(), gvar, idxs, true); - if (t->ty == Tpointer) { + if (t->ty == TY::Tpointer) { result = arrptr; - } else if (t->ty == Tarray) { + } else if (t->ty == TY::Tarray) { LLConstant *clen = LLConstantInt::get(DtoSize_t(), e->numberOfCodeUnits(), false); result = DtoConstSlice(clen, arrptr, e->type); @@ -205,7 +205,7 @@ public: // add to pointer Type *t1b = e->e1->type->toBasetype(); - if (t1b->ty == Tpointer && e->e2->type->isintegral()) { + if (t1b->ty == TY::Tpointer && e->e2->type->isintegral()) { llvm::Constant *ptr = toConstElem(e->e1); dinteger_t idx = undoStrideMul(e->loc, t1b, e->e2->toInteger()); result = llvm::ConstantExpr::getGetElementPtr( @@ -222,7 +222,7 @@ public: LOG_SCOPE; Type *t1b = e->e1->type->toBasetype(); - if (t1b->ty == Tpointer && e->e2->type->isintegral()) { + if (t1b->ty == TY::Tpointer && e->e2->type->isintegral()) { llvm::Constant *ptr = toConstElem(e->e1); dinteger_t idx = undoStrideMul(e->loc, t1b, e->e2->toInteger()); @@ -247,7 +247,7 @@ public: // string literal to dyn array: // reinterpret the string data as an array, calculate the length - if (e->e1->op == TOKstring && tb->ty == Tarray) { + if (e->e1->op == TOKstring && tb->ty == TY::Tarray) { #if 0 StringExp *strexp = static_cast(e1); size_t datalen = strexp->sz * strexp->len; @@ -262,11 +262,12 @@ public: result = toConstElem(e->e1); } // pointer to pointer - else if (tb->ty == Tpointer && e->e1->type->toBasetype()->ty == Tpointer) { + else if (tb->ty == TY::Tpointer && + e->e1->type->toBasetype()->ty == TY::Tpointer) { result = llvm::ConstantExpr::getBitCast(toConstElem(e->e1), lltype); } // global variable to pointer - else if (tb->ty == Tpointer && e->e1->op == TOKvar) { + else if (tb->ty == TY::Tpointer && e->e1->op == TOKvar) { VarDeclaration *vd = static_cast(e->e1)->var->isVarDeclaration(); assert(vd); @@ -277,13 +278,13 @@ public: goto Lerr; } Type *type = vd->type->toBasetype(); - if (type->ty == Tarray || type->ty == Tdelegate) { + if (type->ty == TY::Tarray || type->ty == TY::Tdelegate) { LLConstant *idxs[2] = {DtoConstSize_t(0), DtoConstSize_t(1)}; value = llvm::ConstantExpr::getGetElementPtr( isaPointer(value)->getElementType(), value, idxs, true); } result = DtoBitCast(value, DtoType(tb)); - } else if (tb->ty == Tclass && e->e1->type->ty == Tclass && + } else if (tb->ty == TY::Tclass && e->e1->type->ty == TY::Tclass && e->e1->op == TOKclassreference) { auto cd = static_cast(e->e1)->originalClass(); llvm::Constant *instance = toConstElem(e->e1); @@ -373,7 +374,7 @@ public: assert(vexp); VarDeclaration *vd = vexp->var->isVarDeclaration(); assert(vd); - assert(vd->type->toBasetype()->ty == Tsarray); + assert(vd->type->toBasetype()->ty == TY::Tsarray); DtoResolveVariable(vd); assert(isIrGlobalCreated(vd)); @@ -389,7 +390,7 @@ public: isaPointer(val)->getElementType(), val, idxs, true); // bitcast to requested type - assert(e->type->toBasetype()->ty == Tpointer); + assert(e->type->toBasetype()->ty == TY::Tpointer); result = DtoBitCast(gep, DtoType(e->type)); return; } @@ -434,7 +435,7 @@ public: FuncLiteralDeclaration *fd = e->fd; assert(fd); - if (fd->tok == TOKreserved && e->type->ty == Tpointer) { + if (fd->tok == TOKreserved && e->type->ty == TY::Tpointer) { // This is a lambda that was inferred to be a function literal instead // of a delegate, so set tok here in order to get correct types/mangling. // Horrible hack, but DMD does the same thing in FuncExp::toElem and @@ -487,7 +488,7 @@ public: LLArrayType::get(DtoMemType(elemt), e->elements->length); // dynamic arrays can occur here as well ... - bool dyn = (bt->ty != Tsarray); + bool dyn = (bt->ty != TY::Tsarray); llvm::Constant *initval = arrayLiteralToConst(p, e); @@ -505,7 +506,7 @@ public: : llvm::GlobalValue::UnnamedAddr::None); llvm::Constant *store = DtoBitCast(gvar, getPtrToType(arrtype)); - if (bt->ty == Tpointer) { + if (bt->ty == TY::Tpointer) { // we need to return pointer to the static array. result = store; return; @@ -612,7 +613,7 @@ public: result = constValue; } - if (e->type->ty == Tclass) { + if (e->type->ty == TY::Tclass) { ClassDeclaration *targetClass = static_cast(e->type)->sym; if (InterfaceDeclaration *it = targetClass->isInterfaceDeclaration()) { assert(it->isBaseOf(origClass, NULL)); @@ -627,7 +628,7 @@ public: } } - assert(e->type->ty == Tclass || e->type->ty == Tenum); + assert(e->type->ty == TY::Tclass || e->type->ty == TY::Tenum); result = DtoBitCast(result, DtoType(e->type)); } @@ -639,7 +640,7 @@ public: LOG_SCOPE; TypeVector *tv = static_cast(e->to->toBasetype()); - assert(tv->ty == Tvector); + assert(tv->ty == TY::Tvector); const auto elemCount = static_cast(tv->basetype)->dim->toInteger(); diff --git a/gen/toir.cpp b/gen/toir.cpp index 6add72fd9f..0ff094f107 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -236,7 +236,7 @@ public: // Thus, dump the result to a temporary stack slot (created in the entry // bb) if it is not guaranteed to dominate the end bb after possibly // adding more control flow. - if (result && result->type->ty != Tvoid && + if (result && result->type->ty != TY::Tvoid && !result->definedInFuncEntryBB()) { if (result->isRVal()) { LLValue *lval = DtoAllocaDump(result, ".toElemRValResult"); @@ -354,13 +354,13 @@ public: switch (e->type->toBasetype()->ty) { default: llvm_unreachable("Unexpected complex floating point type"); - case Tcomplex32: + case TY::Tcomplex32: c = DtoConstFP(Type::tfloat32, ldouble(0)); break; - case Tcomplex64: + case TY::Tcomplex64: c = DtoConstFP(Type::tfloat64, ldouble(0)); break; - case Tcomplex80: + case TY::Tcomplex80: c = DtoConstFP(Type::tfloat80, ldouble(0)); break; } @@ -391,17 +391,17 @@ public: LLConstant *arrptr = llvm::ConstantExpr::getGetElementPtr( isaPointer(gvar)->getElementType(), gvar, idxs, true); - if (dtype->ty == Tarray) { + if (dtype->ty == TY::Tarray) { LLConstant *clen = LLConstantInt::get(DtoSize_t(), e->numberOfCodeUnits(), false); result = new DSliceValue(e->type, DtoConstSlice(clen, arrptr, dtype)); - } else if (dtype->ty == Tsarray) { + } else if (dtype->ty == TY::Tsarray) { LLType *dstType = getPtrToType(LLArrayType::get(ct, e->numberOfCodeUnits())); LLValue *emem = (gvar->getType() == dstType) ? gvar : DtoBitCast(gvar, dstType); result = new DLValue(e->type, emem); - } else if (dtype->ty == Tpointer) { + } else if (dtype->ty == TY::Tpointer) { result = new DImValue(e->type, arrptr); } else { llvm_unreachable("Unknown type for StringExp."); @@ -463,7 +463,7 @@ public: DValue *rewrittenLhsStaticArray = nullptr; if (auto se = e->e1->isSliceExp()) { Type *sliceeBaseType = se->e1->type->toBasetype(); - if (se->lwr == nullptr && sliceeBaseType->ty == Tsarray && + if (se->lwr == nullptr && sliceeBaseType->ty == TY::Tsarray && se->type->toBasetype()->nextOf() == sliceeBaseType->nextOf()) rewrittenLhsStaticArray = toElem(se->e1, true); } @@ -513,7 +513,7 @@ public: DValue *r = toElem(e->e2); - if (e->e1->type->toBasetype()->ty == Tstruct && e->e2->op == TOKint64) { + if (e->e1->type->toBasetype()->ty == TY::Tstruct && e->e2->op == TOKint64) { Logger::println("performing aggregate zero initialization"); assert(e->e2->toInteger() == 0); LLValue *lval = DtoLVal(lhs); @@ -548,8 +548,8 @@ public: Type *t2 = e2->type->toBasetype(); // valid array ops would have been transformed by optimize - if ((t1->ty == Tarray || t1->ty == Tsarray) && - (t2->ty == Tarray || t2->ty == Tsarray)) { + if ((t1->ty == TY::Tarray || t1->ty == TY::Tsarray) && + (t2->ty == TY::Tarray || t2->ty == TY::Tsarray)) { base->error("Array operation `%s` not recognized", base->toChars()); fatal(); } @@ -710,7 +710,7 @@ public: FuncDeclaration *fdecl = dve->var->isFuncDeclaration(); assert(fdecl); Expression *thisExp = dve->e1; - LLValue *thisArg = thisExp->type->toBasetype()->ty == Tclass + LLValue *thisArg = thisExp->type->toBasetype()->ty == TY::Tclass ? DtoRVal(thisExp) : DtoLVal(thisExp); // when calling a struct method fnval = new DFuncValue(fdecl, DtoCallee(fdecl), thisArg); @@ -901,7 +901,7 @@ public: PGO.setCurrentStmt(e); // function pointers are special - if (e->type->toBasetype()->ty == Tfunction) { + if (e->type->toBasetype()->ty == TY::Tfunction) { DValue *dv = toElem(e->e1); LLValue *llVal = DtoRVal(dv); if (DFuncValue *dfv = dv->isFunc()) { @@ -938,18 +938,18 @@ public: if (VarDeclaration *vd = e->var->isVarDeclaration()) { LLValue *arrptr; // indexing struct pointer - if (e1type->ty == Tpointer) { - assert(e1type->nextOf()->ty == Tstruct); + if (e1type->ty == TY::Tpointer) { + assert(e1type->nextOf()->ty == TY::Tstruct); TypeStruct *ts = static_cast(e1type->nextOf()); arrptr = DtoIndexAggregate(DtoRVal(l), ts->sym, vd); } // indexing normal struct - else if (e1type->ty == Tstruct) { + else if (e1type->ty == TY::Tstruct) { TypeStruct *ts = static_cast(e1type); arrptr = DtoIndexAggregate(DtoLVal(l), ts->sym, vd); } // indexing class - else if (e1type->ty == Tclass) { + else if (e1type->ty == TY::Tclass) { TypeClass *tc = static_cast(e1type); arrptr = DtoIndexAggregate(DtoRVal(l), tc->sym, vd); } else { @@ -1027,7 +1027,8 @@ public: result = new DLValue(e->type, DtoBitCast(v, DtoPtrToType(e->type))); } else if (vd->toParent2() != p->func()->decl) { Logger::println("nested this exp"); - result = DtoNestedVariable(e->loc, e->type, vd, e->type->ty == Tstruct); + result = + DtoNestedVariable(e->loc, e->type, vd, e->type->ty == TY::Tstruct); } else { Logger::println("normal this exp"); LLValue *v = p->func()->thisArg; @@ -1054,19 +1055,19 @@ public: p->arrays.pop_back(); LLValue *arrptr = nullptr; - if (e1type->ty == Tpointer) { + if (e1type->ty == TY::Tpointer) { arrptr = DtoGEP1(DtoRVal(l), DtoRVal(r)); - } else if (e1type->ty == Tsarray) { + } else if (e1type->ty == TY::Tsarray) { if (p->emitArrayBoundsChecks() && !e->indexIsInBounds) { DtoIndexBoundsCheck(e->loc, l, r); } arrptr = DtoGEP(DtoLVal(l), DtoConstUint(0), DtoRVal(r)); - } else if (e1type->ty == Tarray) { + } else if (e1type->ty == TY::Tarray) { if (p->emitArrayBoundsChecks() && !e->indexIsInBounds) { DtoIndexBoundsCheck(e->loc, l, r); } arrptr = DtoGEP1(DtoArrayPtr(l), DtoRVal(r)); - } else if (e1type->ty == Taarray) { + } else if (e1type->ty == TY::Taarray) { result = DtoAAIndex(e->loc, e->type, l, r, e->modifiable); return; } else { @@ -1095,7 +1096,7 @@ public: // potential bounds have been evaluated DValue *v = toElem(e->e1); auto getBasePointer = [v, etype]() { - if (etype->ty == Tpointer) { + if (etype->ty == TY::Tpointer) { // pointer slicing return DtoRVal(v); } else { @@ -1120,7 +1121,7 @@ public: p->arrays.pop_back(); const bool needCheckUpper = - (etype->ty != Tpointer) && !e->upperIsInBounds; + (etype->ty != TY::Tpointer) && !e->upperIsInBounds; const bool needCheckLower = !e->lowerIsLessThanUpper; if (p->emitArrayBoundsChecks() && (needCheckUpper || needCheckLower)) { llvm::BasicBlock *okbb = p->insertBB("bounds.ok"); @@ -1158,13 +1159,13 @@ public: } // no bounds or full slice -> just convert to slice else { - assert(etype->ty != Tpointer); + assert(etype->ty != TY::Tpointer); eptr = getBasePointer(); // if the slicee is a static array, we use the length of that as DMD seems // to give contrary inconsistent sizesin some multidimensional static // array cases. // (namely default initialization, int[16][16] arr; -> int[256] arr = 0;) - if (etype->ty == Tsarray) { + if (etype->ty == TY::Tsarray) { TypeSArray *tsa = static_cast(etype); elen = DtoConstSize_t(tsa->dim->toUInteger()); @@ -1177,12 +1178,12 @@ public: // The frontend generates a SliceExp of static array type when assigning a // fixed-width slice to a static array. Type *const ety = e->type->toBasetype(); - if (ety->ty == Tsarray) { + if (ety->ty == TY::Tsarray) { result = new DLValue(e->type, DtoBitCast(eptr, DtoPtrToType(e->type))); return; } - assert(ety->ty == Tarray); + assert(ety->ty == TY::Tarray); if (!elen) elen = DtoArrayLen(v); eptr = DtoBitCast(eptr, DtoPtrToType(ety->nextOf())); @@ -1207,7 +1208,7 @@ public: LLValue *eval = nullptr; - if (t->isintegral() || t->ty == Tpointer || t->ty == Tnull) { + if (t->isintegral() || t->ty == TY::Tpointer || t->ty == TY::Tnull) { llvm::ICmpInst::Predicate icmpPred; tokToICmpPred(e->op, isLLVMUnsigned(t), &icmpPred, &eval); @@ -1243,9 +1244,9 @@ public: llvm_unreachable("Unsupported floating point comparison operator."); } eval = p->ir->CreateFCmp(cmpop, DtoRVal(l), DtoRVal(r)); - } else if (t->ty == Taarray) { + } else if (t->ty == TY::Taarray) { eval = LLConstantInt::getFalse(gIR->context()); - } else if (t->ty == Tdelegate) { + } else if (t->ty == TY::Tdelegate) { llvm::ICmpInst::Predicate icmpPred; tokToICmpPred(e->op, isLLVMUnsigned(t), &icmpPred, &eval); @@ -1310,8 +1311,8 @@ public: // the Tclass catches interface comparisons, regular // class equality should be rewritten as a.opEquals(b) by this time - if (t->isintegral() || t->ty == Tpointer || t->ty == Tclass || - t->ty == Tnull) { + if (t->isintegral() || t->ty == TY::Tpointer || t->ty == TY::Tclass || + t->ty == TY::Tnull) { Logger::println("integral or pointer or interface"); llvm::ICmpInst::Predicate cmpop; switch (e->op) { @@ -1334,22 +1335,22 @@ public: Logger::cout() << "rv: " << *rv << '\n'; } eval = p->ir->CreateICmp(cmpop, lv, rv); - if (t->ty == Tvector) { + if (t->ty == TY::Tvector) { eval = mergeVectorEquals(eval, e->op); } } else if (t->isfloating()) // includes iscomplex { eval = DtoBinNumericEquals(e->loc, l, r, e->op); - } else if (t->ty == Tsarray || t->ty == Tarray) { + } else if (t->ty == TY::Tsarray || t->ty == TY::Tarray) { Logger::println("static or dynamic array"); eval = DtoArrayEquals(e->loc, e->op, l, r); - } else if (t->ty == Taarray) { + } else if (t->ty == TY::Taarray) { Logger::println("associative array"); eval = DtoAAEquals(e->loc, e->op, l, r); - } else if (t->ty == Tdelegate) { + } else if (t->ty == TY::Tdelegate) { Logger::println("delegate"); eval = DtoDelegateEquals(e->op, DtoRVal(l), DtoRVal(r)); - } else if (t->ty == Tstruct) { + } else if (t->ty == TY::Tstruct) { Logger::println("struct"); // when this is reached it means there is no opEquals overload. eval = DtoStructEquals(e->op, l, r); @@ -1389,7 +1390,7 @@ public: } else if (e->op == TOKminusminus) { post = llvm::BinaryOperator::CreateSub(val, one, "", p->scopebb()); } - } else if (e1type->ty == Tpointer) { + } else if (e1type->ty == TY::Tpointer) { assert(e->e2->op == TOKint64); LLConstant *offset = e->op == TOKplusplus ? DtoConstUint(1) : DtoConstInt(-1); @@ -1441,13 +1442,13 @@ public: Type *ntype = e->newtype->toBasetype(); // new class - if (ntype->ty == Tclass) { + if (ntype->ty == TY::Tclass) { Logger::println("new class"); result = DtoNewClass(e->loc, static_cast(ntype), e); isArgprefixHandled = true; // by DtoNewClass() } // new dynamic array - else if (ntype->ty == Tarray) { + else if (ntype->ty == TY::Tarray) { IF_LOG Logger::println("new dynamic array: %s", e->newtype->toChars()); assert(e->argprefix == NULL); // get dim @@ -1468,11 +1469,11 @@ public: } } // new static array - else if (ntype->ty == Tsarray) { + else if (ntype->ty == TY::Tsarray) { llvm_unreachable("Static array new should decay to dynamic array."); } // new struct - else if (ntype->ty == Tstruct) { + else if (ntype->ty == TY::Tstruct) { IF_LOG Logger::println("new struct on heap: %s\n", e->newtype->toChars()); TypeStruct *ts = static_cast(ntype); @@ -1562,16 +1563,16 @@ public: Type *et = e->e1->type->toBasetype(); // pointer - if (et->ty == Tpointer) { + if (et->ty == TY::Tpointer) { Type *elementType = et->nextOf()->toBasetype(); - if (elementType->ty == Tstruct && elementType->needsDestruction()) { + if (elementType->ty == TY::Tstruct && elementType->needsDestruction()) { DtoDeleteStruct(e->loc, dval); } else { DtoDeleteMemory(e->loc, dval); } } // class - else if (et->ty == Tclass) { + else if (et->ty == TY::Tclass) { bool onstack = false; TypeClass *tc = static_cast(et); if (tc->sym->isInterfaceDeclaration()) { @@ -1595,7 +1596,7 @@ public: } } // dyn array - else if (et->ty == Tarray) { + else if (et->ty == TY::Tarray) { DtoDeleteArray(e->loc, dval); if (dval->isLVal()) { DtoSetArrayToNull(DtoLVal(dval)); @@ -1698,7 +1699,8 @@ public: DtoBitCast(DtoRVal(cond), fn->getFunctionType()->getParamType(0)); gIR->CreateCallOrInvoke(fn, arg); - } else if (condty->ty == Tpointer && condty->nextOf()->ty == Tstruct) { + } else if (condty->ty == TY::Tpointer && + condty->nextOf()->ty == TY::Tstruct) { const auto invDecl = static_cast(condty->nextOf())->sym->inv; if (!invDecl) @@ -1778,7 +1780,7 @@ public: p->ir->SetInsertPoint(endBB); // DMD allows stuff like `x == 0 && assert(false)` - if (e->type->toBasetype()->ty == Tvoid) { + if (e->type->toBasetype()->ty == TY::Tvoid) { result = nullptr; return; } @@ -1838,7 +1840,7 @@ public: LLPointerType *int8ptrty = getPtrToType(LLType::getInt8Ty(gIR->context())); - assert(e->type->toBasetype()->ty == Tdelegate); + assert(e->type->toBasetype()->ty == TY::Tdelegate); LLType *dgty = DtoType(e->type); DValue *u = toElem(e->e1); @@ -1903,12 +1905,12 @@ public: Type *t1 = e->e1->type->toBasetype(); // handle dynarray specially - if (t1->ty == Tarray) { + if (t1->ty == TY::Tarray) { result = new DImValue(e->type, DtoDynArrayIs(e->op, l, r)); return; } // also structs - if (t1->ty == Tstruct) { + if (t1->ty == TY::Tstruct) { result = new DImValue(e->type, DtoStructEquals(e->op, l, r)); return; } @@ -1916,7 +1918,7 @@ public: // FIXME this stuff isn't pretty LLValue *eval = nullptr; - if (t1->ty == Tdelegate) { + if (t1->ty == TY::Tdelegate) { LLValue *lv = DtoRVal(l); LLValue *rv = nullptr; if (!r->isNull()) { @@ -1927,7 +1929,7 @@ public: } else if (t1->isfloating()) // includes iscomplex { eval = DtoBinNumericEquals(e->loc, l, r, e->op); - } else if (t1->ty == Tpointer || t1->ty == Tclass) { + } else if (t1->ty == TY::Tpointer || t1->ty == TY::Tclass) { LLValue *lv = DtoRVal(l); LLValue *rv = DtoRVal(r); if (lv->getType() != rv->getType()) { @@ -1939,7 +1941,7 @@ public: } eval = (e->op == TOKidentity) ? p->ir->CreateICmpEQ(lv, rv) : p->ir->CreateICmpNE(lv, rv); - } else if (t1->ty == Tsarray) { + } else if (t1->ty == TY::Tsarray) { LLValue *lptr = DtoLVal(l); LLValue *rptr = DtoLVal(r); assert(lptr->getType() == rptr->getType()); @@ -1951,7 +1953,7 @@ public: assert(lv->getType() == rv->getType()); eval = (e->op == TOKidentity) ? p->ir->CreateICmpEQ(lv, rv) : p->ir->CreateICmpNE(lv, rv); - if (t1->ty == Tvector) { + if (t1->ty == TY::Tvector) { eval = mergeVectorEquals(eval, e->op == TOKidentity ? TOKequal : TOKnotequal); } @@ -1985,7 +1987,7 @@ public: Type *dtype = e->type->toBasetype(); LLValue *retPtr = nullptr; - if (!(dtype->ty == Tvoid || dtype->ty == Tnoreturn)) { + if (!(dtype->ty == TY::Tvoid || dtype->ty == TY::Tnoreturn)) { // allocate a temporary for pointer to the final result. retPtr = DtoAlloca(dtype->pointerTo(), "condtmp"); } @@ -2005,7 +2007,7 @@ public: p->ir->SetInsertPoint(condtrue); PGO.emitCounterIncrement(e); DValue *u = toElem(e->e1); - if (retPtr && u->type->toBasetype()->ty != Tnoreturn) { + if (retPtr && u->type->toBasetype()->ty != TY::Tnoreturn) { LLValue *lval = makeLValue(e->loc, u); DtoStore(lval, DtoBitCast(retPtr, lval->getType()->getPointerTo())); } @@ -2013,7 +2015,7 @@ public: p->ir->SetInsertPoint(condfalse); DValue *v = toElem(e->e2); - if (retPtr && v->type->toBasetype()->ty != Tnoreturn) { + if (retPtr && v->type->toBasetype()->ty != TY::Tnoreturn) { LLValue *lval = makeLValue(e->loc, v); DtoStore(lval, DtoBitCast(retPtr, lval->getType()->getPointerTo())); } @@ -2096,16 +2098,16 @@ public: result = toElem(e->e1); Type *e1type = e->e1->type->toBasetype(); - assert(e1type->ty == Tarray); + assert(e1type->ty == TY::Tarray); Type *elemtype = e1type->nextOf()->toBasetype(); Type *e2type = e->e2->type->toBasetype(); - if (e1type->ty == Tarray && e2type->ty == Tdchar && - (elemtype->ty == Tchar || elemtype->ty == Twchar)) { - if (elemtype->ty == Tchar) { + if (e1type->ty == TY::Tarray && e2type->ty == TY::Tdchar && + (elemtype->ty == TY::Tchar || elemtype->ty == TY::Twchar)) { + if (elemtype->ty == TY::Tchar) { // append dchar to char[] DtoAppendDCharToString(e->loc, result, e->e2); - } else { /*if (elemtype->ty == Twchar)*/ + } else { /*if (elemtype->ty == TY::Twchar)*/ // append dchar to wchar[] DtoAppendDCharToUnicodeString(e->loc, result, e->e2); } @@ -2123,7 +2125,7 @@ public: void genFuncLiteral(FuncLiteralDeclaration *fd, FuncExp *e) { if ((fd->tok == TOKreserved || fd->tok == TOKdelegate) && - (e && e->type->ty == Tpointer)) { + (e && e->type->ty == TY::Tpointer)) { // This is a lambda that was inferred to be a function literal instead // of a delegate, so set tok here in order to get correct types/mangling. // Horrible hack, but DMD does the same thing. @@ -2187,7 +2189,7 @@ public: Type *elemType = arrayType->nextOf()->toBasetype(); // is dynamic ? - bool const dyn = (arrayType->ty == Tarray); + bool const dyn = (arrayType->ty == TY::Tarray); // length size_t const len = e->elements->length; @@ -2228,9 +2230,9 @@ public: llvm::Value *storage = DtoRawAlloca(llStoType, DtoAlignment(e->type), "arrayliteral"); initializeArrayLiteral(p, e, storage); - if (arrayType->ty == Tsarray) { + if (arrayType->ty == TY::Tsarray) { result = new DLValue(e->type, storage); - } else if (arrayType->ty == Tpointer) { + } else if (arrayType->ty == TY::Tpointer) { storage = DtoBitCast(storage, llElemType->getPointerTo()); result = new DImValue(e->type, storage); } else { @@ -2366,7 +2368,7 @@ public: goto LruntimeInit; } - if (aatype->ty != Taarray) { + if (aatype->ty != TY::Taarray) { // It's the AssociativeArray type. // Turn it back into a TypeAArray vtype = e->values->tdata()[0]->type; @@ -2395,7 +2397,7 @@ public: valuesInits.push_back(evalConst); } - assert(aatype->ty == Taarray); + assert(aatype->ty == TY::Taarray); Type *indexType = static_cast(aatype)->index; assert(indexType && vtype); @@ -2428,7 +2430,7 @@ public: LLValue *aa = gIR->CreateCallOrInvoke(func, aaTypeInfo, keysArray, valuesArray, "aa"); - if (basetype->ty != Taarray) { + if (basetype->ty != TY::Taarray) { LLValue *tmp = DtoAlloca(e->type, "aaliteral"); DtoStore(aa, DtoGEP(tmp, 0u, 0)); result = new DLValue(e->type, tmp); @@ -2534,7 +2536,7 @@ public: LLValue *gep = DtoGEP(val, 0, i); if (DtoIsInMemoryOnly(el->type)) { DtoMemCpy(gep, DtoLVal(ep)); - } else if (el->type->ty != Tvoid) { + } else if (el->type->ty != TY::Tvoid) { DtoStoreZextI8(DtoRVal(ep), gep); } else { DtoStore(LLConstantInt::get(LLType::getInt8Ty(p->context()), 0, false), @@ -2553,7 +2555,7 @@ public: const unsigned N = e->dim; Type *elementType = type->elementType(); - if (elementType->ty == Tvoid) + if (elementType->ty == TY::Tvoid) elementType = Type::tuns8; const auto getCastElement = [e, elementType](DValue *element) { @@ -2590,7 +2592,7 @@ public: DtoStore(llElements[i], DtoGEP(dstMem, 0, i)); } } - } else if (tsrc->ty == Tarray || tsrc->ty == Tsarray) { + } else if (tsrc->ty == TY::Tarray || tsrc->ty == TY::Tsarray) { // Arrays: prefer a memcpy if the LL element types match, otherwise cast // and store element-wise. if (auto ts = tsrc->isTypeSArray()) { @@ -2678,7 +2680,7 @@ public: } if (Expression *ex = isExpression(e->obj)) { Type *t = ex->type->toBasetype(); - assert(t->ty == Tclass); + assert(t->ty == TY::Tclass); LLValue *val = DtoRVal(ex); @@ -2768,7 +2770,7 @@ bool toInPlaceConstruction(DLValue *lhs, Expression *rhs) { if (auto ve = rhs->isVarExp()) { if (auto symdecl = ve->var->isSymbolDeclaration()) { // exclude void[]-typed `__traits(initSymbol)` (LDC extension) - if (symdecl->type->toBasetype()->ty == Tstruct) { + if (symdecl->type->toBasetype()->ty == TY::Tstruct) { auto sd = symdecl->dsym->isStructDeclaration(); assert(sd); DtoResolveStruct(sd); @@ -2826,7 +2828,7 @@ bool toInPlaceConstruction(DLValue *lhs, Expression *rhs) { } // and static array literals else if (auto al = rhs->isArrayLiteralExp()) { - if (lhs->type->toBasetype()->ty == Tsarray) { + if (lhs->type->toBasetype()->ty == TY::Tsarray) { Logger::println("success, in-place-constructing array literal"); initializeArrayLiteral(gIR, al, DtoLVal(lhs)); return true; diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 04df875bb0..4c16fa16c1 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -42,12 +42,12 @@ bool DtoIsInMemoryOnly(Type *type) { Type *typ = type->toBasetype(); TY t = typ->ty; - return (t == Tstruct || t == Tsarray); + return (t == TY::Tstruct || t == TY::Tsarray); } bool DtoIsReturnInArg(CallExp *ce) { Type *t = ce->e1->type->toBasetype(); - if (t->ty == Tfunction && (!ce->f || !DtoIsIntrinsic(ce->f))) { + if (t->ty == TY::Tfunction && (!ce->f || !DtoIsIntrinsic(ce->f))) { return gABI->returnInArg(static_cast(t), ce->f && ce->f->needThis()); } @@ -56,7 +56,7 @@ bool DtoIsReturnInArg(CallExp *ce) { void DtoAddExtendAttr(Type *type, llvm::AttrBuilder &attrs) { type = type->toBasetype(); - if (type->isintegral() && type->ty != Tvector && type->size() <= 2) { + if (type->isintegral() && type->ty != TY::Tvector && type->size() <= 2) { attrs.addAttribute(type->isunsigned() ? LLAttribute::ZExt : LLAttribute::SExt); } @@ -74,61 +74,61 @@ LLType *DtoType(Type *t) { switch (t->ty) { // basic types - case Tvoid: - case Tint8: - case Tuns8: - case Tint16: - case Tuns16: - case Tint32: - case Tuns32: - case Tint64: - case Tuns64: - case Tint128: - case Tuns128: - case Tfloat32: - case Tfloat64: - case Tfloat80: - case Timaginary32: - case Timaginary64: - case Timaginary80: - case Tcomplex32: - case Tcomplex64: - case Tcomplex80: - // case Tbit: - case Tbool: - case Tchar: - case Twchar: - case Tdchar: - case Tnoreturn: { + case TY::Tvoid: + case TY::Tint8: + case TY::Tuns8: + case TY::Tint16: + case TY::Tuns16: + case TY::Tint32: + case TY::Tuns32: + case TY::Tint64: + case TY::Tuns64: + case TY::Tint128: + case TY::Tuns128: + case TY::Tfloat32: + case TY::Tfloat64: + case TY::Tfloat80: + case TY::Timaginary32: + case TY::Timaginary64: + case TY::Timaginary80: + case TY::Tcomplex32: + case TY::Tcomplex64: + case TY::Tcomplex80: + // case TY::Tbit: + case TY::Tbool: + case TY::Tchar: + case TY::Twchar: + case TY::Tdchar: + case TY::Tnoreturn: { return IrTypeBasic::get(t)->getLLType(); } // pointers - case Tnull: - case Tpointer: { + case TY::Tnull: + case TY::Tpointer: { return IrTypePointer::get(t)->getLLType(); } // arrays - case Tarray: { + case TY::Tarray: { return IrTypeArray::get(t)->getLLType(); } - case Tsarray: { + case TY::Tsarray: { return IrTypeSArray::get(t)->getLLType(); } // aggregates - case Tstruct: - case Tclass: { - const auto isStruct = t->ty == Tstruct; + case TY::Tstruct: + case TY::Tclass: { + const auto isStruct = t->ty == TY::Tstruct; AggregateDeclaration *ad; if (isStruct) { ad = static_cast(t)->sym; } else { ad = static_cast(t)->sym; } - if (ad->type->ty == Terror) { + if (ad->type->ty == TY::Terror) { static LLStructType *opaqueErrorType = LLStructType::create(gIR->context(), Type::terror->toChars()); return opaqueErrorType; @@ -158,12 +158,12 @@ LLType *DtoType(Type *t) { } // functions - case Tfunction: { + case TY::Tfunction: { return IrTypeFunction::get(t)->getLLType(); } // delegates - case Tdelegate: { + case TY::Tdelegate: { return IrTypeDelegate::get(t)->getLLType(); } @@ -171,7 +171,7 @@ LLType *DtoType(Type *t) { // enum // FIXME: maybe just call toBasetype first ? - case Tenum: { + case TY::Tenum: { Type *bt = t->toBasetype(); assert(bt); if (t == bt) { @@ -184,10 +184,10 @@ LLType *DtoType(Type *t) { } // associative arrays - case Taarray: + case TY::Taarray: return getVoidPtrType(); - case Tvector: + case TY::Tvector: return IrTypeVector::get(t)->getLLType(); default: diff --git a/gen/typinf.cpp b/gen/typinf.cpp index a8bd3c622f..c197e3dfc4 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -82,8 +82,8 @@ void emitTypeInfoMetadata(LLGlobalVariable *typeinfoGlobal, Type *forType) { // As those types cannot appear as LLVM values, they are not interesting for // the optimizer passes anyway. Type *t = forType->toBasetype(); - if (t->ty < Terror && t->ty != Tvoid && t->ty != Tfunction && - t->ty != Tident) { + if (t->ty < TY::Terror && t->ty != TY::Tvoid && t->ty != TY::Tfunction && + t->ty != TY::Tident) { const auto metaname = getMetadataName(TD_PREFIX, typeinfoGlobal); if (!gIR->module.getNamedMetadata(metaname)) { @@ -129,7 +129,7 @@ public: RTTIBuilder b(getEnumTypeInfoType()); - assert(decl->tinfo->ty == Tenum); + assert(decl->tinfo->ty == TY::Tenum); TypeEnum *tc = static_cast(decl->tinfo); EnumDeclaration *sd = tc->sym; @@ -190,7 +190,7 @@ public: decl->toChars()); LOG_SCOPE; - assert(decl->tinfo->ty == Tsarray); + assert(decl->tinfo->ty == TY::Tsarray); TypeSArray *tc = static_cast(decl->tinfo); RTTIBuilder b(getStaticArrayTypeInfoType()); @@ -213,7 +213,7 @@ public: decl->toChars()); LOG_SCOPE; - assert(decl->tinfo->ty == Taarray); + assert(decl->tinfo->ty == TY::Taarray); TypeAArray *tc = static_cast(decl->tinfo); RTTIBuilder b(getAssociativeArrayTypeInfoType()); @@ -251,7 +251,7 @@ public: decl->toChars()); LOG_SCOPE; - assert(decl->tinfo->ty == Tdelegate); + assert(decl->tinfo->ty == TY::Tdelegate); Type *ret_type = decl->tinfo->nextOf()->nextOf(); RTTIBuilder b(getDelegateTypeInfoType()); @@ -303,7 +303,7 @@ public: LOG_SCOPE; // create elements array - assert(decl->tinfo->ty == Ttuple); + assert(decl->tinfo->ty == TY::Ttuple); TypeTuple *tu = static_cast(decl->tinfo); size_t dim = tu->arguments->length; @@ -392,7 +392,7 @@ public: decl->toChars()); LOG_SCOPE; - assert(decl->tinfo->ty == Tvector); + assert(decl->tinfo->ty == TY::Tvector); TypeVector *tv = static_cast(decl->tinfo); RTTIBuilder b(getVectorTypeInfoType()); diff --git a/ir/iraggr.cpp b/ir/iraggr.cpp index 83434370a5..81a94d8df9 100644 --- a/ir/iraggr.cpp +++ b/ir/iraggr.cpp @@ -182,7 +182,7 @@ static llvm::Constant *FillSArrayDims(Type *arrTypeD, llvm::Constant *init) { return init; } - if (arrTypeD->ty == Tsarray) { + if (arrTypeD->ty == TY::Tsarray) { init = FillSArrayDims(arrTypeD->nextOf(), init); size_t dim = static_cast(arrTypeD)->dim->toUInteger(); llvm::ArrayType *arrty = llvm::ArrayType::get(init->getType(), dim); diff --git a/ir/irclass.cpp b/ir/irclass.cpp index 39f2e8672d..ae9c0f3950 100644 --- a/ir/irclass.cpp +++ b/ir/irclass.cpp @@ -252,7 +252,7 @@ LLConstant *IrClass::getVtblInit() { } if (fd->leastAsSpecialized(fd2) || fd2->leastAsSpecialized(fd)) { TypeFunction *tf = static_cast(fd->type); - if (tf->ty == Tfunction) { + if (tf->ty == TY::Tfunction) { cd->error("use of `%s%s` is hidden by `%s`; use `alias %s = " "%s.%s;` to introduce base class overload set", fd->toPrettyChars(), diff --git a/ir/irfunction.cpp b/ir/irfunction.cpp index 0cb7b2f5d0..c7d8f83059 100644 --- a/ir/irfunction.cpp +++ b/ir/irfunction.cpp @@ -22,7 +22,7 @@ IrFunction::IrFunction(FuncDeclaration *fd) decl = fd; Type *t = fd->type->toBasetype(); - assert(t->ty == Tfunction); + assert(t->ty == TY::Tfunction); type = static_cast(t); irFty.type = type; diff --git a/ir/irtype.cpp b/ir/irtype.cpp index 0f8cb63034..0553fbd7b3 100644 --- a/ir/irtype.cpp +++ b/ir/irtype.cpp @@ -51,55 +51,55 @@ llvm::Type *IrTypeBasic::basic2llvm(Type *t) { llvm::LLVMContext &ctx = getGlobalContext(); switch (t->ty) { - case Tvoid: - case Tnoreturn: + case TY::Tvoid: + case TY::Tnoreturn: return llvm::Type::getVoidTy(ctx); - case Tint8: - case Tuns8: - case Tchar: + case TY::Tint8: + case TY::Tuns8: + case TY::Tchar: return llvm::Type::getInt8Ty(ctx); - case Tint16: - case Tuns16: - case Twchar: + case TY::Tint16: + case TY::Tuns16: + case TY::Twchar: return llvm::Type::getInt16Ty(ctx); - case Tint32: - case Tuns32: - case Tdchar: + case TY::Tint32: + case TY::Tuns32: + case TY::Tdchar: return llvm::Type::getInt32Ty(ctx); - case Tint64: - case Tuns64: + case TY::Tint64: + case TY::Tuns64: return llvm::Type::getInt64Ty(ctx); - case Tint128: - case Tuns128: + case TY::Tint128: + case TY::Tuns128: return llvm::IntegerType::get(ctx, 128); - case Tfloat32: - case Timaginary32: + case TY::Tfloat32: + case TY::Timaginary32: return llvm::Type::getFloatTy(ctx); - case Tfloat64: - case Timaginary64: + case TY::Tfloat64: + case TY::Timaginary64: return llvm::Type::getDoubleTy(ctx); - case Tfloat80: - case Timaginary80: + case TY::Tfloat80: + case TY::Timaginary80: return target.realType; - case Tcomplex32: + case TY::Tcomplex32: return getComplexType(ctx, llvm::Type::getFloatTy(ctx)); - case Tcomplex64: + case TY::Tcomplex64: return getComplexType(ctx, llvm::Type::getDoubleTy(ctx)); - case Tcomplex80: + case TY::Tcomplex80: return getComplexType(ctx, target.realType); - case Tbool: + case TY::Tbool: return llvm::Type::getInt1Ty(ctx); default: llvm_unreachable("Unknown basic type."); @@ -111,13 +111,14 @@ llvm::Type *IrTypeBasic::basic2llvm(Type *t) { IrTypePointer::IrTypePointer(Type *dt, LLType *lt) : IrType(dt, lt) {} IrTypePointer *IrTypePointer::get(Type *dt) { - assert((dt->ty == Tpointer || dt->ty == Tnull) && "not pointer/null type"); + assert((dt->ty == TY::Tpointer || dt->ty == TY::Tnull) && + "not pointer/null type"); auto &ctype = getIrType(dt); assert(!ctype); LLType *elemType; - if (dt->ty == Tnull) { + if (dt->ty == TY::Tnull) { elemType = llvm::Type::getInt8Ty(getGlobalContext()); } else { elemType = DtoMemType(dt->nextOf()); @@ -139,7 +140,7 @@ IrTypePointer *IrTypePointer::get(Type *dt) { IrTypeSArray::IrTypeSArray(Type *dt, LLType *lt) : IrType(dt, lt) {} IrTypeSArray *IrTypeSArray::get(Type *dt) { - assert(dt->ty == Tsarray && "not static array type"); + assert(dt->ty == TY::Tsarray && "not static array type"); auto &ctype = getIrType(dt); assert(!ctype); @@ -162,7 +163,7 @@ IrTypeSArray *IrTypeSArray::get(Type *dt) { IrTypeArray::IrTypeArray(Type *dt, LLType *lt) : IrType(dt, lt) {} IrTypeArray *IrTypeArray::get(Type *dt) { - assert(dt->ty == Tarray && "not dynamic array type"); + assert(dt->ty == TY::Tarray && "not dynamic array type"); auto &ctype = getIrType(dt); assert(!ctype); @@ -214,9 +215,10 @@ IrTypeVector *IrTypeVector::get(Type *dt) { IrType *&getIrType(Type *t, bool create) { // See remark in DtoType(). - assert((t->ty != Tstruct || t == static_cast(t)->sym->type) && - "use sd->type for structs"); - assert((t->ty != Tclass || t == static_cast(t)->sym->type) && + assert( + (t->ty != TY::Tstruct || t == static_cast(t)->sym->type) && + "use sd->type for structs"); + assert((t->ty != TY::Tclass || t == static_cast(t)->sym->type) && "use cd->type for classes"); t = stripModifiers(t); diff --git a/ir/irtypefunction.cpp b/ir/irtypefunction.cpp index 4e3a9b2e6f..8a1a4ba9a9 100644 --- a/ir/irtypefunction.cpp +++ b/ir/irtypefunction.cpp @@ -43,7 +43,7 @@ IrTypeDelegate::IrTypeDelegate(Type *dt, llvm::Type *lt, IrFuncTy irFty_) : IrType(dt, lt), irFty(std::move(irFty_)) {} IrTypeDelegate *IrTypeDelegate::get(Type *t) { - assert(t->ty == Tdelegate); + assert(t->ty == TY::Tdelegate); TypeFunction *tf = t->nextOf()->isTypeFunction(); assert(tf);