1 (*===-- llvm_target.ml - LLVM OCaml Interface ------------------*- OCaml -*-===*
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 *===----------------------------------------------------------------------===*)
15 module CodeGenOptLevel
= struct
23 module RelocMode
= struct
31 module CodeModel
= struct
41 module CodeGenFileType
= struct
47 exception Error
of string
49 let () = Callback.register_exception
"Llvm_target.Error" (Error
"")
51 module DataLayout
= struct
54 external of_string
: string -> t
= "llvm_datalayout_of_string"
55 external as_string
: t
-> string = "llvm_datalayout_as_string"
56 external byte_order
: t
-> Endian.t
= "llvm_datalayout_byte_order"
57 external pointer_size
: t
-> int = "llvm_datalayout_pointer_size"
58 external intptr_type
: Llvm.llcontext
-> t
-> Llvm.lltype
59 = "llvm_datalayout_intptr_type"
60 external qualified_pointer_size
: int -> t
-> int
61 = "llvm_datalayout_qualified_pointer_size"
62 external qualified_intptr_type
: Llvm.llcontext
-> int -> t
-> Llvm.lltype
63 = "llvm_datalayout_qualified_intptr_type"
64 external size_in_bits
: Llvm.lltype
-> t
-> Int64.t
65 = "llvm_datalayout_size_in_bits"
66 external store_size
: Llvm.lltype
-> t
-> Int64.t
67 = "llvm_datalayout_store_size"
68 external abi_size
: Llvm.lltype
-> t
-> Int64.t
69 = "llvm_datalayout_abi_size"
70 external abi_align
: Llvm.lltype
-> t
-> int
71 = "llvm_datalayout_abi_align"
72 external stack_align
: Llvm.lltype
-> t
-> int
73 = "llvm_datalayout_stack_align"
74 external preferred_align
: Llvm.lltype
-> t
-> int
75 = "llvm_datalayout_preferred_align"
76 external preferred_align_of_global
: Llvm.llvalue
-> t
-> int
77 = "llvm_datalayout_preferred_align_of_global"
78 external element_at_offset
: Llvm.lltype
-> Int64.t
-> t
-> int
79 = "llvm_datalayout_element_at_offset"
80 external offset_of_element
: Llvm.lltype
-> int -> t
-> Int64.t
81 = "llvm_datalayout_offset_of_element"
84 module Target
= struct
87 external default_triple
: unit -> string = "llvm_target_default_triple"
88 external first
: unit -> t
option = "llvm_target_first"
89 external succ
: t
-> t
option = "llvm_target_succ"
90 external by_name
: string -> t
option = "llvm_target_by_name"
91 external by_triple
: string -> t
= "llvm_target_by_triple"
92 external name
: t
-> string = "llvm_target_name"
93 external description
: t
-> string = "llvm_target_description"
94 external has_jit
: t
-> bool = "llvm_target_has_jit"
95 external has_target_machine
: t
-> bool = "llvm_target_has_target_machine"
96 external has_asm_backend
: t
-> bool = "llvm_target_has_asm_backend"
99 let rec step elem lst
=
101 | Some target
-> step (succ target
) (target
:: lst
)
107 module TargetMachine
= struct
110 external create
: triple
:string -> ?cpu
:string -> ?features
:string ->
111 ?level
:CodeGenOptLevel.t
-> ?reloc_mode
:RelocMode.t
->
112 ?code_model
:CodeModel.t
-> Target.t
-> t
113 = "llvm_create_targetmachine_bytecode"
114 "llvm_create_targetmachine_native"
115 external target
: t
-> Target.t
116 = "llvm_targetmachine_target"
117 external triple
: t
-> string
118 = "llvm_targetmachine_triple"
119 external cpu
: t
-> string
120 = "llvm_targetmachine_cpu"
121 external features
: t
-> string
122 = "llvm_targetmachine_features"
123 external data_layout
: t
-> DataLayout.t
124 = "llvm_targetmachine_data_layout"
125 external set_verbose_asm
: bool -> t
-> unit
126 = "llvm_targetmachine_set_verbose_asm"
127 external emit_to_file
: Llvm.llmodule
-> CodeGenFileType.t
-> string ->
129 = "llvm_targetmachine_emit_to_file"
130 external emit_to_memory_buffer
: Llvm.llmodule
-> CodeGenFileType.t
->
131 t
-> Llvm.llmemorybuffer
132 = "llvm_targetmachine_emit_to_memory_buffer"