ae2f_docs
Loading...
Searching...
No Matches
compiler-run.c
1#include <aclspv.h>
2#include <assert.h>
3#include <stdlib.h>
4#include <string.h>
5#include <stdio.h>
6
7#include "./source.auto.h"
8#include "./ocl.auto.h"
9
10char maincontent[sizeof(A_0) + sizeof(A_1) + sizeof(A_2) + sizeof(A_3) + sizeof(A_4) + sizeof(A_5) - 5];
11char oclhead[sizeof(B_0) + sizeof(B_1) - 1];
12#if 1
13int main(void) {
14 struct CXUnsavedFile files[2];
15 const char* ARG[] = { "main.cl" };
16 aclspv_wrd_t* spirv0;
17 aclspv_wrdcount_t spirv_count;
18
19 strcpy(maincontent, A_0);
20 strcat(maincontent, A_1);
21 strcat(maincontent, A_2);
22 strcat(maincontent, A_3);
23 strcat(maincontent, A_4);
24 strcat(maincontent, A_5);
25
26 strcpy(oclhead, B_0);
27 strcat(oclhead, B_1);
28
29 files[0].Contents = maincontent;
30 files[0].Filename = "main.cl";
31 files[0].Length = sizeof(maincontent) - 1;
32
33 files[1].Contents = oclhead;
34 files[1].Filename = "./opencl-c-base.h";
35 files[1].Length = sizeof(oclhead) - 1;
36
37 aclspv_compile(
38 files, 2
39 , ARG, 1
40 , &spirv_count, &spirv0, ae2f_NIL
41 );
42
43 assert(spirv0);
44
45 if(spirv0) {
46 FILE* const fp = fopen("result.spv", "wb");
47 unless(fp) goto FPOPEN_FAILED;
48
49 fwrite(spirv0, sizeof(aclspv_wrd_t), (size_t)spirv_count, fp);
50
51 if(fp) fclose(fp);
52FPOPEN_FAILED:
53 ;
54 }
55
56 free(spirv0);
57
58 return 0;
59}
60#else
61
62#endif
#define unless(a)
Invokes when condition is false.
Definition Keys.h:34
#define ae2f_NIL
Definition Nil.h:13
aclspv_wrd_t aclspv_wrdcount_t
the integer type represents the number of word.
Definition spvty.h:61
#define aclspv_wrd_t
integer as word
Definition spvty.h:16