void CodeGenerator::emit(Module *m) { bool const loggerWasEnabled = Logger::enabled(); if (m->llvmForceLogging && !loggerWasEnabled) { Logger::enable(); } IF_LOG Logger::println("CodeGenerator::emit(%s)", m->toPrettyChars()); LOG_SCOPE; if (global.params.verbose_cg) { printf("codegen: %s (%s)\n", m->toPrettyChars(), m->srcfile->toChars()); } if (global.errors) { Logger::println("Aborting because of errors"); fatal(); } prepareLLModule(m); codegenModule(ir_, m); if (m == g_dMainModule) { codegenModule(ir_, g_entrypointModule); if (global.params.targetTriple->getEnvironment() == llvm::Triple::Android) { // On Android, bracket TLS data with the symbols _tlsstart and _tlsend, as // done with dmd auto startSymbol = new llvm::GlobalVariable( ir_->module, llvm::Type::getInt32Ty(ir_->module.getContext()), false, llvm::GlobalValue::ExternalLinkage, llvm::ConstantInt::get(ir_->module.getContext(), APInt(32, 0)), "_tlsstart", &*(ir_->module.global_begin())); startSymbol->setSection(".tdata"); auto endSymbol = new llvm::GlobalVariable( ir_->module, llvm::Type::getInt32Ty(ir_->module.getContext()), false, llvm::GlobalValue::ExternalLinkage, llvm::ConstantInt::get(ir_->module.getContext(), APInt(32, 0)), "_tlsend"); endSymbol->setSection(".tcommon"); } else if (global.params.targetTriple->isOSLinux()) { // On Linux, strongly define the excecutabe BSS bracketing symbols in // the main module for druntime use (see rt.sections_elf_shared). emitSymbolAddrGlobal(ir_->module, "__bss_start", "_d_execBssBegAddr"); emitSymbolAddrGlobal(ir_->module, "_end", "_d_execBssEndAddr"); } } finishLLModule(m); if (m->llvmForceLogging && !loggerWasEnabled) { Logger::disable(); } }
/** * Loads the DepositSection. */ void MainWindow::loadDepositSection() { CashRegisterDialog dialog(&m_CookieJar, m_ServerUrl, this, Qt::WindowTitleHint); connect(&dialog, SIGNAL(sessionStatusChanged(bool)), this, SLOT(setIsSessionActive(bool)), Qt::QueuedConnection); dialog.init(); if (dialog.exec() == QDialog::Accepted) { DepositSection *section = new DepositSection(&m_CookieJar, &m_PluginFactory, m_ServerUrl, dialog.key(), this); section->setStyleSheetFileName("deposit_details.xsl"); section->setGetDocumentDetailsCmd("get_deposit_details"); section->setGetDocumentListCmd("get_deposit_list"); section->setShowDocumentFormCmd("show_deposit_form"); section->setGetDocumentCmd("get_deposit"); section->setCreateDocumentCmd("create_deposit"); section->setDeleteItemDocumentCmd("delete_cash_deposit"); section->setCreateDocumentTransformerName("deposit"); section->setDocumentListTransformerName("deposit_list"); section->setItemsName("Efectivo"); section->init(); setSection(section); } }
LLConstant *IRState::setGlobalVarInitializer(LLGlobalVariable *&globalVar, LLConstant *initializer) { if (initializer->getType() == globalVar->getType()->getContainedType(0)) { globalVar->setInitializer(initializer); return globalVar; } // Create the global helper variable matching the initializer type. // It inherits most properties from the existing globalVar. auto globalHelperVar = new LLGlobalVariable( module, initializer->getType(), globalVar->isConstant(), globalVar->getLinkage(), initializer, "", nullptr, globalVar->getThreadLocalMode()); globalHelperVar->setAlignment(globalVar->getAlignment()); globalHelperVar->setComdat(globalVar->getComdat()); globalHelperVar->setDLLStorageClass(globalVar->getDLLStorageClass()); globalHelperVar->setSection(globalVar->getSection()); globalHelperVar->takeName(globalVar); // Replace all existing uses of globalVar by the bitcast pointer. auto castHelperVar = DtoBitCast(globalHelperVar, globalVar->getType()); globalVar->replaceAllUsesWith(castHelperVar); // Register replacement for later occurrences of the original globalVar. globalsToReplace.emplace_back(globalVar, castHelperVar); // Reset globalVar to the helper variable. globalVar = globalHelperVar; return castHelperVar; }
/** * Loads the CashRegisterSection. */ void MainWindow::loadCashRegisterSection() { CashRegisterDialog dialog(&m_CookieJar, m_ServerUrl, this, Qt::WindowTitleHint); connect(&dialog, SIGNAL(sessionStatusChanged(bool)), this, SLOT(setIsSessionActive(bool)), Qt::QueuedConnection); dialog.init(); if (dialog.exec() == QDialog::Accepted) { CashRegisterSection *section = new CashRegisterSection(&m_CookieJar, &m_PluginFactory, m_ServerUrl, dialog.key(), this); section->setPreliminaryReportName("Corte de caja preliminar"); section->setReportName("Corte de caja"); section->setObjectName("Caja"); section->setCloseMessage("Una vez cerrada no se podra facturar ni crear" "depositos."); section->init(); setSection(section); } }
void Parser::scan_section() { if (current_char != L_SECTION) return; std::string line = ""; while (scan_char() && current_char != R_SECTION && current_char != NEWLINE) { line += current_char; } //Remember: // Section takes care of freeing the resources of its siblings // so new is actually safe here Section *section = new Section(line); //current_section might be a section, but if not, our ctor guarantees it to be NULL. section->previous = current_section; //Use current_section rather than the getter since we don't want it to instantiate. if (current_section) { section->previous = getSection(); getSection()->next = section; } setSection(section); };
KarbonPatternToolFactory::KarbonPatternToolFactory() : KoToolFactoryBase("KarbonPatternTool") { setToolTip(i18n("Pattern editing")); setSection(mainToolType()); setIconName(koIconNameCStr("pattern")); setPriority(8); }
KoPanToolFactory::KoPanToolFactory() : KoToolFactoryBase(KoPanTool_ID) { setToolTip(i18n("Pan")); setSection(navigationToolType()); setPriority(1); setIconName(koIconNameCStr("tool_pan")); setActivationShapeId("flake/always"); }
KoZoomToolFactory::KoZoomToolFactory() : KoToolFactoryBase("ZoomTool") { setToolTip(i18n("Zoom")); setSection(navigationToolType()); setPriority(0); setIconName(koIconNameCStr("tool_zoom")); setActivationShapeId("flake/always"); }
/** * Loads the MainSection. */ void MainWindow::loadMainSection() { menuBar()->clear(); MainSection *section = new MainSection(&m_CookieJar, &m_PluginFactory, m_ServerUrl, this); setSection(section); }
bool ConfigImpl::load(std::istream& inputstream) { d_parser->setCommentCharacter(d_commentcharacter); d_parser->setDelimiter(d_delimiter); RealOrganiser organiser(d_file); if(d_parser->parse(inputstream, organiser)) { setSection(""); return true; } else { setSection(""); setError(d_parser->getErrorCode(), d_parser->getError()); return false; } }
/** * Loads the WorkingDaySection. */ void MainWindow::loadWorkingDaySection() { WorkingDaySection *section = new WorkingDaySection(&m_CookieJar, &m_PluginFactory, m_ServerUrl, this); section->setPreliminaryReportName("Reporte de ventas preliminar"); section->setReportName("Reporte de ventas"); section->setObjectName("Jornada"); section->setCloseMessage("Se cerraran todas las cajas en esta jornada."); section->init(); setSection(section); }
static void build_module_ref(std::string moduleMangle, llvm::Constant *thisModuleInfo) { // Build the ModuleInfo reference and bracketing symbols. llvm::Type *const moduleInfoPtrTy = DtoPtrToType(Module::moduleinfo->type); std::string thismrefname = "_D"; thismrefname += moduleMangle; thismrefname += "11__moduleRefZ"; auto thismref = new llvm::GlobalVariable( gIR->module, moduleInfoPtrTy, false, // FIXME: mRelocModel != llvm::Reloc::PIC_ llvm::GlobalValue::LinkOnceODRLinkage, DtoBitCast(thisModuleInfo, moduleInfoPtrTy), thismrefname); thismref->setSection(".minfo"); gIR->usedArray.push_back(thismref); }
static void build_llvm_used_array(IRState *p) { if (p->usedArray.empty()) { return; } std::vector<llvm::Constant *> usedVoidPtrs; usedVoidPtrs.reserve(p->usedArray.size()); for (auto constant : p->usedArray) { usedVoidPtrs.push_back(DtoBitCast(constant, getVoidPtrType())); } llvm::ArrayType *arrayType = llvm::ArrayType::get(getVoidPtrType(), usedVoidPtrs.size()); auto llvmUsed = new llvm::GlobalVariable( p->module, arrayType, false, llvm::GlobalValue::AppendingLinkage, llvm::ConstantArray::get(arrayType, usedVoidPtrs), "llvm.used"); llvmUsed->setSection("llvm.metadata"); }
XlPub::~XlPub() { setPublishedArea(NULL); setAlias(NULL); setSection(NULL); }
static void build_dso_registry_calls(std::string moduleMangle, llvm::Constant *thisModuleInfo) { // Build the ModuleInfo reference and bracketing symbols. llvm::Type *const moduleInfoPtrTy = DtoPtrToType(Module::moduleinfo->type); // Order is important here: We must create the symbols in the // bracketing sections right before/after the ModuleInfo reference // so that they end up in the correct order in the object file. auto minfoBeg = new llvm::GlobalVariable(gIR->module, moduleInfoPtrTy, false, // FIXME: mRelocModel != llvm::Reloc::PIC_ llvm::GlobalValue::LinkOnceODRLinkage, getNullPtr(moduleInfoPtrTy), "_minfo_beg"); minfoBeg->setSection(".minfo_beg"); minfoBeg->setVisibility(llvm::GlobalValue::HiddenVisibility); std::string thismrefname = "_D"; thismrefname += moduleMangle; thismrefname += "11__moduleRefZ"; auto thismref = new llvm::GlobalVariable( gIR->module, moduleInfoPtrTy, false, // FIXME: mRelocModel != llvm::Reloc::PIC_ llvm::GlobalValue::LinkOnceODRLinkage, DtoBitCast(thisModuleInfo, moduleInfoPtrTy), thismrefname); thismref->setSection(".minfo"); gIR->usedArray.push_back(thismref); auto minfoEnd = new llvm::GlobalVariable(gIR->module, moduleInfoPtrTy, false, // FIXME: mRelocModel != llvm::Reloc::PIC_ llvm::GlobalValue::LinkOnceODRLinkage, getNullPtr(moduleInfoPtrTy), "_minfo_end"); minfoEnd->setSection(".minfo_end"); minfoEnd->setVisibility(llvm::GlobalValue::HiddenVisibility); // Build the ctor to invoke _d_dso_registry. // This is the DSO slot for use by the druntime implementation. auto dsoSlot = new llvm::GlobalVariable(gIR->module, getVoidPtrType(), false, llvm::GlobalValue::LinkOnceODRLinkage, getNullPtr(getVoidPtrType()), "ldc.dso_slot"); dsoSlot->setVisibility(llvm::GlobalValue::HiddenVisibility); // Okay, so the theory is easy: We want to have one global constructor and // destructor per object (i.e. executable/shared library) that calls // _d_dso_registry with the respective DSO record. However, there are a // couple of issues that make this harder than necessary: // // 1) The natural way to implement the "one-per-image" part would be to // emit a weak reference to a weak function into a .ctors.<somename> // section (llvm.global_ctors doesn't support the necessary // functionality, so we'd use our knowledge of the linker script to work // around that). But as of LLVM 3.4, emitting a symbol both as weak and // into a custom section is not supported by the MC layer. Thus, we have // to use a normal ctor/dtor and manually ensure that we only perform // the call once. This is done by introducing ldc.dso_initialized. // // 2) To make sure the .minfo section isn't removed by the linker when // using --gc-sections, we need to keep a reference to it around in // _every_ object file (as --gc-sections works per object file). The // natural place for this is the ctor, where we just load a reference // on the stack after the DSO record (to ensure LLVM doesn't optimize // it out). However, this way, we need to have at least one ctor // instance per object file be pulled into the final executable. We // do this here by making the module mangle string part of its name, // even thoguht this is slightly wasteful on -singleobj builds. // // It might be a better idea to simply use a custom linker script (using // INSERT AFTER… so as to still keep the default one) to avoid all these // problems. This would mean that it is no longer safe to link D objects // directly using e.g. "g++ dcode.o cppcode.o", though. auto dsoInitialized = new llvm::GlobalVariable( gIR->module, llvm::Type::getInt8Ty(gIR->context()), false, llvm::GlobalValue::LinkOnceODRLinkage, llvm::ConstantInt::get(llvm::Type::getInt8Ty(gIR->context()), 0), "ldc.dso_initialized"); dsoInitialized->setVisibility(llvm::GlobalValue::HiddenVisibility); // There is no reason for this cast to void*, other than that removing it // seems to trigger a bug in the llvm::Linker (at least on LLVM 3.4) // causing it to not merge the %object.ModuleInfo types properly. This // manifests itself in a type mismatch assertion being triggered on the // minfoUsedPointer store in the ctor as soon as the optimizer runs. llvm::Value *minfoRefPtr = DtoBitCast(thismref, getVoidPtrType()); std::string ctorName = "ldc.dso_ctor."; ctorName += moduleMangle; llvm::Function *dsoCtor = llvm::Function::Create( llvm::FunctionType::get(llvm::Type::getVoidTy(gIR->context()), false), llvm::GlobalValue::LinkOnceODRLinkage, ctorName, &gIR->module); dsoCtor->setVisibility(llvm::GlobalValue::HiddenVisibility); build_dso_ctor_dtor_body(dsoCtor, dsoInitialized, dsoSlot, minfoBeg, minfoEnd, minfoRefPtr, false); llvm::appendToGlobalCtors(gIR->module, dsoCtor, 65535); std::string dtorName = "ldc.dso_dtor."; dtorName += moduleMangle; llvm::Function *dsoDtor = llvm::Function::Create( llvm::FunctionType::get(llvm::Type::getVoidTy(gIR->context()), false), llvm::GlobalValue::LinkOnceODRLinkage, dtorName, &gIR->module); dsoDtor->setVisibility(llvm::GlobalValue::HiddenVisibility); build_dso_ctor_dtor_body(dsoDtor, dsoInitialized, dsoSlot, minfoBeg, minfoEnd, minfoRefPtr, true); llvm::appendToGlobalDtors(gIR->module, dsoDtor, 65535); }
Config::Config(const std::wstring& path, const std::string& section) { setPath(path); setSection(section); }
buildIHM(); } void SectionGenerique::signalAndSlot(){ QObject::connect(this,SIGNAL(changeIndex(int)), this->parent(), SLOT(changeIndex(int))); QObject::connect(ui->suivBouton, SIGNAL(clicked()), this, SLOT(goNext())); QObject::connect(this,SIGNAL(changeIndex(int)), this->parent(), SLOT(changeIndex(int))); QObject::connect(this,SIGNAL(setSection()), this->parent(), SLOT(setSectionGenerique())); } void SectionGenerique::buildIHM(){ ui->subTitle->setText("<html><head/><body><p align=\"center\"><span style=\" font-size:18pt; font-weight:600; color:#5d5d5d;\">" +this->section->getNameS()+"</span></p></body></html>"); if(!this->section->getListeDeroul().isEmpty()){//build listes déroulantes QHBoxLayout *hbox = new QHBoxLayout; QVBoxLayout *vbox = new QVBoxLayout;
void Mesh::clean() { uint i, j, idist=0; Vector a, b, c, m; double mdist=0.; arr Tc(T.d0, 3); //tri centers arr Tn(T.d0, 3); //tri normals uintA Vt(V.d0); intA VT(V.d0, 100); //tri-neighbors to a vertex Vt.setZero(); VT=-1; for(i=0; i<T.d0; i++) { a.set(&V(T(i, 0), 0)); b.set(&V(T(i, 1), 0)); c.set(&V(T(i, 2), 0)); //tri center m=(a+b+c)/3.; Tc(i, 0)=m.x; Tc(i, 1)=m.y; Tc(i, 2)=m.z; //farthest tri if(m.length()>mdist) { mdist=m.length(); idist=i; } //tri normal b-=a; c-=a; a=b^c; a.normalize(); Tn(i, 0)=a.x; Tn(i, 1)=a.y; Tn(i, 2)=a.z; //vertex neighbor count j=T(i, 0); VT(j, Vt(j))=i; Vt(j)++; j=T(i, 1); VT(j, Vt(j))=i; Vt(j)++; j=T(i, 2); VT(j, Vt(j))=i; Vt(j)++; } //step through tri list and flip them if necessary boolA Tisok(T.d0); Tisok=false; uintA Tok; //contains the list of all tris that are ok oriented uintA Tnew(T.d0, T.d1); Tok.append(idist); Tisok(idist)=true; int A=0, B=0, D; uint r, k, l; intA neighbors; for(k=0; k<Tok.N; k++) { i=Tok(k); Tnew(k, 0)=T(i, 0); Tnew(k, 1)=T(i, 1); Tnew(k, 2)=T(i, 2); for(r=0; r<3; r++) { if(r==0) { A=T(i, 0); B=T(i, 1); /*C=T(i, 2);*/ } if(r==1) { A=T(i, 1); B=T(i, 2); /*C=T(i, 0);*/ } if(r==2) { A=T(i, 2); B=T(i, 0); /*C=T(i, 1);*/ } //check all triangles that share A & B setSection(neighbors, VT[A], VT[B]); neighbors.removeAllValues(-1); if(neighbors.N>2) MT_MSG("edge shared by more than 2 triangles " <<neighbors); neighbors.removeValue(i); //if(!neighbors.N) cout <<"mesh.clean warning: edge has only one triangle that shares it" <<endl; //orient them correctly for(l=0; l<neighbors.N; l++) { j=neighbors(l); //j is a neighboring triangle sharing A & B D=-1; //align the neighboring triangle and let D be its 3rd vertex if((int)T(j, 0)==A && (int)T(j, 1)==B) D=T(j, 2); if((int)T(j, 0)==A && (int)T(j, 2)==B) D=T(j, 1); if((int)T(j, 1)==A && (int)T(j, 2)==B) D=T(j, 0); if((int)T(j, 1)==A && (int)T(j, 0)==B) D=T(j, 2); if((int)T(j, 2)==A && (int)T(j, 0)==B) D=T(j, 1); if((int)T(j, 2)==A && (int)T(j, 1)==B) D=T(j, 0); if(D==-1) HALT("dammit"); //determine orientation if(!Tisok(j)) { T(j, 0)=B; T(j, 1)=A; T(j, 2)=D; Tok.append(j); Tisok(j)=true; } else { //check if consistent! } } #if 0 //compute their rotation if(neighbors.N>1) { double phi, phimax; int jmax=-1; Vector ni, nj; for(l=0; l<neighbors.N; l++) { j=neighbors(l); //j is a neighboring triangle sharing A & B a.set(&V(T(i, 0), 0)); b.set(&V(T(i, 1), 0)); c.set(&V(T(i, 2), 0)); b-=a; c-=a; a=b^c; a.normalize(); ni = a; a.set(&V(T(j, 0), 0)); b.set(&V(T(j, 1), 0)); c.set(&V(T(j, 2), 0)); b-=a; c-=a; a=b^c; a.normalize(); nj = a; Quaternion q; q.setDiff(ni, -nj); q.getDeg(phi, c); a.set(&V(A, 0)); b.set(&V(B, 0)); if(c*(a-b) < 0.) phi+=180.; if(jmax==-1 || phi>phimax) { jmax=j; phimax=phi; } } if(!Tisok(jmax)) { Tok.append(jmax); Tisok(jmax)=true; } } else { j = neighbors(0); if(!Tisok(j)) { Tok.append(j); Tisok(j)=true; } } #endif } } if(k<T.d0) { cout <<"mesh.clean warning: not all triangles connected: " <<k <<"<" <<T.d0 <<endl; cout <<"WARNING: cutting of all non-connected triangles!!" <<endl; Tnew.resizeCopy(k, 3); T=Tnew; deleteUnusedVertices(); } computeNormals(); }