Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1982)

Issue 4749046: [PATCH] Add APInt(numBits, ArrayRef<uint64_t> bigVal) constructor (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 5 months ago by Jeffrey Yasskin
Modified:
13 years, 5 months ago
Reviewers:
Jeffrey Yasskin (google), eli.friedman
CC:
chandlerc
Visibility:
Public.

Description

Add APInt(numBits, ArrayRef<uint64_t> bigVal) constructor to prevent future ambiguity errors like the one corrected by r135261. Migrate all LLVM callers of the old constructor to the new one.

Patch Set 1 #

Patch Set 2 : Use makeArrayRef() instead of ArrayRef<uint64_t>() #

Unified diffs Side-by-side diffs Delta from patch set Stats (+61 lines, -36 lines) Patch
M include/llvm/ADT/APInt.h View 1 4 chunks +16 lines, -4 lines 0 comments Download
M lib/AsmParser/LLLexer.cpp View 1 chunk +3 lines, -3 lines 0 comments Download
M lib/Bitcode/Reader/BitcodeReader.cpp View 1 2 chunks +4 lines, -4 lines 0 comments Download
M lib/CodeGen/SelectionDAG/FastISel.cpp View 1 1 chunk +1 line, -1 line 0 comments Download
M lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp View 4 chunks +7 lines, -7 lines 0 comments Download
M lib/CodeGen/SelectionDAG/SelectionDAG.cpp View 1 1 chunk +1 line, -1 line 0 comments Download
M lib/ExecutionEngine/ExecutionEngine.cpp View 1 1 chunk +1 line, -1 line 0 comments Download
M lib/Support/APFloat.cpp View 1 6 chunks +7 lines, -7 lines 0 comments Download
M lib/Support/APInt.cpp View 1 1 chunk +14 lines, -6 lines 0 comments Download
M lib/VMCore/ConstantFold.cpp View 1 1 chunk +1 line, -1 line 0 comments Download
M lib/VMCore/Core.cpp View 1 1 chunk +2 lines, -1 line 0 comments Download
M unittests/ADT/APIntTest.cpp View 1 1 chunk +4 lines, -0 lines 0 comments Download

Messages

Total messages: 6
Jeffrey Yasskin
Initial diff at http://codereview.appspot.com/download/issue4749046_1.diff
13 years, 5 months ago (2011-07-17 05:51:56 UTC) #1
Jeffrey Yasskin (google)
Here's the patch. On Sat, Jul 16, 2011 at 10:51 PM, <jyasskin@gmail.com> wrote: > Reviewers: ...
13 years, 5 months ago (2011-07-18 16:58:04 UTC) #2
eli.friedman_gmail.com
On Mon, Jul 18, 2011 at 9:57 AM, Jeffrey Yasskin <jyasskin@google.com> wrote: > Here's the ...
13 years, 5 months ago (2011-07-18 18:33:17 UTC) #3
Jeffrey Yasskin (google)
On Mon, Jul 18, 2011 at 11:33 AM, Eli Friedman <eli.friedman@gmail.com> wrote: > On Mon, ...
13 years, 5 months ago (2011-07-18 18:42:56 UTC) #4
Jeffrey Yasskin (google)
On Mon, Jul 18, 2011 at 11:42 AM, Jeffrey Yasskin <jyasskin@google.com> wrote: > On Mon, ...
13 years, 5 months ago (2011-07-18 21:21:05 UTC) #5
eli.friedman_gmail.com
13 years, 5 months ago (2011-07-18 22:00:10 UTC) #6
On Mon, Jul 18, 2011 at 2:20 PM, Jeffrey Yasskin <jyasskin@google.com> wrote:
> On Mon, Jul 18, 2011 at 11:42 AM, Jeffrey Yasskin <jyasskin@google.com> wrote:
>> On Mon, Jul 18, 2011 at 11:33 AM, Eli Friedman <eli.friedman@gmail.com>
wrote:
>>> On Mon, Jul 18, 2011 at 9:57 AM, Jeffrey Yasskin <jyasskin@google.com>
wrote:
>>>> Here's the patch.
>>>>
>>>> On Sat, Jul 16, 2011 at 10:51 PM,  <jyasskin@gmail.com> wrote:
>>>>> Reviewers: eli.friedman_gmail.com,
>>>>>
>>>>> Message:
>>>>> Initial diff at
>>>>> http://codereview.appspot.com/download/issue4749046_1.diff
>>>>>
>>>>> Description:
>>>>> Add APInt(numBits, ArrayRef<uint64_t> bigVal) constructor to prevent
>>>>> future ambiguity errors like the one corrected by r135261.  Migrate all
>>>>> LLVM callers of the old constructor to the new one.
>>>>>
>>>>>
>>>>> Please review this at http://codereview.appspot.com/4749046/
>>>>>
>>>>> Affected files:
>>>>>   M include/llvm/ADT/APInt.h
>>>>>   M lib/AsmParser/LLLexer.cpp
>>>>>   M lib/Bitcode/Reader/BitcodeReader.cpp
>>>>>   M lib/CodeGen/SelectionDAG/FastISel.cpp
>>>>>   M lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
>>>>>   M lib/CodeGen/SelectionDAG/SelectionDAG.cpp
>>>>>   M lib/ExecutionEngine/ExecutionEngine.cpp
>>>>>   M lib/Support/APFloat.cpp
>>>>>   M lib/Support/APInt.cpp
>>>>>   M lib/VMCore/ConstantFold.cpp
>>>>>   M lib/VMCore/Core.cpp
>>>>>   M unittests/ADT/APIntTest.cpp
>>>
>>> @@ -342,7 +353,8 @@ public:
>>>
>>>     if (isSingleWord())
>>>       return isUIntN(N, VAL);
>>> -    return APInt(N, getNumWords(), pVal).zext(getBitWidth()) == (*this);
>>> +    return APInt(N, ArrayRef<uint64_t>(pVal,
>>> getNumWords())).zext(getBitWidth())
>>> +      == (*this);
>>>   }
>>>
>>>   /// @brief Check if this APInt has an N-bits signed integer value.
>>>
>>> makeArrayRef just landed; use it. :)  Same in a couple other places.
>>
>> Silly codebase, changing out from under me. ;-) Will do.
>>
>>> Otherwise, looks fine.
>>>
>>> As a followup, could you eliminate both the "APInt(unsigned numBits,
>>> unsigned numWords, const uint64_t bigVal[])" and the "APInt(unsigned
>>> numBits, uint64_t val, bool isSigned = false)" constructors?  (It
>>> should just require ArrayRef-izing and adding an
>>> "APInt::getSigned(unsigned numBits, uint64_t val)" helper.)
>>
>> How do you want to handle dependent codebases? I was thinking to leave
>> APInt(...bigVal[]) in for a version to let people switch, but I guess
>> LLVM does tend to remove things more aggressively than that. I'm only
>> willing to commit to fixing clang myself if you want me to both fix
>> things and remove the deprecated constructors.
>
> By which I mean that I'm not volunteering to fix anything besides
> clang, but I am happy to fix clang.

K; I'll fix llvm-gcc; and it should be easy enough to fix dragonegg.

> Also, do you want APInt::getSigned() to take a uint64_t or an int64_t?
> IIRC, taking uint64_t introduces some warnings when we pass literal
> negative numbers, and we made ConstantInt::getSigned() take an int64_t
> for that reason. Hm, without the bool-taking version of APInt(),
> ConstantInt::get() will need an if, or we'll have to change it to not
> accept signed numbers either.

I guess int64_t, since it is expecting a signed value. :)  Making
ConstantInt::get use an if doesn't seem like a big deal.

-Eli
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b