diff options
author | Christopher Lamb <christopher.lamb@gmail.com> | 2008-02-04 02:31:56 +0000 |
---|---|---|
committer | Christopher Lamb <christopher.lamb@gmail.com> | 2008-02-04 02:31:56 +0000 |
commit | ebb97e98c03f8d7034bd3748a10e35f39a95c289 (patch) | |
tree | 9304659bdd12a3b9e9965ebec497f777d508e919 /CodeGen | |
parent | 550ce0f9b732388ea6f0ab6881d28ef3f5f4906b (diff) |
Add experimental support for address space qualified types. Address space
qualifiers use the __attribute__((address_space(id))) syntax.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46691 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen')
-rw-r--r-- | CodeGen/CGDecl.cpp | 3 | ||||
-rw-r--r-- | CodeGen/CodeGenModule.cpp | 9 | ||||
-rw-r--r-- | CodeGen/CodeGenTypes.cpp | 16 |
3 files changed, 20 insertions, 8 deletions
diff --git a/CodeGen/CGDecl.cpp b/CodeGen/CGDecl.cpp index 23c707d8c4..a6c5da7c26 100644 --- a/CodeGen/CGDecl.cpp +++ b/CodeGen/CGDecl.cpp @@ -84,7 +84,8 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const BlockVarDecl &D) { DMEntry = new llvm::GlobalVariable(LTy, false, llvm::GlobalValue::InternalLinkage, - Init, D.getName(), &CGM.getModule()); + Init, D.getName(), &CGM.getModule(), 0, + Ty.getAddressSpace()); } diff --git a/CodeGen/CodeGenModule.cpp b/CodeGen/CodeGenModule.cpp index edf3dc4283..382f651272 100644 --- a/CodeGen/CodeGenModule.cpp +++ b/CodeGen/CodeGenModule.cpp @@ -131,7 +131,8 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D, llvm::Constant *&Entry = GlobalDeclMap[D]; if (Entry) return Entry; - const llvm::Type *Ty = getTypes().ConvertTypeForMem(D->getType()); + QualType ASTTy = D->getType(); + const llvm::Type *Ty = getTypes().ConvertTypeForMem(ASTTy); // Check to see if the global already exists. llvm::GlobalVariable *GV = getModule().getGlobalVariable(D->getName(), true); @@ -140,7 +141,8 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D, if (GV == 0) { return Entry = new llvm::GlobalVariable(Ty, false, llvm::GlobalValue::ExternalLinkage, - 0, D->getName(), &getModule()); + 0, D->getName(), &getModule(), 0, + ASTTy.getAddressSpace()); } // If the pointer type matches, just return it. @@ -162,7 +164,8 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D, // making a new global of the correct type, RAUW, then steal the name. llvm::GlobalVariable *NewGV = new llvm::GlobalVariable(Ty, false, llvm::GlobalValue::ExternalLinkage, - 0, D->getName(), &getModule()); + 0, D->getName(), &getModule(), 0, + ASTTy.getAddressSpace()); NewGV->takeName(GV); // Replace uses of GV with the globalvalue we will endow with a body. diff --git a/CodeGen/CodeGenTypes.cpp b/CodeGen/CodeGenTypes.cpp index 9e8a2e0ea6..326503197f 100644 --- a/CodeGen/CodeGenTypes.cpp +++ b/CodeGen/CodeGenTypes.cpp @@ -199,7 +199,8 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { } case Type::Pointer: { const PointerType &P = cast<PointerType>(Ty); - return llvm::PointerType::getUnqual(ConvertType(P.getPointeeType())); + QualType ETy = P.getPointeeType(); + return llvm::PointerType::get(ConvertType(ETy), ETy.getAddressSpace()); } case Type::Reference: { const ReferenceType &R = cast<ReferenceType>(Ty); @@ -245,7 +246,8 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { // Struct return passes the struct byref. if (!ResultType->isFirstClassType() && ResultType != llvm::Type::VoidTy) { - const llvm::Type *RType = llvm::PointerType::getUnqual(ResultType); + const llvm::Type *RType = llvm::PointerType::get(ResultType, + FP.getResultType().getAddressSpace()); QualType RTy = Context.getPointerType(FP.getResultType()); TypeHolderMap.insert(std::make_pair(RTy.getTypePtr(), llvm::PATypeHolder(RType))); @@ -263,6 +265,10 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { return llvm::FunctionType::get(ResultType, ArgTys, isVarArg); } + + case Type::ASQual: + return ConvertType(cast<ASQualType>(Ty).getBaseType()); + break; case Type::ObjCInterface: assert(0 && "FIXME: add missing functionality here"); @@ -386,8 +392,10 @@ void CodeGenTypes::DecodeArgumentTypes(const FunctionTypeProto &FTP, if (Ty->isFirstClassType()) ArgTys.push_back(Ty); else { - QualType PTy = Context.getPointerType(FTP.getArgType(i)); - const llvm::Type *PtrTy = llvm::PointerType::getUnqual(Ty); + QualType ATy = FTP.getArgType(i); + QualType PTy = Context.getPointerType(ATy); + unsigned AS = ATy.getAddressSpace(); + const llvm::Type *PtrTy = llvm::PointerType::get(Ty, AS); TypeHolderMap.insert(std::make_pair(PTy.getTypePtr(), llvm::PATypeHolder(PtrTy))); |