LLType* DtoType(Type* t) { t = stripModifiers( t ); if (t->ctype) { return t->ctype->getLLType(); } IF_LOG Logger::println("Building type: %s", t->toChars()); LOG_SCOPE; assert(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 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: { return IrTypeBasic::get(t)->getLLType(); } // pointers case Tnull: case Tpointer: { return IrTypePointer::get(t)->getLLType(); } // arrays case Tarray: { return IrTypeArray::get(t)->getLLType(); } case Tsarray: { return IrTypeSArray::get(t)->getLLType(); } // aggregates case Tstruct: { TypeStruct* ts = static_cast<TypeStruct*>(t); if (ts->sym->type->ctype) { // This should not happen, but the frontend seems to be buggy. Not // sure if this is the best way to handle the situation, but we // certainly don't want to override ts->sym->type->ctype. IF_LOG Logger::cout() << "Struct with multiple Types detected: " << ts->toChars() << " (" << ts->sym->locToChars() << ")" << std::endl; return ts->sym->type->ctype->getLLType(); } return IrTypeStruct::get(ts->sym)->getLLType(); } case Tclass: { TypeClass* tc = static_cast<TypeClass*>(t); if (tc->sym->type->ctype) { // See Tstruct case. IF_LOG Logger::cout() << "Class with multiple Types detected: " << tc->toChars() << " (" << tc->sym->locToChars() << ")" << std::endl; return tc->sym->type->ctype->getLLType(); } return IrTypeClass::get(tc->sym)->getLLType(); } // functions case Tfunction: { return IrTypeFunction::get(t)->getLLType(); } // delegates case Tdelegate: { return IrTypeDelegate::get(t)->getLLType(); } // typedefs // enum // FIXME: maybe just call toBasetype first ? case Ttypedef: case Tenum: { Type* bt = t->toBasetype(); assert(bt); return DtoType(bt); } // associative arrays case Taarray: return getVoidPtrType(); case Tvector: { return IrTypeVector::get(t)->getLLType(); } /* Not needed atm as VarDecls for tuples are rewritten as a string of VarDecls for the fields (u -> _u_field_0, ...) case Ttuple: { TypeTuple* ttupl = static_cast<TypeTuple*>(t); return DtoStructTypeFromArguments(ttupl->arguments); } */ default: llvm_unreachable("Unknown class of D Type!"); } return 0; }
bool PPCKindHandler::isLazyImmediate(Kind kind) { llvm_unreachable("Unimplemented: PPCKindHandler::isLazyImmediate"); return false; }
bool PPCKindHandler::isLazyTarget(Kind kind) { llvm_unreachable("Unimplemented: PPCKindHandler::isLazyTarget"); return false; }
bool PPCKindHandler::isPointer(Kind kind) { llvm_unreachable("Unimplemented: PPCKindHandler::isPointer"); return false; }
bool PPCKindHandler::isCallSite(Kind kind) { llvm_unreachable("Unimplemented: PPCKindHandler::isCallSite"); return false; }
TrinaryExprPtr LinGen::encodeInst(BasicBlock *p, std::vector<BasicBlock *> &pcds, BasicBlock::iterator it){ BasicBlock *currentBB = it -> getParent(); assert(currentBB && "current basic block is null"); // std::cout << "\nInstruction" << std::endl; // it -> print(outs()); // std::string s = p ? p -> getName().str() : "null"; // std::string postDomName = !pcds.empty() ? pcds.back()->getName().str() // : "null"; // std::cout << "CURRENT BB: " // << currentBB -> getName().str() // << "PREVIOUS BB: " // << s // <<"Common: " // << postDomName // << std::endl; unsigned opcode = it->getOpcode(); if(opcode != Instruction::PHI && !pcds.empty() && pcds.back() == currentBB) return Expression::mkTrinExpr(Expression::mkTrue(), Expression::mkTrue(), Expression::mkTrue()); TrinaryExprPtr enc; switch (opcode) { case Instruction::Br:{ enc = encodeBr(pcds, cast<BranchInst>(it)); break; } case Instruction::Call:{ // check if this call was inserted by the VarsForArrays pass. If such then // only its name and its first parameters name are relevant. CallInst *call = dyn_cast<CallInst>(it); Function *f = call -> getCalledFunction(); if(f == array_aux_1 || f == array_aux_2){ Value *param = call -> getArgOperand(0); context -> setOldArrayName(param); if(f == array_aux_2){ context -> setNewArrayName(call); } enc = Expression::mkTrinExpr(Expression::mkTrue(), Expression::mkTrue(), Expression::mkTrue()); } else { BinaryExprPtr ann = encodeAnn(cast<CallInst>(it)); enc = Expression::mkTrinExpr(Expression::mkTrue(), ann -> getExpr1(), ann -> getExpr2()); } break; } case Instruction::Ret:{ enc = Expression::mkTrinExpr(Expression::mkTrue(), Expression::mkTrue(), Expression::mkTrue()); break; } case Instruction::Unreachable:{ enc = Expression::mkTrinExpr(Expression::mkTrue(), Expression::mkTrue(), Expression::mkTrue()); break; } case Instruction::Add: case Instruction::FAdd: case Instruction::Sub: case Instruction::FSub: case Instruction::Mul: case Instruction::FMul: case Instruction::UDiv: case Instruction::SDiv: case Instruction::FDiv: case Instruction::URem: case Instruction::SRem: case Instruction::FRem: case Instruction::And: case Instruction::Or: case Instruction::Xor: case Instruction::Shl: case Instruction::LShr: case Instruction::AShr:{ ExprPtr e = encoder.encode(cast<BinaryOperator>(it)); enc = Expression::mkTrinExpr(e, Expression::mkTrue(), Expression::mkTrue()); break; } case Instruction::ICmp:{ ExprPtr e = encoder.encode(cast<ICmpInst>(it)); enc = Expression::mkTrinExpr(e, Expression::mkTrue(), Expression::mkTrue()); break; } case Instruction::SExt:{ ExprPtr e = encoder.encode(cast<SExtInst>(it)); enc = Expression::mkTrinExpr(e, Expression::mkTrue(), Expression::mkTrue()); break; } case Instruction::ZExt:{ ExprPtr e = encoder.encode(cast<ZExtInst>(it)); enc = Expression::mkTrinExpr(e, Expression::mkTrue(), Expression::mkTrue()); break; } case Instruction::Select:{ ExprPtr e = encoder.encode(cast<SelectInst>(it)); enc = Expression::mkTrinExpr(e, Expression::mkTrue(), Expression::mkTrue()); break; } case Instruction::PHI:{ assert(p && "trying to encode a phi instruction with no previous block\n"); ExprPtr e = encoder.encode(cast<PHINode>(it),p); enc = Expression::mkTrinExpr(e, Expression::mkTrue(), Expression::mkTrue()); break; } case Instruction::Switch:{ assert(0 && "switch not implemented yet"); // ExprPtr e = encoder.encode(cast<SwitchInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::Alloca:{ ExprPtr e = encodeArray(cast<AllocaInst>(it)); enc = Expression::mkTrinExpr(e, Expression::mkTrue(), Expression::mkTrue()); break; } case Instruction::Store:{ ExprPtr e = encodeArray(cast<StoreInst>(it)); enc = Expression::mkTrinExpr(e, Expression::mkTrue(), Expression::mkTrue()); break; } case Instruction::Load:{ ExprPtr e = encodeArray(cast<LoadInst>(it)); enc = Expression::mkTrinExpr(e, Expression::mkTrue(), Expression::mkTrue()); break; } case Instruction::GetElementPtr:{ ExprPtr e = encodeArray(cast<GetElementPtrInst>(it)); enc = Expression::mkTrinExpr(e, Expression::mkTrue(), Expression::mkTrue()); break; } case Instruction::PtrToInt:{ assert(0 && "PtrToInt not implemented yet"); // ExprPtr e = encoder.encode(cast<PtrToIntInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::VAArg:{ assert(0 && "VAArg not implemented yet"); // ExprPtr e = encoder.encode(cast<VAArgInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::Invoke:{ assert(0 && "Invoke not implemented yet"); // ExprPtr e = encoder.encode(cast<InvokeInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::Trunc:{ assert(0 && "Trunc not implemented yet"); // ExprPtr e = encoder.encode(cast<TruncInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::FPTrunc:{ assert(0 && "FPTrunc not implemented yet"); // ExprPtr e = encoder.encode(cast<FPTruncInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::FPExt:{ assert(0 && "FPExt not implemented yet"); // ExprPtr e = encoder.encode(cast<FPExtInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::UIToFP:{ assert(0 && "UIToFP not implemented yet"); // ExprPtr e = encoder.encode(cast<UIToFPInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::SIToFP:{ assert(0 && "SIToFP not implemented yet"); // ExprPtr e = encoder.encode(cast<SIToFPInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::FPToUI:{ assert(0 && "FPToUI not implemented yet"); // ExprPtr e = encoder.encode(cast<FPToUIInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::FPToSI:{ assert(0 && "FPToSI not implemented yet"); // ExprPtr e = encoder.encode(cast<FPToSIInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::IntToPtr:{ assert(0 && "IntToPtr not implemented yet"); // ExprPtr e = encoder.encode(cast<IntToPtrInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::BitCast:{ assert(0 && "BitCast not implemented yet"); // ExprPtr e = encoder.encode(cast<BitCastInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::FCmp:{ assert(0 && "FCmp not implemented yet"); // ExprPtr e = encoder.encode(cast<FCmpInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::ExtractElement:{ assert(0 && "ExtractElement not implemented yet"); // ExprPtr e = encoder.encode(cast<ExtractElementInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::InsertElement:{ assert(0 && "InsertElement not implemented yet"); // ExprPtr e = encoder.encode(cast<InsertElementInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::ShuffleVector:{ assert(0 && "ShuffleVector not implemented yet"); // ExprPtr e = encoder.encode(cast<ShuffleVectorInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::ExtractValue:{ assert(0 && "ExtractValue not implemented yet"); // ExprPtr e = encoder.encode(cast<ExtractValueInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } case Instruction::InsertValue:{ assert(0 && "InsertValue not implemented yet"); // ExprPtr e = encoder.encode(cast<InsertValueInst>(it)); // ExprPtr impl = ExprUtils::mkImpl(pi.encode(), e); // vcs.addToE(impl); // psi2.add(impl); break; } default: std::cout << "UNREACHABLE OPCODE: " << it->getOpcode() << std::endl; llvm_unreachable("Illegal opcode!"); } ++it; if(it != currentBB -> end()){ TrinaryExprPtr enc2 = encodeInst(p,pcds,it); ExprPtr context; if(globalCtx) context = enc -> getExpr2(); else context = ExprUtils::mkAnd(enc -> getExpr1(),enc -> getExpr2()); return Expression::mkTrinExpr( ExprUtils::mkAnd(enc -> getExpr1(), enc2 -> getExpr1()), ExprUtils::mkAnd(enc -> getExpr2(), enc2 -> getExpr2()), ExprUtils::mkAnd(enc -> getExpr3(), ExprUtils::mkImpl(context, enc2 -> getExpr3()))); } else return enc; }
Version Version::parseCompilerVersionString( StringRef VersionString, SourceLoc Loc, DiagnosticEngine *Diags) { Version CV; SmallString<16> digits; llvm::raw_svector_ostream OS(digits); SmallVector<std::pair<StringRef, SourceRange>, 5> SplitComponents; auto checkVersionComponent = [&](unsigned Component, SourceRange Range) { unsigned limit = CV.Components.size() == 0 ? 9223371 : 999; if (Component > limit) { if (Diags) Diags->diagnose(Range.Start, diag::compiler_version_component_out_of_range, limit); else llvm_unreachable("Compiler version component out of range"); } }; splitVersionComponents(SplitComponents, VersionString, Loc, Diags, /*skipQuote=*/true); uint64_t ComponentNumber; for (size_t i = 0; i < SplitComponents.size(); ++i) { StringRef SplitComponent; SourceRange Range; std::tie(SplitComponent, Range) = SplitComponents[i]; // Version components can't be empty. if (SplitComponent.empty()) { if (Diags) Diags->diagnose(Range.Start, diag::empty_version_component); else llvm_unreachable("Found empty compiler version component"); continue; } // The second version component isn't used for comparison. if (i == 1) { if (!SplitComponent.equals("*")) { if (Diags) { Diags->diagnose(Range.Start, diag::unused_compiler_version_component) .fixItReplaceChars(Range.Start, Range.End, "*"); } else { llvm_unreachable("Expected * for second compiler version component"); } } CV.Components.push_back(0); continue; } // All other version components must be numbers. if (!SplitComponent.getAsInteger(10, ComponentNumber)) { checkVersionComponent(ComponentNumber, Range); CV.Components.push_back(ComponentNumber); continue; } else if (Diags) { Diags->diagnose(Range.Start, diag::version_component_not_number); } else { llvm_unreachable("Invalid character in _compiler_version condition"); } } if (CV.Components.size() > 5) { if (Diags) { Diags->diagnose(Loc, diag::compiler_version_too_many_components); } else { llvm_unreachable("Compiler version must not have more than 5 components"); } } return CV; }
Operator::~Operator() { llvm_unreachable("should never destroy an Operator"); }