FPge_expr::FPge_expr(Target* _target, int wE, int wF) : Operator(_target) { ostringstream name; name<<"FPge_expr_" <<wE<<"_"<<wF; setName(name.str()); setCopyrightString("Fabrizio Ferrandi (2011-2017)"); /* Set up the IO signals */ addFPInput ("X", wE,wF); addFPInput ("Y", wE,wF); addOutput ("R", 1); /* VHDL code description */ manageCriticalPath(_target->localWireDelay() + _target->lutDelay()); vhdl << tab << declare("nY",wE+wF+3) << " <= Y"<< range(wE+wF+2,wE+wF+1) << " & not(Y"<< of(wE+wF) << ") & Y" << range(wE+wF-1,0) << ";" << endl; FPAdderSinglePath * value_difference = new FPAdderSinglePath(_target, wE, wF, wE, wF, wE, wF); value_difference->changeName(getName()+"value_difference"); oplist.push_back(value_difference); inPortMap (value_difference, "X", "X"); inPortMap (value_difference, "Y", "nY"); outPortMap (value_difference, "R","valueDiff"); vhdl << instance(value_difference, "value_difference"); syncCycleFromSignal("valueDiff"); setCriticalPath(value_difference->getOutputDelay("R")); manageCriticalPath(_target->localWireDelay() + _target->lutDelay()); vhdl << tab << "R(0) <= '1' when (valueDiff" << of(wE+wF) << "='0' or (valueDiff" << range(wE+wF+2,wE+wF+1) << " = \"00\")) else '0';" << endl; }
Decl& Parser::on_type_template_parameter(Name& n) { Decl& parm = build.make_type_parameter(n); declare(cxt, current_scope(), parm); return parm; }
// Create a saved scope for the function body and add the parameters // to it. This will allow parameter names to be looked up during // subsequent elaboration. Note that name hiding will also be diagnosed // later. static void declare_parms(Context& cxt, Term& t, Decl_list& parms) { Enter_scope scope(cxt, cxt.saved_scope(t)); for (Decl& p : parms) declare(cxt, p); }
DeclarationNode::DeclarationNode(DeclarationSpecifiersNode* declSpecifier , SymbolTable* _table) : declSpecifier(declSpecifier) { declare(_table); nodeData = toOperations(); }
Decl& Parser::on_class_declaration(Name& n, Type& t, Stmt& s) { Decl& d = build.make_class_declaration(n, t, s); declare(cxt, current_scope(), d); return d; }
// Add the declaration d to the given scope. void declare(Context& cxt, Scope& scope, Decl& decl) { if (Overload_set* ovl = scope.lookup(decl.name())) declare(cxt, *ovl, decl); else scope.bind(decl); }
// Called just prior to analyzing the definition, declare all of the // parameters into the saved function scope. Decl& Parser::enter_function_declaration(Decl& d) { Function_decl& fn = cast<Function_decl>(d); for (Decl& p : fn.parameters()) declare(cxt, p); return d; }
declist() { extern peeksym, peekc, csym[], cval; auto o; while((o=symbol())==19 & cval<10) declare(cval); peeksym = o; }
void declare_functions(node_t* node){ //The only possible child. node_t* functionlist = node->children[0]; for(int i = 0;i < functionlist->n_children; i++){ node_t* function = functionlist->children[i]; declare(function->children[0],0,TRUE); } }
ste *symboltable::lookup(lexid * name) { ste *p = find(name); if (p == NULL) { Error.Error("%s undeclared.", name->getname()); p = declare(name, errordecl); } return (p); }
void Interpreter::enableDynamicLookup(bool value /*=true*/) { m_DynamicLookupEnabled = value; if (isDynamicLookupEnabled()) { if (loadModuleForHeader("cling/Interpreter/DynamicLookupRuntimeUniverse.h") != kSuccess) declare("#include \"cling/Interpreter/DynamicLookupRuntimeUniverse.h\""); } }
PUBLIC void init_type(void) { void_type = prim_type("void"); char_type = prim_type("char"); int_type = prim_type("integer"); bool_type = prim_type("boolean"); scalar_type = prim_type("*scalar*"); string_type = prim_type("*string*"); text_type = prim_type("text"); err_type = prim_type("*err_type*"); def_const("true", bool_type, "TRUE"); def_const("false", bool_type, "FALSE"); dummy_def = def_const("*dummy*", err_type, ""); _input_ = declare(VAR, enter("input", BUILTIN), text_type); _output_ = declare(VAR, enter("output", BUILTIN), text_type); }
void ParseGlobalDeclarations() { funcdecl = FALSE; for(;;) { switch(lastst) { case id: case kw_interrupt: case kw_pascal: case kw_nocall: case kw_oscall: case kw_typedef: case kw_byte: case kw_char: case kw_int: case kw_short: case kw_unsigned: case kw_signed: case kw_long: case kw_struct: case kw_union: case kw_enum: case kw_void: case kw_float: case kw_double: lc_static += declare(&gsyms,sc_global,lc_static,bt_struct); break; case kw_register: NextToken(); error(ERR_ILLCLASS); lc_static += declare(&gsyms,sc_global,lc_static,bt_struct); break; case kw_private: case kw_static: NextToken(); lc_static += declare(&gsyms,sc_static,lc_static,bt_struct); break; case kw_extern: NextToken(); if (lastst==kw_pascal) { isPascal = TRUE; NextToken(); } else if (lastst==kw_oscall || lastst==kw_interrupt || lastst==kw_nocall) NextToken(); ++global_flag; declare(&gsyms,sc_external,0,bt_struct); --global_flag; break; default: return; } } }
PRIVATE type prim_type(char *name) { ident sym = enter(name, BUILTIN); type p = alloc_type(); p->x_kind = PRIMTYPE; p->x_name = sym; declare(TYPE, sym, p); return p; }
NodePtr elem() { NodePtr e = simpleelem(); if (e != NULL) return e; if (e = comment()) return e; if (e = declare()) return e; if (e = text()) return e; if (e = fullelem()) return e; return e; }
void ParseStructMembers(TYP *tp, int ztype) { int slc; slc = 0; tp->val_flag = 1; // tp->val_flag = FALSE; while( lastst != end) { if(ztype == bt_struct) slc += declare(&(tp->lst),sc_member,slc,ztype); else slc = imax(slc,declare(&tp->lst,sc_member,0,ztype)); } bit_offset = 0; bit_next = 0; bit_width = -1; tp->size = tp->alignment ? tp->alignment : slc; NextToken(); }
DeclarationNode::DeclarationNode(DeclarationSpecifiersNode* declSpecifier, InitDeclaratorListNode* initDeclList, SymbolTable* _table ) : declSpecifier(declSpecifier), initDeclList(initDeclList) { declare(_table); nodeData = toOperations(); }
/******************** class symboltable ********************/ symboltable::symboltable() { constdecl *temp; int i = 0; for (i = 0; i < MAXSCOPES; i++) { scopes[i] = 0; scopestack[i] = NULL; } curscope = 0; scopedepth = 0; /* enter useful stuff. */ declare(ltable.enter("boolean"), booltype); temp = new constdecl(1, booltype); declare(ltable.enter("true"), temp); temp = new constdecl(0, booltype); declare(ltable.enter("false"), temp); ::offset = 0; }
//Recursivly walk a tree looking for VARIABLE nodes int32_t declare_tree(node_t *node){ if(node->type.index == VARIABLE){ declare(node,next_stack_offset, FALSE); next_stack_offset -= 4; } for(int i = 0; i < node->n_children; i++){ node_t* child = node->children[i]; declare_tree(child); } }
Decl& Parser::on_variable_declaration(Name& n, Type& t, Def& d) { Decl* ret; if (parsing_nonstatic_member()) ret = &cxt.make_field_declaration(n, t, d); else ret = &cxt.make_variable_declaration(n, t, d); ret->spec_ = take_decl_specs(); declare(cxt, *ret); return *ret; }
CSMPrefs::State::State (const Files::ConfigurationManager& configurationManager) : mConfigFile ("openmw-cs.cfg"), mConfigurationManager (configurationManager), mCurrentCategory (mCategories.end()) { if (sThis) throw std::logic_error ("An instance of CSMPRefs::State already exists"); load(); declare(); sThis = this; }
void EBPFControl::emit(CodeBuilder* builder) { auto hitType = EBPFTypeFactory::instance->create(IR::Type_Boolean::get()); builder->emitIndent(); hitType->declare(builder, hitVariable, false); builder->endOfStatement(true); for (auto a : controlBlock->container->controlLocals) emitDeclaration(builder, a); builder->emitIndent(); codeGen->setBuilder(builder); controlBlock->container->body->apply(*codeGen); builder->newline(); }
void Interpreter::IncludeCXXRuntime() { // Set up common declarations which are going to be available // only at runtime // Make sure that the universe won't be included to compile time by using // -D __CLING__ as CompilerInstance's arguments #ifdef _WIN32 // We have to use the #defined __CLING__ on windows first. //FIXME: Find proper fix. declare("#ifdef __CLING__ \n#endif"); #endif declare("#include \"cling/Interpreter/RuntimeUniverse.h\""); if (!isInSyntaxOnlyMode()) { // Set up the gCling variable if it can be used std::stringstream initializer; initializer << "namespace cling {namespace runtime { " "cling::Interpreter *gCling=(cling::Interpreter*)" << (uintptr_t)this << ";} }"; declare(initializer.str()); } }
void define_parameters(node_t* node){ node_t* parlist = node->children[1]; if(parlist != NULL){ int32_t offset = 4 + parlist->n_children*4; for(int i = 0; i < parlist->n_children; i++){ declare(parlist->children[i], offset, FALSE); offset -= 4; } } }
// FIXME: There's a lot of duplication hereabouts. Can we reduce it? Decl& Parser::on_variable_declaration(Name& n, Type& t, Expr& e) { Decl* ret; if (declaring_member(*this)) ret = &cxt.make_field_declaration(n, t, e); else ret = &cxt.make_variable_declaration(n, t, e); ret->spec_ = take_decl_specs(); declare(cxt, *ret); return *ret; }
Decl& Parser::on_function_declaration(Name& n, Decl_list& p, Type& t, Stmt& s) { Decl* ret; if (declaring_member(*this)) ret = &cxt.make_method_declaration(n, p, t, s); else ret = &cxt.make_function_declaration(n, p, t, s); ret->spec_ = take_decl_specs(); declare(cxt, *ret); return *ret; }
void ParseAutoDeclarations(TABLE *ssyms) { SYM *sp; funcdecl = 0; for(;;) { worstAlignment = 0; switch(lastst) { case kw_cdecl: case kw_interrupt: case kw_naked: case kw_nocall: case kw_oscall: case kw_pascal: case kw_typedef: error(ERR_ILLCLASS); lc_auto += declare(ssyms,sc_auto,lc_auto,bt_struct); break; case ellipsis: case id: //return; sp = search(lastid,&gsyms[0]); if (sp) { if (sp->storage_class==sc_typedef) { lc_auto += declare(ssyms,sc_auto,lc_auto,bt_struct); break; } } return; case kw_register: NextToken(); case kw_exception: case kw_volatile: case kw_const: case kw_int8: case kw_int16: case kw_int32: case kw_int64: case kw_byte: case kw_char: case kw_int: case kw_short: case kw_unsigned: case kw_signed: case kw_long: case kw_struct: case kw_union: case kw_enum: case kw_void: case kw_float: case kw_double: lc_auto += declare(ssyms,sc_auto,lc_auto,bt_struct); break; case kw_thread: NextToken(); lc_thread += declare(ssyms,sc_thread,lc_thread,bt_struct); break; case kw_static: NextToken(); lc_static += declare(ssyms,sc_static,lc_static,bt_struct); break; case kw_extern: NextToken(); if (lastst==kw_oscall || lastst==kw_interrupt || lastst == kw_nocall || lastst==kw_naked) NextToken(); ++global_flag; declare(&gsyms[0],sc_external,0,bt_struct); --global_flag; break; default: return; } } }
void declare_interface_ref(interface_ref iref, declaration gparms, environment env, attribute attribs) { const char *iname = (iref->word2 ? iref->word2 : iref->word1)->cstring.data; nesc_declaration idecl = require(l_interface, iref->location, iref->word1->cstring.data); struct data_declaration tempdecl; data_declaration old_decl, ddecl; init_data_declaration(&tempdecl, CAST(declaration, iref), iname, void_type); tempdecl.kind = decl_interface_ref; tempdecl.type = NULL; tempdecl.itype = idecl; tempdecl.container = current.container; tempdecl.required = current.spec_section == spec_uses; tempdecl.gparms = gparms ? make_gparm_typelist(gparms) : NULL; handle_decl_attributes(attribs, &tempdecl); old_decl = env_lookup(env->id_env, iname, TRUE); if (old_decl) error("redefinition of `%s'", iname); ddecl = declare(env, &tempdecl, FALSE); iref->attributes = attribs; iref->ddecl = ddecl; if (idecl->abstract) { generic_used = TRUE; check_abstract_arguments("interface", ddecl, idecl->parameters, iref->args); ddecl->itype = interface_copy(parse_region, iref, current.container->abstract); ddecl->functions = ddecl->itype->env; } else { copy_interface_functions(parse_region, current.container, ddecl, ddecl->itype->env); if (iref->args) error("unexpected type arguments"); } /* We don't make the interface type generic. Instead, we push the generic type into each function in copy_interface_functions. This is because the syntax for invoking or defining a function on a generic interface is interfacename.functionname[generic args](...) */ if (gparms) set_interface_functions_gparms(ddecl->functions, ddecl->gparms); ddecl->type = make_interface_type(ddecl); }
void ParseParameterDeclarations(int fd) { funcdecl = fd; for(;;) { switch(lastst) { case kw_interrupt: case kw_nocall: case kw_oscall: case kw_pascal: case kw_typedef: error(ERR_ILLCLASS); declare(&lsyms,sc_auto,0,bt_struct); break; case id: case kw_byte: case kw_char: case kw_int: case kw_short: case kw_unsigned: case kw_signed: case kw_long: case kw_struct: case kw_union: case kw_enum: case kw_void: case kw_float: case kw_double: declare(&lsyms,sc_auto,0,bt_struct); break; case kw_static: NextToken(); error(ERR_ILLCLASS); lc_static += declare(&gsyms,sc_static,lc_static,bt_struct); break; case kw_extern: NextToken(); error(ERR_ILLCLASS); if (lastst==kw_oscall || lastst==kw_interrupt || lastst == kw_nocall) NextToken(); ++global_flag; declare(&gsyms,sc_external,0,bt_struct); --global_flag; break; default: return; } } }
LNSMul::LNSMul(Target * target, int wE, int wF) : Operator(target), wE(wE), wF(wF) { ostringstream name; /* The name has the format: LNSMul_wE_wF where: wE = width of the integral part of the exponent wF = width of the fractional part of the exponent */ name << "LNSMul_" << wE << "_" << wF; setName(name.str()); setCopyrightString("Jérémie Detrey, Florent de Dinechin (2003-2004), Sylvain Collange (2008)"); addInput ("nA", wE + wF + 3); addInput ("nB", wE + wF + 3); addOutput("nR", wE + wF + 3); addConstant("wE", "positive", wE); addConstant("wF", "positive", wF); //vhdl << tab << declare("eRn", wE+wF+1) << " <= (nA(wE+wF-1) & nA(wE+wF-1 downto 0)) + (nB(wE+wF-1) & nB(wE+wF-1 downto 0));\n"; IntAdder *my_adder = new IntAdder(target, wE+wF+1); oplist.push_back(my_adder); vhdl << tab << declare("X", wE+wF+1) << "<= nA(wE+wF-1) & nA(wE+wF-1 downto 0);\n"; vhdl << tab << declare("Y", wE+wF+1) << "<= nB(wE+wF-1) & nB(wE+wF-1 downto 0);\n"; inPortMap (my_adder, "X", "X"); inPortMap (my_adder, "Y", "Y"); inPortMapCst(my_adder, "Cin", "'0'"); outPortMap (my_adder, "R","eRn"); vhdl << instance(my_adder, "my_add"); vhdl << tab << declare("sRn") << " <= nA(wE+wF) xor nB(wE+wF);\n"; vhdl << tab << declare("xRn", 2) << " <= \"00\" when eRn(wE+wF downto wE+wF-1) = \"10\" else\n" << tab << " \"10\" when eRn(wE+wF downto wE+wF-1) = \"01\" else\n" << tab << " \"01\";\n"; vhdl << tab << declare("nRn", wE+wF+3) << " <= xRn & sRn & eRn(wE+wF-1 downto 0);\n"; vhdl << tab << declare("xA", 2) << " <= nA(wE+wF+2 downto wE+wF+1);\n"; vhdl << tab << declare("xB", 2) << " <= nB(wE+wF+2 downto wE+wF+1);\n"; vhdl << tab << declare("xAB", 4) << " <= xA & xB when xA >= xB else\n" << tab << " xB & xA;\n"; vhdl << tab << "with xAB select\n" << tab << tab << "nR(wE+wF+2 downto wE+wF+1) <= xRn when \"0101\",\n" << tab << " \"00\" when \"0000\" | \"0100\",\n" << tab << " \"10\" when \"1001\" | \"1010\",\n" << tab << " \"11\" when others;\n" << tab << "\n" << tab << "nR(wE+wF downto 0) <= nRn(wE+wF downto 0);\n"; }