[llvm] r333970 - [MIRParser] Add parser support for 'true' and 'false' i1s.
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 4 17:17:14 PDT 2018
Author: aemerson
Date: Mon Jun 4 17:17:13 2018
New Revision: 333970
URL: http://llvm.org/viewvc/llvm-project?rev=333970&view=rev
Log:
[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
Added:
llvm/trunk/test/CodeGen/MIR/Generic/parse-integer-true-false.mir
Modified:
llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=333970&r1=333969&r2=333970&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Mon Jun 4 17:17:13 2018
@@ -1373,8 +1373,11 @@ bool MIParser::parseTypedImmediateOperan
auto Loc = Token.location();
lex();
- if (Token.isNot(MIToken::IntegerLiteral))
- return error("expected an integer literal");
+ if (Token.isNot(MIToken::IntegerLiteral)) {
+ if (Token.isNot(MIToken::Identifier) ||
+ !(Token.range() == "true" || Token.range() == "false"))
+ return error("expected an integer literal");
+ }
const Constant *C = nullptr;
if (parseIRConstant(Loc, C))
return true;
Added: llvm/trunk/test/CodeGen/MIR/Generic/parse-integer-true-false.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/Generic/parse-integer-true-false.mir?rev=333970&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/Generic/parse-integer-true-false.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/Generic/parse-integer-true-false.mir Mon Jun 4 17:17:13 2018
@@ -0,0 +1,11 @@
+# RUN: llc -run-pass none -o - %s | FileCheck %s
+# Parse an i1 being a 'true' or 'false'
+---
+name: i1_true_false
+body: |
+ bb.0:
+ ; CHECK: %0:_(s1) = G_CONSTANT i1 true
+ ; CHECK: %1:_(s1) = G_CONSTANT i1 false
+ %0:_(s1) = G_CONSTANT i1 true
+ %1:_(s1) = G_CONSTANT i1 false
+...
More information about the llvm-commits
mailing list