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/DomainInstance.h ------------------------------ -*- 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 #ifndef COMMA_CODEGEN_DOMAININSTANCE_HDR_GUARD 00010 #define COMMA_CODEGEN_DOMAININSTANCE_HDR_GUARD 00011 00012 #include "CodeGen.h" 00013 00014 #include "llvm/Support/IRBuilder.h" 00015 00016 namespace comma { 00017 00018 class CommaRT; 00019 00020 class DomainInstance { 00021 00022 public: 00023 DomainInstance(CommaRT &CRT); 00024 00025 void init(); 00026 00027 enum FieldId { 00028 Info, 00029 Next, 00030 Params, 00031 Requirements 00032 }; 00033 00035 const std::string &getTypeName() const { return theTypeName; } 00036 00038 const llvm::StructType *getType() const; 00039 00041 const llvm::PointerType *getPointerTypeTo() const; 00042 00043 template <FieldId F> 00044 struct FieldIdTraits { 00045 typedef const llvm::PointerType FieldType; 00046 }; 00047 00048 template <FieldId F> 00049 typename FieldIdTraits<F>::FieldType *getFieldType() const; 00050 00052 llvm::Value *loadInfo(llvm::IRBuilder<> &builder, 00053 llvm::Value *Instance) const; 00054 00057 llvm::Value *loadParamVec(llvm::IRBuilder<> &builder, 00058 llvm::Value *instance) const; 00059 00062 llvm::Value *loadParam(llvm::IRBuilder<> &builder, 00063 llvm::Value *instance, 00064 unsigned paramIdx) const; 00065 00067 llvm::Value *loadLocalVec(llvm::IRBuilder<> &builder, 00068 llvm::Value *instance) const; 00069 00071 void setLocalVec(llvm::IRBuilder<> &builder, 00072 llvm::Value *instance, 00073 llvm::Value *vec) const; 00074 00076 llvm::Value *loadLocalInstance(llvm::IRBuilder<> &builder, 00077 llvm::Value *instance, 00078 unsigned localID) const; 00079 00080 private: 00081 CommaRT &CRT; 00082 CodeGen &CG; 00083 const llvm::TargetData &TD; 00084 00086 static const std::string theTypeName; 00087 00089 llvm::PATypeHolder theType; 00090 }; 00091 00092 //===----------------------------------------------------------------------===// 00093 // DomainInstance::getFieldType specializations for each field in a 00094 // domain_instance. 00095 00096 template <> inline 00097 DomainInstance::FieldIdTraits<DomainInstance::Info>::FieldType * 00098 DomainInstance::getFieldType<DomainInstance::Info>() const { 00099 typedef FieldIdTraits<Info>::FieldType FTy; 00100 return llvm::cast<FTy>(getType()->getElementType(Info)); 00101 } 00102 00103 template <> inline 00104 DomainInstance::FieldIdTraits<DomainInstance::Next>::FieldType * 00105 DomainInstance::getFieldType<DomainInstance::Next>() const { 00106 typedef FieldIdTraits<Next>::FieldType FTy; 00107 return llvm::cast<FTy>(getType()->getElementType(Next)); 00108 } 00109 00110 template <> inline 00111 DomainInstance::FieldIdTraits<DomainInstance::Params>::FieldType * 00112 DomainInstance::getFieldType<DomainInstance::Params>() const { 00113 typedef FieldIdTraits<Params>::FieldType FTy; 00114 return llvm::cast<FTy>(getType()->getElementType(Params)); 00115 } 00116 00117 template <> inline 00118 DomainInstance::FieldIdTraits<DomainInstance::Requirements>::FieldType * 00119 DomainInstance::getFieldType<DomainInstance::Requirements>() const { 00120 typedef FieldIdTraits<Requirements>::FieldType FTy; 00121 return llvm::cast<FTy>(getType()->getElementType(Requirements)); 00122 } 00123 00124 } // end comma namespace. 00125 00126 #endif