Skip to content

Commit 8c26e47

Browse files
authored
[LLParser] Merge xor constantexpr parsing with add/mul/shl/lshr/ashr. (#67371)
Not sure if xor is sticking around or not. I see and/or was already removed. This changes the error messages and makes one error message more accurate.
1 parent 2ff45f0 commit 8c26e47

File tree

2 files changed

+6
-26
lines changed

2 files changed

+6
-26
lines changed

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3903,7 +3903,8 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
39033903
case lltok::kw_mul:
39043904
case lltok::kw_shl:
39053905
case lltok::kw_lshr:
3906-
case lltok::kw_ashr: {
3906+
case lltok::kw_ashr:
3907+
case lltok::kw_xor: {
39073908
bool NUW = false;
39083909
bool NSW = false;
39093910
bool Exact = false;
@@ -3934,34 +3935,13 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
39343935
return error(ID.Loc, "operands of constexpr must have same type");
39353936
// Check that the type is valid for the operator.
39363937
if (!Val0->getType()->isIntOrIntVectorTy())
3937-
return error(ID.Loc, "constexpr requires integer operands");
3938+
return error(ID.Loc,
3939+
"constexpr requires integer or integer vector operands");
39383940
unsigned Flags = 0;
39393941
if (NUW) Flags |= OverflowingBinaryOperator::NoUnsignedWrap;
39403942
if (NSW) Flags |= OverflowingBinaryOperator::NoSignedWrap;
39413943
if (Exact) Flags |= PossiblyExactOperator::IsExact;
3942-
Constant *C = ConstantExpr::get(Opc, Val0, Val1, Flags);
3943-
ID.ConstantVal = C;
3944-
ID.Kind = ValID::t_Constant;
3945-
return false;
3946-
}
3947-
3948-
// Logical Operations
3949-
case lltok::kw_xor: {
3950-
unsigned Opc = Lex.getUIntVal();
3951-
Constant *Val0, *Val1;
3952-
Lex.Lex();
3953-
if (parseToken(lltok::lparen, "expected '(' in logical constantexpr") ||
3954-
parseGlobalTypeAndValue(Val0) ||
3955-
parseToken(lltok::comma, "expected comma in logical constantexpr") ||
3956-
parseGlobalTypeAndValue(Val1) ||
3957-
parseToken(lltok::rparen, "expected ')' in logical constantexpr"))
3958-
return true;
3959-
if (Val0->getType() != Val1->getType())
3960-
return error(ID.Loc, "operands of constexpr must have same type");
3961-
if (!Val0->getType()->isIntOrIntVectorTy())
3962-
return error(ID.Loc,
3963-
"constexpr requires integer or integer vector operands");
3964-
ID.ConstantVal = ConstantExpr::get(Opc, Val0, Val1);
3944+
ID.ConstantVal = ConstantExpr::get(Opc, Val0, Val1, Flags);
39653945
ID.Kind = ValID::t_Constant;
39663946
return false;
39673947
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; Found by inspection of the code
22
; RUN: not llvm-as < %s > /dev/null 2> %t
3-
; RUN: grep "constexpr requires integer operands" %t
3+
; RUN: grep "constexpr requires integer or integer vector operands" %t
44

55
@0 = global i32 ashr (float 1.0, float 2.0)

0 commit comments

Comments
 (0)