From fe6ca546825304e49a73eaa2c4ced57e1a8d6a5b Mon Sep 17 00:00:00 2001 From: Michael Liao Date: Fri, 17 Feb 2023 15:58:23 -0500 Subject: [PATCH] [LangRef] Correct value ranges for address space, vector, and float bit sizes. - The current implementation checks them for 24-bit inegers but the document says 23-bit one effectively by listing the range as [1,2^23). - Minor error message correction. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D144685 --- llvm/docs/LangRef.rst | 8 ++++---- llvm/lib/IR/DataLayout.cpp | 4 ++-- llvm/test/Assembler/invalid-datalayout17.ll | 2 +- llvm/test/Assembler/invalid-datalayout4.ll | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index b4c9cff..2ba5fba 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -2770,23 +2770,23 @@ as follows: specified, the default index size is equal to the pointer size. All sizes are in bits. The address space, ``n``, is optional, and if not specified, denotes the default address space 0. The value of ``n`` must be - in the range [1,2^23). + in the range [1,2^24). ``i:[:]`` This specifies the alignment for an integer type of a given bit - ````. The value of ```` must be in the range [1,2^23). + ````. The value of ```` must be in the range [1,2^24). ```` is optional and defaults to ````. For ``i8``, the ```` value must equal 8, that is, ``i8`` must be naturally aligned. ``v:[:]`` This specifies the alignment for a vector type of a given bit - ````. The value of ```` must be in the range [1,2^23). + ````. The value of ```` must be in the range [1,2^24). ```` is optional and defaults to ````. ``f:[:]`` This specifies the alignment for a floating-point type of a given bit ````. Only values of ```` that are supported by the target will work. 32 (float) and 64 (double) are supported on all targets; 80 or 128 (different flavors of long double) are also supported on some - targets. The value of ```` must be in the range [1,2^23). + targets. The value of ```` must be in the range [1,2^24). ```` is optional and defaults to ````. ``a:[:]`` This specifies the alignment for an object of aggregate type. diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp index ae248e9..444630d 100644 --- a/llvm/lib/IR/DataLayout.cpp +++ b/llvm/lib/IR/DataLayout.cpp @@ -305,7 +305,7 @@ Error DataLayout::parseSpecifier(StringRef Desc) { if (Error Err = getInt(Tok, AddrSpace)) return Err; if (!isUInt<24>(AddrSpace)) - return reportError("Invalid address space, must be a 24bit integer"); + return reportError("Invalid address space, must be a 24-bit integer"); // Size. if (Rest.empty()) @@ -571,7 +571,7 @@ Error DataLayout::setAlignment(AlignTypeEnum AlignType, Align ABIAlign, // an assert. See D67400 for context. assert(Log2(ABIAlign) < 16 && Log2(PrefAlign) < 16 && "Alignment too big"); if (!isUInt<24>(BitWidth)) - return reportError("Invalid bit width, must be a 24bit integer"); + return reportError("Invalid bit width, must be a 24-bit integer"); if (PrefAlign < ABIAlign) return reportError( "Preferred alignment cannot be less than the ABI alignment"); diff --git a/llvm/test/Assembler/invalid-datalayout17.ll b/llvm/test/Assembler/invalid-datalayout17.ll index 519f5c1..b7eab74 100644 --- a/llvm/test/Assembler/invalid-datalayout17.ll +++ b/llvm/test/Assembler/invalid-datalayout17.ll @@ -1,3 +1,3 @@ ; RUN: not llvm-as < %s 2>&1 | FileCheck %s target datalayout = "i16777216:16:16" -; CHECK: Invalid bit width, must be a 24bit integer +; CHECK: Invalid bit width, must be a 24-bit integer diff --git a/llvm/test/Assembler/invalid-datalayout4.ll b/llvm/test/Assembler/invalid-datalayout4.ll index 2d946d3..99a6a60 100644 --- a/llvm/test/Assembler/invalid-datalayout4.ll +++ b/llvm/test/Assembler/invalid-datalayout4.ll @@ -1,3 +1,3 @@ ; RUN: not llvm-as < %s 2>&1 | FileCheck %s target datalayout = "p16777216:64:64:64" -; CHECK: Invalid address space, must be a 24bit integer +; CHECK: Invalid address space, must be a 24-bit integer -- 2.7.4