Skip to content

Commit d496cc8

Browse files
committedJun 5, 2018
[MIRParser] Add parser support for 'true' and 'false' i1s.
We already output true and false in the printer, but the parser isn't able to read it. Differential Revision: https://reviews.llvm.org/D47424 llvm-svn: 333970
1 parent 293c269 commit d496cc8

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
 

Diff for: ‎llvm/lib/CodeGen/MIRParser/MIParser.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -1373,8 +1373,11 @@ bool MIParser::parseTypedImmediateOperand(MachineOperand &Dest) {
13731373

13741374
auto Loc = Token.location();
13751375
lex();
1376-
if (Token.isNot(MIToken::IntegerLiteral))
1377-
return error("expected an integer literal");
1376+
if (Token.isNot(MIToken::IntegerLiteral)) {
1377+
if (Token.isNot(MIToken::Identifier) ||
1378+
!(Token.range() == "true" || Token.range() == "false"))
1379+
return error("expected an integer literal");
1380+
}
13781381
const Constant *C = nullptr;
13791382
if (parseIRConstant(Loc, C))
13801383
return true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# RUN: llc -run-pass none -o - %s | FileCheck %s
2+
# Parse an i1 being a 'true' or 'false'
3+
---
4+
name: i1_true_false
5+
body: |
6+
bb.0:
7+
; CHECK: %0:_(s1) = G_CONSTANT i1 true
8+
; CHECK: %1:_(s1) = G_CONSTANT i1 false
9+
%0:_(s1) = G_CONSTANT i1 true
10+
%1:_(s1) = G_CONSTANT i1 false
11+
...

0 commit comments

Comments
 (0)
Please sign in to comment.