diff --git a/include/llvm/IR/CallingConv.h b/include/llvm/IR/CallingConv.h index 1eaf4f7f469..702c35f58fa 100644 --- a/include/llvm/IR/CallingConv.h +++ b/include/llvm/IR/CallingConv.h @@ -20,10 +20,13 @@ namespace llvm { /// the well-known calling conventions. /// namespace CallingConv { + /// LLVM IR allows to use arbitrary numbers as calling convention identifiers. + typedef unsigned ID; + /// A set of enums which specify the assigned numeric values for known llvm /// calling conventions. /// @brief LLVM Calling Convention Representation - enum ID { + enum { /// C - The default llvm calling convention, compatible with C. This /// convention is the only calling convention that supports varargs calls. /// As with typical C calling conventions, the callee/caller have to diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index f363b550647..cfdb1d4742f 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -1464,7 +1464,7 @@ bool LLParser::ParseOptionalDLLStorageClass(unsigned &Res) { /// ::= 'preserve_allcc' /// ::= 'cc' UINT /// -bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) { +bool LLParser::ParseOptionalCallingConv(unsigned &CC) { switch (Lex.getKind()) { default: CC = CallingConv::C; return false; case lltok::kw_ccc: CC = CallingConv::C; break; @@ -1489,12 +1489,8 @@ bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) { case lltok::kw_preserve_mostcc:CC = CallingConv::PreserveMost; break; case lltok::kw_preserve_allcc: CC = CallingConv::PreserveAll; break; case lltok::kw_cc: { - unsigned ArbitraryCC; Lex.Lex(); - if (ParseUInt32(ArbitraryCC)) - return true; - CC = static_cast(ArbitraryCC); - return false; + return ParseUInt32(CC); } } @@ -3131,7 +3127,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { unsigned Visibility; unsigned DLLStorageClass; AttrBuilder RetAttrs; - CallingConv::ID CC; + unsigned CC; Type *RetType = nullptr; LocTy RetTypeLoc = Lex.getLoc(); if (ParseOptionalLinkage(Linkage) || @@ -3803,7 +3799,7 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) { AttrBuilder RetAttrs, FnAttrs; std::vector FwdRefAttrGrps; LocTy NoBuiltinLoc; - CallingConv::ID CC; + unsigned CC; Type *RetType = nullptr; LocTy RetTypeLoc; ValID CalleeID; @@ -4217,7 +4213,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS, AttrBuilder RetAttrs, FnAttrs; std::vector FwdRefAttrGrps; LocTy BuiltinLoc; - CallingConv::ID CC; + unsigned CC; Type *RetType = nullptr; LocTy RetTypeLoc; ValID CalleeID; diff --git a/lib/AsmParser/LLParser.h b/lib/AsmParser/LLParser.h index b7d8f21442b..aa62bcc8daf 100644 --- a/lib/AsmParser/LLParser.h +++ b/lib/AsmParser/LLParser.h @@ -226,7 +226,7 @@ namespace llvm { } bool ParseOptionalVisibility(unsigned &Visibility); bool ParseOptionalDLLStorageClass(unsigned &DLLStorageClass); - bool ParseOptionalCallingConv(CallingConv::ID &CC); + bool ParseOptionalCallingConv(unsigned &CC); bool ParseOptionalAlignment(unsigned &Alignment); bool ParseOptionalDereferenceableBytes(uint64_t &Bytes); bool ParseScopeAndOrdering(bool isAtomic, SynchronizationScope &Scope,