diff --git a/llvm/lib/AsmParser/Lexer.l b/llvm/lib/AsmParser/Lexer.l index 5e60654c84c6..93b84be44131 100644 --- a/llvm/lib/AsmParser/Lexer.l +++ b/llvm/lib/AsmParser/Lexer.l @@ -44,10 +44,6 @@ void set_scan_string (const char * str) { llvmAsmlval.type = Instruction::Enum; \ return sym -#define RET_ENUM(type, Enum, sym) \ - llvmAsmlval.type = Enum; \ - return sym - // Construct a token value for an obsolete token #define RET_TY(CTYPE, SYM) \ llvmAsmlval.PrimType = CTYPE;\ @@ -272,30 +268,26 @@ setle { RET_TOK(BinaryOpVal, SetLE, SETLE); } setge { RET_TOK(BinaryOpVal, SetGE, SETGE); } icmp { RET_TOK(OtherOpVal, ICmp, ICMP); } fcmp { RET_TOK(OtherOpVal, FCmp, FCMP); } -eq { RET_ENUM(IPredicate, ICmpInst::ICMP_EQ, EQ); } -ne { RET_ENUM(IPredicate, ICmpInst::ICMP_NE, NE); } -slt { RET_ENUM(IPredicate, ICmpInst::ICMP_SLT, SLT); } -sgt { RET_ENUM(IPredicate, ICmpInst::ICMP_SGT, SGT); } -sle { RET_ENUM(IPredicate, ICmpInst::ICMP_SLE, SLE); } -sge { RET_ENUM(IPredicate, ICmpInst::ICMP_SGE, SGE); } -ult { RET_ENUM(IPredicate, ICmpInst::ICMP_ULT, ULT); } -ugt { RET_ENUM(IPredicate, ICmpInst::ICMP_UGT, UGT); } -ule { RET_ENUM(IPredicate, ICmpInst::ICMP_ULE, ULE); } -uge { RET_ENUM(IPredicate, ICmpInst::ICMP_UGE, UGE); } -ordeq { RET_ENUM(FPredicate, FCmpInst::FCMP_OEQ, ORDEQ); } -ordne { RET_ENUM(FPredicate, FCmpInst::FCMP_ONE, ORDNE); } -ordlt { RET_ENUM(FPredicate, FCmpInst::FCMP_OLT, ORDLT); } -ordgt { RET_ENUM(FPredicate, FCmpInst::FCMP_OGT, ORDGT); } -ordle { RET_ENUM(FPredicate, FCmpInst::FCMP_OLE, ORDLE); } -ordge { RET_ENUM(FPredicate, FCmpInst::FCMP_OGE, ORDGE); } -ord { RET_ENUM(FPredicate, FCmpInst::FCMP_ORD, ORD); } -uno { RET_ENUM(FPredicate, FCmpInst::FCMP_UNO, UNO); } -unoeq { RET_ENUM(FPredicate, FCmpInst::FCMP_UEQ, UNOEQ); } -unone { RET_ENUM(FPredicate, FCmpInst::FCMP_UNE, UNONE); } -unolt { RET_ENUM(FPredicate, FCmpInst::FCMP_ULT, UNOLT); } -unogt { RET_ENUM(FPredicate, FCmpInst::FCMP_UGT, UNOGT); } -unole { RET_ENUM(FPredicate, FCmpInst::FCMP_ULE, UNOLE); } -unoge { RET_ENUM(FPredicate, FCmpInst::FCMP_UGE, UNOGE); } +eq { return EQ; } +ne { return NE; } +slt { return SLT; } +sgt { return SGT; } +sle { return SLE; } +sge { return SGE; } +ult { return ULT; } +ugt { return UGT; } +ule { return ULE; } +uge { return UGE; } +oeq { return OEQ; } +one { return ONE; } +olt { return OLT; } +ogt { return OGT; } +ole { return OLE; } +oge { return OGE; } +ord { return ORD; } +uno { return UNO; } +ueq { return UEQ; } +une { return UNE; } phi { RET_TOK(OtherOpVal, PHI, PHI_TOK); } call { RET_TOK(OtherOpVal, Call, CALL); } diff --git a/llvm/lib/AsmParser/llvmAsmParser.y b/llvm/lib/AsmParser/llvmAsmParser.y index 8d0b7a271437..45ded16af627 100644 --- a/llvm/lib/AsmParser/llvmAsmParser.y +++ b/llvm/lib/AsmParser/llvmAsmParser.y @@ -1076,11 +1076,10 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { %token ADD SUB MUL UDIV SDIV FDIV UREM SREM FREM AND OR XOR %token SETLE SETGE SETLT SETGT SETEQ SETNE // Binary Comparators %token ICMP FCMP -%token EQ NE SLT SGT SLE SGE ULT UGT ULE UGE %type IPredicates -%token ORDEQ ORDNE ORDLT ORDGT ORDLE ORDGE ORD UNO UNOEQ UNONE -%token UNOLT UNOGT UNOLE UNOGE %type FPredicates +%token EQ NE SLT SGT SLE SGE ULT UGT ULE UGE +%token OEQ ONE OLT OGT OLE OGE ORD UNO UEQ UNE // Memory Instructions %token MALLOC ALLOCA FREE LOAD STORE GETELEMENTPTR @@ -1128,9 +1127,25 @@ SetCondOps : SETLE | SETGE | SETLT | SETGT | SETEQ | SETNE; CastOps : TRUNC | ZEXT | SEXT | FPTRUNC | FPEXT | BITCAST | UITOFP | SITOFP | FPTOUI | FPTOSI | INTTOPTR | PTRTOINT; ShiftOps : SHL | LSHR | ASHR; -IPredicates : EQ | NE | SLT | SGT | SLE | SGE | ULT | UGT | ULE | UGE ; -FPredicates : ORDEQ | ORDNE | ORDLT | ORDGT | ORDLE | ORDGE | ORD | UNO - | UNOEQ | UNONE | UNOLT | UNOGT | UNOLE | UNOGE ; +IPredicates + : EQ { $$ = ICmpInst::ICMP_EQ; } | NE { $$ = ICmpInst::ICMP_NE; } + | SLT { $$ = ICmpInst::ICMP_SLT; } | SGT { $$ = ICmpInst::ICMP_SGT; } + | SLE { $$ = ICmpInst::ICMP_SLE; } | SGE { $$ = ICmpInst::ICMP_SGE; } + | ULT { $$ = ICmpInst::ICMP_ULT; } | UGT { $$ = ICmpInst::ICMP_UGT; } + | ULE { $$ = ICmpInst::ICMP_ULE; } | UGE { $$ = ICmpInst::ICMP_UGE; } + ; + +FPredicates + : OEQ { $$ = FCmpInst::FCMP_OEQ; } | ONE { $$ = FCmpInst::FCMP_ONE; } + | OLT { $$ = FCmpInst::FCMP_OLT; } | OGT { $$ = FCmpInst::FCMP_OGT; } + | OLE { $$ = FCmpInst::FCMP_OLE; } | OGE { $$ = FCmpInst::FCMP_OGE; } + | ORD { $$ = FCmpInst::FCMP_ORD; } | UNO { $$ = FCmpInst::FCMP_UNO; } + | UEQ { $$ = FCmpInst::FCMP_UEQ; } | UNE { $$ = FCmpInst::FCMP_UNE; } + | ULT { $$ = FCmpInst::FCMP_ULT; } | UGT { $$ = FCmpInst::FCMP_UGT; } + | ULE { $$ = FCmpInst::FCMP_ULE; } | UGE { $$ = FCmpInst::FCMP_UGE; } + | TRUETOK { $$ = FCmpInst::FCMP_TRUE; } + | FALSETOK { $$ = FCmpInst::FCMP_FALSE; } + ; // These are some types that allow classification if we only want a particular // thing... for example, only a signed, unsigned, or integral type.