void TypeInfoEnumDeclaration::llvmDefine() { Logger::println("TypeInfoEnumDeclaration::llvmDefine() %s", toChars()); LOG_SCOPE; RTTIBuilder b(Type::typeinfoenum); assert(tinfo->ty == Tenum); TypeEnum *tc = static_cast<TypeEnum *>(tinfo); EnumDeclaration *sd = tc->sym; // TypeInfo base b.push_typeinfo(sd->memtype); // char[] name b.push_string(sd->toPrettyChars()); // void[] init // emit void[] with the default initialier, the array is null if the default // initializer is zero if (!sd->defaultval || tinfo->isZeroInit(0)) { b.push_null_void_array(); } // otherwise emit a void[] with the default initializer else { LLType* memty = DtoType(sd->memtype); #if DMDV2 LLConstant* C = LLConstantInt::get(memty, sd->defaultval->toInteger(), !isLLVMUnsigned(sd->memtype)); #else LLConstant* C = LLConstantInt::get(memty, sd->defaultval, !isLLVMUnsigned(sd->memtype)); #endif b.push_void_array(C, sd->memtype, sd); } // finish b.finalize(ir.irGlobal); }
DValue *binMod(Loc &loc, Type *type, DValue *lhs, Expression *rhs, bool loadLhsAfterRhs) { auto rvals = evalSides(lhs, rhs, loadLhsAfterRhs); if (type->iscomplex()) return DtoComplexMod(loc, type, rvals.lhs, rvals.rhs); LLValue *l = DtoRVal(DtoCast(loc, rvals.lhs, type)); LLValue *r = DtoRVal(DtoCast(loc, rvals.rhs, type)); LLValue *res; if (type->isfloating()) { res = gIR->ir->CreateFRem(l, r); } else if (!isLLVMUnsigned(type)) { res = gIR->ir->CreateSRem(l, r); } else { res = gIR->ir->CreateURem(l, r); } return new DImValue(type, res); }
DValue *binShr(Loc &loc, Type *type, DValue *lhs, Expression *rhs, bool loadLhsAfterRhs) { auto op = (isLLVMUnsigned(type) ? llvm::Instruction::LShr : llvm::Instruction::AShr); return binBitwise(op, loc, type, lhs, rhs, loadLhsAfterRhs); }