This machine mirrors various open-source projects.
20 Gbit/s uplink.
If there are any issues or you want another project mirrored, please contact
mirror-service -=AT=- netcologne DOT de !
00001 //===-- codegen/InstanceInfo.cpp ------------------------------ -*- C++ -*-===// 00002 // 00003 // This file is distributed under the MIT license. See LICENSE.txt for details. 00004 // 00005 // Copyright (C) 2009-2010, Stephen Wilson 00006 // 00007 //===----------------------------------------------------------------------===// 00008 00009 #include "CodeGen.h" 00010 #include "CodeGenTypes.h" 00011 #include "InstanceInfo.h" 00012 #include "SRInfo.h" 00013 #include "comma/codegen/Mangle.h" 00014 00015 using namespace comma; 00016 using llvm::dyn_cast; 00017 using llvm::cast; 00018 using llvm::isa; 00019 00020 SubroutineDecl *InstanceInfo::getKeySRDecl(SubroutineDecl *srDecl) 00021 { 00022 // Declaration nodes which correspond to the public view always have their 00023 // origin link set to the corresponding private view. 00024 DeclRegion *region = srDecl->getDeclRegion(); 00025 if (isa<DomainInstanceDecl>(region)) { 00026 srDecl = srDecl->getOrigin(); 00027 region = srDecl->getDeclRegion(); 00028 } 00029 00030 // Check that some basic assumptions hold. The declarative region must have 00031 // been resolved to either a PercentDecl or AddDecl. 00032 assert((isa<PercentDecl>(region) || isa<AddDecl>(region)) && 00033 "Inconsistent context for subroutine declaration!"); 00034 00035 // Further reduce the SubroutineDecl to its completion, if present. 00036 if (srDecl->getDefiningDeclaration()) 00037 srDecl = srDecl->getDefiningDeclaration(); 00038 00039 return srDecl; 00040 } 00041 00042 InstanceInfo::InstanceInfo(CodeGen &CG, DomainInstanceDecl *instance) 00043 : instance(instance), 00044 linkName(mangle::getLinkName(instance)), 00045 compiledFlag(false) 00046 { 00047 CodeGenTypes CGT(CG, instance); 00048 00049 DeclRegion::DeclIter I; 00050 DeclRegion::DeclIter E; 00051 00052 // Construct an SRInfo node for each public declaration provided by the 00053 // instance. 00054 E = instance->endDecls(); 00055 for (I = instance->beginDecls(); I != E; ++I) { 00057 if (SubroutineDecl *srDecl = dyn_cast<SubroutineDecl>(*I)) { 00058 SubroutineDecl *key = getKeySRDecl(srDecl); 00059 00060 assert(!srInfoTable.count(key) && 00061 "Multiple declarations map to the same key!"); 00062 00063 llvm::Function *fn = CG.makeFunction(instance, srDecl, CGT); 00064 srInfoTable[key] = new SRInfo(key, fn); 00065 } 00066 } 00067 00068 // Similarly for every private declaration that is not visible thru the 00069 // public interface. 00070 Domoid *domoid = instance->getDefinition(); 00071 AddDecl *impl = domoid->getImplementation(); 00072 E = impl->endDecls(); 00073 for (I = impl->beginDecls(); I != E; ++I) { 00074 // FIXME: Support all declaration kinds. 00075 if (SubroutineDecl *srDecl = dyn_cast<SubroutineDecl>(*I)) { 00076 SubroutineDecl *key = getKeySRDecl(srDecl); 00077 00078 // If an info structure already exists for this declaration, skip 00079 // it. 00080 if (srInfoTable.count(key)) 00081 continue; 00082 00083 llvm::Function *fn = CG.makeFunction(instance, srDecl, CGT); 00084 srInfoTable[key] = new SRInfo(key, fn); 00085 } 00086 } 00087 }