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/CodeGenTypes.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_CODEGENTYPES_HDR_GUARD 00010 #define COMMA_CODEGEN_CODEGENTYPES_HDR_GUARD 00011 00012 #include "comma/ast/AstBase.h" 00013 00014 #include "llvm/ADT/DenseMap.h" 00015 #include "llvm/ADT/ScopedHashTable.h" 00016 #include "llvm/DerivedTypes.h" 00017 00018 namespace comma { 00019 00020 class CGContext; 00021 class CodeGen; 00022 00029 class CodeGenTypes { 00030 00031 public: 00032 CodeGenTypes(CodeGen &CG, DomainInstanceDecl *context) 00033 : CG(CG), topScope(rewrites), context(context) { 00034 if (context) 00035 addInstanceRewrites(context); 00036 }; 00037 00038 const llvm::Type *lowerType(const Type *type); 00039 00040 const llvm::Type *lowerDomainType(const DomainType *type); 00041 00042 const llvm::IntegerType *lowerEnumType(const EnumerationType *type); 00043 00044 const llvm::FunctionType *lowerSubroutine(const SubroutineDecl *decl); 00045 00046 const llvm::IntegerType *lowerDiscreteType(const DiscreteType *type); 00047 00048 const llvm::ArrayType *lowerArrayType(const ArrayType *type); 00049 00050 const llvm::StructType *lowerRecordType(const RecordType *type); 00051 00052 const llvm::Type *lowerIncompleteType(const IncompleteType *type); 00053 00054 const llvm::PointerType *lowerThinAccessType(const AccessType *type); 00055 00056 const llvm::StructType *lowerFatAccessType(const AccessType *type); 00057 00058 const llvm::Type *lowerAccessType(const AccessType *type); 00059 00060 const llvm::Type *lowerUniversalType(const UniversalType *type); 00061 00064 const llvm::StructType *lowerArrayBounds(const ArrayType *arrTy); 00065 00068 const llvm::StructType *lowerScalarBounds(const DiscreteType *type); 00069 00071 const llvm::StructType *lowerRange(const Range *range); 00072 00075 unsigned getComponentIndex(const ComponentDecl *component); 00076 00079 unsigned getTypeAlignment(const llvm::Type *type) const; 00080 00082 uint64_t getTypeSize(const llvm::Type *type) const; 00083 00089 const Type *resolveType(const Type *type); 00090 00093 //@ 00094 enum CallConvention { 00095 CC_Simple, 00096 CC_Sret, 00097 CC_Vstack 00098 }; 00099 00100 CallConvention getConvention(const SubroutineDecl *decl); 00102 00103 private: 00104 CodeGen &CG; 00105 00106 typedef llvm::ScopedHashTable<const Type*, const Type*> RewriteMap; 00107 typedef llvm::ScopedHashTableScope<const Type*, const Type*> RewriteScope; 00108 RewriteMap rewrites; 00109 RewriteScope topScope; 00110 00111 DomainInstanceDecl *context; 00112 00115 typedef llvm::DenseMap<const ComponentDecl*, unsigned> ComponentIndexMap; 00116 ComponentIndexMap ComponentIndices; 00117 00123 typedef llvm::DenseMap<const Type*, const llvm::Type*> TypeMap; 00124 TypeMap loweredTypes; 00125 00126 const DomainType *rewriteAbstractDecl(const AbstractDomainDecl *abstract); 00127 00128 const llvm::IntegerType *getTypeForWidth(unsigned numBits); 00129 00130 void addInstanceRewrites(const DomainInstanceDecl *instance); 00131 00137 const llvm::Type *&getLoweredType(const Type *type) { 00138 return loweredTypes.FindAndConstruct(type).second; 00139 } 00140 }; 00141 00142 }; // end comma namespace 00143 00144 #endif