llvm.org GIT mirror llvm / e53d605
Add in support for SPIR to LLVM core. This adds a new target and two new calling conventions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164948 91177308-0d34-0410-b5e6-96231b3b80d8 Micah Villmow 6 years ago
6 changed file(s) with 37 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
6464 nvptx, // NVPTX: 32-bit
6565 nvptx64, // NVPTX: 64-bit
6666 le32, // le32: generic little-endian 32-bit CPU (PNaCl / Emscripten)
67 amdil // amdil: amd IL
67 amdil, // amdil: amd IL
68 spir // SPIR: standard portable IR for OpenCL
6869 };
6970 enum VendorType {
7071 UnknownVendor,
9393
9494 /// MBLAZE_INTR - Calling convention used for MBlaze interrupt support
9595 /// routines (i.e. GCC's save_volatiles attribute).
96 MBLAZE_SVOL = 74
96 MBLAZE_SVOL = 74,
97
98 /// SPIR_FUNC - Calling convention for SPIR non-kernel device functions.
99 /// No lowering or expansion of arguments.
100 /// Structures are passed as a pointer to a struct with the byval attribute.
101 /// Functions can only call SPIR_FUNC and SPIR_KERNEL functions.
102 /// Functions can only have zero or one return values.
103 /// Variable arguments are not allowed, except for printf.
104 /// How arguments/return values are lowered are not specified.
105 /// Functions are only visible to the devices.
106 SPIR_FUNC = 75,
107
108 /// SPIR_KERNEL - Calling convention for SPIR kernel functions.
109 /// Inherits the restrictions of SPIR_FUNC, except
110 /// Cannot have non-void return values.
111 /// Cannot have variable arguments.
112 /// Can also be called by the host.
113 /// Is externally visible.
114 SPIR_KERNEL = 76
97115 };
98116 } // End CallingConv namespace
99117
524524 KEYWORD(msp430_intrcc);
525525 KEYWORD(ptx_kernel);
526526 KEYWORD(ptx_device);
527 KEYWORD(spir_kernel);
528 KEYWORD(spir_func);
527529
528530 KEYWORD(cc);
529531 KEYWORD(c);
11001100 /// ::= 'msp430_intrcc'
11011101 /// ::= 'ptx_kernel'
11021102 /// ::= 'ptx_device'
1103 /// ::= 'spir_func'
1104 /// ::= 'spir_kernel'
11031105 /// ::= 'cc' UINT
11041106 ///
11051107 bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) {
11171119 case lltok::kw_msp430_intrcc: CC = CallingConv::MSP430_INTR; break;
11181120 case lltok::kw_ptx_kernel: CC = CallingConv::PTX_Kernel; break;
11191121 case lltok::kw_ptx_device: CC = CallingConv::PTX_Device; break;
1122 case lltok::kw_spir_kernel: CC = CallingConv::SPIR_KERNEL; break;
1123 case lltok::kw_spir_func: CC = CallingConv::SPIR_FUNC; break;
11201124 case lltok::kw_cc: {
11211125 unsigned ArbitraryCC;
11221126 Lex.Lex();
8080 kw_arm_apcscc, kw_arm_aapcscc, kw_arm_aapcs_vfpcc,
8181 kw_msp430_intrcc,
8282 kw_ptx_kernel, kw_ptx_device,
83 kw_spir_kernel, kw_spir_func,
8384
8485 kw_signext,
8586 kw_zeroext,
4141 case nvptx64: return "nvptx64";
4242 case le32: return "le32";
4343 case amdil: return "amdil";
44 case spir: return "spir";
4445 }
4546
4647 llvm_unreachable("Invalid ArchType!");
8283 case nvptx64: return "nvptx";
8384 case le32: return "le32";
8485 case amdil: return "amdil";
86 case spir: return "spir";
8587 }
8688 }
8789
170172 .Case("nvptx64", nvptx64)
171173 .Case("le32", le32)
172174 .Case("amdil", amdil)
175 .Case("spir", spir)
173176 .Default(UnknownArch);
174177 }
175178
201204 .Case("nvptx", Triple::nvptx)
202205 .Case("nvptx64", Triple::nvptx64)
203206 .Case("amdil", Triple::amdil)
207 .Case("spir", Triple::spir)
204208 .Default(Triple::UnknownArch);
205209 }
206210
225229 .Case("nvptx64", "nvptx64")
226230 .Case("le32", "le32")
227231 .Case("amdil", "amdil")
232 .Case("spir", "spir")
228233 .Default(NULL);
229234 }
230235
259264 .Case("nvptx64", Triple::nvptx64)
260265 .Case("le32", Triple::le32)
261266 .Case("amdil", Triple::amdil)
267 .Case("spir", Triple::spir)
262268 .Default(Triple::UnknownArch);
263269 }
264270
669675
670676 static unsigned getArchPointerBitWidth(llvm::Triple::ArchType Arch) {
671677 switch (Arch) {
678 case llvm::Triple::spir:
672679 case llvm::Triple::UnknownArch:
673680 return 0;
674681
725732 break;
726733
727734 case Triple::amdil:
735 case Triple::spir:
728736 case Triple::arm:
729737 case Triple::cellspu:
730738 case Triple::hexagon:
771779 T.setArch(UnknownArch);
772780 break;
773781
782 case Triple::spir:
774783 case Triple::mips64:
775784 case Triple::mips64el:
776785 case Triple::nvptx64: