[PATCH] Add a trivial X86 calling convention for WebKit JavaScript.

Chris Lattner clattner at apple.com
Sat Oct 26 18:06:40 PDT 2013


On Oct 21, 2013, at 8:21 PM, Andrew Trick <atrick at apple.com> wrote:

> Hi lhames, ributzka, echristo,
> 
> Push all args on the stack and return RAX.

How "nailed down" is this calling convention?  Should it be marked experimental as well?

If you're happy with the name, the patch LGTM.  It needs a testcase though.

-Chris

> 
> http://llvm-reviews.chandlerc.com/D1997
> 
> Files:
>  include/llvm/IR/CallingConv.h
>  lib/AsmParser/LLLexer.cpp
>  lib/AsmParser/LLParser.cpp
>  lib/AsmParser/LLToken.h
>  lib/Target/X86/X86CallingConv.td
> 
> Index: include/llvm/IR/CallingConv.h
> ===================================================================
> --- include/llvm/IR/CallingConv.h
> +++ include/llvm/IR/CallingConv.h
> @@ -51,6 +51,9 @@
>     // (HiPE).
>     HiPE = 11,
> 
> +    // WebKit JS - Calling convention for stack based JavaScript calls
> +    WebKit_JS = 12,
> +
>     // Target - This is the start of the target-specific calling conventions,
>     // e.g. fastcall and thiscall on X86.
>     FirstTargetCC = 64,
> Index: lib/AsmParser/LLLexer.cpp
> ===================================================================
> --- lib/AsmParser/LLLexer.cpp
> +++ lib/AsmParser/LLLexer.cpp
> @@ -559,6 +559,7 @@
>   KEYWORD(intel_ocl_bicc);
>   KEYWORD(x86_64_sysvcc);
>   KEYWORD(x86_64_win64cc);
> +  KEYWORD(webkit_jscc);
> 
>   KEYWORD(cc);
>   KEYWORD(c);
> Index: lib/AsmParser/LLParser.cpp
> ===================================================================
> --- lib/AsmParser/LLParser.cpp
> +++ lib/AsmParser/LLParser.cpp
> @@ -1349,6 +1349,7 @@
> ///   ::= 'spir_kernel'
> ///   ::= 'x86_64_sysvcc'
> ///   ::= 'x86_64_win64cc'
> +///   ::= 'webkit_jscc'
> ///   ::= 'cc' UINT
> ///
> bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) {
> @@ -1371,6 +1372,7 @@
>   case lltok::kw_intel_ocl_bicc: CC = CallingConv::Intel_OCL_BI; break;
>   case lltok::kw_x86_64_sysvcc:  CC = CallingConv::X86_64_SysV; break;
>   case lltok::kw_x86_64_win64cc: CC = CallingConv::X86_64_Win64; break;
> +  case lltok::kw_webkit_jscc:    CC = CallingConv::WebKit_JS; break;
>   case lltok::kw_cc: {
>       unsigned ArbitraryCC;
>       Lex.Lex();
> Index: lib/AsmParser/LLToken.h
> ===================================================================
> --- lib/AsmParser/LLToken.h
> +++ lib/AsmParser/LLToken.h
> @@ -92,6 +92,7 @@
>     kw_ptx_kernel, kw_ptx_device,
>     kw_spir_kernel, kw_spir_func,
>     kw_x86_64_sysvcc, kw_x86_64_win64cc,
> +    kw_webkit_jscc,
> 
>     // Attributes:
>     kw_attributes,
> Index: lib/Target/X86/X86CallingConv.td
> ===================================================================
> --- lib/Target/X86/X86CallingConv.td
> +++ lib/Target/X86/X86CallingConv.td
> @@ -151,6 +151,15 @@
>   CCIfType<[i64], CCAssignToReg<[R15, RBP, RAX, RDX]>>
> ]>;
> 
> +// X86-64 WebKit_JS return-value convention.
> +def RetCC_X86_64_WebKit_JS : CallingConv<[
> +  // Promote all types to i64
> +  CCIfType<[i8, i16, i32], CCPromoteToType<i64>>,
> +
> +  // Return: RAX
> +  CCIfType<[i64], CCAssignToReg<[RAX]>>
> +]>;
> +
> // This is the root return-value convention for the X86-32 backend.
> def RetCC_X86_32 : CallingConv<[
>   // If FastCC, use RetCC_X86_32_Fast.
> @@ -167,6 +176,9 @@
>   // HiPE uses RetCC_X86_64_HiPE
>   CCIfCC<"CallingConv::HiPE", CCDelegateTo<RetCC_X86_64_HiPE>>,
> 
> +  // Handle JavaScript calls.
> +  CCIfCC<"CallingConv::WebKit_JS", CCDelegateTo<RetCC_X86_64_WebKit_JS>>,
> +
>   // Handle explicit CC selection
>   CCIfCC<"CallingConv::X86_64_Win64", CCDelegateTo<RetCC_X86_Win64_C>>,
>   CCIfCC<"CallingConv::X86_64_SysV", CCDelegateTo<RetCC_X86_64_C>>,
> @@ -329,6 +341,15 @@
>   CCIfType<[i32, i64, f32, f64], CCAssignToStack<8, 8>>
> ]>;
> 
> +def CC_X86_64_WebKit_JS : CallingConv<[
> +  // Promote i8/i16 arguments to i32.
> +  CCIfType<[i8, i16], CCPromoteToType<i32>>,
> +
> +  // Integer/FP values are always stored in stack slots that are 8 bytes in size
> +  // and 8-byte aligned.
> +  CCIfType<[i32, i64, f32, f64], CCAssignToStack<8, 8>>
> +]>;
> +
> //===----------------------------------------------------------------------===//
> // X86 C Calling Convention
> //===----------------------------------------------------------------------===//
> @@ -520,6 +541,7 @@
> def CC_X86_64 : CallingConv<[
>   CCIfCC<"CallingConv::GHC", CCDelegateTo<CC_X86_64_GHC>>,
>   CCIfCC<"CallingConv::HiPE", CCDelegateTo<CC_X86_64_HiPE>>,
> +  CCIfCC<"CallingConv::WebKit_JS", CCDelegateTo<CC_X86_64_WebKit_JS>>,
>   CCIfCC<"CallingConv::X86_64_Win64", CCDelegateTo<CC_X86_Win64_C>>,
>   CCIfCC<"CallingConv::X86_64_SysV", CCDelegateTo<CC_X86_64_C>>,
> <D1997.1.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list