forked from tinygo-org/go-llvm
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathTargetBindings.cpp
More file actions
50 lines (41 loc) · 1.74 KB
/
TargetBindings.cpp
File metadata and controls
50 lines (41 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//===- TargetBindings.cpp - Additional bindings for target ---------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "TargetBindings.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Target/TargetMachine.h"
using namespace llvm;
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(TargetMachine, LLVMTargetMachineRef)
LLVMTargetMachineRef LLVMGoCreateTargetMachineWithOptions(
LLVMTargetRef T, const char *Triple, const char *CPU,
const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc,
LLVMCodeModel CodeModel,
LLVMBool FunctionSections, LLVMBool DataSections,
LLVMBool UniqueSectionNames) {
LLVMTargetMachineRef TM =
LLVMCreateTargetMachine(T, Triple, CPU, Features, Level, Reloc,
CodeModel);
if (!TM)
return nullptr;
TargetMachine *Machine = unwrap(TM);
Machine->Options.FunctionSections = !!FunctionSections;
Machine->Options.DataSections = !!DataSections;
Machine->Options.UniqueSectionNames = !!UniqueSectionNames;
return TM;
}
LLVMBool LLVMGoTargetMachineFunctionSections(LLVMTargetMachineRef TM) {
TargetMachine *Machine = unwrap(TM);
return Machine && Machine->Options.FunctionSections;
}
LLVMBool LLVMGoTargetMachineDataSections(LLVMTargetMachineRef TM) {
TargetMachine *Machine = unwrap(TM);
return Machine && Machine->Options.DataSections;
}
LLVMBool LLVMGoTargetMachineUniqueSectionNames(LLVMTargetMachineRef TM) {
TargetMachine *Machine = unwrap(TM);
return Machine && Machine->Options.UniqueSectionNames;
}