00001 //===-- codegen/InstanceInfo.h -------------------------------- -*- C++ -*-===// 00002 // 00003 // This file is distributed under the MIT license. See LICENSE.txt for details. 00004 // 00005 // Copyright (C) 2009, Stephen Wilson 00006 // 00007 //===----------------------------------------------------------------------===// 00008 00009 //===----------------------------------------------------------------------===// 00014 //===----------------------------------------------------------------------===// 00015 00016 #ifndef COMMA_CODEGEN_INSTANCEINFO_HDR_GUARD 00017 #define COMMA_CODEGEN_INSTANCEINFO_HDR_GUARD 00018 00019 #include "comma/ast/Decl.h" 00020 00021 #include "llvm/ADT/DenseMap.h" 00022 00023 namespace comma { 00024 00025 class CodeGen; 00026 class SRInfo; 00027 00028 class InstanceInfo { 00029 00030 public: 00032 00033 const Domoid *getDefinition() const { return instance->getDefinition(); } 00034 Domoid *getDefinition() { return instance->getDefinition(); } 00036 00038 00039 const DomainInstanceDecl *getInstanceDecl() const { return instance; } 00040 DomainInstanceDecl *getInstanceDecl() { return instance; } 00042 00044 llvm::StringRef getLinkName() const { return linkName; } 00045 00049 SRInfo *lookupSRInfo(SubroutineDecl *srDecl) { 00050 return srInfoTable.lookup(getKeySRDecl(srDecl)); 00051 } 00052 00054 SRInfo *getSRInfo(SubroutineDecl *srDecl) { 00055 SRInfo *info = lookupSRInfo(srDecl); 00056 assert(info && "SRInfo lookup failed!"); 00057 return info; 00058 } 00059 00061 void markAsCompiled() { compiledFlag = true; } 00062 00064 bool isCompiled() const { return compiledFlag; } 00065 00066 private: 00068 InstanceInfo(CodeGen &CG, DomainInstanceDecl *instance); 00069 friend class CodeGen; 00070 00072 DomainInstanceDecl *instance; 00073 00075 typedef llvm::DenseMap<SubroutineDecl*, SRInfo*> SRInfoMap; 00076 SRInfoMap srInfoTable; 00077 00079 std::string linkName; 00080 00081 bool compiledFlag; 00082 00086 static SubroutineDecl *getKeySRDecl(SubroutineDecl *srDecl); 00087 }; 00088 00089 } // end comma namespace. 00090 00091 #endif