diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -2376,6 +2376,8 @@ This specifies pointer types with the specified address spaces as :ref:`Non-Integral Pointer Type ` s. The ``0`` address space cannot be specified as non-integral. +``fe:`` + This specifies the size of floating point environment. On every specification that takes a ``:``, specifying the ```` alignment is optional. If omitted, the preceding ``:`` diff --git a/llvm/include/llvm/IR/DataLayout.h b/llvm/include/llvm/IR/DataLayout.h --- a/llvm/include/llvm/IR/DataLayout.h +++ b/llvm/include/llvm/IR/DataLayout.h @@ -123,6 +123,7 @@ unsigned AllocaAddrSpace; MaybeAlign StackNaturalAlign; unsigned ProgramAddrSpace; + unsigned FPEnvironmentSize; MaybeAlign FunctionPtrAlign; FunctionPtrAlignType TheFunctionPtrAlignType; @@ -212,6 +213,7 @@ FunctionPtrAlign = DL.FunctionPtrAlign; TheFunctionPtrAlignType = DL.TheFunctionPtrAlignType; ProgramAddrSpace = DL.ProgramAddrSpace; + FPEnvironmentSize = DL.FPEnvironmentSize; ManglingMode = DL.ManglingMode; LegalIntWidths = DL.LegalIntWidths; Alignments = DL.Alignments; @@ -285,6 +287,8 @@ unsigned getProgramAddressSpace() const { return ProgramAddrSpace; } + unsigned getFPEnvironmentSize() const { return FPEnvironmentSize; } + bool hasMicrosoftFastStdCallMangling() const { return ManglingMode == MM_WinCOFFX86; } diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp --- a/llvm/lib/IR/DataLayout.cpp +++ b/llvm/lib/IR/DataLayout.cpp @@ -179,6 +179,7 @@ AllocaAddrSpace = 0; StackNaturalAlign.reset(); ProgramAddrSpace = 0; + FPEnvironmentSize = 0; FunctionPtrAlign.reset(); TheFunctionPtrAlignType = FunctionPtrAlignType::Independent; ManglingMode = MM_None; @@ -255,6 +256,18 @@ continue; } + if (Tok == "fe") { + if (Rest.empty()) + report_fatal_error( + "Missing size specification for FP environment in datalayout string"); + Split = split(Rest, ':'); + Rest = Split.second; + FPEnvironmentSize = inBytes(getInt(Split.first)); + if (!Rest.empty()) + report_fatal_error("Extra item in FP environment specification"); + continue; + } + char Specifier = Tok.front(); Tok = Tok.substr(1); diff --git a/llvm/unittests/IR/DataLayoutTest.cpp b/llvm/unittests/IR/DataLayoutTest.cpp --- a/llvm/unittests/IR/DataLayoutTest.cpp +++ b/llvm/unittests/IR/DataLayoutTest.cpp @@ -56,4 +56,10 @@ DL.getValueOrABITypeAlignment(MaybeAlign(), FourByteAlignType)); } +TEST(DataLayoutTest, FPEnvironmentProperties) { + EXPECT_EQ(0, DataLayout("").getFPEnvironmentSize()); + EXPECT_EQ(0, DataLayout("fe:0").getFPEnvironmentSize()); + EXPECT_EQ(4, DataLayout("fe:32").getFPEnvironmentSize()); +} + } // anonymous namespace