xref: /aosp_15_r20/external/llvm/bindings/ocaml/backends/backend_ocaml.c (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker /*===-- backend_ocaml.c - LLVM OCaml Glue -----------------------*- C++ -*-===*\
2*9880d681SAndroid Build Coastguard Worker |*                                                                            *|
3*9880d681SAndroid Build Coastguard Worker |*                     The LLVM Compiler Infrastructure                       *|
4*9880d681SAndroid Build Coastguard Worker |*                                                                            *|
5*9880d681SAndroid Build Coastguard Worker |* This file is distributed under the University of Illinois Open Source      *|
6*9880d681SAndroid Build Coastguard Worker |* License. See LICENSE.TXT for details.                                      *|
7*9880d681SAndroid Build Coastguard Worker |*                                                                            *|
8*9880d681SAndroid Build Coastguard Worker |*===----------------------------------------------------------------------===*|
9*9880d681SAndroid Build Coastguard Worker |*                                                                            *|
10*9880d681SAndroid Build Coastguard Worker |* This file glues LLVM's OCaml interface to its C interface. These functions *|
11*9880d681SAndroid Build Coastguard Worker |* are by and large transparent wrappers to the corresponding C functions.    *|
12*9880d681SAndroid Build Coastguard Worker |*                                                                            *|
13*9880d681SAndroid Build Coastguard Worker |* Note that these functions intentionally take liberties with the CAMLparamX *|
14*9880d681SAndroid Build Coastguard Worker |* macros, since most of the parameters are not GC heap objects.              *|
15*9880d681SAndroid Build Coastguard Worker |*                                                                            *|
16*9880d681SAndroid Build Coastguard Worker \*===----------------------------------------------------------------------===*/
17*9880d681SAndroid Build Coastguard Worker 
18*9880d681SAndroid Build Coastguard Worker #include "llvm-c/Target.h"
19*9880d681SAndroid Build Coastguard Worker #include "caml/alloc.h"
20*9880d681SAndroid Build Coastguard Worker #include "caml/memory.h"
21*9880d681SAndroid Build Coastguard Worker 
22*9880d681SAndroid Build Coastguard Worker /* TODO: Figure out how to call these only for targets which support them.
23*9880d681SAndroid Build Coastguard Worker  * LLVMInitialize ## target ## AsmPrinter();
24*9880d681SAndroid Build Coastguard Worker  * LLVMInitialize ## target ## AsmParser();
25*9880d681SAndroid Build Coastguard Worker  * LLVMInitialize ## target ## Disassembler();
26*9880d681SAndroid Build Coastguard Worker  */
27*9880d681SAndroid Build Coastguard Worker 
28*9880d681SAndroid Build Coastguard Worker #define INITIALIZER1(target) \
29*9880d681SAndroid Build Coastguard Worker   CAMLprim value llvm_initialize_ ## target(value Unit) {  \
30*9880d681SAndroid Build Coastguard Worker     LLVMInitialize ## target ## TargetInfo();              \
31*9880d681SAndroid Build Coastguard Worker     LLVMInitialize ## target ## Target();                  \
32*9880d681SAndroid Build Coastguard Worker     LLVMInitialize ## target ## TargetMC();                \
33*9880d681SAndroid Build Coastguard Worker     return Val_unit;                                       \
34*9880d681SAndroid Build Coastguard Worker   }
35*9880d681SAndroid Build Coastguard Worker 
36*9880d681SAndroid Build Coastguard Worker #define INITIALIZER(target) INITIALIZER1(target)
37*9880d681SAndroid Build Coastguard Worker 
38*9880d681SAndroid Build Coastguard Worker INITIALIZER(TARGET)
39