This is an archive of the discontinued LLVM Phabricator instance.

[MIRParser] Add parser support for 'true' and 'false' i1s.
ClosedPublic

Authored by aemerson on May 27 2018, 9:08 AM.

Details

Diff Detail

Repository
rL LLVM

Event Timeline

aemerson created this revision.May 27 2018, 9:08 AM
thegameg added inline comments.May 29 2018, 3:13 AM
lib/CodeGen/MIRParser/MIParser.cpp
1389

It looks like parseIRConstant already handles true and false. Can we reuse that here?

1907

Can we get a test for the errors here?

rtereshin added inline comments.May 29 2018, 10:10 AM
lib/CodeGen/MIRParser/MIParser.cpp
1389

Also, parseIRConstant will produce a neat error message if the boolean literal isn't specified as i1:

error: /Volumes/Data/llvm/test/CodeGen/MIR/AArch64/parse-integer-true-false.mir:9:32: constant expression type mismatch
    %0:_(s32) = G_CONSTANT i32 true

while the current version will just silently replace the type with i1.

aemerson added inline comments.May 29 2018, 4:34 PM
lib/CodeGen/MIRParser/MIParser.cpp
1389

Sure, that makes it a lot simpler.

aemerson updated this revision to Diff 149467.Jun 1 2018, 7:44 AM
rtereshin added inline comments.Jun 1 2018, 11:22 AM
lib/CodeGen/MIRParser/MIParser.cpp
1378

Why startswith instead of direct comparisons? Is it going to parse truee as true?

aemerson added inline comments.Jun 2 2018, 3:40 AM
lib/CodeGen/MIRParser/MIParser.cpp
1378

It won't parse that because parseIRConstant will fail, but you're right I had startswith mistakenly because it was a stringref view onto the raw source since they're not tokens any more, which in the debugger looked like a longer string than just "true" or "false".

aemerson updated this revision to Diff 149607.Jun 2 2018, 4:13 AM
rtereshin accepted this revision.Jun 4 2018, 9:01 AM
This revision is now accepted and ready to land.Jun 4 2018, 9:01 AM
thegameg accepted this revision.Jun 4 2018, 9:11 AM
This revision was automatically updated to reflect the committed changes.