Index: docs/LangRef.rst =================================================================== --- docs/LangRef.rst +++ docs/LangRef.rst @@ -1877,8 +1877,15 @@ must be a multiple of 8-bits. If omitted, the natural stack alignment defaults to "unspecified", which does not prevent any alignment promotions. +``P
`` + Specifies the address space that corresponds to program memory. + Harvard architectures can use this to specify what space LLVM + should place things such as functions or switch lookup tables + into. If omitted, the program memory space defaults to the + default address space of 0, which corresponds to a Von Neumann + architecture that has code and data in the same space. ``A
`` - Specifies the address space of objects created by '``alloca``'. + Specifies the address space of objects created by '``alloca``'. Defaults to the default address space of 0. ``p[n]:::`` This specifies the *size* of a pointer and its ```` and Index: include/llvm/IR/DataLayout.h =================================================================== --- include/llvm/IR/DataLayout.h +++ include/llvm/IR/DataLayout.h @@ -113,6 +113,7 @@ unsigned AllocaAddrSpace; unsigned StackNaturalAlign; + unsigned ProgramAddrSpace; enum ManglingModeT { MM_None, @@ -196,6 +197,7 @@ BigEndian = DL.isBigEndian(); AllocaAddrSpace = DL.AllocaAddrSpace; StackNaturalAlign = DL.StackNaturalAlign; + ProgramAddrSpace = DL.ProgramAddrSpace; ManglingMode = DL.ManglingMode; LegalIntWidths = DL.LegalIntWidths; Alignments = DL.Alignments; @@ -252,6 +254,8 @@ unsigned getStackAlignment() const { return StackNaturalAlign; } unsigned getAllocaAddrSpace() const { return AllocaAddrSpace; } + unsigned getProgramAddressSpace() const { return ProgramAddrSpace; } + bool hasMicrosoftFastStdCallMangling() const { return ManglingMode == MM_WinCOFFX86; } Index: include/llvm/IR/GlobalValue.h =================================================================== --- include/llvm/IR/GlobalValue.h +++ include/llvm/IR/GlobalValue.h @@ -177,6 +177,7 @@ GlobalValue(const GlobalValue &) = delete; unsigned getAlignment() const; + unsigned getAddressSpace() const; enum class UnnamedAddr { None, Index: lib/IR/DataLayout.cpp =================================================================== --- lib/IR/DataLayout.cpp +++ lib/IR/DataLayout.cpp @@ -181,6 +181,7 @@ BigEndian = false; AllocaAddrSpace = 0; StackNaturalAlign = 0; + ProgramAddrSpace = 0; ManglingMode = MM_None; NonIntegralAddressSpaces.clear(); @@ -358,6 +359,10 @@ StackNaturalAlign = inBytes(getInt(Tok)); break; } + case 'P': { // Function address space. + ProgramAddrSpace = inBytes(getInt(Tok)); + break; + } case 'A': { // Default stack/alloca address space. AllocaAddrSpace = getInt(Tok); if (!isUInt<24>(AllocaAddrSpace)) Index: lib/IR/Globals.cpp =================================================================== --- lib/IR/Globals.cpp +++ lib/IR/Globals.cpp @@ -107,6 +107,11 @@ return cast(this)->getAlignment(); } +unsigned GlobalValue::getAddressSpace() const { + PointerType *PtrTy = getType(); + return PtrTy->getAddressSpace(); +} + void GlobalObject::setAlignment(unsigned Align) { assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); assert(Align <= MaximumAlignment && Index: lib/Target/AVR/AVRTargetMachine.cpp =================================================================== --- lib/Target/AVR/AVRTargetMachine.cpp +++ lib/Target/AVR/AVRTargetMachine.cpp @@ -25,7 +25,7 @@ namespace llvm { -static const char *AVRDataLayout = "e-p:16:16:16-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-n8"; +static const char *AVRDataLayout = "e-P1-p:16:16:16-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-n8"; /// Processes a CPU name. static StringRef getCPU(StringRef CPU) {